home *** CD-ROM | disk | FTP | other *** search
/ Simtel MSDOS - Coast to Coast / simteldosarchivecoasttocoast2.iso / asmutil / stdlib.zip / PUTI.ASM < prev    next >
Assembly Source File  |  1990-04-30  |  819b  |  51 lines

  1. stdlib        segment    para public 'slcode'
  2.         assume    cs:stdlib
  3.         extrn    sl_putc:far
  4. ;
  5. ; Puti prints the value in AX as a signed integer value.
  6. ;
  7.         public    sl_puti
  8. sl_Puti        proc    far
  9.         push    ax bx dx
  10.         cmp    ax, 0
  11.         jge    Doit
  12.         push    ax
  13.         mov    al, '-'
  14.         call    sl_Putc
  15.         pop    ax
  16.         neg    ax
  17. ;
  18. DoIt:        call    puti2
  19.         pop    dx bx ax
  20.         ret
  21. sl_Puti        endp
  22. ;
  23. ; Putu prints the value in AX as an unsigned integer value.
  24. ;
  25.         public    sl_PutU
  26. sl_PutU        proc    far
  27.         push    ax bx dx
  28.         call    PutI2
  29.         pop    dx bx ax
  30.         ret
  31. sl_PutU        endp
  32. ;
  33. ; PutI2- Recursive routine to actually print the value in AX as an integer.
  34. ;
  35. Puti2        proc    near
  36.         mov    bx, 10
  37.         xor    dx, dx
  38.         div    bx
  39.         or    ax, ax        ;See if ax=0
  40.         jz    Done
  41.         push    dx
  42.         call    Puti2
  43.         pop    dx
  44. Done:        mov    al, dl
  45.         or    al, '0'
  46.         call    sl_Putc
  47.         ret
  48. PutI2        endp
  49. stdlib        ends
  50.         end
  51.