Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Why is this MIPS program giving me a stack overflow error on MIPS and what do I need to change to make it work .text

Why is this MIPS program giving me a stack overflow error on MIPS and what do I need to change to make it work

.text main: #assume value m is already in $t0, n in $t1 add $a0,$0,$t0 add $a1,$0,$t1 jal weightedsum # call procedure add $t3,$0,$v0 # move the return value from $v0 to where we want syscall

weightedsum: addi $sp,$sp,-4 # Moving Stack pointer sw $t0, 0($sp) # Store previous value jal sum add $t0,$v0,$a1 # Procedure Body add $v0,$0,$t0 # Result lw $t0, 0($sp) # Load previous value addi $sp,$sp,4 # Moving Stack pointer jr $ra # return (Copy $ra to PC) sum:

addi $sp,$sp,-4 # Moving Stack pointer sw $t0, 0($sp) # Store previous value add $t0,$v0,$v0 # Procedure Body add $v0,$0,$t0 # Result lw $t0, 0($sp) # Load previous value addi $sp,$sp,4 # Moving Stack pointer jr $ra

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data Access Patterns Database Interactions In Object Oriented Applications

Authors: Clifton Nock

1st Edition

0321555627, 978-0321555625

More Books

Students also viewed these Databases questions

Question

Was there an effort to involve the appropriate people?

Answered: 1 week ago

Question

18. If you have power, then people will dislike and fear you.

Answered: 1 week ago