YYYEJI

[MIPS] Procedure call 본문

Computer architectures

[MIPS] Procedure call

YEJI ⍢ 2022. 10. 10. 20:32
728x90

Procedure 란

C에서 흔히 말하는 function을 말합니다.

subroutine이라는 이름도 사용합니다.

 

즉, Procedure, function, subroutine은 함수를 의미하는 단어들 입니다.

 

 

Procedure call 은 함수를 부르는 과정입니다.

 

 

MIPS에서 procedure에 관련된 공간은 아래와 같습니다.

①  $a0 ~ $a3 - argument

②  $v0 ~ $v1 - return value

③   $ra - return address

 

 

procedure call 을 할 때 사용하는 instruction은 JAL과 JR이 있습니다.

①  JAL Label - function call 이 실행되면

✓  $ra ← 104 (Current PC value)

✓  PC ← 200 (from 104)

 

 

②  JR $ra - function return 이 실행되면 

✓  PC ← 104 (from $ra)

 

 

이렇게 함수가 MIPS에서 사용됩니다.

 

 

NOTE) 위 그림에서 caller는 main function,

callee는 label function 입니다.

 

 

◡̈

 

'Computer architectures' 카테고리의 다른 글

[CA] Simple Memory Layout  (0) 2022.10.13
[MIPS] Procedure Call using Stack  (0) 2022.10.10
[MIPS] Addressing mode  (0) 2022.10.10
[MIPS] Pseudo Instructions  (0) 2022.10.10
[MIPS] LUI instruction  (0) 2022.10.10