         title sub-module
code     segment 'CODE' public
         public hex

         extrn display : far
         extrn kbin    :  far
         extrn crlf    :  far

         assume cs:code, ds:dcode 
;--------------------
hex       proc   far  ; hex code in DL to print 2 digit (and to DX)
          push ax
          push bx
          push cx
          push ds 
          mov  ax,dcode   ; set DS 
          mov  ds,ax 
          push dx         ; store dx for next time ax <= dx
          lea  bx,table   ;set addr tab code to bx
          mov  al,dl      ; code to al
          clc             ; clear carry
          shr  al,1       ; get hay byte to rigth part reg
          shr  al,1
          shr  al,1
          shr  al,1
          xlatb           ; tranlate char in al to al
          mov  dl,al
          mov  @s_char1,al 
          call display
          pop  ax             ; source code to ax
          and  ax,00001111b   ; left byte
          xlatb 
          mov  @s_char2,al
          mov  dl,al
          call display  
          mov dx, word ptr @s_char1   ;   to dx
          pop ds 
          pop cx
          pop bx
          pop ax
          ret
hex       endp
code      ends
dcode     segment
table     db   '0123456789ABCDEF'
@s_char1  db   0  ; save tratlate char
@s_char2  db   0
dcode     ends
          end 
