ECE445
Lecture 3
1) Write the MIPS assembly language instruction to implement the C instruction given below.
f = a - b;
Assume the following
a is in $s1
b is in $s2
c is in $s3
d is in $s4
f is in $s0 - correct answer sub $s0, $s1, $s2
Lecture 3
2) Write the MIPS assembly language instruction(s) to implement the C instruction given below.
f = d + c - 3;
Assume the following
a is in $s1
b is in $s2
c is in $s3
d is in $s4
f is in $s0 - correct answer add $s0, $s3, $s4
addi $s0, $s0, - 3
Lecture 3
3) Write the MIPS assembly language instruction(s) to implement the C instruction given below.
,f = a && 0xF8F8;
Assume the following
a is in $s1
b is in $s2
c is in $s3
d is in $s4
f is in $s0 - correct answer andi $s0, $s1, 0xF8F8
Lecture 3
4) Write the MIPS assembly language instruction(s) to implement the C instruction given below.
f = b || c || d;
Assume the following
a is in $s1
b is in $s2
c is in $s3
d is in $s4
f is in $s0 - correct answer or $s0, $s3, $s4; or $s0, $s0, $s2
Lecture 3
5) Write the MIPS assembly language instruction(s) to implement the C instruction given below.
f = c * 8;
Assume the following
a is in $s1
b is in $s2
c is in $s3
d is in $s4
,f is in $s0 - correct answer sll $s0, $s3, 3
Lecture 3
6) Write the MIPS assembly language instruction to read data from the given memory location into
variable f.
f = MEM[0x1000001C];
Assume the following
f is in $s0
Memory address 0x10000000 is in $t0 - correct answer lw $s0, 28($t0)
Lecture 3
7) Write the MIPS assembly language instruction to write data from variable f to the given memory
location.
MEM[0x10000024] = f;
Assume the following
f is in $s0
Memory address 0x10000000 is in $t0 - correct answer sw $s0, 36($t0)
Lecture 3
8) Which of the following MIPS assembly language instructions is not an R-type instruction?
sub $s0, $t1, $t3
and $t0, $t2, $t4
sll $s1, $s2, 5
beq $s4, $t5, next
slt $t7, $s6, $s7 - correct answer beq
, Lecture 3
9) Which of the following MIPS assembly language instructions is not an I-type instruction?
lw $s0, 8($t0)
addu $s2, $s4, $s6
addi $t1, $t2, 17
bne $s3, $t3, end
sw $s5, 20($t4) - correct answer addu
Lecture 3
10) Convert the MIPS assembly language instruction given below to MIPS machine language.
sub $t0, $s1, $s5 - correct answer 0x02354022
Lecture 3
11) Convert the MIPS assembly language instruction given below to MIPS machine language.
lw $s0, 20($t1) - correct answer 0x8d300014
Lecture 3
12) Convert the MIPS assembly language instruction given below to MIPS machine language.
srl $s1, $t0, 2 - correct answer A?
Lecture 3
13) Which of the following MIPS machine language instructions is not an R-type instruction?
0xAE2B0034
ML instruction