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

Hello, can you please correct the errors from my assignment 12:06? a mail-attach

ID: 3741290 • Letter: H

Question

Hello, can you please correct the errors from my assignment

12:06? a mail-attachment.googleusercontent.com 11 of 13 Scanned by CamScanner IIIMIPS Structures Translate the following into MIPS, assuming the reglster assignments below. You may use as necessary 130 pts, 15 pts eachl. temporaries able hreshold g addressof a end else diff x-Y 3 end at this pain 2. while (threshold> aly eyo xaY: 3 Scanned by CamScanner v. Functions: Part Below is a Java function that takes an array of ta elements and computes their sum public int aun(int arr, int ) int total 0 SO for (int i-0; i N1 ?++)-1 total-totalarri return total Translate this code into equivalent MIPS code (20 pts. You may use temporaries as necessary. arr contains the address o

Explanation / Answer

1.

sub       $t0, $s0, $s1 ; compute x-y

bltz      $t0, B1                                                            ; if x<y then x-y will be negative, check if t0<0

sw                    $t0, 0($s2)                                           ; if x<y is false then store x-y into diff(else part)

j                       END

B1:

sub                   $t0, $s1, $s0 ; compute y-x-y

sw                    $t0, 0($s2)

END:

_exit

2.

lui                    $t0, 4 ; assuming integer array & int takes 4 bytes

mult     $t0, $s1                                               ; $LO=$t0*$s1=4*y which is the offset of a[y] from base address

add                  $s4, $s4, $LO                          ; add offset to base address

LOOP:

sub                   $t1, $s3, 0($s4)                       ; if $t1 negative then end the loop

bltz      $t1, END

sw                    0($s4),0($s0)                           ; x=a[y]

addi     $s1, $s1, 1                                           ; y++

addi     $s4, $s4, 4                                           ; increment offset to point to next element

j LOOP

END:

_exit

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Chat Now And Get Quote