Problem 5. The given assembly code is not correct for a procedure. Write the cor
ID: 3752965 • Letter: P
Question
Problem 5. The given assembly code is not correct for a procedure. 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 $ao, $0, 20 addi $a1, $0,45 addi $s3,$ad, 6 #do not change this line al func1 add $s1, $v0, $s3 #$s3 needs to be $a0+6 as in line3 funcl: addi $s3, $ad, 50 #do not change this line add $a2, $s3, $a1 #do not change this line jal func2 addi vo, $v1, $ao jr Sra addi $v1,$a2,100 r SraExplanation / Answer
Please find the code below:::::
main:
addi $a0,$0, 20 #load 20 in a0
addi $a1, $0,45 #load 45 in a1
addi $s3,$a0, 6 #do not change this line
jal func1 #call func1
add $s1, $v0, $s3 #$s3 needs to be $a0+6 as in line3
func1:
move $t7,$ra #save return address to t7
move $t6,$s3 #save value of s3 to t6
addi $s3, $a0, 50 #do not change this line
add $a2, $s3, $a1 #do not change this line
jal func2
add $v0, $v1, $a0
move $ra,$t7
move $s3,$t6 #save value back to s3 so that it will be a0+6
jr $ra
#need to terminate execution now
li $v0,11
syscall
func2:
addi $v1,$a2,100
jr $ra
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.