PROGRAM
.model small
.stack
print macro p
lea dx,p
mov ah,09h
int 21h
endm
.data
m1 db 10,13,"Enter the Hexadecimal Number:$"
m2 db 10,13,"The Binary Number:$"
a db 30 dup("$")
.code
mov ax,@data
mov ds,ax
print m1
mov si,01h
l1: mov ah,01h
int 21h
cmp al,0dh
je next
l2: cmp al,64
jg ab
jl cn
ab: cmp al,71
jg cn
l3: sub al,7
cn: sub al,30h
l4: mov a[si],al
inc si
jmp l1
next: mov di,si
mov si,01h
print m2
l5: mov bl,a[si]
and bl,0ffh
mov cx,04h
l6: mov al,bl
and al,8h
je pzero
mov dl,31h
jmp l7
pzero: mov dl,30h
l7: mov ah,02h
int 21h
shl bl,01
loop l6
inc si
cmp si,di
jne l5
mov ah,4ch
int 21h
end
OUTPUT
Enter the Hexadecimal Number: AD
The Binary Number: 10101101
No comments:
Post a Comment