- Information
- AI Chat
Was this document helpful?
Mips ref exam - this is the mips reference sheet
Course: Introduction To Computer Science (FIT1008)
89 Documents
Students shared 89 documents in this course
University: Monash University
Was this document helpful?
MIPS reference sheet for FIT1008 and FIT2085
Semester 2, 2019
Table 1: System calls
Call code
($v0)
Service Arguments Returns Notes
1 Print integer $a0 = value to print - value is signed
4 Print string $a0 = address of string to print - string must be termi-
nated with ’\0’
5 Input integer - $v0 = entered integer value is signed
8 Input string $a0 = address at which the
string will be stored
$a1 = maximum number of
characters in the string
– returns if $a1-1 char-
acters or Enter typed,
the string is termi-
nated with ’\0’
9 Allocate memory $a0 = number of bytes $v0 = address of first byte -
10 Exit - - ends simulation
Table 2: General-purpose registers
Number Name Purpose
R00 $zero provides constant zero
R01 $at reserved for assembler
R02, R03 $v0, $v1 system call code, return value
R04–R07 $a0--$a3 system call and function arguments
R08–R15 $t0--$t7 temporary storage (caller-saved)
R16–R23 $s0--$s7 temporary storage (callee-saved)
R24, R25 $t8, $t9 temporary storage (caller-saved)
R28 $gp pointer to global area
R29 $sp stack pointer
R30 $fp frame pointer
R31 $ra return address
Table 3: Assembler directives
.data assemble into data segment
.text assemble into text (code) segment
.word w1[, w2, ...] allocate word(s) with initial value(s)
.space n allocate n bytes of uninitialized, unaligned space
.ascii ”string” allocate ASCII string, do not terminate
.asciiz ”string” allocate ASCII string, terminate with ’\0’
Table 4: Function calling convention
On function call:
Caller: Callee:
saves temporary registers on stack saves value of $ra on stack
passes arguments on stack saves value of $fp on stack
calls function using jal fn label copies $sp to $fp
allocates local variables on stack
On function return:
Callee: Caller:
sets $v0 to return value clears arguments off stack
clears local variables off stack restores temporary registers off stack
restores saved $fp off stack uses return value in $v0
restores saved $ra off stack
returns to caller with jr $ra