%macro printhello 0
section .rodata
%%msg: db "Hello, world.", 10, 0
section .text
push %%msg
call printf
add esp, 4
%endmacro
The problem is that every time the macro appears in the program, NASM preprocessor will invent a new name for the label msg
and there will be multiple definitions of the same string "Hello, world."
I could define the string without the %%
prefix, but if the macro will be used more than once, I will get an assembly error for redefining the same symbol, msg
. So how can I avoid multiple definitions of that string?