I'm trying to write a simple x64 assembly program on mac using nasm. Here is my program:
global start
section .text
start:
mov r10, 3; Store 3 to r10
mov r9, 4; Store 4 to r9
mov rax, r10; Move 3 to rax because multiply needs an arg in rax
mul r9; Multiply 3*4. Result in rax.
mov r9, rax; Move result back to r9.
mov [myVar], r9; Store result to global
mov r11, [myVar]; Load global result into r11
mov rdi, r11; Move result into rax, the argument for syscall
mov rax, 0x02000001; Select exit system call
syscall
section .bss
myVar:
resq 1
I'm assembling using this command:
nasm -fmacho64 test.s
I get this error:
test.s:10: error: Mach-O 64-bit format does not support 32-bit absolute addresses
test.s:11: error: Mach-O 64-bit format does not support 32-bit absolute addresses
What am I missing? I just want a 64 bit global variable I can read to and write from.