Section: Array Operations & Code Conversions
Aim: To convert a given hexadecimal number to decimal number and also to verify the result.
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 hexadecimal number with B register value.
- When both match, the equivalent decimal value is in A 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 | MVI | C, 00 | Initialize C register for carry | |
| 4109 | LOOP | INR | B | Increment B reg |
| 410A | ADI | 01 | Increment A reg | |
| 410C | DAA | Decimal Adjust Accumulator | ||
| 410D | JNC | NEXT | If there is no carry go to NEXT | |
| 4110 | INR | C | Increment C register | |
| 4111 | NEXT | MOV | D, A | Transfer A to D |
| 4112 | MOV | A, B | Transfer B to A | |
| 4113 | CMP | M | Compare M & A | |
| 4114 | MOV | A, D | Transfer D to A | |
| 4115 | JNZ | LOOP | If acc and given number are not equal, then go to LOOP | |
| 4118 | STA | 4201 | Store the result in a memory location | |
| 411B | MOV | A, C | Transfer C to A | |
| 411C | STA | 4202 | Store the carry in another memory location | |
| 411F | HLT | Stop the program |
Observation:
- Input:
- Address
4200:D5
- Address
- Output:
- Address
4201:13 - Address
4202:02
- Address
Result: Thus an ALP program for conversion of hexadecimal to decimal was executed and the result is verified.
Flowchart:
+-------------------+
| START |
+---------+---------+
|
v
+-------------------+
| [HL] <- 4200H |
+---------+---------+
|
v
+-------------------+
| [A] <- 00H |
+---------+---------+
|
v
+-------------------+
| [B] <- 00H |
+---------+---------+
|
v
+-------------------+
| [C] <- 00H |
+---------+---------+
|
v <------------------+
+-------------------+ |
| [B] <- [B] + 1 | |
+---------+---------+ |
| |
v |
+-------------------+ |
| [A] <- [A] + 1 | |
+---------+---------+ |
| |
v |
+-------------------+ |
| Decimal Adjust | |
| Accumulator | |
+---------+---------+ |
| |
v |
/ \ |
/ Is \ |
/ there a \ |
< Carry? > |
\ (CY = 1) / |
\ / |
\ / |
| |
+-----------+-----------+ |
| | |
YES NO |
| | |
v | |
+-------------------+ | |
| [C] <- [C] + 1 | | |
+---------+---------+ | |
| | |
+-----------+-----------+ |
| |
v |
+-------------------+ |
| [D] <- [A] | |
| [A] <- [B] | |
+---------+---------+ |
| |
v |
/ \ |
/ Is \ |
/ [A] = \ |
< [M]? > |
\ / |
\ / |
\ / |
| |
+-----------+------------+ |
| | |
YES NO |
| +---------+
v
+-------------------+
| <- [A] |
| [A] <- [C] |
| <- [A] |
+---------+---------+
|
v
+-------------------+
| STOP |
+-------------------+
Viva Questions:
- What is meant by instruction DAA?
- Why data bus is bi-directional?
- Specifies the function of address bus and the direction of address bus?
- How many memory location can be addressed by a microprocessor with the 14 address lines?
- List various instructions that can be used to clear accumulator in 8085?
- When the Ready signal of 8085 is sampled by the processor?
- List out the similarities b/w the CALL_RET and PUSH_POP instructions?
For all 2026 published articles list: click here:
…till the next post, bye-bye & take care