Mips Instruction Format Cheat Sheet Page 8

ADVERTISEMENT

Use of the stack in procedure call
Before the subroutine executes, save registers.
Jump to the subroutine
using jump-and-link
(jal
address)
(jal
address means ra ¨ PC + 4; PC ¨ address)
After the subroutine executes, restore the registers.
Return from the subroutine
using jr (jump register)
(jr ra means PC ¨ (ra))
Example
int leaf (int g, int h, int i, int j)
{
int f;
f = (g + h) – (i + j);
return f;
}
The arguments g, h, i, j are put in $a0-$a3.
The result f is put into $s0, and returned to $v0.

ADVERTISEMENT

00 votes

Related Articles

Related forms

Related Categories

Parent category: Education