12.5.3.4 Flow-Control between Command Lists |
The following Flow-Control Commands are available for altering the sequence of execution between entire command lists.
These may be used to effect a conditional or unconditional transfer of execution away from the current list.
If the branch is taken, execution continues at the beginning of the target list, and finishes normally at the end it.
void otherList () { // do other stuff quit(); } void mainList() { // do local stuff if (IOPort.Read() == CONDITION) otherList(); // BRANCH_LIST_COND // do more local stuff, but only if branch was not taken. if (flagVariable == true) otherList(); // BRANCH_LIST_COND_FLAG // do even more local stuff, but only if branch was not taken. otherList(); // BRANCH_LIST // we never get here. }
ListAPI Method | SP-ICE-3 Command |
---|---|
AppendBranchList(Int32, UInt32, IOPort, Boolean, Boolean, UInt32)[COND] | |
These may be used to effect conditional or unconditional sub-routine calls from the current list.
The conditional call can be dependent upon the condition or value read from an I/O Port, or upon the state of a boolean flag variable.
When execution reaches the end of a sub-routine list, it automatically returns to the calling list at the command following the call command.
void subList1 () { // do 1 stuff return; } void subList2 () { // do 2 stuff return; } void subList3 () { // do 3 stuff return; } void mainList() { // do local stuff // unconditional call: subList1(); // CALL_LIST // do more local stuff // conditional call: if (IOPort.Read() == CONDITION) subList2(); // CALL_LIST_COND // do much more local stuff // conditional call: if (flagVariable == true) subList3(); // CALL_LIST_COND_FLAG // do even more local stuff }
ListAPI Method | SP-ICE-3 Command |
---|---|
AppendCallList(Int32, UInt32, IOPort, Boolean, Boolean, UInt32)[COND] | |
These may be used to effect the selection, dependent upon the condition or value read from an I/O Port, or upon the value of an integer variable, of any one of several alternate lists, to which execution is transferred.
void otherListA () { // do A stuff stop; } void otherListB () { // do B stuff stop; } void otherListC () { // do C stuff stop; } void mainList() { // do stuff switch (IOPort.Read()) { // SWITCH case CONDA: otherListA(); // CASE_BRANCH_LIST case CONDB: otherListB(); // CASE_BRANCH_LIST default: otherListC(); // DEFAULT_BRANCH_LIST } // we never get here }
ListAPI Method | SP-ICE-3 Command |
---|---|
AppendSwitch(String)[VAR] | |
These may be used to effect the selection, dependent upon some condition, of any one of several alternative sub-routines, which is then called from current list.
When execution reaches the end of a sub-routine list, it automatically returns to the calling list at the command following the end of the switch block.
void subListA () { // do A stuff return; } void subListB () { // do B stuff return; } void subListC () { // do C stuff return; } void mainList() { // do stuff switch (IOPort.Read()) // SWITCH { case CONDA: subListA(); // CASE_CALL_LIST break; case CONDB: subListB(); // CASE_CALL_LIST break; default: subListC(); // DEFAULT_CALL_LIST break; } // do more stuff }
ListAPI Method | SP-ICE-3 Command |
---|---|
AppendSwitch(IOPort, Boolean)[PORT] | |
AppendSwitch(IntegerVariable)[VAR] | |
An unconditional or unconditional exit command can be used to force execution to return from a sub-routine to the calling list.
void subList1 () { // do some 1 stuff // check an early termination condition if (IOPort.Read() == CONDITION) return; // EXIT_LIST_COND // do more 1 stuff // check another early termination condition if (flagVariable == true) return; // EXIT_LIST_COND_FLAG // do even more 1 stuff return; } void mainList() { // do some main stuff // unconditional call: subList1(); // CALL_LIST // do more main stuff }
ListAPI Method | SP-ICE-3 Command |
---|---|
AppendExitList(UInt32, IOPort, Boolean, Boolean, UInt32)[PORT] | |