Back

Branch

Idealogic’s Glossary

Branch (in a computer program) — a statement leads a computer to perform another sequence of statements, that are not consecutive, which interrupts a sequence of statements, instructions. Branches are useful in design of flow of control of a program so that at some instances some segments of the program can run independently based on certain conditions provided in the program. This capability is useful in helping in the provision of repetitive code blocks, branching and logical operations whereby a program is able to determine the subsequent step that it is supposed to undertake depending on the input given or the state of the system.

In the context of ISAs a branch can be defined as an operation that makes it possible for changing the path of an instruction stream in the course of the branch instruction execution. This is what makes it possible to introduce the flexibility and the complexity of the software behavior since this describes the sequence of steps that must be taken at some instance. Branch instructions are typically classified into two main categories: It is divided into three forms of the branches namely the unconditional and the conditional branches. An unconditional branch is a branch which always alters the flow of control of the program, that is, it transfers the control to a different set of instructions. But a conditional branch changes the direction of control flow only when some condition is met for example when a variable is equal to some value.

Indeed, in areas such as cryptography, a lot of effort is spent on eliminating or at least minimizing branching, sometimes by using branchless code. Some techniques, for example, bitwise operations or conditional moves can replace branches in order to prevent timing attacks, in which the attacker might be able to prise out information on the cryptographic process from the fact that certain parts of the code are executed at certain times. Therefore, the software may use the branch-less code in order to enhance the security and to decrease the possibility of occurrence of such vulnerabilities and therefore reflect better security in important operations.