8085 program to convert 8 bit BCD number into ASCII Code
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
Please Login to comment...