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

  1. ;****************************************************************************
  2. ; Filename: ULTOA.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: PSZ @ultoa(LONG value,PSZ string,LONG radix);
  12. ;    Input: Eax, value - value to convert to ASCII
  13. ;           Edx, string - string pointer
  14. ;           Ecx, radix - radix to convert too, 2 to 36
  15. ;   Output: string pointer
  16. ;  Comment: Converts a unsigned value to a string. The radix must be between
  17. ;           2 and 36 or ultoa will return NULL. The string output can be
  18. ;           up to 33 characters (including the '\0').
  19. ;****************************************************************************
  20.  
  21.     Include    STDDEF.INC
  22.  
  23.     Codeseg
  24.  
  25. Extrn NumberConvert:Byte
  26.  
  27. Proc    ultoa   ,3
  28.         Cmp    Ecx,2
  29.         Jb    @@Exit
  30.         Cmp    Ecx,36
  31.         Ja    @@Exit
  32.         TestZ    Edx
  33.         Jz    @@Exit
  34.         Push    Ebx
  35.         Sub    Esp,36
  36.         Push    Edx
  37.         Lea    Ebx,[Esp+4+35]
  38.         Mov    [Byte Ebx],0
  39.     Align    4
  40. @@Loop:        Clear    Edx
  41.         Div    Ecx
  42.         Dec    Ebx
  43.         Mov    Dl,[NumberConvert+Edx]
  44.         TestZ    Eax
  45.         Mov    [Ebx],Dl
  46.         Jnz    @@Loop
  47.         Mov    Edx,Ebx
  48.         Mov    Eax,[Esp]
  49.         Call    @stpcpy
  50.         Mov    Edx,Eax
  51.         Pop    Eax,+36,Ebx
  52.         Ret
  53.     Align    4
  54. @@Exit:        Clear    Eax
  55.         Ret
  56. Endp
  57.  
  58.     End
  59.