MICROCONTROLLER (8051)
16 BIT ADDITION
AIM:
            To write an assembly language program in microcontroller to perform addition between two 16 bit numbers.
APPARATUS REQUIRED:
                                    8051 kit, power chord
ALGORITHM:
1.      Start the program.
2.      Get the first 8 bit data (MSB) of the 16 bit in accumulator.
3.      Add another 8 bit data (MSB) with the accumulator content.
4.      Move the address location to Data Pointer.
5.      Store the added result (MSB) in the Data Pointer.
6.      Get the first 8 bit data (LSB) of the 16 bit in accumulator.
7.      Add another 8 bit data (LSB) with the accumulator content.
8.      Increment the Data Pointer.
9.      Store the added result (LSB) in the Data Pointer.
10. Stop the program.
PROGRAM:      
|     ADDRESS  |        LABEL  |        OPCODE  |        MNEMONICS  |        OPERAND  |        COMMENTS  |   
|     4100  |        |        C3  |        CLRC  |        |        Clear the content  |   
|     4101  |        |        74  |        MOV  |        A, #Data M1  |        Move the data (MSB)   34 to accumulator.  |   
|     4102  |        |        34  |        |        |        |   
|     4103  |        |        24  |        ADD  |        A, #Data M2  |        Add the content of   acc and the second MSB 78 data.  |   
|     4104  |        |        78  |        |        |        |   
|     4105  |        |        90  |        MOV  |        DPTR, #4150  |        Move the address   location 4150 to DPTR.  |   
|     4106  |        |        41  |        |        |        |   
|     4107  |        |        50  |        |        |        |   
|     4108  |        |        F0  |        MOVX  |        @DPTR,A  |        Move the content of   accumulator to the address location (4150) in DPTR  |   
|     4109  |        |        A3  |        INC   |        DPTR  |        Increment the content   of DPTR.  |   
|     410A  |        |        74  |        MOV  |        A, #Data L1  |        Move the data (LSB)   12 to accumulator  |   
|     410B  |        |        12  |        |        |        |   
|     410C  |        |        34  |        ADDC  |        A, #Data L2  |        Add the content of   acc and the second (LSB) 56 data.  |   
|     410D  |        |        56  |        |        |        |   
|     410E  |        |        F0  |        MOVX  |        @DPTR,A  |        Move the content of   accumulator to the address location (4151) in DPTR  |   
|     410F  |        |        80  |        HERE:SJMP HERE  |        |        |   
|     4110  |        |        FE  |        |        |        |   
INPUT:
4102:34 (MSB)                                                                410B:12 (LSB)
4104:78 (MSB)                                                                410D: 56 (LSB)
OUTPUT:
4150: AC (MSB)                                                        4151:  68 (LSB)
 RESULT:
            Thus an assembly language program for the addition of two 16 bit numbers in microcontroller was written and executed successfully.  
No comments:
Post a Comment