Problem – Write an assembly language program in 8085 microprocessor to convert an 8 bit BCD number into hexadecimal number.
Assumptions – Assume that starting address of the program is 2000, input memory locations, 2050, 2051, and output memory location is 2052.
Example –
INPUT: 2050:02H
2051: 09H
OUTPUT:2052: 1DH
Algorithm –
- Initialize memory pointer to 2050
- Get the most significant digit
- Multiply the MSD by 10 using repeated addition
- Add LSD to result obtained in above step
- Store the converted result in memory 2052
Program –
| Memory Address | Mnemonics | Comments |
|---|---|---|
| 2000 | LXI H, 2050 | |
| 2003 | MOV A, M | A<-M |
| 2004 | ADD A | A<-A+A |
| 2005 | MOV B, A | B<-A |
| 2006 | ADD A | A<-A+A |
| 2007 | ADD A | A |
| 2008 | ADD B | A<-A+B |
| 2009 | INX H | |
| 200A | ADD M | A<-A+M |
| 200B | INX H | |
| 200C | MOV M, A | M<-A |
| 200D | HLT | TERMINATE THE PROGRAM |
Explanation – Registers H, L, B, A are used for general purpose.
- LXI H, 2050: will load the HL pair register with the address 2050 of memory location.
- MOV A, M: copies the content of memory into register A.
- ADD A: add the content of accumulator with itself.
- MOV B, A: move the content of accumulator into register B.
- ADD A: add the content of accumulator with itself.
- ADD A: add the content of accumulator with itself.
- ADD B: add the content of accumulator with register B and store the result in accumulator.
- INX H: increment register pair HL.
- ADD M: add the content of accumulator with memory and store the result in accumulator.
- INX H: increment register pair HL.
- MOV M, A: copies the content of accumulator into memory.
- HLT: stops executing the program and halts any further execution.
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 an 8 bit BCD number into hexadecimal number
- 8085 program to convert 8 bit BCD number into ASCII Code
- 8085 program to convert a hexadecimal number into ASCII code
- 8086 program to convert 8 bit BCD number into ASCII Code
- 8085 program to convert a BCD number to binary
- 8085 program to convert an 8 bit number into Grey number
- 8086 program to convert 8 bit ASCII to BCD number
- 8085 program to add 2-BCD numbers
- 8086 program to convert a 16 bit decimal number to Hexadecimal
- 8085 program for hexadecimal counter
- 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 convert ASCII code into HEX code
- 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
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.
Improved By : Akanksha_Rai

