PhysicsTeacher.in

High School Physics

HEX to BCD conversion program in 8085 – PhysicsTeacher.in

Last updated on March 10th, 2022 at 03:10 pm

In this post, we will see how to convert a given Hexadecimal number into its equivalent BCD number using the 8085 microprocessor instruction set. (HEX to BCD conversion)

Algorithm for HEX to BCD Conversion with 8085 microprocessor

1) Initialize memory pointer to 4150 H
2) Get the Hexadecimal 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 to convert a given Hexadecimal number into its equivalent BCD number using the 8085 microprocessor

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

Program to convert a given Hexadecimal number into its equivalent BCD number using the 8085 microprocessor
Program to convert a given Hexadecimal number into its equivalent BCD number using the 8085 microprocessor

Observation

Input: 4150 : FF
Output: 4151 : 55 (LSB)
4152 : 02 (MSB)

Result

Thus the 8085 microprocessor program to convert HEX data to BCD data was executed.

See also  How to Interface a RAM chip with 8085 microprocessor
Scroll to top
error: physicsTeacher.in