Until you become familiar with the SPIM registers use only registers $t0-$t9
and $s0-$s7
Use symbolic names rather than real values to avoid clashing with special
uses of a register, for example register $28 ($gp) is initialized to a
special address in the data segment
Input/Output Instructions
The interface to the screen and keyboard is through a group of registers
and a special instruction: the syscall instruction
this instruction wakes up the system programs which are privileged and
can interface to the keyboard and screen
the system program looks to $v0 for a code to determine what function needs
to be performed
the system program uses $a0 for data it needs (e.g., printing a number
to the screen) or as the destination of data (e.g., data being read from
keyboard input)
Service
Code
Arguments
Result
print integer
1
$a0 = integer
read integer
5
integer in $v0
print string
4
$a0 = string addr
read string
8
$a0 = buffer $a1 = length
Examples
Using Labels
Absolute values of addresses are difficult to keep track of
We would rather deal with names or labels
Instructions or data directives can be labeled
the value of the label is the address of the corresponding memory location
this label can be used in other instructions in lieu of the actual numerical
value of the memory address
Examples
Immediate Instructions
Such instructions are useful when we know the values of one of the operands
Examples: addi, lui, li, la
Instruction Types
Pseudoinstructions vs. native instructions
Some instructions may have to be translated into sequences of simpler instructions,
for example when using labels in instructions since labels are themselves
32 bit quantities