Question: Write a procedure, bfind ( ), in C code using pointer-based and convert it into MIPS assembly language with clear and necessary comments . The
- Write a procedure, bfind( ), in C code using pointer-based and convert it into MIPS assembly language with clear and necessary comments. The procedure should take a single argument that is a pointer to a null-terminated string in register $a0. The bfind procedure should locate the first character b in the string and return its address. If there are no bs in the string, then bfind should return a pointer to the null character at the end of the string. For example, if the argument to bfind points to the string "imbibe," then the return value will be a pointer to the third character of the string. Use minimum number of MIPS instructions.
C code:
char *bfind(const char *str)
{
char *p;
for(p=str;*p;p++)
{
if(*p==b)
return p;
}
return p;
}
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
