bcd to hex conversion in 8085
Algorithm
1. Initialize memory pointer to 4150 H
2. Get the Most Significant Digit (MSD)
3. Multiply the MSD by ten using repeated addition
4. Add the Least Significant Digit (LSD) to the result obtained in previous step
5. Store the HEX data in Memory
Program
LXI H,5000
MOV A,M ;Initialize memory pointer
ADD A ;MSD X 2
MOV B,A ;Store MSD X 2
ADD A ;MSD X 4
ADD A ;MSD X 8
ADD B ;MSD X 10
INX H ;Point to LSD
ADD M ;Add to form HEX
INX H
MOV M,A ;Store the result
HLT
Result
Input:
Data 0: 02H in memory location 5000
Data 1: 09H in memory location 5001
Output:
Data 0: 1DH in memory location 5002