Status Register (ST0)
2-24
Table 2−6. Instructions Affected by V flag (Continued)
Instruction Description
XMACD P,loc16,*(pma)
V = 1 on signed overflow
XRETC COND V = 0 if tested
N
Bit 5
Negative flag. During certain operations, N is set if the result of the operation is a negative
number or cleared if the result is a positive number. At reset, N is cleared.
Results in ACC are tested for the negative condition. Bit 31 of ACC is the sign bit. If bit 31
is a 0, ACC is positive; if bit 31 is a 1, ACC is negative. N is set if a result in ACC is negative
or cleared if a result is positive.
Results in AH, AL, and other 16-bit registers or data-memory locations are also tested for
the negative condition. In these cases bit 15 of the value is the sign bit (1 indicates negative,
0 indicates positive). N is set if the value is negative or cleared if the value is positive.
The TEST ACC instruction sets N if the value in ACC is negative. Otherwise the instruction
clears N.
As shown in Table 2−7, under overflow conditions, the way the N flag is set for compare
operations is different from the way it is set for addition or subtraction operations. For addi-
tion or subtraction operations, the N flag is set to match the most significant bit of the trun-
cated result. For compare operations, the N flag assumes infinite precision. This applies
to operations whose result is loaded to ACC, AH, AL, another register, or a data-memory
location.
Table 2−7. Negative Flag Under Overflow Conditions
A
†
B
†
(A − B)
Subtraction
Compare
‡
Pos Neg
Neg
(due to overflow in positive direction)
N = 1 N = 0
Neg Pos
Pos
(due to overflow in negative direction)
N = 0 N = 1
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
Á
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
Á
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
†
For 32-bit data: Pos = Positive number from 00000000
16
to 7FFFFFFF
16
Neg = Negative number from 80000000
16
to FFFFFFFF
16
For 16-bit data: Pos = Positive number from 0000
16
to 7FFF
16
Neg = Negative number from 8000
16
to FFFF
16
‡
The compare instructions are CMP, CMPB, CMPL, MIN, MAX, MINL, and MAXL.
N can be summarized as follows:
0
The tested number is positive, or N has been cleared.
1 The tested number is negative, or N has been set.