Page 1 of 1

Macro limitation with asm?

Posted: Mon Feb 20, 2006 7:21 pm
by Trond

Code: Select all

Global g
Macro Var(a)
  !mov eax, [v_a]
EndMacro
Var(g)
This fails, because the a is not subsituted with the g. Now, let's try this:

Code: Select all

Global g
Macro Var(a)
  !mov eax, [v_ a]
EndMacro
Var(g)
This fails, because while the a is substituted with the g, there is a space after the underline (= syntax error).

Now, is the only option to enable inline asm? I don't like it because of several reasons like the case correction and that the referencing of variables is not untouched.

What if I want a macro that is called like this:
Address(variable)
and moves the memory address of variable into eax? I can't use the approaches above with !. But I can always turn on inline asm and it should be a way to do it, or not?

Code: Select all

Global g = 5
Macro Address(a)
  MOV eax, a
EndMacro
Address(g)
This code doesn't work, because it gives me the value of a, not the address of a.

Code: Select all

Global g = 5
Macro Address(*a)
  MOV eax, *a
EndMacro
Address(g)
Not even close!

Code: Select all

Global g = 5
Macro Address(a)
  MOV eax, *a
EndMacro
Address(g)
A BUG in the macro parser: The asterisk goes into the trash can without warning.

Code: Select all

Global g = 5
Macro Address(a)
  MOV eax, @a
EndMacro
Address(g)
Hmm, @variable doesn't work in inline asm?

Now I don't have any more options but changing the requirements to get the macro to work. Like Address(@variable). But that's what I want to avoid.

Is this a logic "hole" in the macro system?

Posted: Mon Feb 20, 2006 7:39 pm
by Fred
Try this:

Code: Select all

Global g
Macro Var(a)
  !mov eax, [v_#a]
EndMacro
Var(g)

Posted: Mon Feb 20, 2006 7:44 pm
by Trond
Thank you, I should have read the readme file.