16-BIT DIVISION
AIM:
To write an ALP for division of two 16-bit Numbers.
APPARATUS REQUIRED:
8085 kit, power chord
ALGORITHM:
1. Start the program
2. Load the dividend in HL register pair.
3. Load the divisor in BE register pair.
4. Move the content of L register to A register.
5. Subtract C register.
6. Move the content of A register to L register.
7. Move the content of H register to A register.
8. Subtract A with borrow.
9. Check for carry and increment the HL register pair.
10. Add B with A and carry.
11. Exchange HL with DE register pair.
12. Store the result in HL register pair.
13. Stop the process.
PROGRAM:
| Address | Label | Opcode | Mnemonic | Operand | Comments |
| 4200 | | 21,3B,AF | LXI | H,AF3B | Load the dividend |
| 4203 | | 01,CB,3A | LXI | B,3ACB | Load the divisor |
| 4206 | | 11,00,00 | LXI | D,0000 | Clear the DE reg pair |
| 4209 | NEXT | 7D | MOV | A,L | Move the content of L register to A register |
| 420A | | 91 | SUB | C | Subtract C register |
| 420B | | 6F | MOV | L,A | Move the content of A register to L register |
| 420C | | 7C | MOV | A,H | Move the content of H register to A register |
| 420D | | 98 | SBB | B | Subtract A with Borrow. |
| 420E | | 67 | MOV | H,A | Move the content of A register to H register |
| 420F | | DA,16,42 | JC | OVER | Check for carry |
| 4212 | | 13 | INX | D | If no carry, increment the DE register pair. |
| 4213 | | C3,09,42 | JMP | NEXT | Jump to the specified address. |
| 4216 | OVER | 7D | MOV | A,L | Move the content of L register to A register |
| 4217 | | 81 | ADD | C | Add the content of C register with A |
| 4218 | | 6F | MOV | L,A | Move the content of A register to L register |
| 4219 | | 7C | MOV | A,H | Move the content of H register to A register |
| 421A | | 88 | ADC | B | Add the content of B with A and carry. |
| 421B | | 67 | MOV | H,A | Move the content of A register to H register |
| 421C | | 22,00,45 | SHLD | 4500 | Store the result in HL reg pair. |
| 421F | | EB | XCHG | | Exchange HL pair with DE pair |
| 4220 | | 22,02,42 | SHLD | 4502 | Store the result in HL reg pair |
| 4223 | | 76 | HLT | | Stop the process. |
INPUT: OUTPUT:
AF3B (IN HL PAIR) 4500: A5
4501: 39
3ACB (IN BC PAIR) 4502: 02
4503: 00
RESULT:
Thus the assembly language program for 16-bit Division is executed and the results are verified
0 comments:
Post a Comment