437
Condition Flags Section 9-20
Using the Condition Flags The Condition Flags are shared by all of the instructions, so their status may
change often in a single cycle. Be sure to read the Condition Flags immedi-
ately after the execution of instruction, preferably in a branch from the same
execution condition.
Since the Condition Flags are shared by all of the instructions, program oper-
ation can be changed from its expected course by interruption of a single task.
Be sure to consider the effects of interrupts when writing the program. Refer
to SECTION 2 Programming of CS/CJ Series Programming Manual (W394)
for more details.
The Condition Flags are cleared when the program switches tasks, so the sta-
tus of a Condition Flag cannot be passed to another task. For example the
status of a flag in task 1 cannot be read in task 2.
Saving and Loading Condition Flag Status
The Condition Flag status instructions (CCS(282) and CCL(283)) can be used
to save and load the status of the Condition Flags between different locations
within a task (program) or between different tasks or cycles.
The following example shows how the Equals Flag is used at a different loca-
tion in the same task.
Note This instruction does not exist in CJ1 CPU Units.
Less Than or
Equals Flag
P_LE < = Turned ON when the first operand of a Comparison Instruction is less
than or equal to the second.
Always ON Flag P_On ON Always ON. (Always 1.)
Always OFF Flag P_Off OFF Always OFF. (Always 0.)
Name Symbol Label Function
=
Instruction A
The result from instruction A is
reflected in the Equals Flag.
Instruction B
Instruction
LD
Instruction A
AND
Instruction B
Operand
Condition Flag
Example: P_EQ
CMP
CCS
CCL
P_EQ
Stores result of comparison in the Condition Flags.
This will enable loading the results to use with
Instruction B.
Saves status of Condition Flags.
Loads the statuses of the Conditions Flags that
were stored.
The result of the comparison instruction in the
Equals Flag can be used by Instruction B without
interference from Instruction A.
Instruction A
Instruction B
Task