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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.