Omron CJ2 CPU UNIT SOFTWARE User Manual page 250

Cj2 cpu unit software
Hide thumbs Also See for CJ2 CPU UNIT SOFTWARE:
Table of Contents

Advertisement

6 I/O Memory Areas
Using the Condition Flags
The Condition Flags are shared by all of the instructions, so their status may change often in a sin-
gle cycle. Be sure to read the Condition Flags immediately after the execution of instruction, prefera-
bly in a branch from the same execution condition.
Condition Flag
Example: P_EQ
Precautions for Correct Use
Precautions for Correct Use
• Because the Condition Flags are shared by all of the instructions, program operation 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.
• The Condition Flags are cleared when the program switches tasks, so the status of a Condi-
tion 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 location in the same task.
Task
P_EQ
6-44
Instruction A
The result from instruction A is
reflected in the Equals Flag.
Instruction B
Stores result of comparison in the Condition Flags.
CMP
This will enable loading the results to use with
Instruction B.
CCS
Saves status of Condition Flags.
Instruction A
Loads the statuses of the Conditions Flags that
CCL
were stored.
The result of the comparison instruction in the
Instruction B
P_EQ Flag can be used by Instruction B without
interference from Instruction A.
Instruction
Operand
LD
Instruction A
P_EQ
AND
Instruction B
CJ2 CPU Unit Software User's Manual

Advertisement

Table of Contents
loading

Table of Contents