Notice
Recent Posts
Recent Comments
Link
250x250
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | 4 | 5 | 6 | 7 |
| 8 | 9 | 10 | 11 | 12 | 13 | 14 |
| 15 | 16 | 17 | 18 | 19 | 20 | 21 |
| 22 | 23 | 24 | 25 | 26 | 27 | 28 |
Tags
- Pipelining
- Java
- Algorithm
- control
- CSS
- mysql
- for
- instruction
- Rag
- XML
- Linux
- web
- openai
- DS
- react
- github
- php
- javascript
- DB
- html
- MIPS
- architecture
- function
- DATAPATH
- AI
- Class
- system
- python
- computer
- data structure
Archives
- Today
- Total
YYYEJI
[MIPS] Procedure Call using Stack 본문
728x90

Procedure call을 할 때 stack을 사용합니다.
✓ main 함수는 caller
✓ label 함수는 callee
ʷʰʸ
main 함수에서 $s0 register을 사용하다가 jal instruction을 수행해서
label 함수로 갔을 때 label 함수도 $s0 register을 사용할 수도 있습니다.
이때, main 함수에서 $s0 값을 저장하지 않고 label 함수로 넘어간다면 main 함수의 $s0 값이 사라지게 됩니다.
그래서 caller 함수에서는 stack register의 값을 push하고 pop 할 수 있습니다.

위와 같이 register의 값을 저장하기 위해 stack을 사용합니다.
✓ Stack poiner ($sp)로 어느 stack의 위치가 active한지 알려줍니다.
✓ Spilling register의 의미는 function에서 사용했던 register를 보관한다는 뜻입니다.

✓ reserved - push value (in caller procedure)
✓ restored - pop value (in caller procedure)

note) stack - last in first out
◡̈
728x90
'Computer architectures' 카테고리의 다른 글
| [MIPS] Bit-wise AND(&)로 Logical AND(&&) 구하기 (2) | 2022.10.19 |
|---|---|
| [CA] Simple Memory Layout (0) | 2022.10.13 |
| [MIPS] Procedure call (0) | 2022.10.10 |
| [MIPS] Addressing mode (0) | 2022.10.10 |
| [MIPS] Pseudo Instructions (0) | 2022.10.10 |