MIPS Assembly

advertisement
MIPS Assembly
Questions
• Is it correct to write this instruction?
add $s0, $s1, $s2, $s3
Questions
• Is it correct to write this instruction?
add $s0, $s0, $s0
Questions
• How to use only one instruction to set $t0 to 0?
Questions
• Is it correct to write this instruction?
lw $s0, 100($s0)
Questions
• Is it correct to write this instruction?
lw $s0, $s1($s0)
Questions
• Is it correct to write this instruction?
add $s0, 100($s1), $s2
Questions
• Suppose memory at address 1000 to 1028 are storing 1,2,…,8 (in each
4 bytes). Suppose $t0 is 1000. What will be in $t0 after this
instruction?
lw $t0, 16($t0)
Exercise
• Suppose we have the address of A[i] in $t0, where A is an integer
array. Write instructions to swap A[i] and A[i+1].
lw
lw
sw
sw
$t1,
$t2,
$t2,
$t1,
0(t0)
4(t0)
0(t0)
4(t0)
Processor
Memory
Address
100
t1
t2 xxxxxxxxx
x
100
101
t0
t0+4
100
101
t0
t0+4
101
101
t0
t0+4
101
100
t0
t0+4
t1
t2
100
101
t1
t2
100
101
t1
t2
100
101
Assume the values
are 100 and 101
Download