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

  1.     page    66,132
  2. ;******************************** CONV21.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. WORD_TO_DEC_STDOUT - display byte as decimal to stdout
  15. ;
  16. ; inputs  ax = word
  17. ; output  none
  18. ;* * * * * * * * * * * * * *
  19. 
  20. ;==========================================================================
  21. ;  inputs:  ax = binary value
  22. ;  outputs: none
  23. ;
  24. ;  registers destroyed:  ax,dx
  25. ;
  26.     extrn    ten:word
  27.     public    word_to_dec_stdout
  28. word_to_dec_stdout    proc    far
  29.         call    local_proc
  30.         retf
  31. word_to_dec_stdout    endp
  32. ;--------------------------------
  33. local_proc:        xor    dx,dx
  34.         div    cs:ten            ;divide curent binary val by 10
  35.         or    ax,ax            ;check if done
  36.         jz    db_display        ;  jmp if done
  37.         push    dx            ;save remainder
  38.         call    local_proc            ;recursion
  39.         pop    dx
  40. db_display:    add    dl,30h            ;convert char. to ascii
  41.         mov    ah,2
  42.         int    21h            ;display char. in -dl-
  43.         ret
  44. LIBSEG    ENDS
  45.     end
  46.  
  47.