New features in Asmosphere

The earlier Asmosphere (~May 200 had a simple macro language without parameters. It also had a method of calling functions like a high level language (suitable for stdcall or Cdecl). It was also possible to pass string
literals, which would always leave their pointers in the eax register.

But linking to DLLs was quite hard work and relied on some of the procaddresses being passed with thinBasic variables.

To make coding more efficient and escape from the minutiae of assembly coding it was necessary to introduce a few more elements into the preprocessor layer.

Here is a recap of the recent Asmospsphere developments: (the ones that made it)

Structures and variables and arrays were introduced to represent data in similar way to higher level languages.

type

types can be specified in multiline or single line format.


type vec3
(
8 x
8 y
8 z
)

type rect 4 left 4 top 4 width 4 bottom


types can contain other types


type bounding_box
(
4 id
vec3 A
vec3 B
)


types can inherit other types

type vec5
(
vec3,
8 u
8 v
)



var
Variables can be defined with or without TYPE

the structure or number of bytes is given first. Dimensions are specified in brackets)


var 4 vv ww
var 8 xx yy zz

var rect rec
var rect recs(100)
var vec3 vecs(10,10)


variables use the familiar dot notation when referring to their elements

mov eax, rec.top

variables are associared with specified index(es) using statements like this:

indexers `ebp` offset 0 descending
indexers `esi` offset 4 ascending
indexers `ebp+eax*4` offset 0 descending


To help with variable management the following constants are available for use as literals

sizeof size of a type, element or variable
offsetof offset of a variable or element
spanof size of a dimension in an array variable




def

Macros can now support parameters %1..%9

def greeting messagebox 0,`%1 %2`,`Greeting`,0

greeting Hello World!


As you can see, prototypes are not used, Instead, the macro 'consumes'
adjacent words and incorporates them into its body. There a few restrictions where the %params may be placed.

Some %params are a little more specialised:

%0 takes the word to the left of the macro

%b takes all the words on the line to the left

%e takes all the words on the line to the right or an entire block if this is delineated by brackets.

%a Assignment: this takes the words on the line to the left and spits them out in the line following the next proc.


defs types and vars have much in common. They are all local and can therefore be confined with in scope by using brackets.

These macro words have priority over almost all other words. It is therefore possible to create instant mini-languages for a particular task in your program. They will be out of scope beyond the closing bracket - and any prior meanings of the words will be restored.


defs may contain other defs:
note the double %% to disguise the macro parameters on the primary expansion.

def floats
(
def + fadd %%1
def - fsub %%1
)



Ruining the syntax:

Breaking the rules macro names may be composed of several symbols, words or whole phrases:

def `floating point operations`
(
def + fadd %%1
def - fsub %%1
def A qword [edx+08]
def B qword [edx+16]
)


(
floating point operations
+ A
- B
)