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 ADDRESS | OPCODES | MNEMONICS |
8500 | 90 86 03 | MOV DPTR,#8603H |
8503 | E0 | MOVX A,@DPTR |
8504 | F8 | MOV R0,A |
8505 | 90 86 01 | MOV DPTR,#8601H |
8508 | E0 | MOVX A,@DPTR |
8509 | FA | MOV R2,A |
850A | 98 | SUBB A,R0 |
850B | 90 87 01 | MOV DPTR,#8701H |
850E | F0 | MOVX @DPTR,A |
850F | 90 86 02 | MOV DPTR,#8602H |
8512 | E0 | MOVX A,@DPTR |
8513 | F9 | MOV R1,A |
8514 | 90 86 00 | MOV DPTR,#8600H |
8517 | E0 | MOVX A,@DPTR |
8518 | 99 | SUBB A,R |
8519 | 90 87 00 | MOV DPTR,#8700H |
851C | F0 | MOVX @DPTR,A |
851D | 80 00 | SJMP E |
851F | 80 FE | E: 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.
What to do for 40 bit?