MIPS
ASSEMBLY LANGUAGE
3
types:
1)
Memory-reference instructions
2)
Arithmetic-logical instructions
3)
Branch and Jump instructions
Simple
operations in MIPS:
C
version:
f
= (g + h) [where f, g, and h are assigned to registers $s0,
$s1, $s2]
MIPS
version:
add
$s0, $s1, $s2
C
Version:
f
= (i + j) [where f, i, and h are assigned to registers $s0,
$s3, $s4]
MIPS
Version:
sub
$s0, $s3, $s4
C
Version:
g
= h + A[8] [where g and h assigned to registers $s1, $s2, t
registers are temporary registers]
MIPS
Version:
lw
$t0, 8($s3)
add
$s1, $s2, $t0
C
Version:
A[12]
= h + A[8] [h = $s2]
MIPS
Version:
lw
$t0, 32($s3)
add
$t0, $s2, $t0
sw
$t0, 48($s3)
C
Version:
g
= h + A[i] [g = $s1; h = $s2, i = $s4, A = $s3]
MIPS
Version:
add
$t1, $s4, $s4
add
$t1, $t1, $t1
add
$t1, $t1, $s3
lw
$t0, 0($t1)
add
$s1, $s2, $t0
IN-LAB
EXERCISE
|