MIT6.S081笔记:lecture 5
MIT6.S081笔记:lecture 5 calling conventions and stack
Calling convenstions
RISC-V Register File
Integer Instructions
lb t0, 8(sp)
loads from memory address (sp+8) into register t0
lb = load byte, lh = load halfword, lw = load word, ld = load doubleword
add a0, t0, t1
adds value of t0 to the value of t1 and stores the sum into a0
addi a0, t0, -10
adds value of t0 to the value -10 and stores the sum into a0
mul a0, t0, t1
multiplies the value of t0 to the value of t1 and stores the product int a0
Pseudo Instructions
- translate to real instructions by assembler
Branching Instructions
- a way to jump to different parts of your code
- Branching refers to the “conditional jump” instructions, such as
beq, bne, bgt, bge, blt, ble
for branch-if equals, not equals, greater than, greater than or equals, less than, and less than or equals, respectively.
1 | # t0 = 0 |
Stack
Stack frame
stack frame is generated by function calls
start from high addresses and grow downwards to low addresses
the return address and to prev frame pointer are at a predictable position
sp - bottom of the stack
fp - top of the current frame
Use backtrace to debug
- Post title:MIT6.S081笔记:lecture 5
- Post author:sixwalter
- Create time:2023-08-05 11:14:26
- Post link:https://coelien.github.io/2023/08/05/course-learning/MIT6.S081/lec5/
- Copyright Notice:All articles in this blog are licensed under BY-NC-SA unless stating additionally.
Comments