NASM - The Netwide Assembler
NASM Forum => Programming with NASM => Topic started by: gammac on June 27, 2014, 12:48:16 PM
-
Hello!
The following macro is part of my real macro, but I reduced it to the problem.
%macro show_problem 0
%define %%str
%xdefine %%str %%str %+ 0x0
%endmacro
It gives me this error:
fatal: (show_problem:3) No lvalue found on pasting
The macro works well if I initialize %%str, but I don't need any initialization value. Is it possible to initialize it with something that do not expand? Or something that would only expand to a space character? I feel, if I had tried thousand things but nothing worked.
A work around is not the problem, but maybe a workaround can be avoided.
Thank you
-
I don't know the answer to that one. I'm not a sophisticated macro user. I do use a macro with something defined "as nothing"...
%define ptr
%define offset
; some Masm/Tasm code
This causes "ptr" and "offset" to "vanish", as intended. So I'm not surprised your macro doesn't work. Obviously you intend something different... but I'm not sure what.
Best,
Frank
-
%xdefine %%str %%str %+ %%l,
this line builds a sequence like that one: 5,18,16,22,0,1,
but it only works if %%str is initialy defined with something.
btw: str is a bad name, because this sequence must be a token or a token sequence
db %%str ; as string results in
db "5,18,16,22,0,1,0"
db %%str ; as token sequence results in
db 5,18,16,22,0,1,0
-
That won't work because the concatenation operator (%+) requires a valid left-hand value (lvalue) to concatenate to. You could wrap the code in an %ifdef statement instead.
%ifdef %%str
%xdefine %%str %%str %+ %%l,
%else
%define %%str %%l,
%endif
-
Thank you!
I'd hoped that there is an valid empty token, that acts like zero in arithmetic additions or as "" in string concatenation.
Maybe it will be implemented in one of the next versions of NASM?!