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

  1.     page    66,132
  2. ;******************************** CONV06.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. BYTE_TO_HEX_STR - convert hex byte to two ascii characters
  15. ;
  16. ; inputs:    al = hex byte
  17. ;         ds:si = storage buffer for ascii
  18. ;         
  19. ; output:    si = points past last store (bumped by 2)
  20. ;* * * * * * * * * * * * * *
  21. 
  22. ;----------------------------------------------------------------------------
  23.     public    BYTE_TO_HEX_STR
  24. BYTE_TO_HEX_STR    PROC    FAR
  25.     mov    cs:crt_direct,0
  26.     jmp    hex1_entry
  27. BYTE_TO_HEX_STR    ENDP    
  28. comment 
  29. ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -( CONVERT )
  30. BYTE_TO_HEX_CRT - convert hex byte to ascii and display
  31. ;
  32. ; inputs:    al = hex byte
  33. ;         ds:si = storage buffer for ascii
  34. ;         
  35. ; output:    si = points past last store (bumped by 2)
  36. ;* * * * * * * * * * * * * *
  37. 
  38.     public    BYTE_TO_HEX_CRT
  39. BYTE_TO_HEX_CRT    proc    far
  40.     mov    cs:crt_direct,1
  41. BYTE_TO_HEX_CRT    ENDP    
  42. hex1_entry    PROC    FAR    
  43.     push    ax
  44.     mov    ah,al        ;save for later
  45.     shr    al,1
  46.     shr    al,1
  47.     shr    al,1
  48.     shr    al,1
  49.     call    btha        ;convert one nibble
  50.     xchg    ah,al
  51.     call    btha
  52.     pop    ax
  53.     retf
  54. HEX1_ENTRY    ENDP
  55. ;-----------------------    
  56. CRT_DIRECT    DB    0
  57. ;-----------------------
  58. btha:    and    al,0fh
  59.     add    al,90h        ;convert
  60.     daa            ;  -al- bits 0-3
  61.     adc    al,40h        ;     to hex
  62.     daa            ;        ascii
  63.     cmp    cs:crt_direct,0
  64.     je    btha_stuff
  65.     int    29h
  66.     ret
  67. btha_stuff:    
  68.     mov    byte ptr [si],al
  69.     inc    si
  70.     ret    
  71. comment 
  72. ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -( CONVERT )
  73. WORD_TO_HEX_STR - convert hex word to four ascii characters
  74. ;
  75. ; inputs:    ax = hex word
  76. ;         ds:si = storage for 4 ascii characters
  77. ;         
  78. ; output:    si = pointer past last store (bumped by 4)
  79. ;* * * * * * * * * * * * * *
  80. 
  81.     public    WORD_TO_HEX_STR
  82. WORD_TO_HEX_STR    PROC    FAR
  83.     MOV    CS:CRT_DIRECT,0
  84.     jmp    hex2_entry
  85. WORD_TO_HEX_STR    ENDP
  86.  
  87. comment 
  88. ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -( CONVERT )
  89. WORD_TO_HEX_CRT - hex word to ascii and display it
  90. ;
  91. ; inputs:    ax = hex word
  92. ;         ds:si = storage for 4 ascii characters
  93. ;         
  94. ; output:    si = pointer past last store (bumped by 4)
  95. ;* * * * * * * * * * * * * *
  96. 
  97.     public    WORD_TO_HEX_CRT
  98. WORD_TO_HEX_CRT    PROC    FAR
  99.     mov    cs:crt_direct,1
  100. WORD_TO_HEX_CRT    ENDP    
  101. hex2_entry    PROC    FAR        
  102.     xchg    ah,al
  103.     call    hex1_entry
  104.     xchg    ah,al
  105.     call    hex1_entry
  106.     retf
  107. HEX2_ENTRY    ENDP
  108. comment 
  109. ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -( CONVERT )
  110. DWORD_TO_HEX_STR - hex double word to ascii
  111. ;
  112. ;INPUTS: DX,AX = HEX
  113. ;
  114. ;OUTPUTS: si points past last byte stored
  115. ;* * * * * * * * * * * * * *
  116. 
  117.     public    DWORD_TO_HEX_STR
  118. DWORD_TO_HEX_STR    proc    far
  119.     mov    cs:crt_direct,0
  120.     jmp    hex4_entry
  121. DWORD_TO_HEX_STR    endp
  122.  
  123. comment 
  124. ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -( CONVERT )
  125. DWORD_TO_HEX_CRT - hex double word to ascii and display
  126. ;
  127. ;INPUTS: DX,AX = HEX
  128. ;
  129. ;OUTPUTS: NONE
  130. ;* * * * * * * * * * * * * *
  131. 
  132.     public    DWORD_TO_HEX_CRT
  133. DWORD_TO_HEX_CRT    proc    far
  134.     mov    cs:crt_direct,1
  135. hex4_entry:
  136.     xchg    ax,dx
  137.     call    hex2_entry
  138.     xchg    ax,dx
  139.     jmp    hex2_entry    
  140. DWORD_TO_HEX_CRT    endp
  141.  
  142. LIBSEG    ENDS
  143.     end
  144.