我正在尝试进行一项必须让程序要求一个整数的赋值,只是将它递增1,然后再次输出。但是,在输入所述整数后,我收到“Segmentation fault”错误消息。我完全迷失了,请帮忙,这可能是一个非常愚蠢的错误。
.global main
readString: .asciz "%ld"
main:
subq $8, %rsp # reserving space for the variable on the stack
leaq -8(%rbp), %rsi # loading the effective memory adress into %rsi
movq $readString, %rdi # Load the first argument of scanf into %rdi
movq $0, %rax # Clear %rax
call scanf # Calling scanf from the C library
movq %rsi, %r9 # Loading the scanned integer into %r9
inc %r9 # Increment %r9 by one
movq $0, %rax # Clear %rax
movq %r9, %rdi # Loading the incremented integer into %rdi
call printf # Calling printf from the C library
call end # Ending the program
end:
mov $0, %rdi # Loading the exit code
call exit # Calling the exit code