caller calls callee
Set register x10(a0) - x17(a7) with the arguments in order before caling the function.
(8 registers)
If the function takes more than 8 arguments, the rest of the arguments are passed to the callee using memory.
RISC-V calle convention is designed to pass only one value from callee to caller
<Return Value>
Use register x10(a0) - x11(a1)
x10 [31:0]
x11 [63: 32]
If we do not have to use a0, a1 after calling a function,
we can reuse a0, a1 register to send the result back to the caller
-> can save registers, use registers for other optimization
If the return value is larger than 64-bit, the return value is passed through memory.
<Prodecure Call Instrucitons>
Procedure call: jump-and-link instruction
jal x1, ProcedureLabel
jumps to the target address
save the address of the next instruction in x1
x1's register name is ra (return address)
x1: store return address
Procedure return: jump-and-link register instruction
jalr x0, offset(x2)
x0: save return address, x2: basic address
jump to offset + address in x2
address of the next instruction -> x0
'SKKU SW > Computer Architecture' 카테고리의 다른 글
[컴퓨터구조] 캐시 실패의 처리 (0) | 2023.06.01 |
---|---|
[컴퓨터구조] 5. Memory Hierarchy 메모리 계층구조 (0) | 2023.05.28 |
[컴퓨터구조] RISC-V Instruction Formats(2) (0) | 2023.04.15 |
[컴퓨터구조] RISC-V Instruction Formats(1) (0) | 2023.04.14 |
[컴퓨터구조] Logical operations (0) | 2023.04.14 |