GNU assembler: creating a symbol using macro argument -
i have macro creates labels, want create labels if aren't defined. problem label built using macro argument, , assembler doesn't symbols generated using macro arguments. code doesn't work. errors out on ifndef. there other way write this?
.macro create_handler modifier .ifndef handler\modifier handler\modifier: code more code .endif .endif
error: junk @ end of line, first unrecognized character `\'
i think there 2 problems. 1 \modifier:
looks macro argument named modifier:
, colon. need use \modifier\():
instead. \()
breaks string parser knows have ended name of argument.
second, last .endif
should .endm
:
.macro create_handler modifier .ifndef handler\modifier handler\modifier\(): .4byte 0 .endif .endm create_handler foo create_handler foo
this results in listing (ignore line numbers, added 1 of existing files):
74 0010 00000000 create_handler foo 75 create_handler foo defined symbols ../src/core_dict.s:74 .text:00000010 handlerfoo
as can see, 1 handlerfoo
created.
Comments
Post a Comment