![](http://datasheet.mmic.net.cn/380000/-PD784928Y_datasheet_16744934/-PD784928Y_308.png)
308
CHAPTER 7 DESCRIPTION OF INSTRUCTIONS
Subtract
Byte Data Subtraction
[Instruction format]
SUB dst, src
[Operation]
dst, CY
←
dst – src
[Operands]
Mnemonic
Operands (dst, src)
Mnemonic
Operands (dst, src)
SUB
A, #byte
SUB
A, [saddrp]
r, #byte
A, [%saddrg]
saddr, #byte
[saddrp], A
sfr, #byte
[%saddrg], A
r, r’
A, !addr16
A, saddr2
A, !!addr24
r, saddr
!addr16, A
saddr, r
!!addr24, A
r, sfr
A, mem
sfr, r
mem, A
saddr, saddr’
[Flags]
S
Z
AC
P/V
CY
×
×
×
V
×
[Description]
The source operand (src) specified by the 2nd operand is subtracted from the destination operand (dst) specified
by the 1st operand, and the result is stored in the destination operand (dst) and the CY flag.
The destination operand (dst) can be cleared to 0 by making the source operand (src) and destination operand
(dst) the same.
The S flag is set (1) if bit 7 of dst is set (1) as a result of the subtraction, and cleared (0) otherwise.
The Z flag is set (1) if dst is 0 as a result of the subtraction, and cleared (0) otherwise.
The AC flag is set (1) if a borrow is generated out of bit 4 into bit 3 as a result of the subtraction, and cleared
(0) otherwise.
The P/V flag is set (1) if a borrow is generated out of bit 6 into bit 7 and a borrow is not generated in bit 7 as
a result of the subtraction (when underflow is generated by a two’s complement type operation), or if a borrow
is not generated out of bit 6 into bit 7 and a borrow is generated in bit 7 (when overflow is generated by a two’s
complement type operation), and is cleared (0) otherwise.
The CY flag is set (1) if a borrow is generated in bit 7 as a result of the subtraction, and cleared (0) otherwise.
[Coding example]
SUB D, L ; Subtracts the L register from the D register and stores the result in the D register
SUB