Addition of two numbers using 8051

AIM

To perform 16-bit addition of two 16-bit data using immediate addressing and store the result in memory.

THEORY

As there is only one 16-bit Register in 89C51, 16-bit addition is performed by using ADDC instruction twice, i.e. adding LSD first and MSD next.

DATAM1 – 12; DATAM2 = 56.

DATAM1 – MSD OF DATA1,

DATAM2 – MSD OF DATA2,

DATAL1 – LSD OF DATA1,

DATAL2 – LSD OF DATA2.

ASSEMBLY PROGRAM TO ADD TWO 16 BIT NUMBER

ADDRESSOPCODEMNEMONICS
850090 85 01MOV DPTR,#8501H
8503E0MOVX A,@DPTR
8504F5 F0MOV B,A
850690 85 03MOV DPTR,#8503H
8509E0MOVX A,@DPTR
850A35 F0ADDC A,B
850C90 8601MOV DPTR,#8601H
850FF0MOVX @DPTR,A
851090 85 00MOV DPTR,#8500H
8513E0MOVX A,@DPTR
8514F5 F0MOV B,A
851690 85 02MOV DPTR,#8502H
8519E0 MOVX A,@DPTR
851A35 F0 ADDC A,B
851C90 86 00MOV DPTR,#8600H
851FF0MOVX @DPTR,A
852080 FEE: SJMP E

PROCEDURE

Enter the above opcodes from 8500 in the trainer.

☞Execute the program.

☞Check for the result at 8550 and 8551.

☞Change data and see if the result at 8550 changes accordingly.

EXAMPLE:

The program is to add the 16-bit data 1234 with the data 5678 and store the result at the locations RESULT: [8550] = AC (LSB); [8551] = 68 (MSB). DATAL1 – 34; DATAL2 = 78.

RESULT

Thus the Addition of two 16 bit numbers is stored in the resultant memory

This program is done thru 8051 Lab Trainer Kit

Pantech:
Leave a Comment

This website uses cookies.