I am new to ASM, and I'm trying to create a basic hello world program, using a function :
section .text
global main
print_msg:
push rbp
mov rbp, rsp
mov rax, 1
mov rdi, 1
mov rsi, Buffer ;to change
mov rdx, BufferSize ;to change
syscall
mov rsp, rbp
pop rbp
ret
main:
mov rdi, Buffer
mov rsi, BufferSize
call print_msg
mov rax, 60
mov rdi, 0
syscall
section .rodata
Buffer: db 'Hello, world !', 0x0A
BufferSize: equ $-Buffer
This code actually work, but only because I directly copied Buffer in rsi and BufferSize in rdx, in my "print_msg" function, but I want to copy the received arguements in these two registers, I saw something like :
mov rsi, [rsp + 8]
mov rdx, [rsp + 12]
But It doesn't work here.