13.07.2015 Views

CJ2 CPU Unit Software User's Manual - CIP ETI

CJ2 CPU Unit Software User's Manual - CIP ETI

CJ2 CPU Unit Software User's Manual - CIP ETI

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

6 I/O Memory Areas Using the Condition FlagsThe Condition Flags are shared by all of the instructions, so their status may change often in a singlecycle. Be sure to read the Condition Flags immediately after the execution of instruction, preferablyin a branch from the same execution condition.Condition FlagExample: P_EQInstruction AThe result from instruction A isreflected in the Equals Flag.Instruction BInstructionLDInstruction AANDInstruction BOperandP_EQPrecautions for Correct Use• Because the Condition Flags are shared by all of the instructions, program operation can bechanged from its expected course by interruption of a single task. Be sure to consider theeffects of interrupts when writing the program.• The Condition Flags are cleared when the program switches tasks, so the status of a ConditionFlag cannot be passed to another task. For example the status of a flag in task 1 cannotbe read in task 2. Saving and Loading Condition Flag StatusThe Condition Flag status instructions (CCS(282) and CCL(283)) can be used to save and load thestatus of the Condition Flags between different locations within a task (program) or between differenttasks or cycles.66-20 Condition FlagsThe following example shows how the Equals Flag is used at a different location in the same task.TaskCMPCCSStores result of comparison in the Condition Flags.This will enable loading the results to use withInstruction B.Saves status of Condition Flags.6-2-2 Output BitsInstruction AP_EQCCLInstruction BLoads the statuses of the Conditions Flags thatwere stored.The result of the comparison instruction in theP_EQ Flag can be used by Instruction B withoutinterference from Instruction A.<strong>CJ2</strong> <strong>CPU</strong> <strong>Unit</strong> <strong>Software</strong> User’s <strong>Manual</strong>6-43

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!