home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / Programming / Misc / CLISP-1.LHA / CLISP960530-sr.lha / amiga / jchlib / misc / strlen.c < prev   
Encoding:
Text File  |  1995-08-22  |  483 b   |  19 lines

  1. /* only loop over tst.b (a0)+ */
  2. int strlen(const char* str)
  3. {
  4.   register const char* ptr = str;
  5.   while (*ptr++) ;
  6.   return ~(str - ptr);
  7. }
  8.  
  9. /* almost identical to:
  10.         move.l  (sp)+,a0
  11.         move.l a0,d0
  12. slloop:
  13.         tst.l   (a0)+           ; Test for null-terminator and increment A0
  14.         bne.b   slloop          ; Repeat if we didn't find the terminator
  15.         not.l   d0              ; D0 = -D0 - 1
  16.         add.l   a0,d0           ; D0 = A0 - D0 - 1
  17.         rts
  18. */
  19.