Tuesday, March 22, 2016

8051 Subtraction of 16-bit Numbers

This SUBB instruction along with carry flag is used for multi-byte numbers and will take care of the borrow of the lower operand. If CY = 1 prior to executing the SUBB instruction, it also subtracts 1 from the result.

Program to subtract 2762H – 1296H:

ORG 0H
MAIN :
CLR A
CLR C
MOV A, #62H
SUBB A, #96H ; 62 – 96 = CCH, C = 1
MOV R7, A
MOV A, #27H
SUBB A, #12H ; 27 – 12 – 1 = 14H
MOV R6, A
END; end of asm source file



Related topics:
8051 Addition of Unsigned Numbers   |   8051 Addition of 16-bit Numbers   |   8051 Subtraction of Unsigned Numbers   |   8051 Multiplication Unsigned 8-bit   |   8051 Division Unsigned 8-bit   |   8051 SUBB Instruction

List of topics: 8051

No comments:

Post a Comment