Author Topic: Concatenating into strings  (Read 468 times)

Offline eekee

  • New Member
  • Posts: 1
Concatenating into strings
« on: December 20, 2019, 11:28:54 PM »
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: [Select]
defword foo should include both
Code: [Select]
foo: and
Code: [Select]
db 'foo'
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: [Select]
%xdefine q '

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

Is there a 'proper' way to do this?