Google Search

Wednesday, October 27, 2010

8 BIT SUBTRACTION MICROCONTROLLER (8051)

To write an assembly language program in microcontroller to perform subtraction between two 8 bit numbers.

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 HERE 80 SJMP HERE
420A FE

INPUT:
4202: 20 4204: 10
OUTPUT:
4500: 10

0 comments:

Post a Comment