home *** CD-ROM | disk | FTP | other *** search
/ C!T ROM 5 / ctrom5b.zip / ctrom5b / PROGRAM / ASM / ALIB30B / CONV22.ASM < prev    next >
Assembly Source File  |  1994-12-01  |  1KB  |  63 lines

  1.     page    66,132
  2. ;******************************** CONV22.ASM *********************************
  3.  
  4. LIBSEG           segment byte public "LIB"
  5.         assume cs:LIBSEG , ds:nothing
  6.  
  7. ;----------------------------------------------------------------------------
  8. .xlist
  9.     include  mac.inc
  10.     include  common.inc
  11. .list
  12. comment 
  13. ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -( CONVERT )
  14. DWORD_TO_DEC_STDOUT - display dword as decimal to stdout
  15. ;
  16. ; inputs  dx,ax = dword
  17. ; output  dx.ax destroyed
  18. ;* * * * * * * * * * * * * *
  19. 
  20. ;==========================================================================
  21.     extrn    ten:word
  22.     public    dword_to_dec_stdout  
  23. DWORD_TO_DEC_STDOUT    proc    far
  24.     push    bx
  25.     call    local_proc
  26.     pop    bx
  27.     retf
  28. dword_to_dec_stdout    endp
  29.  
  30. local_proc:    push    ax
  31.         mov    ax,dx
  32.         xor    dx,dx
  33.         div    cs:ten
  34.         mov    bx,ax
  35.         pop    ax
  36.         div    cs:ten
  37.         xchg    bx,dx
  38. ;
  39. ; dx,ax = quotient
  40. ;    bx = remainder
  41.  
  42.         or    ax,ax
  43.         jnz    dd_more
  44.         or    dx,dx
  45.         jnz    dd_more
  46.         mov    dx,bx
  47.         jmp    ddb_display
  48. dd_more:
  49.         push    bx            ;save remainder        
  50.     
  51.         call    local_proc             ;recursion
  52.         pop    dx
  53. ddb_display:    add    dl,30h            ;convert char. to ascii
  54.         mov    ah,2
  55.         int    21h            ;display char. in -dl-
  56.         ret
  57. LIBSEG    ENDS
  58.     end
  59.  
  60.  
  61.  
  62.