x86-64 uses registers to pass arguments, as your code also illustrates:
mov rdi, Buffer
mov rsi, BufferSize
call print_msg
If you loaded rdi
and rsi
with the arguments, why do you expect them to be on the stack in the called function? CALL
doesn't do anything to the registers, and only puts the return address on the stack. Thus, your two arguments are still happily in rdi
and rsi
. Just mov
them to the correct place:
mov rdx, rsi
mov rsi, rdi
mov rax, 1
mov rdi, 1
syscall