8085 program to convert 8 bit BCD number into ASCII Code
Last Updated :
08 Feb, 2024
Problem – Write an assembly-level language program to convert 8-bit BCD number to its respective ASCII Code.Â
Assumptions –Â
Starting address of program: 2000Â
Input memory location: 2050Â
Output memory location: 3050 and 3051Â
ASCII Code for Digits 0 – 9Â
Example –Â
Algorithm –Â Â
- Input the content of 2050 in accumulatorÂ
Â
- Move content of Accumulator to register BÂ
Â
- Separate the least significant digit using AND with 0F and ADD 30 to accumulatorÂ
Â
- Store content of accumulator to memory location 3050Â
Â
- Move content of register B to AccumulatorÂ
Â
- Separate the most significant digit using AND with F0Â
Â
- Rotate Content of Accumulator 4 timesÂ
Â
- ADD 30 to accumulatorÂ
Â
- Store content of accumulator to memory location 3051Â
Â
Program –Â
Address |
Mnemonics |
Comments |
2000 |
LDA 2050 |
A <- [2050] |
2003 |
MOV B, A |
B <- A |
2004 |
ANI 0F |
A <- A & 0F |
2006 |
ADI 30 |
A <- A + 30 |
2008 |
STA 3050 |
[3050]<-A |
200B |
MOV A, B |
A <- B |
200C |
ANI F0 |
A <- A & F0 |
200E |
RLC |
Rotate A left |
200F |
RLC |
Rotate A left |
2010 |
RLC |
Rotate A left |
2011 |
RLC |
Rotate A left |
2012 |
ADI 30 |
A <- A + 30 |
2014 |
STA 3051 |
[3051]<-A |
2017 |
HLT |
Stop Execution |
Explanation –Â
- LDA 2050 load the content of memory location 2050 to accumulatorÂ
Â
- MOV B, A copy the content of accumulator to register BÂ
Â
- ANI 0F AND the content of accumulator with immediate data 0FÂ
Â
- ADI 30 ADD 30 to accumulatorÂ
Â
- STA 3050 store the content of accumulator to memory location 3050Â
Â
- MOV A, B copy the content of register B to accumulatorÂ
Â
- ANI F0 AND the content of accumulator with immediate data F0Â
Â
- RLC rotate the content of accumulator left without carryÂ
Â
- RLC rotate the content of accumulator left without carryÂ
Â
- RLC rotate the content of accumulator left without carryÂ
Â
- RLC rotate the content of accumulator left without carryÂ
Â
- ADI 30 ADD 30 to accumulatorÂ
Â
- STA 3051 store the content of accumulator to memory location 3051Â
Â
- HLT stops the execution of program Â
Advantages:
Simple: The program is relatively short and easy to understand. It doesn’t require any complex operations or calculations, making it easy to implement.
Efficient: The program uses only a few instructions, so it executes quickly and doesn’t require much memory.
Useful: The program can be used in a variety of applications where BCD to ASCII conversion is required, such as in digital displays or in communication with other devices.
Disadvantages:
Limited input range: The program can only handle 8-bit BCD numbers, which limits its usefulness in some applications.
Limited output range: The program can only output ASCII codes for the tens and ones digits of the BCD number, which limits its usefulness in some applications.
Requires additional code: If the program is used in a larger application, additional code may be needed to input the BCD number, output the ASCII code, and handle any errors or exceptions.
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...