Section: Arithmetic & Logic Operations
Aim: To divide two 8-bit numbers stored in memory and also to verify the result.
Apparatus Required: 8085 microprocessor kit, key board.
Algorithm:
- Load Divisor and Dividend.
- Subtract divisor from dividend.
- Count the number of times of subtraction, which equals the quotient.
- Stop subtraction when the dividend is less than the divisor. The dividend now becomes the remainder. Otherwise, go to step 2.
- Stop the program execution.
Program:
| Address | Label | Mnemonics | Operand | Comment |
|---|---|---|---|---|
| 4100 | MVI | B,00 | Clear B reg for quotient | |
| 4102 | LXI | H,4200 | Initialize HL reg. to 4200H | |
| 4105 | MOV | A,M | Transfer dividend to acc. | |
| 4106 | INX | H | Increment HL reg. to point next mem. Location. | |
| 4107 | LOOP | SUB | M | Subtract divisor from dividend |
| 4108 | INR | B | Increment B reg | |
| 4109 | JNC | LOOP | Jump to LOOP if result does not yield borrow | |
| 410C | ADD | M | Add divisor to acc. | |
| 410D | DCR | B | Decrement B reg | |
| 410E | INX | H | Increment HL reg. to point next mem. Location. | |
| 410F | MOV | M,A | Transfer the remainder from acc. to memory. | |
| 4110 | INX | H | Increment HL reg. to point next mem. Location. | |
| 4111 | MOV | M,B | Transfer the quotient from B reg. to memory. | |
| 4112 | HLT | Stop the program |
Observation:
- Input:
- Address
4200:06 - Address
4201:02
- Address
- Output:
- Address
4202:00(Remainder) - Address
4203:03(Quotient)
- Address
Result: Thus an ALP was written for 8-bit division and also the result is verified.
Flowchart:
+-------------------+
| START |
+---------+---------+
|
v
+-------------------+
| [B] <- 00H |
+---------+---------+
|
v
+-------------------+
| [HL] <- 4200H |
+---------+---------+
|
v
+-------------------+
| [A] <- [M] |
+---------+---------+
|
v
+-------------------+
| [HL] <- [HL] + 1 |
+---------+---------+
|
v <------------------+
+-------------------+ |
| [A] <- [A] - [M] | |
+---------+---------+ |
| |
v |
+-------------------+ |
| [B] <- [B] + 1 | |
+---------+---------+ |
| |
v |
/ \ |
/ Is \ |
/ there a \ |
< Borrow? > |
\ (CY = 1) / |
\ / |
\ / |
| |
+-----------+-----------+ |
| | |
YES NO |
| +---------+
v
+-------------------+
| [A] <- [A] + [M] |
+---------+---------+
|
v
+-------------------+
| [B] <- [B] - 1 |
+---------+---------+
|
v
+-------------------+
| [HL] <- [HL] + 1 |
+---------+---------+
|
v
+-------------------+
| [M] <- [A] |
| (Remainder) |
+---------+---------+
|
v
+-------------------+
| [HL] <- [HL] + 1 |
+---------+---------+
|
v
+-------------------+
| [M] <- [B] |
| (Quotient) |
+---------+---------+
|
v
+-------------------+
| STOP |
+-------------------+
Viva Questions:
- What SUB M instruction will do?
- Describe SBB M instruction.
- Express the use of SUI with an example.
- Where SBI can be used?
- Give the purpose of the instruction LDAX D.
- How will you perform Division using ADD instruction?
- What is the need of ALE signal in 8085?
- What are the addressing modes of 8085?
- List the interrupt signals of 8085?
For all 2026 published articles list: click here:
…till the next post, bye-bye & take care