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

  1. ;****************************************************************************
  2. ; Filename: LTOA.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 @ltoa(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 value to a string. @ltoa is sign sensitive and will
  17. ;           add a '-' if the sign bit is set. The radix must be between 2 and
  18. ;           36 or @ltoa will return NULL. The string output can be up to 33
  19. ;           characters (including the '\0').
  20. ;****************************************************************************
  21.  
  22.     Include    STDDEF.INC
  23.  
  24.     Codeseg
  25.  
  26. Extrn NumberConvert:Byte
  27.  
  28. Proc     ltoa ,3
  29.         Cmp    Ecx,2
  30.         Jb    @@Exit
  31.         Cmp    Ecx,36
  32.         Ja    @@Exit
  33.         Or    Eax,Eax
  34.         Push    Ebx
  35.         Jns    @@Next
  36.         Sub    Esp,36
  37.         Mov    [Byte Edx],"-"
  38.                 Neg     Eax                
  39.         Push    Edx
  40.         Lea    Ebx,[Esp+4+35]
  41.         Mov    [Byte Ebx],0
  42.     Align    4
  43. @@Loop00:    Clear    Edx
  44.         Div    Ecx
  45.         Dec    Ebx
  46.         Mov    Dl,[NumberConvert+Edx]
  47.         TestZ    Eax
  48.         Mov    [Ebx],Dl
  49.         Jnz    @@Loop00
  50.         Mov    Eax,[Esp]
  51.         Mov    Edx,Ebx
  52.         Inc    Eax
  53.         Call    @stpcpy
  54.         Mov    Edx,Eax
  55.         Pop    Eax
  56.                 Add     Esp,36
  57.                 Pop     Ebx
  58.         Ret
  59.     Align    4
  60. @@Next:        Sub    Esp,36
  61.         Push    Edx
  62.         Lea    Ebx,[Esp+4+35]
  63.         Mov    [Byte Ebx],0
  64.     Align    4
  65. @@Loop01:    Clear    Edx
  66.         Div    Ecx
  67.         Dec    Ebx
  68.         Mov    Dl,[NumberConvert+Edx]
  69.         TestZ    Eax
  70.         Mov    [Ebx],Dl
  71.         Jnz    @@Loop01
  72.         Mov    Eax,[Esp]
  73.         Mov    Edx,Ebx
  74.         Call    @stpcpy
  75.         Mov    Edx,Eax
  76.         Pop    Eax
  77.                 Add     Esp,36
  78.                 Pop     Ebx
  79.         Ret
  80.     Align    4
  81. @@Exit:        Clear    Eax
  82.         Ret
  83. Endp
  84.  
  85.     End
  86.