Question

8, 100% This MIPS/S am includes a subroutine called myadd that performs x=(y+2): . In the space below. replace the myadd subroutine with one named mymin that will make x-min(y,z). Your code may take advantage of the fact that x, y, and z are consecutive words in memory. You should test your routine using SPIM before you submit it, which will require merging it with a test framework like the one used in this MIPS/SPIM program -- but only submit the mymin routine here # Addition routine: #x=y+z text .globl myadd myadd: $t0, y $t1, $t1, $t2, #t1 = z z e(St1) $t0, $t1 addu # t2 = y + z SW $t2, e(Ste) jr Sra # return

0 0
Add a comment Improve this question Transcribed image text
Answer #1
.text
.globl mymin

mymin:
        la $t0, y            # t0 = y
        lw $t0, 0($t0)
        la $t1, z            # t1 = z
        lw $t1, 0($t1) 
        slt $t2, $t0, $t1    # t2 = 1 if t0 < t1 otherwise t2 = 0
        beqz $t2, else       # if t2 = 0 then jump label else 
        la $t2,  x           # x = t1
        sw $t1, 0($t2)
        b end                # jump to the end of function (skip else part)
else:
        la $t2,  x           # x = t0
        sw $t0, 0($t2)
end:
        jr $ra               # return

if you find any difficulty to understand this, please comment. I always here to help you

thank you.

Add a comment
Know the answer?
Add Answer to:
8, 100% This MIPS/S am includes a subroutine called myadd that performs x=(y+2): . In the...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a MIPSzy subroutine, power, that accepts 2 arguments x and y and computes x^y ....

    Write a MIPSzy subroutine, power, that accepts 2 arguments x and y and computes x^y . You can assume that x and y are both larger than 0. The main program passes the two parameters and receives the return value through the program stack. addi $t0, $zero, 5100 top: lw $t1, 0($t0) beq $t1, $zero, done addi $sp, $sp, -4 sw $t1, 0($sp) addi $t2, $zero,4 addi $sp, $sp, -4 sw $t2, 0($sp) addi $sp, $sp, -4 jal power lw...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT