NASM issue on OSX 64-bit

I am learning ASM and I have a little problem. I cannot "declare" more than one line in "section.data". I am 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 should print "test1 test2" in STDOUT, but it does not work. Result:

test2

It only works for the last saved line! If anyone knows why, please tell me!

+4
source share
1 answer

If you are using nasm2.11.08, there is a problem documented here to do relative addressing in combination with several entries in the data section.

You can do one (or both) of two things to be sure.

-, , , . , , , , .

-, nasm, , . , , 2.11.08, .

+2

All Articles