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

please help!! This MIPS/SPIM program includes a subroutine called myadd that per

ID: 3801875 • Letter: P

Question

please help!!

This MIPS/SPIM program includes a subroutine called myadd that performs x=(y+z);. In the space below, replace the myadd subroutine with one named myxor that will make x have the value it would get if C code like x=(y^z); were executed, i.e., the result of eXclusive ORing y and z. 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 myxor 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 = y + z # .text .globl my add myadd: la $t0, y #t0 = y lw $t0, 0($t0) la $t1, z #t1 = z lw $t1, 0($t1) addu $t2, $t0, $t1 #t2 = y + z la $t0, x #x = 12 sw $t2, 0($t0) jr $ra #return

Explanation / Answer

Ans:: Myxor routine:::

# Bitwise 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 # returns