Skip to content
Related Articles

Related Articles

Improve Article

8085 program to convert ASCII code into HEX code

  • Last Updated : 14 Jun, 2018

Problem – Write an assembly level language program to convert ASCII code to its respective HEX Code.


DATA: 31H in memory location 2050
DATA: 0BH in memory location 3050 

Assume that starting address of program, input memory location, and output memory locations are 2000, 2050, and 3050 respectively.

Algorithm –

  1. Input the content of 2050 in accumulator.
  2. Subtract 30H from accumulator.
  3. Compare the content of accumulator with 0AH.
  4. If content of accumulator is less than 0A then goto step 6 else goto step 5.
  5. Subtract 07H from accumulator.
  6. Store content of accumulator to memory location 3050.
  7. Terminate the program.

Program –

2000LDA 2050A<-[2050]
2003SUI 30HA<-A-30
2005CPI 0AH
2007JC 200DCheck for carry
200BSUI 07HA<-A-07H
200DSTA 3050[3050]<-A
2010HLTStop execution

Explanation –

  1. LDA 2050 load the content of memory location 2050 to accumulator.
  2. SUI 30H subtracts 30H immediately from accumulator.
  3. CPI 0AH compare immediately 0AH with the data of accumulator.
  4. JC 200D check for carry if yes then go to address 200D.
  5. SUI 07H subtracts 07H immediately from accumulator.
  6. STA 3050 store the content of accumulator to memory location 3050.
  7. 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 :