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

4# 5 # This program computes the maximum magnitude for the elements of array A 6

ID: 3880615 • Letter: 4

Question

4# 5 # This program computes the maximum magnitude for the elements of array A 6 # and stores the value of the element with maximum magnitude at the label maxmag: 7 8 9 ·data 10 # DO NOT change the following three labels (you may change the initial values): 11 A: .word 1, -14, 9, 1o, -11, 6, 56, -60, 78, 100, 4, 5, o, 3, -5, 9 12 13 maxmag: .alloc 1 14 15 .text 16 17 main: addi $11, $0,15 18 19 20 21 lui $1, 4097 ori $9, i, o 1w $16,0 ($9) addi $9,$9,4 addi $11, $il,-1 23 24 25 loop: 1w 12,0 (St1) 26 27 28 sit 1, 12, 16 bne 1,co, next 1w 916,0 (912) 29 30 31 next: addi 011,011,-1 addi 99,99,4 bne 11,co,loop 32 34 35 $16,maxmag ($0) sw 36 # return to OS 7 3: 31 30 39

Explanation / Answer

Revised code (Debugged):-

.data
A: .word 1,-14,9,10,-11,6,56,-60,-78,100,4,-5,0,3,-5,9

maxmag: .alloc 1

.text

main:
addi $11,$0,15
la $9,A
lw $16,0($9)

addi $9,$9,4
addi $11,$11,-1

loop:

lw $12,0($9)

slt $1,$12,$16
bne $1,$0,next
move $16,$12


next:

addi $9,$9,4
addi $11,$11,-1
bne $11,$0,loop

sw $14,maxmag

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