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

  1. stdlib        segment    para public 'slcode'
  2.         assume    cs:stdlib
  3.         extrn   sl_putc:far, sl_ISize:far, sl_USize:far
  4. ;
  5. ; Puti prints the value in AX as a signed integer value.  CX contains the
  6. ; minimum field width for the number.
  7. ;
  8.         public  sl_PutiSize
  9. sl_PutiSize     proc    far
  10.         push    ax
  11.         push    bx
  12.         push    cx
  13.         push    dx
  14.         push    ax
  15.         call    sl_ISize
  16.         sub     cx, ax
  17.         js      NoSpaces
  18.         jcxz    NoSpaces
  19.         mov     al, ' '
  20. SpcsLoop:       call    sl_Putc
  21.         loop    SpcsLoop
  22. NoSpaces:       pop     ax
  23.         cmp    ax, 0
  24.         jge    Doit
  25.         push    ax
  26.         mov    al, '-'
  27.         call    sl_Putc
  28.         pop    ax
  29.         neg    ax
  30. ;
  31. DoIt:        call    puti2
  32.         pop     dx
  33.         pop     cx
  34.         pop     bx
  35.         pop     ax
  36.         ret
  37. sl_PutiSize     endp
  38. ;
  39. ; Putu prints the value in AX as an unsigned integer value.
  40. ;
  41.         public  sl_PutUSize
  42. sl_PutUSize     proc    far
  43.         push    ax
  44.         push    bx
  45.         push    cx
  46.         push    dx
  47.         push    ax
  48.         call    sl_USize
  49.         sub     cx, ax
  50.         js      NoUSpaces
  51.         jcxz    NoUSpaces
  52.         mov     al, ' '
  53. SpcsLp2:        call    sl_Putc
  54.         loop    SpcsLp2
  55. NoUSpaces:      pop     ax
  56.         call    PutI2
  57.         pop     dx
  58.         pop     cx
  59.         pop     bx
  60.         pop     ax
  61.         ret
  62. sl_PutUSize     endp
  63. ;
  64. ; PutI2- Recursive routine to actually print the value in AX as an integer.
  65. ;
  66. Puti2        proc    near
  67.         mov    bx, 10
  68.         xor    dx, dx
  69.         div    bx
  70.         or    ax, ax        ;See if ax=0
  71.         jz    Done
  72.         push    dx
  73.         call    Puti2
  74.         pop    dx
  75. Done:        mov    al, dl
  76.         or    al, '0'
  77.         call    sl_Putc
  78.         ret
  79. PutI2        endp
  80. stdlib        ends
  81.         end
  82.