This question already has an answer here:
- NASM compiling x86_64 ASM label addresses off by 256 bytes in Mach-O when using multiple db declarations? 2 answers
I'm learning ASM and I have a small problem. I can't "declare" more than one string in "section.data". I'm trying something like this:
section .data
string1 db "test1 ", 0;
string2 db "test2 ", 0;
section .text
global _test
extern _puts
_test:
lea rdi, [rel string1]
call _puts
lea rdi, [rel string2]
call _puts
ret
This function is supposed to print "test1 test2 " on STDOUT, but it doesn't work. The result is:
test2
It only works for the last string stored! If someone know why, please tell me!