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

Write the corrected version of the following assembly code. Your corrected versi

ID: 1766149 • Letter: W

Question

Write the corrected version of the following assembly code. Your corrected version should preserve the functions main, func1, and func2 and also ensure that their main operations do not change. Please pay special attention to the line comments below.

main:
addi $a0, $0, 20
addi $a1, $0, 45
addi $s3, $a0, 6 #do not change this line
jal func1
add $s1, $v0, $s3 #$s3 needs to be $a0+6 as in line 3

func1:
addi $s3, $a0, 50 #do not change this line

add $a2, $s3, $a1 #do not change this line

jal func2
addi $v0, $v1, $a0

jr $ra

func2:
addi $v1,$a2,100

jr $ra

Explanation / Answer

Answer:

        Jump and link

        Jal lable

Add $a3,$s3,$0(#storing s3 value in a3)

Jal func1(# now jump)

Add $s3,$a3,$0(#restore the value of s3)

Add $s1,$v0,$s3(#now add as required )