home *** CD-ROM | disk | FTP | other *** search
/ Microsoft Programmer's Library 1.3 / Microsoft-Programers-Library-v1.3.iso / sampcode / alde_c / misc / lib / dlibssrc / strrchr.s < prev    next >
Encoding:
Text File  |  1987-10-05  |  668 b   |  41 lines

  1. *    #include <stdio.h>
  2. *    
  3. *    char *strrchr(string, symbol)
  4. *    register char *string;
  5. *    register char symbol;
  6. *    /*
  7. *     *    Return a pointer to the last occurance of <symbol> in <string>.
  8. *     *    NULL is returned if <symbol> is not found.
  9. *     */
  10. *    {
  11. *        register char *p = string;
  12. *    
  13. *        while(*string++)
  14. *            ;
  15. *        do {
  16. *            if(*--string == symbol)
  17. *                return(string);
  18. *        } while(string != p);
  19. *        return(NULL);
  20. *    }
  21.  
  22. .text
  23. .globl _strrchr
  24. _strrchr:
  25.     move.l    4(a7),a0
  26.     move.w    8(a7),d0
  27.     move.l    a0,a1
  28. strrchr1:
  29.     tst.b    (a0)+
  30.     bne    strrchr1
  31. strrchr2:
  32.     cmp.b    -(a0),d0
  33.     bne    strrchr3
  34.     move.l    a0,d0
  35.     rts
  36. strrchr3:
  37.     cmp.l    a0,a1
  38.     bne    strrchr2
  39.     clr.l    d0
  40.     rts
  41.