131 Week 14 - Branching Flashcards
Pipelining
A way to exploit inherent parallelism inside the control unit to speed up the fetch-decode-execute cycle.
Program counter (PC)
A register which contains the address of the next instruction to be executed
Branch instructions
An instruction that manually changes PC to a different instruction than the next sequential instruction in memory.
Syntax:
branchOperator target
E.g.,
b target_label
Types of brancing
Conditional branch: perform a jump when a condition is true
Unconditional branching: always executes the target instruction
Label
Labels are symbols that represent addresses.
The address given by a label is calculated during assembly.
They can point to instructions or data.
Program-relative addressing
A reference to a label within the same section using PC +/- an offset.
Compare instruction
Compare instructions performs a comparison (substraction), updates the CPSR and discards the result.
Operator: cmp (CoMPare)
Syntax:
cmp destinationRegister, sourceRegister
E.g.,
cmp r1,r2
Conditional branching
Branch operations can also use the condition code in order to branch under certain conditions.
Conditional branching instructions depend on the CPSR’s condition bits (which are changed before the branch instruction via an arithmetic operation or compare instruction). If the relevant CPSR bit is true, branching will occur.
Conditional codes
There are conditional codes which can be added to the end of a branch instruction to create a conditional branch.
Syntax: b+code
E.g., beq means branch if equals
Conditional codes can be found here:
https://developer.arm.com/documentation/dui0379/e/arm-and-thumb-instructions/condition-codes
Conditional instructions
Any conditional code can be added to an instruction to make it conditional.
E.g., ADDEQ means add if equal.
MOVLT means move if less than.
If-then instructions
Thumb-2 introduced the If-Then (IT) instruction which allows for conditional execution for up to four consecutive instructions.
Instructions within an IT block must also specify the condition code to be applied.