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

  1.     page    66,132
  2. ;******************************** CONV04.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. ;----------------------------------------------------------------------------
  13.     extrn    lib_info:near
  14. comment 
  15. ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -( CONVERT )
  16. WORD_TO_DEC_STR - convert an integer value to an ASCIIZ string
  17. ;
  18. ; inputs:    DS:[SI] pointing to a buffer space
  19. ;            (WORD_TO_DEC_STR) AX = integer value
  20. ;            WORD_TO_DEC_STR requires a 7-byte (or greater) buffer;
  21. ;            
  22. ; output:    ASCIIZ string at DS:[SI]; numerals are right-justified
  23. ;* * * * * * * * * * * * * *
  24. 
  25.     PUBLIC    WORD_TO_DEC_STR
  26. WORD_TO_DEC_STR    PROC    FAR
  27.     APUSH   AX,BX,CX,DX,DI,SI,ES,DS
  28.     POP     ES
  29.     MOV     DI,SI
  30.     CLD
  31.     MOV     SI,AX
  32.     MOV     CX,0006
  33.     MOV     AL,20h    ; ' '
  34.     REPZ    STOSB
  35.     MOV     ES:[DI],CL
  36.     MOV     AX,SI
  37.     MOV     BX,000Ah
  38.     OR      SI,SI
  39.     JNS     wts_cont
  40.     NEG     AX
  41. wts_cont:    
  42.     XOR     DX,DX
  43.     DIV     BX
  44.     ADD     DX,+30h
  45.     DEC     DI
  46.     MOV     ES:[DI],DL
  47.     OR      AX,AX
  48.     JNZ     wts_cont
  49.     MOV     AL,20h    ; ' '
  50.     OR      SI,SI
  51.     JNS     wts_exit
  52.     MOV     AL,2D    ; '-'
  53. wts_exit:    
  54.     DEC     DI
  55.     STOSB
  56.     APOP    ES,SI,DI,DX,CX,BX,AX
  57.     RETF
  58. WORD_TO_DEC_STR ENDP
  59. comment 
  60. ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -( CONVERT )
  61. WORD_TO_DEC_CRT - convert word to decimal ascii and display
  62. ;
  63. ; inputs:  ax = binary value
  64. ;          di = display offset
  65. ;          ch = color
  66. ;          
  67. ; outputs: none
  68. ;
  69. ; registers changed:  ax,dx
  70. ;* * * * * * * * * * * * * *
  71. 
  72. ten    dw    10
  73.  
  74.      public    WORD_TO_DEC_CRT
  75. WORD_TO_DEC_CRT       proc    far
  76.         push    es
  77.         mov    es,cs:lib_info.crt_seg
  78.         call    word_to_crt1
  79.         pop    es
  80.         retf
  81. WORD_TO_DEC_CRT    endp
  82.  
  83. word_to_crt1    proc    near
  84.         xor    dx,dx
  85.         div    cs:ten            ;divide curent binary val by 10
  86.         or    ax,ax            ;check if done
  87.         jz    db_display        ;  jmp if done
  88.         push    dx            ;save remainder
  89.         call    word_to_crt1           ;recursion
  90.         pop    dx
  91. db_display:    mov    al,dl
  92.         add    al,30h
  93.         mov    ah,ch            ;get color
  94.         stosw
  95.         ret
  96. word_to_crt1    endp        
  97. ;---------------------------------------------------------------------------
  98.  
  99. LIBSEG    ENDS
  100.     end
  101.