5-107
5 Understanding Programming
CJ2 CPU Unit Software User’s Manual
5-10 Precautions
5
5-10-1 Condition Flags
The Equals Flag will turn ON if D100 in the rung above contains #0010. #0200 will be moved to
D200 for instruction (1), but then the Equals Flag will be turned OFF because the #0200 source data
is not 0000 Hex. The MOV instruction at (2) will then be executed and #0300 will be moved to D300.
A rung will therefore have to be inserted as shown below to prevent execution results for the first
MOV instruction from being picked up.
z Using Execution Results from Differentiated Instructions
With differentiated instructions, execution results for instructions are reflected in Condition Flags
only when execution condition is met, and results for a previous rung (rather than execution results
for the differentiated instruction) will be reflected in Condition Flags in the next cycle. You must there-
fore be aware of what Condition Flags will do in the next cycle if execution results for differentiated
instructions to be used.
In the following for example, instructions A and B will execute only if execution condition C is met, but
the following problem will occur when instruction B picks up execution results from instruction A. If
execution condition C remains ON in the next cycle after instruction A was executed, then instruction
B will unexpectedly execute (by the execution condition) when the Condition Flag goes from OFF to
ON because of results reflected from a previous rung.
CMP
D100
MOV
D200
MOV
D300
P_EQ
A
A
A
#0010
Reflects CMP execution results.
#0200
#0300
C
Condition Flag
P_EQ (Equals Flag)
@Instruction B
@Instruction A
Reflects execution results for instruction A
when execution condition is met.
Reflects execution results for a previous
rung in the next cycle.
Previous rung