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

  1. stdlib        segment    para public 'slcode'
  2.         assume    cs:stdlib
  3.         extrn   sl_putc:far, sl_LSize:far, sl_ULSize:far
  4. ;
  5. ; Putl prints the value in DX:AX as a signed dword integer value.
  6. ;
  7.         public  sl_putlsize
  8. sl_Putlsize     proc    far
  9.         push    ax
  10.         push    bx
  11.         push    cx
  12.         push    dx
  13.         push    ax
  14.         call    sl_LSize
  15.         sub     cx, ax
  16.         js      NoSpcs
  17.         jcxz    NoSpcs
  18.         mov     al, ' '
  19. PutSpcs:        call    sl_Putc
  20.         loop    PutSpcs
  21. ;
  22. NoSpcs:         pop     ax
  23.         cmp     dx, 0
  24.         jge    Doit
  25.         push    ax
  26.         mov    al, '-'
  27.         call    sl_Putc
  28.         pop    ax
  29.         neg    dx
  30.         neg    ax
  31.         sbb    dx, 0
  32. ;
  33. DoIt:        call    puti2
  34.         pop    dx
  35.         pop    cx 
  36.         pop    bx 
  37.         pop    ax
  38.         ret
  39. sl_Putlsize     endp
  40. ;
  41. ; Putul prints the value in DX:AX as an unsigned dword integer value.
  42. ;
  43.         public    sl_PutULSize
  44. sl_PutULSize    proc    far
  45.         push    ax 
  46.         push    bx 
  47.         push    cx 
  48.         push    dx
  49.         push    ax
  50.         call    sl_ULSize
  51.         sub     cx, ax
  52.         js      NoSpcs2
  53.         jcxz    NoSpcs2
  54.         mov     al, ' '
  55. PutSpcs2:       call    sl_Putc
  56.         loop    PutSpcs2
  57. NoSpcs2:        pop     ax
  58. ;
  59.         call    PutI2
  60.         pop    dx 
  61.         pop    cx 
  62.         pop    bx 
  63.         pop    ax
  64.         ret
  65. sl_PutULSize    endp
  66. ;
  67. ; PutI2- Recursive routine to actually print the value in AX as an integer.
  68. ;
  69. Puti2        proc    near
  70.         call    Div10
  71.         cmp    ax, dx        ;See if dx:ax=0
  72.         jnz    NotDone
  73.         or    ax, ax
  74.         jz    Done
  75. NotDone:    push    bx
  76.         call    Puti2
  77.         pop    bx
  78. Done:        mov    al, bl
  79.         or    al, '0'
  80.         call    sl_Putc
  81.         ret
  82. PutI2        endp
  83. ;
  84. ; Div10- Divides DX:AX by 10 leaving the remainder in BL and the quotient
  85. ;     in DX:AX.
  86. ;
  87. Div10        proc    near
  88.         mov    cx, 10
  89.         mov    bx, ax
  90.         xchg    ax, dx
  91.         xor    dx, dx
  92.         div    cx
  93.         xchg    bx, ax
  94.         div    cx
  95.         xchg    dx, bx
  96.         ret
  97. Div10        endp
  98. stdlib        ends
  99.         end
  100.