Branching

The branch instruction is available in various permutations, but in all circumstances it is essentially a goto. The target of a branch instruction is a label. Most branch instructions are conditional and based on a Boolean condition. For an unconditional goto, use the br instruction. Loop and other transfer-of-control statements in C# are implemented with some combination of branch instructions.

A conditional branch can be made with the brtrue and brfalse statements. The brtrue instruction branches on a true condition, whereas the brfalse branches on a false condition. These instructions consume a Boolean value, which must be placed on the evaluation stack prior to the statements.

Comparison instructions perform a comparison of the top ...

Get Programming Microsoft® Visual C#® 2008: The Language now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.