.model tiny
.code
public showbyte
showbyte proc near
push cx                 ;preserve the calling-code's CX register. It's the native counter loops!
                ;strategy: copy dl into dh.
                ;in DH, translate upper 4 bits. in DL translate lower 4 bits
mov dh, dl
mov cl, 4
shr dh, cl                 ;Bit Shift Right by amount specified in cl.
add dh, 30h                 ;sets number equivalent to ascii values 0-9
cmp dh, 39h
jna sb_cont1                 ;jump if not above- if ascii is wthin range of 0-9, work on next number in DL
add dh, 7                 ;otherwise, number is above 9 and needs to be represented be Alfa char A-F
sb_cont1:
and dl, 00001111b                 ;clears top 4 bits
add dl, 30h
cmp dl, 39h
jna sb_cont2
add dl, 7
sb_cont2:
pop cx                ;restore the calling-code's CX register.
ret
showbyte endp
end showbyte