SourcePoint Intel Help

Table of Contents

switch

Cause execution to branch to one of several case statements.

Syntax

switch (expr)

{

ย ย ย case label-expr: [ commands ]

ย ย ย [ ... ]

ย ย ย [ default: commands ]

}

Where:

expr

Specifies a number or an expression. The value of expr is compared to the value of the label in each case statement.

case label-expr:

Specifies a number or an expression whose value is compared to expr. The colon (:) is required punctuation.

commands

Any emulator commands, including break (which causes an immediate exit from the switch control construct). You cannot use the include command.

default

Specifies the statement that is executed if none of the case statements label-expr: values match that of expr. The colon (:) is required punctuation.

Discussion

Use the switch control construct to transfer execution control to any commands following the case label-expr: statement whose value matches the value of the switch expression. If no case label-expr: matches, no commands are executed unless there is a default statement. You can specify only one default statement. Once command execution begins at a case label-expr:, it continues through all remaining case commands unless the break command is encountered.

The include command is not executable inside the switch control construct.

Example

Command input:

define ord4 value = 3

switch(value)

{

case 0:

ย ย ย ย ย printf("saw 0\n")

ย ย ย ย ย break

case 3:

ย ย ย ย ย printf("saw 3\n")

ย ย ย ย ย break

default

ย ย ย ย ย printf("illegal value\n")

ย ย ย ย ย break

}

Result:

saw 3

Related Topics: