Section: Array Operations & Code Conversions
Aim: To convert a given decimal number to hexadecimal number.
Apparatus Required: 8085 microprocessor kit, key board.
Algorithm:
- Initialize the memory location to the data pointer.
- Increment B register.
- Increment accumulator by 1 and adjust it to decimal every time.
- Compare the given decimal number with accumulator value.
- When both matches, the equivalent hexadecimal value is in B register.
- Store the resultant in memory location.
Program:
| Address | Label | Mnemonics | Operand | Comment |
|---|---|---|---|---|
| 4100 | LXI | H, 4200 | Initialize HL reg. to 4200H | |
| 4103 | MVI | A, 00 | Initialize A register | |
| 4105 | MVI | B, 00 | Initialize B register | |
| 4107 | LOOP | INR | B | Increment B reg. |
| 4108 | ADI | 01 | Increment A reg | |
| 410A | DAA | Decimal Adjust Accumulator | ||
| 410B | CMP | M | Compare M & A | |
| 410C | JNZ | LOOP | If acc and given number are not equal, then go to LOOP | |
| 410F | MOV | A, B | Transfer B reg to acc | |
| 4110 | STA | 4201 | Store the result in a memory location | |
| 4113 | HLT | Stop the program |
Observation:
- Input: Address
4200:21 - Output: Address
4201:15
Result: Thus an ALP program for conversion of decimal to hexadecimal was written and executed.
Flowchart:
+-------------------+
| START |
+---------+---------+
|
v
+-------------------+
| [HL] <- 4200H |
+---------+---------+
|
v
+-------------------+
| [A] <- 00H |
+---------+---------+
|
v
+-------------------+
| [B] <- 00H |
+---------+---------+
|
v <------------------+
+-------------------+ |
| [B] <- [B] + 1 | |
+---------+---------+ |
| |
v |
+-------------------+ |
| [A] <- [A] + 1 | |
+---------+---------+ |
| |
v |
+-------------------+ |
| Decimal Adjust | |
| Accumulator | |
+---------+---------+ |
| |
v |
/ \ |
/ Is \ |
/ [A] = \ |
< [M]? > |
\ / |
\ / |
\ / |
| |
+-----------+------------+ |
| | |
YES NO |
| +--------+
v
+-------------------+
| [A] <- [B] |
+---------+---------+
|
v
+-------------------+
| <- [A] |
+---------+---------+
|
v
+-------------------+
| STOP |
+-------------------+
Viva Questions:
- What is meant by ADI instruction?
- What is the function of DAA instruction?
- What is the function of XCHG instruction?
- How you can load 16-bit data in 8500H and 8501H memory locations?
- What is the difference between LHLD and SHLD instructions?
- What is physical address?
- Define OFFSET address.
For all 2026 published articles list: click here:
…till the next post, bye-bye & take care