NASM Forum > Programming with NASM

Concatenating into strings

(1/1)

eekee:
I want to expand a macro parameter into both a label and a string. It's for a forth interpreter where I want to pass the name of a 'word' to a macro once, and have that name expand into both a label and a string. For instance, the expansion of
--- Code: ---defword foo
--- End code ---
should include both
--- Code: ---foo:
--- End code ---
and
--- Code: ---db 'foo'
--- End code ---

I've found a way to do it, but it's rather weird, is two macros, and produces a warning, "unterminated string" on the first macro. This is a simplified form:

--- Code: ---%xdefine q '

%macro defword 1
%1:    db %[q]%1%[q],13,10
%1len equ $-%1
%endmacro

--- End code ---

Is there a 'proper' way to do this?

Navigation

[0] Message Index

Go to full version