8 BIT SUBTRACTION
AIM:
To write an assembly language program in microcontroller to perform subtraction between two 8 bit numbers.
APPARATUS REQUIRED:
8051 kit, power chord
ALGORITHM:
1. Start the program.
2. Get the first 8 bit data in accumulator.
3. Subtract another 8 bit data with the accumulator content.
4. Move the address location to Data Pointer.
5. Store the subtracted result in the Data Pointer.
6. Stop the program.
PROGRAM:
| ADDRESS | LABEL | OPCODE | MNEMONICS | OPERAND | COMMENTS |
| 4200 | | C3 | CLRC | | Clear the content |
| 4201 | | 74 | MOV | A, #Data 1 | Move the data (20) to accumulator. |
| 4202 | | 20 | | | |
| 4203 | | 94 | SUBB | A, #Data 2 | Subtract the content of acc and the second data (10) |
| 4204 | | 10 | | | |
| 4205 | | 90 | MOV | DPTR, #4500 | Move the address location 4500 to DPTR. |
| 4206 | | 45 | | | |
| 4207 | | 00 | | | |
| 4208 | | F0 | MOVX | @DPTR,A | Move the content of accumulator to the address location (4500) in DPTR |
| 4209 | | 80 | HERE:SJMP HERE | | |
| 420A | | FE | | | |
INPUT:
4202: 20 4204: 10
OUTPUT:
4500: 10
RESULT:
Thus an assembly language program for the subtraction of two 8 bit numbers in microcontroller was written and executed successfully.
0 comments:
Post a Comment