What registers should arguments be placed in for procedure calls?
$a0 - $a3
What registers should data be placed in to be output from a procedure call?
$v0 - $v1
Non-nested procedure call sequence of actions
1. Put arguments in registers $a0 - $a3
2. Transfer control to the procedure using jal
3. Acquire storage space (if needed)
4. Perform the task
5. Place results in registers $v0 - $v1
6. Return to the calling procedure using jr $ra
How is overwriting data in registers prevented?
The newly called procedure will save the results of registers it will use before it performs it's actions. Then, it restores them before it returns to the calling procedure.
$sp stands for
Stack pointer
$fp stands for
Frame pointer
Which pointer is "on top" of the stack?
The stack pointer
What is the purpose of $fp
To "frame" the current function, or region of the stack
MiniMIPS memory regions (lowest address (0) to highest)
Reserved area for OS
Program text segment
Static data segment
Dynamic data segment
The stack
Which regions of MiniMIPS memory are in the data segment?
Static data segment
Dynamic data segment
$gp points to
The start of the dynamic data segment
Order of variables on the stack
1. Saved registers
2. Local variables
MiniMIPS loading and storing byte instructions
lb
lbu
sb
MiniMIPS lb instruction
Stands for "load byte"
Loads a single byte from main memory
The register is sign-extended
MiniMIPS lbu instruction
Stands for "load byte unsigned"
Loads a single byte from memory, treats it as unsigned value
The register is zero-extended
MiniMIPS sb instruction
Stands for "store byte"
Stores a byte into memory
Methods of accessing an array
Pointer - Store the address of the current element and increment it directly
Index - Store an index and add it to some base address to access an element
MiniMIPS multiplication/division instructions
mult
div
mfhi
mflo
MiniMIPS mult instruction
$hi becomes rs x rt
$lo becomes rs x rt
MiniMIPS div instruction
$hi becomes rs mod rt$lo becomes rs / rt
MiniMIPS mfhi instruction
Moves the content of $hi to rd
MiniMIPS mflo instruction
Moves the content of $lo to rd
MiniMIPS logical shift instructions
sllsrl
sllvsrlv
MiniMIPS sll instruction
Shifts the value addressed by rt left by sh places
Places value in rd
MiniMIPS srl instruction
Shifts the value addressed by rt right by sh places
Places value in rd
MiniMIPS sllv instruction
Shifts the value addressed by rt left by the number of places in specified by a register given by rsPlaces value in rd
MiniMIPS sllv instruction
Shifts the value addressed by rt right by the number of places in specified by a register given by rs
Places value in rd
Which MiniMIPS instructions have unsigned versions