
2.2.59 (1) SUB (B)
SUB (SUBtract binary)
Subtract Binary
Operation
Rd – Rs
→
Rd
Assembly-Language Format
SUB.B
Rs, Rd
Operand Size
Byte
Condition Code
H: Set to 1 if there is a borrow at bit 3;
otherwise cleared to 0.
N: Set to 1 if the result is negative; otherwise
cleared to 0.
Z:
Set to 1 if the result is zero; otherwise
cleared to 0.
V: Set to 1 if an overflow occurs; otherwise
cleared to 0.
C: Set to 1 if there is a borrow at bit 7;
otherwise cleared to 0.
I
UI
H
U
N
Z
V
C
—
—
↕
—
↕
↕
↕
↕
Description
This instruction subtracts the contents of an 8-bit register Rs (source operand) from the contents
of an 8-bit register Rd (destination operand) and stores the result in the 8-bit register Rd.
Available Registers
Rd: R0L to R7L, R0H to R7H
Rs: R0L to R7L, R0H to R7H
Operand Format and Number of States Required for Execution
Notes
The SUB.B instruction can operate only on general registers. Immediate data can be subtracted
from general register contents by using the SUBX instruction. Before executing SUBX #xx:8, Rd,
first set the Z flag to 1 and clear the C flag to 0. The following coding examples can also be used
to subtract nonzero immediate data #IMM.
(1)
ORC #H'05, CCR
SUBX #(IMMÐ1), Rd
(2)
ADD #(0ÐIMM), Rd
XORC #H'01, CCR
Instruction Format
1st byte
2nd byte
3rd byte
4th byte
Register direct
SUB.B
Rs, Rd
1
8
rs
rd
2
No. of
States
Addressing
Mode
Mnemonic
Operands
177