home *** CD-ROM | disk | FTP | other *** search
/ Computer Select (Limited Edition) / Computer Select.iso / dobbs / v17n03 / ucrasm.exe / SOURCE.EXE / PUTL.ASM < prev    next >
Encoding:
Assembly Source File  |  1991-10-12  |  1.3 KB  |  84 lines

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