Question
-Write MIPS assembly code for the following C function. Assume that `A` contains integer 0's and 1's representing the individual bits of a binary number.
-Write MIPS assembly code for the following C function. Assume that `A` contains integer 0's and 1's representing the individual bits of a binary number.
**Do not use code for a stack**
**Do not use pseudo-instructions.**
int binToDec (int A[], int begin, int end)
// precondition: A contains integer 0's and 1's
{
int k;
int powOfTwo = 1;
int decimal = 0;
for(k = end; k >= begin; k--)
{
if ( A[k] == 1 )
decimal += powOfTwo;
powOfTwo *= 2;
}
return decimal;
}
Any other code that may be used for reference is assumed as complete. The only code that I have a reference to is posted above. If you could include comments for each line of MIPS instruction assembly code I would appreciate it! Thank you
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started