MIPS Functions Exercise

Tom Kelliher, CS 240

Feb. 25, 2002

The following C function will return the number of occurrences of the character c in the string s:

int strccnt(char *s, char c)
{
   int count = 0;

   while (*s != '\0')
   {
      if (*s == c)
         ++count;

      ++s;
   }

   return count;
}
Write MIPS assembly corresponding to this function. Your assembly code should push and pop a frame for the function. Assume that s is passed through $a0 and stored in $s0, c is passed through $a1 and stored in $s1, count is kept in $s2, and $s3 is used to hold the current character from s. Count is returned through $v0. Use this for your frame map:

E-mail your solution, in ASCII text form, to Send mail to kelliher AT DOMAIN bluebird.goucher.edu by 5:00 PM on the 25th.



Thomas P. Kelliher
Thu Feb 21 17:33:46 EST 2002
Tom Kelliher