This MIPS/SPIM program includes a subroutine called myadd that performs x = (y +
ID: 3803017 • Letter: T
Question
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 MIPSLSPIM program -- but only submit the m routine here. Remember that you can and myxor should comment your code, especially if there are any known bugs. Half off for documented bugs.:-) #### # # Addition routine # # x = y + z # .text .globl myadd my add: leftarrow $s0, y #t0 = y lw $t0,0($t0) la $t1, z # t1 = z addu $t 2, $t0, $t1. #t2 = y + z la $t0, x #x = t2 SW $t2,0($t0) jr $ra #returnExplanation / 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
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.