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

R M 0 NC O R at 67% G 10:40 6. 100% This MIPS/SPIM program includes a subroutine

ID: 3605168 • Letter: R

Question

R M 0 NC O R at 67% G 10:40 6. 100% This MIPS/SPIM program includes a subroutine called my add that performs X= (y+z);. In the space below, replace the myadd subroutine with one named isodd that will make x have the value 1 if y has an odd value and 0 if it is even. 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 mand routine here. Remember that you can and should comment your code, especially if there are any known bugs. Half off for documented bugs. :-) #### # Addition routine: # x = + z .text globl myadd myadd: la Sto, y # to y Iw Sto, Oct0) la St1, z #t1 = 2 Iw St1, o($t1) addu $t2, $to, St1# t2 = y + la # x = t2 Sto, X St2, o( $t0) w jr $ra # return

Explanation / Answer

######
#
# XOR routine
#
# x = y ^ Z
#

.text
.globl myxor

myxor:
       la   $t0, y         # t0 = y
       lw   $t0, 0($t0)
       la   $t1, z            # t1 = z
       lw   $t1, 0($t1)
       xor   $t2, $t0, $t1   # t2 = y ^ z
       la   $t0, x           # x = t2
       sw   $t2, 0($t0)
      
       jr $ra               # return