addi $sp, $sp, -4 * number of caller saved registers
Save in-use registers (we may not have any to save):
sw $t0, 0($sp) sw $t1, 4($sp) ...
Grow the stack to pass arguments (if any):
addi $sp, $sp, -4 * number of arguments
Put the arguments on the stack:
sw ..., 0($sp) # First argument sw ..., 4($sp) # Second argument ...
Jump to the function (puts the return address into $ra):
jal functionLabel
To summarize:
addi $sp, $sp, -4 * number of caller saved registers sw $t0, 0($sp) sw $t1, 4($sp) ... addi $sp, $sp, -4 * number of arguments sw ..., 0($sp) # First argument sw ..., 4($sp) # Second argument ... jal functionLabel
First | Previous | Page 1 | Next | Last |
---|