Calling conventions define how functions receive parameters and return values. They are essential to ensure correct execution when calling functions in assembly, C, or any other language.
ret instruction ensures execution resumes at the caller.rbp and adjusting rsp. Some conventions require the caller to clean up the stack.section .text ; Code section starts
global _start ; Entry point for the program
_start:
call my_function ; Call the function my_function
mov eax, 60 ; Load exit system call number (60) into eax
xor edi, edi ; Set exit status to 0 (edi = 0)
syscall ; Invoke system call to exit the program
my_function:
push rbp ; Save the old base pointer
mov rbp, rsp ; Set new base pointer to the current stack pointer
; Function body here (can include logic)
pop rbp ; Restore the old base pointer
ret ; Return to the caller
What is the purpose of the ret instruction in assembly?
Which register is used to store the return address?
Where are function parameters stored in x86-64?
Which register is used to pass the first integer argument in x86-64?
What is the primary purpose of the stack frame?
Which calling convention is used in Linux 64-bit systems?
What does the mov rbp, rsp instruction do?
Which instruction is responsible for calling a function in assembly?