I wrote this just to print out an integer, why am I getting a segmentation fault? (Using the gnu assembler)
.extern printf
.data
n: .long 12345
.text
.global _start
_start:
xorq %rax, %rax
movq n, %rdi
call printf
movq $60, %rax # syscall number for exit
xor %rdi, %rdi # status 0
syscall # call kernel
I keep getting a segmentation fault. Also-- am I also meant to set %rsi to something or is that just for syscalls? Also I always link it with gcc so extern is not the issue. I've also tried changing n to n: .string "12345\n\0" but it still gives me a segmentation fault