Add with Carry – ADDC A, src-byte
ADDC simultaneously adds the byte variable indicated, the carry flag and the Accumulator contents, leaving the result in the Accumulator. The carry and auxiliary-carry flags are set respectively, if there is a carry-out from bit 7 or bit 3, and cleared otherwise. When adding unsigned integers, the carry flag indicates an overflow occurred. OV is set if there is a carry-out of bit 6 but not out of bit 7, or a carry-out of bit 7 but not out of bit 6; otherwise OV is cleared. When adding signed integers, OV indicates a negative number produced as the sum of two positive operands or a positive sum from two negative operands. Four source operand addressing modes are allowed: register, direct, register-indirect, or immediate.
ADDC A,Rn
Encoding:00111nnn
ADDC A, direct address
Encoding:00110101 direct address
ADDC A,@Ri
Encoding:0011011i
ADDC A,#immediate data
Encoding:00110100 immediate data
Example:
The Accumulator holds 0C3H (11000011B) and register 0 holds 0AAH (10101010B) with the carry flag set. The following instruction,
ADDC A,R0
leaves 6EH (01101110B) in the Accumulator with AC cleared and both the Carry flag and OV set to 1.
Example:
ORG 0H
MAIN :
MOV A, #0H
MOV A, #9CH
ADD A, #64H ; A= 9C+ 64, C= 1
MOV A, #0C3H
MOV R0, #0AAH
ADD A, R0 ; A = C3 + AA + 1= 6EH
END ; end of asm source file
Related topics:
8051 Addition | 8051 Addition of Unsigned Numbers | 8051 Addition of 16-bit Numbers | 8051 Binary Coded Decimal | 8051 ADDC Instruction | 8051 ADD Instruction
List of topics: 8051
No comments:
Post a Comment