.text
.global main
// code for main
main:
push %r13
push %r14
push %r15
pushq $2
call show
pop %r15
pop %r14
pop %r13
mov $0,%rax
ret
// code for show
show:
popq x
pushq x
popq gen
lea genfmt_(%rip),%rdi
movq gen(%rip),%rsi
.extern printf
call printf
ret
.data
gen: .quad 0
genfmt_: .byte '%','u',10,0
x: .quad 0
The title pretty much sums it up. I have no idea why this is generating a segmentation fault error. From my understanding the stack pointer is aligned when I push r15,r14,r13 I then keep it aligned before calling print f. I'm new to assembly so any help is appreciated!