Skip to content
Related Articles

Related Articles

Improve Article

8085 program to convert 8 bit BCD number into ASCII Code

  • Last Updated : 22 May, 2018

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 –

  1. Input the content of 2050 in accumulator
  2. Move content of Accumulator to register B
  3. Separate the least significant digit using AND with 0F and ADD 30 to accumulator
  4. Store content of accumulator to memory location 3050
  5. Move content of register B to Accumulator
  6. Separate the most significant digit using AND with F0
  7. Rotate Content of Accumulator 4 times
  8. ADD 30 to accumulator
  9. Store content of accumulator to memory location 3051

Program –

AddressMnemonicsComments
2000LDA 2050A <- [2050]
2003MOV B, AB <- A
2004ANI 0FA <- A & 0F
2006ADI 30A <- A + 30
2008STA 3050[3050]<-A
200BMOV A, BA <- B
200CANI F0A <- A & F0
200ERLCRotate A left
200FRLCRotate A left
2010RLCRotate A left
2011RLCRotate A left
2012ADI 30A <- A + 30
2014STA 3051[3051]<-A
2017HLTStop Execution

Explanation –

  1. LDA 2050 load the content of memory location 2050 to accumulator
  2. MOV B, A copy the content of accumulator to register B
  3. ANI 0F AND the content of accumulator with immediate data 0F
  4. ADI 30 ADD 30 to accumulator
  5. STA 3050 store the content of accumulator to memory location 3050
  6. MOV A, B copy the content of register B to accumulator
  7. ANI F0 AND the content of accumulator with immediate data F0
  8. RLC rotate the content of accumulator left without carry
  9. RLC rotate the content of accumulator left without carry
  10. RLC rotate the content of accumulator left without carry
  11. RLC rotate the content of accumulator left without carry
  12. ADI 30 ADD 30 to accumulator
  13. STA 3051 store the content of accumulator to memory location 3051
  14. 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.

 

My Personal Notes arrow_drop_up
Recommended Articles
Page :