@all
- you shouldn't use 'test' as a name for the macro, because TEST is a keyword in FASM
Code: Select all
!macro bla
!{
MessageRequester("test","hello")
!}
!bla
!bla
- the difference between macros and procedures is, that the body of a macro is filled in to each position, where it is called. This speeds up, because no procedure-call is made, but blows up your code, if you call a big macro at many different places.
- you can use parameters (S.M. already showed it), but it's a bit 'unhandy' unless implemented in PB. :
Code: Select all
Global a.l, b.f
!macro my_macro op1, op2
!{
!MOV [v_a], op1
!MOV [v_b], op2
Debug a
Debug b
!}
c = 999
!MOV eax, [v_c]
!my_macro eax, 1.238
Another way uses the stack:
Code: Select all
Global tempL1.l, tempL2.l, tempL3.l
!macro my_macro2
!{
!POP [v_tempL1]
!POP [v_tempL2]
!POP [v_tempL3]
tempL1 = tempL1 + tempL2 + tempL3
!PUSH [v_tempL1]
!}
param1 = 1
param2 = 2
param3 = 3
result = 0
!PUSH [v_param1]
!PUSH [v_param2]
!PUSH [v_param3]
!my_macro2
!POP [v_result]
Debug result
@traumatic
I don't know a way to use the macro-parameters directly in the macro's body outside an ASM-line. We'll always have to wrap the values to a variable before.
=> Macros would be very nice to have, and I think this could't be too complicated because FASM does the main job anyway. Perhaps PB 4.0
