Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Problem 1 Points (40) The following problems deal with translating from C to MIP

ID: 3725967 • Letter: P

Question

Problem 1 Points (40) The following problems deal with translating from C to MIPS. Assume that the variables g, h, i, and j are given and could be considered 32-bit integers as declared in a C program a, f=f+ gt h+ i+ j + 2; b. f= g-(f+5); 1. Provide the MIPS assembly code for the above C statements. Use a minimal number of MIPS assembly instructions 2. For the C statements above, how many MIPS assembly instructions are needed to perform the C statement? c. add f. g, h b. addi f, f,1 sub f, g, h 3. For the MIPS statements above, what is a corresponding C statement? 4. If the variables f, g, h, and i have values 1,2,3, and 4 respectively What is the end value of f? 5. Using WeMips online emulator, execute your MIPS code and provide screen shots of your outputs. (30 pts)

Explanation / Answer

#1)

# a) f = -g + h + B[4]

# assuming f is $s0, g is $s1, h is $s2, i is $s3, j is $s4
# A is $s6 and B is $s7

move $s0, $s2       # f = h
sub $s0, $s0, $s1   # f = -g + h
lw $t0, 16($s7)       # $t0 = B[4]
add $s0, $s0, $t0   # f = -g+h+B[4]


# b) f = g-(f+5)

# assuming f is $s0, g is $s1, h is $s2, i is $s3, j is $s4

addi $s0, $s0, 5   # f = f+5
mul $t0, $s0, -1   # $t0 = -(f+5)
addi $s0, $s1, 0   # f = g
add $s0, $s0, $t0   # f = g-(f+5)

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote