Nothing Special   »   [go: up one dir, main page]

BCD To Binary

Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

bcd no is one in which each digit in the no is encoded in its 4 digit binary form

for example
1895 in bcd is 0001 1000 1001 0101
from this if we wish to convert back to 1895 multiply each set of 4 binary numbers(decoded in their
decimal form) by successive powers powers of 10
so we have 1x103+8x102+9x10+5=1895
if we have 67 in bcd mask 6 and store 7 in a register
then mask 7 and move bits of 6 to the right .then multiply them with 10 then add 7

(2200H) = 67H
(2300H) = 6 x OAH + 7 = 3CH + 7 = 43H
LDA 2200H
MOV B,A
ANI 0F
MOV C,A
MOV A,B
ANI F0
RRC//used to move all bits in the acc to right by one position
RRC//using them 4 times moves the bits from higher nibble to lower nibble entirely
RRC
RRC
MOV B,A
MVI D 0A
LOOP:ADD B
DCR D
JNZ LOOP
ADD C
STA 2100
HLT

You might also like