home *** CD-ROM | disk | FTP | other *** search
/ Simtel MSDOS - Coast to Coast / simteldosarchivecoasttocoast2.iso / asmutil / stdlib.zip / ISIZE.ASM < prev    next >
Assembly Source File  |  1990-04-29  |  1KB  |  60 lines

  1. stdlib          segment para public 'slcode'
  2.         assume    cs:stdlib
  3. ;
  4. ; ISize- Returns the number of print positions required by an integer value.
  5. ;       On Input:
  6. ;                       AX: Integer to get the size of.
  7. ;
  8. ;       On Output:
  9. ;                       AX: Digit count for the integer.
  10. ;
  11.         public  sl_ISize
  12. sl_ISize    proc    far
  13.         cmp     ax, 0
  14.         jge     ISize2
  15.         neg     ax
  16.         call    GetUSize
  17.         inc     ax
  18.         ret
  19. ;
  20. ISize2:         call    GetUSize
  21.         ret
  22. sl_ISize    endp
  23. ;
  24. ; USize- Same as above, except for unsigned numbers.
  25. ;
  26.         public  sl_USize
  27. sl_USize        proc    far
  28.         call    GetUSize
  29.         ret
  30. sl_USize        endp
  31. ;
  32. ; GetUSize- Does the actual size comparison.
  33. ;
  34. GetUSize        proc    near
  35.         cmp     ax, 10
  36.         ja      GUS1
  37.         mov     ax, 1
  38.         ret
  39. ;
  40. GUS1:           cmp     ax, 100
  41.         ja      GUS2
  42.         mov     ax, 2
  43.         ret
  44. ;
  45. GUS2:           cmp     ax, 1000
  46.         ja      GUS3
  47.         mov     ax, 3
  48.         ret
  49. GUS3:           cmp     ax, 10000
  50.         ja      GUS4
  51.         mov     ax, 4
  52.         ret
  53. ;
  54. GUS4:           mov     ax, 5
  55.         ret
  56. GetUSize        endp
  57. ;
  58. stdlib        ends
  59.         end
  60.