next up previous contents
Next: brcc and brcs Up: Register Arithmetics and Conditional Previous: Adding an 8-bit Constant   Contents

Conditional Branches

A program that does not make decisions is not very useful. In other words, if all instructions of a program must execute from start to end, consecutively and only in one directioy, many complicated algorithms (methods) cannot be implemented.

The most basic decision making mechanism is called a condition branch. In this case, ``branching'' means continuing execution at an instruction location possibly other than the immediately following instruction. The location to branch to is usually the only operand a condition branch instruction requires. In order to make decisions, status flags are detected by conditional branch instructions. A condition branch instruction checks a status flag, then branches or continue execution depending on the value of the designated status flag.

This means a processor can only make very simple decisions based on whether a result is zero or not, negative or not, or whether the result carries. As we will see later, such simple decision making mechanisms can combine to very complicated decision making.

For now, we will only discuss three pairs of condition branches.



Subsections
next up previous contents
Next: brcc and brcs Up: Register Arithmetics and Conditional Previous: Adding an 8-bit Constant   Contents
Tak Auyeung 2003-11-10