Macros Examples .



Mutli Mov


[mov | mov #1 #2]


mov eax 1, ebx 2, ecx 3


Unfolded:


 mov eax 1 | mov ebx 2 | mov ecx 3




MemToMem Move


[move | push #2 | pop #1 | #+1]


move D§Variable1 D§Variable2


Unfolded:


 push D§Variable2 | pop D§Variable1




Mem Exchange


[push #1 | push #2 | pop #1 | pop #2 | #+1]


Exchange D§Variable1 D§Variable2


Unfolded:


 push D§Variable1 | push D§Variable2

pop D§Variable1 | pop D§Variable2




Call


[push | push #1 | #+1]

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


call MyFunction


Unfolded:


 call MyFunction


Example with parameters:


call MyFunction D§Variable1 D§Variable2


Unfolded:


 push D§Variable2 | pop D§Variable1 | call MyFunction




Using HLL Equates in HLL Macros


[= e, < b, > a, <s l, >s g, =< be, <= be, => ae, >= ae, <> ne]


Usage example, in the next example:




One Intruction Conditional Jump


[On | cmp #1 #3 | jn#2 O1 | #4>l | O1:]


On eax > 55, call MyFunction D§Variable1, D§Variable2, eax


Unfolded:


    push cmp eax 55 | jna O1>

  push eax | push D§Variable2 | push D§Variable1

call MyFunction

O1:



Enum


[Enum | {#2 (#x-1+#F)}| #+1]


Enum 0, One, Two, Three, Four


Unfolded (An Equates Set Declaration is outputted, where the enumeration base is the first number after 'Enum'):


[One 1, Two 2, Three 3, Four 4]




Procedure


Used Internal Strings:


&1, size of Argument(s) (for ending Ret n, in EndP). Set by Argument(s)

&2, size of Local (for Stack Management). Set by Local

&3, what to pop before ret. Set by Uses.


[Proc | &1=0 | &2=0 | &3= | #1 | push ebp | mov ebp esp]


[ExitP | jmp P9>>]


[Arguments | {#1 Arg#x} | #+1 | &1=SizeOf#x]

[Argument  | {#1 Arg#x} | #+1 | &1=SizeOf#x]


[Local | {#1 Local#x} | #+1 | sub esp SizeOf#x | &2=SizeOf#x]


[StrucPtrs | {#3 ebp+#2+#F} | #+2]


[Structure | {#1 ebp-&2-4} | sub esp #2+4 | mov D§#1 esp | StrucPtrs 0-&2-#2-4 #L>3]


[Uses | push #1>L | &3=pop #L>1]


[EndP | P9: | &3 | mov esp ebp | pop ebp | ret &1]


Equates for pointing to transmitted parameters:


[Arg1 ebp+8, Arg2 ebp+12, Arg3 ebp+16, Arg4 ebp+20, Arg5 ebp+24 Arg6 ebp+28, Arg7 ebp+32, Arg8 ebp+36, Arg9 ebp+40, Arg10 ebp+44]


Equates for pointing Local Stack data:


[Local1 ebp-4, Local2 ebp-8, Local3 ebp-12, Local4 ebp-16, Local5 ebp-20, Local6 ebp-24, Local7 ebp-28, Local8 ebp-32, Local9 ebp-36, Local10 ebp-40]


Equates for the Stack Sizes:


[SizeOf1 4, SizeOf2 8, SizeOf3 12, SizeOf4 16, SizeOf5 20, SizeOf6 24, SizeOf7 28, SizeOf8 32, SizeOf9 36, SizeOf10 40]



Proc MyProcedure:

Arguments @Line, @Row

Local @Color

Structure @POINT 8, @xDis 0,  @yDis 4

Uses esi, edi, ebx


; ...

EndP

Notice that this EndP restores the stack by Popping the preserved Registers, as saved into the &3 Internal String, and that the Structure is given by the Structures Dialog




MessageBox


[MessageBox

#If #N=1

call 'USER32.MessageBoxA' &NULL, {#1, 0}, {'Hi', 0}, &MB_OK

#Else_If #N=2

call 'USER32.MessageBoxA' &NULL, #2, {#1, 0}, &MB_OK

#Else_If #N=3

call 'USER32.MessageBoxA' &NULL, #2, {#1, 0}, #3

#Else_If #N=4

call 'USER32.MessageBoxA' #1, #3, {#2, 0}, #4

#Else

#Error 'The MessageBox Macro expects 2, 3 or 4 Parameters'

#End_If]


MessageBox 'Hello'


Unfolded:


 push &MB_OK | push &0 | push &0 | push &NULL

call 'USER32.MessageBoxA'


If more parameters are given in the Evocation (represented by the #N Condition), they are supposed to be: 1) for the Title, 2) for the Style, and 3) for the Parent. If more than four Parameters are passed to the Macro, it produces an Error Message, at Compile-Time.


~~~~~~~