ParaMacros  ..



Macros used as Parameters


Normal Macros can not be used as Instructions' Parameters, but an extended feature is available when you want more evoluted formulations of your Instructions' Parameters: With the use of the  '{' and '}' Characters, you may write things like:

_________________________________________


; Normal macros:


[RGB | (#1 or (#2 shl 8) or (#3 shl 16))]


[ReverseByte | (#1 xor 0FF)]


[call | push #L>2 | call #1]


; Normal Procedure:


Proc MyRoutine:

   Arguments @Val1, @RGB, @Val3, 

             @String1Pointer,                            @String2Pointer, 

             @RealPointer

   Local @Integer

   

    Hexprint D@Val1

    hexprint D@RGB

    Hexprint D@Val3

    mov eax D@String1Pointer

    Showme eax

    mov eax D@String2Pointer

    Showme eax

    mov ebx D@RealPointer

    fld R$ebx

    fistp D@Integer

    Hexprint D@Integer  ; 04D2 >>> 1234

EndP

_________________________________________


; Use of Parameters Macros:


call MyRoutine,

     1, 

    {RGB 011, (011*2), {ReverseByte 0}}

     3,

    {'Hi!', 0}, 

    {'Coco!', 0},

    {R$ 1234,5}

_________________________________________


The second Parameter shows the usage of a {RGB Macro} unfolded as an expression, which is, finally resolved into one single Immediate. Notice that nested Invocations are allowed: ReverseByte is one another ParaMacro Invocation.


Such ParaMacros, for Parameters, are to be unfolded, of course, into something that should be accepted as any other normal Parameter (Expressions, ...). For example, you can not include Run-Time Values -D$MyValue-, or Mnemonics, as this would be the job of a Compiler (outputting silently things, that you have not written, behind your back), and not of a true Assembler. This feature, like normal Macros and Equates belongs to the Compile-Time process.


Take care that abuse of ParaMacros, with multiple Levels of nested Members, will tend to make your Sources as unreadable as those written in C .



On the Fly Data


In addition to these Parameters Macros, you may, with the same '{' and '}' Characters, to define Data on the fly. 


The frontier between the true Assembler and Compiler is close to being overflown with this feature, as seen in the example's Parameters 4 to 6: In case of direct Data Declarations, the ParaMacros parser outputs something behind your back without your knowledge: That is, Macro Automatic Labels. What is pushed on the Stack, for Parameters 4, 5 and 6, is nothing but Automatic Labels to the concerned Data, in the same way they are generated when you declare Data by normal Macros. 


If the Data are Strings, the String Markers ( '  or '' ) are all you need for a Declaration. For the Values Data (Reals or Integers), you have to provide the Size Markers (R$, Q$, or whatever...), the usual way.


Though I am not enamored with love and desire for this last implementation, I choose to provide it because it seems to be much appreciated by some users, as a useful means to implement quick and dirty definitions of 'one shot' Data. 


~~~~~~~