12.5.3.1 Flow-Control within the current Command List |
The following Flow-Control Commands are available for altering the sequence of execution within the current command list.
Note |
---|
Most intra-list Flow-Control Commands take an integer parameter which specifies the position of the target command, i.e. index of the target command within the current CommandList. It is generally the application's business to ensure that correct index values are specified. However, keeping track of forward references from Branch commands to the locations of as yet undefined target commands can become tedious, and require "ingenious" programming. Consequently, certain Flow-Control Commands are implemented with variants that accept labels for their target definitions. Please refer to 12.5.3.3 Flow-Control using Labels within the current Command List for more details.
|
An unconditional branch is used to force a deviation from the normal sequence of execution within the current list.
goto someLineNumber;
ListAPI Method | SP-ICE-3 Command |
---|---|
A conditional branch may be used to allow a choice, dependent upon the condition or value read from an I/O Port, or on the state of a boolean flag variable, between two alternative continuations of the sequence of execution within the current list.
if (IOPort.Read() == CONDITION) goto someLineNumber; // or if (flagVariable == true) goto someLineNumber;
ListAPI Method | SP-ICE-3 Command |
---|---|
AppendBranchAbs(Int32, UInt32, IOPort, Boolean, Boolean, UInt32)[COND] | |
AppendBranchRel(Int32, UInt32, IOPort, Boolean, Boolean, UInt32)[COND] | |
A switch command may be used to allow 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 possible continuations of the sequence of execution within the current list.
switch (IOPort.Read()) { // SWITCH case condA: goto lineNumA; // CASE_GOTO case condB: goto lineNumB; // CASE_GOTO // etc default: goto lineNumC; // DEFAULT_GOTO } lineNumA: // more commands here lineNumB: // further commands here lineNumC: // even more commands here
ListAPI Method | SP-ICE-3 Command |
---|---|
AppendSwitch(String)[VAR] | |
An unconditional or unconditional exit command can be used to force execution of the current list to finish before the reaching the end of the list.
void mainList() { // do some main stuff // check an early termination condition if (IOPort.Read() == CONDITION) return; // EXIT_LIST // do more stuff // check another early termination condition if (flagVariable == true) return; // EXIT_LIST_FLAG // do even more stuff // normal end of list here }
ListAPI Method | SP-ICE-3 Command |
---|---|
AppendExitList[PORT] | |
AppendExitList[VAR] |