CSE230: Exam 1 Practice 2025
Questions and Answers 100% Pass
For the following C statement, what is the corresponding MIPS assembly code?
Assume that the variables f, g, h, and i are given and could be considered 32-bit
integers as declared in a C program. Use a minimal number of MIPS assembly
instructions.
f = g + (h − 5); - ANSWER-addi i ,h, -5
add f, g, i
For the following MIPS assembly instructions above, what is a corresponding C
statement?
add f, g, h add f, i, f - ANSWER-add f,g,h
add f,i,f
For the following C statement, what is the corresponding MIPS assembly code?
Assume that the variables f, g, h, i, and j are assigned to registers $s0, $s1, $s2, $s3,
and $s4, respectively. Assume that the base address of the arrays A and B are in
registers $s6 and $s7, respectively.
COPYRIGHT ©️ 2025 ALL RIGHTS RESERVED...TRUSTED & VERIFIED 1
, B[8] = A[i−j]; - ANSWER-sub $s5, $s2, $s3
sll $s5,$s5,2
add $s5,$s6,$s5
lw $s6, 0($s5)
św $s6, 32 $(s7)
For the MIPS assembly instructions below, what is the corresponding C statement?
Assume that the variables f, g, h, i, and j are assigned to registers $s0, $s1, $s2, $s3,
and $s4, respectively. Assume that the base address of the arrays A and B are in
registers $s6 and $s7, respectively.
sll $t0, $s0, 2 # $t0 = f * 4
add $t0, $s6, $t0 # $t0 = &A[f]
sll $t1, $s1, 2 # $t1 = g * 4
add $t1, $s7, $t1 # $t1 = &B[g]
lw $s0, 0($t0) # f = A[f]
addi $t2, $t0, 4
lw $t0, 0($t2)
add $t0, $t0, $s0
sw $t0, 0($t1) - ANSWER-B[g] = A[f] + A[1+f];
COPYRIGHT ©️ 2025 ALL RIGHTS RESERVED...TRUSTED & VERIFIED 2
Questions and Answers 100% Pass
For the following C statement, what is the corresponding MIPS assembly code?
Assume that the variables f, g, h, and i are given and could be considered 32-bit
integers as declared in a C program. Use a minimal number of MIPS assembly
instructions.
f = g + (h − 5); - ANSWER-addi i ,h, -5
add f, g, i
For the following MIPS assembly instructions above, what is a corresponding C
statement?
add f, g, h add f, i, f - ANSWER-add f,g,h
add f,i,f
For the following C statement, what is the corresponding MIPS assembly code?
Assume that the variables f, g, h, i, and j are assigned to registers $s0, $s1, $s2, $s3,
and $s4, respectively. Assume that the base address of the arrays A and B are in
registers $s6 and $s7, respectively.
COPYRIGHT ©️ 2025 ALL RIGHTS RESERVED...TRUSTED & VERIFIED 1
, B[8] = A[i−j]; - ANSWER-sub $s5, $s2, $s3
sll $s5,$s5,2
add $s5,$s6,$s5
lw $s6, 0($s5)
św $s6, 32 $(s7)
For the MIPS assembly instructions below, what is the corresponding C statement?
Assume that the variables f, g, h, i, and j are assigned to registers $s0, $s1, $s2, $s3,
and $s4, respectively. Assume that the base address of the arrays A and B are in
registers $s6 and $s7, respectively.
sll $t0, $s0, 2 # $t0 = f * 4
add $t0, $s6, $t0 # $t0 = &A[f]
sll $t1, $s1, 2 # $t1 = g * 4
add $t1, $s7, $t1 # $t1 = &B[g]
lw $s0, 0($t0) # f = A[f]
addi $t2, $t0, 4
lw $t0, 0($t2)
add $t0, $t0, $s0
sw $t0, 0($t1) - ANSWER-B[g] = A[f] + A[1+f];
COPYRIGHT ©️ 2025 ALL RIGHTS RESERVED...TRUSTED & VERIFIED 2