Question
- For this question we assume MIPS has no divide instructions so you are not allowed to use them. You are to implement a MIPS function labelled div that divides two 16-bit unsigned numbers. Adjust appropriately for 16 bit numbers and 32 bit arithmetic. When the function is called the dividend is in $a0 and the divisor is in $a1. Upon return the quotient should be in $vo and the remainder in $v1. Your submitted file must be called div.asm and should only contain your div function and not the code you used to test it. We will be inserting your function into our own code to test it so make sure it follows the specifications above and the standard MIPS register usage conventions presented in class.
B2 [50]You are to extend the MIPS assembly language program fmean.asm provided with this assignment.
In addition to computing and displaying the mean, your modified program is to compute and display the range of the input data. The range is the maximum input value minus the minimum input value (the values are not input in any particular order).
Your program must have a new function for computing the range Use the given display routine for displaying the results. Your output should be appropriately labeled.
Your submitted file must be named fp.asm.
Solution Preview
This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.
div:move $t0, $zero # set quotient = 0
move $t1, $a0 # set remainder = devidend
sll $t2, $a1, 16 # set divisor
move $t3, $zero # set counter = 0
#move $t4, $zero # set number of loop
addi $t4, $zero, 17 # add 17
Loop:
# sub $t1, $t1, $t2 # rem = rem - divisor
slt $t5, $t1, $t2 # if(t1 < t2) t5 = 1 else t5 = 0
beq $t5, $zero, Greater # if rem >= 0 move to Greater...