Does NASM have something like as's .SET, which changes the value of a symbol? I *thought* %assign would be my friend, but alas, I was wrong yet again It would be useful to build a linked list, like this:
default rel
%assign lnk 0
%macro node 3 ; usage: node "name". 4, 7
db %2 ; insert name length
db %1 ; insert name
align 8, db 0 ; pad 0s to 8-byte boundary
dq %3 ; store value
dq lnk ; store link to preceding node
%assign lnk $-16 ; set new value of link for next node
%endmacro
; satisfy NASM, ld, an lldb for examining results
global _main
_main: jmp $
node "OUN",2, 1
node "TROIS",5,3
With that, I get this:
$ nasm -g -f macho64 -o demo.o demo.s
demo.s:15: error: non-constant value given to `%assign'
demo.s:9: ... from macro `node' defined here
demo.s:16: error: non-constant value given to `%assign'
demo.s:9: ... from macro `node' defined here