The .for token behaves like the for keyword in C, except that multiple increment commands must be separated by semicolons, not by commas.

.for (InitialCommand ; Condition ; IncrementCommands) { Commands } 

Syntax Elements

Specifies a command that will be executed before the loop begins. Only a single initial command is permitted.

Specifies a condition. If this evaluates to zero, it is treated as false; otherwise it is true. Enclosing Condition in parentheses is optional. Condition must be an expression, not a debugger command. It will be evaluated by the default expression evaluator (MASM or C++). For details, see Numerical Expression Syntax.

Specifies one or more commands that will be executed at the conclusion of each loop. If you wish to use multiple increment commands, separate them by semicolons but do not enclose them in braces.

Specifies one or more commands that will be executed repeatedly as long as the condition is true. This block of commands needs to be enclosed in braces, even if it consists of a single command. Multiple commands should be separated by semicolons, but the final command before the closing brace does not need to be followed by a semicolon.

Additional Information

For information about other control flow tokens and their use in debugger command programs, see Using Debugger Command Programs.


If all the work is being done by the increment commands, you can omit Condition entirely and simply use an empty pair of braces.

Here is an example of a .for statement with multiple increment commands:

0:000> .for (r eax=0; @eax < 7; r eax=@eax+1; r ebx=@ebx+1) { .... }

The .break and .continue tokens can be used to exit or restart the Commands block.