SourcePoint Intel Help

Table of Contents

while

Group and execute commands while a condition is true.

Syntax

while(bool-cond) {commands}

Where:

bool-cond

specifies a number or an expression that is evaluated and tested. The loop repeats until expr evaluates to false (zero). ย The parentheses are required.

commands

specifies any emulator commands. When you enter more than one command, you must enclose them in braces ({ }).

Discussion

Use the while control construct to execute the specified commands 0 (zero) or more times, as long as bool-cond evaluates to true (non-zero). ย To break out of a loop press ctrl+break.

Note: The include command is not executable inside a while control.

Example 1

The following example demonstrates a while control construct. While the index is greater than zero, decrement the index and add 5 to the sum on every iteration of the loop.

Command input:

define ord1 i = 5
define ord1 sum = 0
while (i > 0)

{

ย ย ย i -= 1

ย ย ย sum += 5

ย ย ย printf("i = %d sum = %d\n", i, sum)

}

Result:

i = 4 sum = 5
i = 3 sum = 10
i = 2 sum = 15
i = 1 sum = 20
i = 0 sum = 25

Related Topics: