Intro to MIPS Assembly Language
Let's Start with Addition
C | MIPS |
a = b + c; |
add a, b, c |
-
This is general format for MIPS
add
instruction (and
sub
instruction),
but what are variables a
, b
, and c
?
-
add
and sub
instructions always acts on
registers
-
Let's assume variables
a
, b
,
c
, d
, e
have been put in
$s0
, $s1
, $s2
,
$s3
, $s4
-
add a, b, c
should be
add $s0, $s1, $s2
-
Operands always have to be in registers?
-
There is also an
addi
instruction (but not a
subi
instruction) that adds an
immediately following constant.
C | MIPS |
a = b + 4; |
addi $s0, $s1, 4 |
Alyce Brady, Kalamazoo College