SourcePoint AMD Help

Table of Contents

if

Group and conditionally execute emulator commands.

Syntax

if (bool-cond) {commands1} [ else {commands2}]

Where:

bool-cond

specifies a number or an expression which must evaluate as either true (non-zero) or false (zero).

commands1

specifies one or more emulator commands (commands1) that are executed when bool-cond evaluates to true. ย The braces ({}) are required when you enter multiple commands.

commands2

specifies one or more emulator commands that are executed if bool-cond evaluates to false. The braces ({}) are required when you enter multiple commands.

Discussion

Use the if control construct to conditionally execute commands. The if control construct tests the bool-cond condition and, if true (non-zero), executes the commands in the commands1 specification. When using the else option, any commands in the commands2 specification are executed when the specified condition evaluates to false (zero).

If constructs can be nested. When nested, the optional else clause associates with the closest if clause. The if control construct resembles the C language if control construct.

The else option must be on the same command line as the end of the {commands1} block. If desired, you can use the continuation character (\) followed by the Enter key at the end of the last line of the {commands1} block to move the else option to the next line.

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

Example 1

The following example shows how to use the if control construct to test a condition. If the test condition (a > b) evaluates to true, then z takes the value of a. If the test condition evaluates to false, z takes the value of b. Assume that aa, bb, and zz have been previously defined as int1 values.

Command input:

define int1 aa = 1
define int1 bb = 2
define int1 zz
if (aa > bb)

{
zz = aa

} else {
zz = bb

}
zz

Result:

02H

Example 2

The following example shows how to use the if control construct with the else clause.

Command input:

if (bState)
{
printf("bState is true\n")
} else {
printf("bState is false\n")
}

ย 

ย