Function Items Flashcards
What is a function in programming
a stored subroutine that performs a specific task based on the parameters with which it is provided
How do we name and label a function in MIPS
same way as a reg label and there is no different between that and other labels.
How do we call a function in MIPS
jal function_name
How do we return from function in MIPS?
jr $ra
Where do we return from the function? In other words, what will be the next instruction executed after the function return?
the next instruction executed is the one immediately following the jal
What is caller?
the program that instigates a procedure and provides the necessary parameter values
Callee
a procedure that executes a series of store instructions based on parameters provided by the caller and then returns control to the caller
Stack pointer
a value denoting the most recently allocated address in a stack that shows where registers should be spilled or where old register values can be found. In MIPS, it is register $sp. The top of the stack
The stack pointer is adjusted by one word for each register that is saved or restored.
The stack grows from a higher address to a lower address
You push values onto the stack by subtracting from the stack pointer. Adding to the stack pointer shrinks the stack, and thereby pops values off of it.
What are MIPS function calling conventions regarding s-registers.
$s0 - $s7: saved registers that must be preserved on a procedure call (if used, the callee saves and restores them)
t-registers
$t0 - $t9: temporary registers that are not preserved by the callee on a procedure call
Where do we save the value of the register?
On stack