NASM - The Netwide Assembler
NASM Forum => Programming with NASM => Topic started by: radlyeel on September 01, 2022, 09:14:47 PM
-
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
-
If you use %define instead of %assign, it assembles. Reading the manual, I believe it acts the same, but accepts memory addresses as part of the macro.
-
Is this any help?
https://forum.nasm.us/index.php?topic=1769.
Best,
Frank
-
Is this any help?
https://forum.nasm.us/index.php?topic=1769./myccpay (https://www.myccpay.me/)
Best,
Frank
Hello, Frank Kotler
I also have this same question and I cannot find any proper answers, But today i was find my solution is here.
Thanks,