To convert given Hexa decimal number into its equivalent BCD number using 8085
instruction set
ALGORITHM:
1) Initialize memory pointer to 4150 H
2) Get the Hexa decimal number in C - register
3) Perform repeated addition for C number of times
4) Adjust for BCD in each step
5) Store the BCD data in Memory
PROGRAM:
LXI H,4150 Initialize memory pointer
MVI D,00 Clear D- reg for Most significant Byte
XRA A Clear Accumulator
MOV C,M Get HEX data
LOOP2: ADI 01 Count the number one by one
DAA Adjust for BCD count
JNC LOOP1
INR D
LOOP1: DCR C
JNZ LOOP2
STA 4151 Store the Least Significant Byte
MOV A,D
STA 4152 Store the Most Significant Byte
HLT
OBSERVATION:
Input: 4150 : FF
Output: 4151 : 55 (LSB)
4152 : 02 (MSB)
instruction set
ALGORITHM:
1) Initialize memory pointer to 4150 H
2) Get the Hexa decimal number in C - register
3) Perform repeated addition for C number of times
4) Adjust for BCD in each step
5) Store the BCD data in Memory
PROGRAM:
LXI H,4150 Initialize memory pointer
MVI D,00 Clear D- reg for Most significant Byte
XRA A Clear Accumulator
MOV C,M Get HEX data
LOOP2: ADI 01 Count the number one by one
DAA Adjust for BCD count
JNC LOOP1
INR D
LOOP1: DCR C
JNZ LOOP2
STA 4151 Store the Least Significant Byte
MOV A,D
STA 4152 Store the Most Significant Byte
HLT
OBSERVATION:
Input: 4150 : FF
Output: 4151 : 55 (LSB)
4152 : 02 (MSB)
HEX TO BCD CONVERSION
Reviewed by enakta13
on
August 20, 2012
Rating: