Download presentation
Presentation is loading. Please wait.
1
MIPS Assembly
2
Questions Is it correct to write this instruction?
add $s0, $s1, $s2, $s3 No. Can only take two for add, produce one
3
Questions Is it correct to write this instruction? add $s0, $s0, $s0
Yes
4
Questions How to use only one instruction to set $t0 to 0?
Add $t0, $0, $0
5
Questions Is it correct to write this instruction? lw $s0, 100($s0)
Yes
6
Questions Is it correct to write this instruction? lw $s0, $s1($s0)
No. The number must be a constant
7
Questions Is it correct to write this instruction?
add $s0, 100($s1), $s2 No. The two numbers to be added must be registers, not from memory
8
Questions Suppose memory at address 1000 to 1028 are storing 1,2,…,8 (in each 4 bytes). Suppose $t0 is What will be in $t0 after this instruction? lw $t0, 16($t0) 5
9
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 $t1, 0(t0) lw $t2, 4(t0) sw $t2, 0(t0) sw $t1, 4(t0)
10
Processor Memory Address t1 100 Assume the values are 100 and 101 100 t0 t2 xxxxxxxxxx 101 t0+4 lw $t1, 0(t0) lw $t2, 4(t0) sw $t2, 0(t0) sw $t1, 4(t0) t1 100 100 t0 t2 101 101 t0+4 t1 100 101 t0 t2 101 101 t0+4 t1 100 101 t0 t2 101 100 t0+4
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.