Question: . Homework No. 5 Analyze the following MIPS code and give line-by-line explanations of the instructions. After making that, guess (write) the C program it

.
Homework No. 5 Analyze the following MIPS code and give line-by-line explanations

Homework No. 5 Analyze the following MIPS code and give line-by-line explanations of the instructions. After making that, guess (write) the C program it has been translated from. function: main: addiu $sp, $sp, -40 addiu $sp, $sp, -32 SW SW $ra, 36($sp) $fp, 32($sp) SW $ra, 28($sp) SW $fp, 24($sp) move $fp, $sp move $fp, $sp SW $4, 28($fp) SW $zero, 20($fp) SW $5, 24($fp) addiu $4, $zero, 7 lw $2, 28($fp) addiu $5, $zero, 3 lw $1, 24($fp) jal function slt $1, $1, $2 beqz $1, $B_2 nop addiu $2, $zero, 0 nop j move $sp, $fp $B 1 lw $fp, 24($sp) nop lw $ra, 28($sp) $B_1: addiu $sp, $sp, 32 lw $1, 28($fp) jr $ra SW $1, 16($fp) nop lw $1, 24($fp) $.str: SW $1, 28($fp) .asciz "%3d" lw $1, 16($fp) j SW $1, 24($fp) $B_2 nop $B_2: lw $1, 28($fp) SW j $1, 20($fp) $B_3 nop $B_3: $2, 20($fp) $1, 24($fp) slt $1, $1, $2 bnez $1, $B_6 nop j $B_4 nop $B_4: lw $5, 20($fp) lui $1, %hi($.str) addiu jal $4, $1, %10 ($.str) printf nop j $B_5 nop $B_5: $1, 20($fp) addiu $1, $1, 1 SW $1, 20($fp) $B_3 $B_6: addiu jr $ra nop $sp, $fp $fp, 32($sp) $ra, 36($sp) $sp, $sp, 40

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!