Question: Assembly Language ##################################################################### ## PROBLEM 1: weighted_avg ## ## Compute a weighted average of three 32-bit numbers, A, B, and C ## return (.25A +

Assembly Language

#####################################################################

## PROBLEM 1: weighted_avg ## ## Compute a weighted average of three 32-bit numbers, A, B, and C ## return (.25A + .25B + .5C) ## A,B, and C are in $a0, $a1, and $a2 respectively. The result ## should be returned in $v0. ## ## HINT: Do not use mult/div or floating point values. To keep ## precision for as long as possible, minimize the number of ## division operations. ##################################################################### weighted_avg: # YOUR CODE HERE jr $ra

main: ######################################## ## TEST PROBLEM 1 ## ########################################

li $a0, 1 jal print_problem_header

li $a0, 42 li $a1, 10 li $a2, 10 jal weighted_avg # weighted_avg = 18 move $a0, $v0 jal print_int jal print_space

li $a0, 500 li $a1, 1000 li $a2, 500 jal weighted_avg # weighted_avg = 625 move $a0, $v0 jal print_int jal print_space

li $a0, 30 li $a1, 31 li $a2, 30 jal weighted_avg # weighted_avg = 30 move $a0, $v0 jal print_int jal print_newline

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!