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

QUESTION 1 (10 POINTS) FUCNTION CALLS MIPs native assembly code only has two bra

ID: 3780252 • Letter: Q

Question

QUESTION 1 (10 POINTS) FUCNTION CALLS MIPs native assembly code only has two branch instructions, beq and bne, and only one comparison instruction. slt. Using these instructions (along with, e.g., the ori instruction to set a register to 0 or 1), write the MIPS assembly language equivalents for each of the following "C" code snippets, and then also translate the resulting assembly instructions into machine code explaining for each line how you worked out the machine instruction (Assume that x s stored in register $6 y is stored in register $7, and z s stored in register $8. Remember that in "C", if an expression is true, it evaluates to 1 and if false, it evaluates to 0. Refer to Appendix A of the textbook for descriptions of MIPS assembly language) (b) x ((++z) y); (c) x y) (x

Explanation / Answer

2.Ans

jr $ra   
find: sub $sp,8
sw $s0,($sp)   
sw $ra,4($sp)   
move $s0, $a0   
sub $a0, 1
jal factorial   
mul $v0,$s0,$v0   
lw $s0,($sp)
lw $ra,4($sp)
add $sp,8
jr $ra


main:
la $a0,input
li $v0,4
syscall
li $v0,5
syscall
move $a0,$v0
jal factorial
move $t0,$v1
bnez $t0,overflow1
move $a0,$v0
li $v0,1
syscall
b end
overflow1:
la $a0,overflow
li $v0,4
syscall
end:
li $v0,10
syscall
.data

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