Hardware manual
Microcomputer Technical Q&A
9
Q&A No.: QAH8S-008
Category: Instruction
Subject: SUBX Instruction
Question
Why is the Z flag value unchanged when the result of a SUBX (subtraction with carry) instruction
operation is 0?
Answer
This is because the SUBX instruction operation result is ANDed with the Z flag value before
execution of the instruction. The logical equation is shown below.
Z = Z' · Rm · Rm-1 ... · R0
When the execution result is 0, Rm · Rm-1 ... · R0 (abbreviated to Rn below) is 1. As the Z flag
value for this instruction is the AND of Rn and Z', when the execution result is 0, the Z flag value
is held.
Notes: m = 31 (longword size), 15 (word-size), or 8 (byte-size)
Ri = Bit I of result
Z' = Z flag value before instruction execution
Applicable Products
Applicability Series Applicability Series Applicability Series
Yes Entire H8S Series H8S/2655 H8S/2350
H8S/2355 H8S/2357 H8S/2345
H8S/2245 H8S/2148 H8S/2144
H8S/2138 H8S/2134 H8S/2128
H8S/2124 — — — —