Question: MIPS Assembly Modify the file solution.asm so that the program performs the following recursive function ( here given in C code ) . The conventions

MIPS Assembly
Modify the file solution.asm so that the program performs the following recursive function (here given in C code). The conventions for how subroutines are set up
(e.g. restoring registers) must be followed according to what we went through in the lecture.
int bitcount(unsigned x)
{
int bit;
if (x ==0) return 0;
bit = x & 0x1;
return bit + bitcount(x >>1);
}
In the file data.asm the parameter x is defined. This file is included in the code file. Modify the variable as needed to test different inputs. But note that you must not change variable names etc. for the automatic tests to work! You may also not print any additional text to the console.
The response Cshould be returned in register $v0.
Code in the data.asm:
.data
x: .word 5
The code in solution.asm which will be modified:
.include "data.asm"
.text
main:
jal bitcount
j exit
bitcount:
jr $ra
exit:
MIPS Assembly Modify the file solution.asm so

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!