Showing posts with label binary to bcd. Show all posts
Showing posts with label binary to bcd. Show all posts

Tuesday, 20 November 2012

PROGRAM TO CONVERT 8-BIT BINARY NUMBER TO ITS GRAY CODE FORM

mmicroprocessor.blogspot.com
.model small

.data
opr db 04h
res db ?

.code
.startup
mov al,opr
mov bl,al
rcr al,1
xor al,bl
mov res,al
mov al,res
mov dl,al
mov bh,al
and dl,0f0h
mov cl,4
ror dl,cl
add dl,30h
cmp dl,'9'
jbe a1
add dl,7h
a1:
mov ah,02h
int 21h
mov dl,bh
and dl,0fh
add dl,30h
cmp dl,'9'
jbe a0
add dl,7h
a0:
mov ah,02h
int 21h
mov ah,4ch
int 21h
end


Output:
06

PROGRAM TO CONVERT BCD NUMBER TO BINARY NUMBER

mmicroprocessor.blogspot.com
.model small

.data
bcd equ 12h
result db ?

.code
.startup
mov al,bcd
mov bl,bcd
and al,0f0h
mov cl,4
rol al,cl
mov cl,10d;binary=(6x10d+7)
mul cl
and bl,0fh
add al,bl
mov result,al

mov dl,al
mov bh,al
and dl,0f0h
mov cl,4
ror dl,cl
add dl,30h
cmp dl,'9'
jbe a1
add dl,7h
a1:mov ah,02h
int 21h
mov dl,bh
and dl,0fh
add dl,30h
cmp dl,'9'
jbe a0
add dl,7h
a0:
mov ah,02h
int 21h
mov ah,4ch
int 21h
end


Output:
0C