The following code works. However, it does NOT work if I remove the #1 line. I do not understand why storing $0 in %rax makes it work.
.section .data
msg: .ascii "Hello world!\n"
.text
.globl main:
main:
movq $msg, %rdi
movq $0, %rax #1
call printf
The following code seg faults
.section .data
msg: .ascii "Hello world!\n"
.text
.globl main:
main:
movq $msg, %rdi
call printf
I read that to do a sys call an integer value that designates the call is required in %rax. I have done this using write() and it worked beautifully. However, examples I find for printf don't seem to have this requirement.
Any help with this matter is appreciated. I can explain more if necessary