The code below is giving an arithmetic overflow. Correct the below given the below code, so...

90.2K

Verified Solution

Question

Programming

The code below is giving an arithmetic overflow. Correct thebelow given the below code, so that the value of s0 is printedbefore calling the function fun1, inside the function Fun1 andafter returning from Fun1 in main. Upload the corrected .asm or .sfile in the drop box.


.text

main:

addi $s0,$zero,2

jal Disp

jal Fun1

jal Disp

j Exit

Fun1:

addi $sp,$sp,-4

sw $s0,0($sp)

addi $s0,$s0,15

jal Disp

lw $s0,0($sp)

addi $sp,$sp,4

jr $ra

Disp:

li $v0,1

move $a0,$s0

syscall

jr $ra

Exit:

li $v0,10

syscall

Answer & Explanation Solved by verified expert
4.3 Ratings (738 Votes)
Hope this will help you If you have any doubt please let meknowPlease go through all thenotesNotes 1 All most allcoding part is given I just stored the return address of Function1into stack before calling a disp function because when we arecalling a function disp the value of ra register is changed andthat address is remained in ra    See Answer
Get Answers to Unlimited Questions

Join us to gain access to millions of questions and expert answers. Enjoy exclusive benefits tailored just for you!

Membership Benefits:
  • Unlimited Question Access with detailed Answers
  • Zin AI - 3 Million Words
  • 10 Dall-E 3 Images
  • 20 Plot Generations
  • Conversation with Dialogue Memory
  • No Ads, Ever!
  • Access to Our Best AI Platform: Flex AI - Your personal assistant for all your inquiries!
Become a Member

Other questions asked by students