home *** CD-ROM | disk | FTP | other *** search
/ Groovy Bytes: Behind the Moon / groovybytes.iso / GROOVY / SND_TOOL / FUNK108A.ZIP / DOS32V30.ZIP / PAL / STRINGS / STRLEN.ASM < prev    next >
Encoding:
Assembly Source File  |  1995-05-20  |  1.1 KB  |  49 lines

  1. ;****************************************************************************
  2. ; Filename: STRLEN.ASM
  3. ;   Author: Peter Andersson
  4. ;  Version: 0.0
  5. ;  Created: 1995.02.09
  6. ;  Updated: -
  7. ;****************************************************************************
  8. ; Copyright Peter Andersson, 1994-1995.
  9. ; All rights reserved.
  10. ;****************************************************************************
  11. ; Function: ULONG @strlen(PSZ string);
  12. ;    Input: Eax, string - pointer to string
  13. ;   Output: length of the string in bytes excluding '\0'
  14. ;  Comment: strlen checks how long a string is in bytes excluding the '\0'.
  15. ;****************************************************************************
  16.  
  17.     Include    STDDEF.INC
  18.  
  19.     Codeseg
  20.  
  21. Proc    strlen  ,1
  22.         Mov    Ecx,Eax
  23.         Jmp    @@Next01
  24.     Align    4
  25. @@Loop01:    Add    Eax,4
  26. @@Next01:    Mov    Edx,[Eax]
  27.         TestZ    Dl
  28.         Jz    @@Exit01
  29.         TestZ    Dh
  30.         Jz    @@Exit02
  31.         Test    Edx,0FF0000h
  32.         Jz    @@Exit03
  33.         Test    Edx,0FF000000h
  34.         Jnz    @@Loop01
  35.         Add    Eax,3
  36.         Sub    Eax,Ecx
  37.         Ret
  38.     Align    4
  39. @@Exit03:    Add    Eax,2
  40.         Sub    Eax,Ecx
  41.         Ret
  42.     Align    4
  43. @@Exit02:    Inc    Eax
  44. @@Exit01:    Sub    Eax,Ecx
  45.         Ret
  46. Endp
  47.  
  48.     End
  49.