Section: Arithmetic & Logic Operations
Aim: To add two 8-bit numbers stored at consecutive memory locations and also to verify the result.
Apparatus Required: 8085 microprocessor kit, keyboard.
Algorithm:
- Initialize memory pointer to data location.
- Get the first number from memory into accumulator.
- Get the second number and add it to the accumulator.
- Store the answer at another memory location.
Program:
| Address | Label | Mnemonics | Operand | Comment |
|---|---|---|---|---|
| 4100 | START | MVI | C, 00 | Clear C reg. |
| 4102 | LXI | H, 4200 | Initialize HL reg. to 4200 | |
| 4105 | MOV | A, M | Transfer first data to accumulator | |
| 4106 | INX | H | Increment HL reg. to point next memory location | |
| 4107 | ADD | M | Add first number to acc. content | |
| 4108 | JNC | L1 | Jump to location if result does not yield carry | |
| 410B | INR | C | Increment C reg. | |
| 410C | L1 | INX | H | Increment HL reg. to point next memory location |
| 410D | MOV | M, A | Transfer the result from acc. to memory | |
| 410E | INX | H | Increment HL reg. to point next memory location | |
| 410F | MOV | M, C | Move carry to memory | |
| 4110 | HLT | Stop the program |
Observation:
- Input:
- Memory location
4200:40 - Memory location
4201:20
- Memory location
- Output:
- Memory location
4202:60(Sum) - Memory location
4203:00(Carry)
- Memory location
Result: Thus the two 8-bit numbers stored at 4200 & 4201 are added and the result is stored at 4202 & 4203.
Flow Chart:
+-------------------+
| START |
+---------+---------+
|
v
+-------------------+
| [C] <- 00H |
+---------+---------+
|
v
+-------------------+
| [HL] <- 4200H |
+---------+---------+
|
v
+-------------------+
| [A] <- [M] |
+---------+---------+
|
v
+-------------------+
| [HL] <- [HL] + 1 |
+---------+---------+
|
v
+-------------------+
| [A] <- [A] + [M] |
+---------+---------+
|
v
/ \
/ Is \
/ there a \
< Carry? >
\ /
\ /
\ /
|
+-----------+-----------+
| |
YES NO
| |
v |
+-------------------+ |
| [C] <- [C] + 1 | |
+---------+---------+ |
| |
+-----------+-----------+
|
v
+-------------------+
| [HL] <- [HL] + 1 |
+---------+---------+
|
v
+-------------------+
| [M] <- [A] |
+---------+---------+
|
v
+-------------------+
| [HL] <- [HL] + 1 |
+---------+---------+
|
v
+-------------------+
| [M] <- [C] |
+---------+---------+
|
v
+-------------------+
| STOP |
+-------------------+
Viva Questions:
- What is the function of
LXI H, 4000 Hinstruction? - How can you store data in a memory location?
- What is the meaning of
INX? - How can you read data from a memory location?
- What are the flags available in 8085?
- What is the function of the RESET key of an 8085 microprocessor kit?
- What is the function of
JNCinstruction? - What is the difference between conditional and unconditional jump instructions?
- What is multibyte addition/subtraction?
For all 2026 published articles list: click here:
…till the next post, bye-bye & take care