Subtraction of two numbers using 8051

Spread the love

16-BIT SUBTRACTION

AIM

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

THEORY

Using the accumulator, subtraction is performed and the result is stored. Immediate addressing is employed. The SUBB instruction writes the result in the accumulator.

EXAMPLE:

8600 – MSB of first operand 8601 – MSB of second operand 8602 – LSB of first operand 8603 – LSB of second operand Result 8700 – MSB 8701 – LSB

ASSEMBLY PROGRAM TO SUBTRACT TWO 16 BIT NUMBER

MEMORY ADDRESSOPCODESMNEMONICS
850090 86 03MOV DPTR,#8603H
8503E0MOVX A,@DPTR
8504F8MOV R0,A
850590 86 01MOV DPTR,#8601H
8508E0MOVX A,@DPTR
8509FAMOV R2,A
850A98SUBB A,R0
850B90 87 01MOV DPTR,#8701H
850EF0MOVX @DPTR,A
850F90 86 02MOV DPTR,#8602H
8512E0MOVX A,@DPTR
8513F9MOV R1,A
851490 86 00MOV DPTR,#8600H
8517E0MOVX A,@DPTR
851899SUBB A,R
851990 87 00      MOV DPTR,#8700H
851CF0MOVX @DPTR,A
851D80 00SJMP E
851F80 FEE: SJMP E

PROCEDURE

☞Enter the input data in memory location 8600 to 8603.

☞Enter the above opcodes from 8500.

☞Execute the program.

☞Result stored in 8700 & 8701. Change data and check result in 8700, 8701.

RESULT

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

One comment

Leave a Reply

Your email address will not be published. Required fields are marked *

fourteen − 13 =

This site uses Akismet to reduce spam. Learn how your comment data is processed.