Mzsmunna
10/16/2019 - 8:43 AM

BIN to HEX


.MODEL SMALL
.STACK 100H
.DATA
M1 DB 'Enter Binery:$'
M2 DB 'HEX is:$'  
m3 db 'Total 1: $'
m4 db 'Total 0: $'  
A db ?
B db ? 
C db ?
.CODE
MAIN PROC
MOV AX,@DATA
MOV DS,AX 

mov A,'0'
mov B,'0'

LEA DX,M1
MOV AH,9
INT 21H
MOV CX,16
MOV AH,1
INT 21H

L1:

 CMP AL,0DH
 JE L2
 
 AND AL,0FH
 SHL BX,1
 
 OR BL,AL
 INT 21H
 JMP L1
 
 L2:
 MOV AH,2
 MOV DL,0DH
 INT 21H
 MOV DL,0AH
 INT 21H
 
 LEA DX,M2
 MOV AH,9
 INT 21H
 
  mov C,'0'
 


disp:

    
             
    xor cx,cx
    mov cx,4  
    jcxz exit 
    
top:
    mov ah,2
    mov dl,bh
    shr dl,4
    cmp dl,0Ah
    jl number
    add dl,37h
    int 21h 
    jmp endjob
    
number:
    add dl,30h
    int 21h
    
endjob:
    
    rol bx,4
    loop top
    
                    
        
exit:
            
    mov ah,4ch
    int 21h
    main endp
end main