.MODEL SMALL
.STACK 100H
.DATA

TEXT1 DB 'TYPE A BINARY NUMBER , UP TO 16 DIGITS : $'
TEXT2 DB 0DH,0AH,'IN HEX IT IS $'
text3 db 13,10,'your digit is out of the range..$'
digits db '0123456789ABCDEF'
.CODE
MAIN:
MOV AX,@DATA
MOV DS,AX
XOR BX,BX
mov ch,16
MOV AH,9
LEA DX,TEXT1
INT 21H

WHILE1:cmp ch,0
je end_while
mov ah,1
int 21h
CMP AL,0DH
JE END_WHILE
sub al,30h
cmp al,1
ja out_range
SHL BX,1
add BL,AL
dec ch
jmp while1
out_range:lea dx,text3
mov ah,9
int 21h
JMP WHILE1
END_WHILE:
MOV AH,9
LEA DX,TEXT2
INT 21H

mov ch,4
next_digit:cmp ch,0
je finish
mov cl,4
mov si,0
t1:cmp cl,0
je to_next
shl si,1
shl bx,1
adc si,0
dec cl
jmp t1
to_next:dec ch
       mov dl,digits[si]
       mov ah,2
       int 21h
   jmp next_digit
finish:

MOV AH,4CH
INT 21H
    END MAIN
  end



