Problem – Write an assembly level language program to convert 8 bit BCD number to its respective ACSII 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
Attention reader! Don’t stop learning now. Get hold of all the important CS Theory concepts for SDE interviews with the CS Theory Course at a student-friendly price and become industry ready.
Recommended Posts:
- 8086 program to convert 8 bit BCD number into ASCII Code
- 8085 program to convert an 8 bit BCD number into hexadecimal number
- 8085 program to convert ASCII code into HEX code
- 8086 program to convert 8 bit ASCII to BCD number
- 8085 program to convert a hexadecimal number into ASCII code
- 8085 code to convert binary number to ASCII code
- 8086 program to convert an 8 bit BCD number into hexadecimal number
- 8085 program to convert a BCD number to binary
- 8085 program to convert an 8 bit number into Grey number
- 8085 program to add 2-BCD numbers
- 8086 program to add two 8 bit BCD numbers
- 8086 program to add two 16 bit BCD numbers with carry
- 8086 program to subtract two 8 bit BCD numbers
- 8086 program to subtract two 16 bit BCD numbers
- 8085 program to count number of ones in the given 8-bit number
- 8085 program to find 1's and 2's complement of 8-bit number
- 8085 program to find 1’s and 2’s complement of 16-bit number
- 8085 program to find sum of digits of 8 bit number
- 8085 program to find square of a 8 bit number
- 8085 program to reverse 16 bit number
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

