So I'm learning x86_64 nasm assembly on my mac for fun. After hello world and some basic arithmetic, I tried copying a slightly more advanced hello world program from this site and modifying it for 64 bit intel, but I can't get rid of this one error message: hello.s:53: error: Mach-O 64-bit format does not support 32-bit absolute addresses
. Here is the command I use to assemble and link: nasm -f macho64 hello.s && ld -macosx_version_min 10.6 hello.o
. And here is the relevant line:
cmp rsi, name+8
rsi is the register I am using for my index in the loop, and name is a quad word reserved for the user input which is the name, which by this point has already been written.
Here is a part of the code (to see the rest, click the link and go to the bottom, the only difference is that I use 64 bit registers):
loopAgain:
mov al, [rsi] ; al is a 1 byte register
cmp al, 0x0a ; if al holds an ascii newline...
je exitLoop ; then jump to label exitLoop
; If al does not hold an ascii newline...
mov rax, 0x2000004 ; System call write = 4
mov rdi, 1 ; Write to stdout = 1
mov rdx, 1 ; Size to write
syscall
inc rsi
cmp rsi, name+8 ; LINE THAT CAUSES ERROR
jl loopAgain
gcc -S
, and look at the assembly to see how GCC handles it. – Diffluentname: resb 8
– Larvicide