Question: 7. This (now familiar) MIPS/SPIM program includes a subroutine called my add that performs x-y+z;. In the space below, replace the myadd subroutine with one

7. This (now familiar) 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 ham that will compute x=ham(?,2); the Hamming Distance between y and z Hamming Distance is defined as the number of bits that differ, and the following C code gives a simple algorithm to compute it. This uses a little trick credited to Brian Kernighan (and described here) to count the "population" of Is in the XOR of the two numbers; to (to 1) removes the least-significant 1 bit from the value of to extern int x, y, z; void ham(void) int to y*z; int tl -0 while (to) t1-t1+ 1; x-tli # Addition routine: text globl myadd myadd: #t0 = y a $to, y w $to, 0(StO) la $11, 2 w $t1, 0(St1) a $t0, x sw $12, 0(Sto) jr $ra #return
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
