Macro limitation with asm?

Everything else that doesn't fall into one of the other PB categories.
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Macro limitation with asm?

Post 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?
Fred
Administrator
Administrator
Posts: 18351
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Post by Fred »

Try this:

Code: Select all

Global g
Macro Var(a)
  !mov eax, [v_#a]
EndMacro
Var(g)
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post by Trond »

Thank you, I should have read the readme file.
Post Reply