| Branches and Jumps | ||||||||||||
| In assembly language, change the order of execution with a branch or jump | ||||||||||||
| branch: conditional (not always) | ||||||||||||
| jump: unconditional (always) | ||||||||||||
| What does it mean to branch? | ||||||||||||
| Normally, PC <--- PC + 4 changes PC to point to next sequential instruction | ||||||||||||
| Why add 4? | ||||||||||||
| Because each instruction is 32 bits (4 bytes) | ||||||||||||
| Jump: PC <--- target_location | ||||||||||||
| Conditional branch ("branch"): | ||||||||||||
| if (condition) | ||||||||||||
| PC <--- target_location | ||||||||||||
| else | ||||||||||||
| PC <--- PC + 4 | ||||||||||||
| Unconditional branch ("jump"): | ||||||||||||
| goto target_location | ||||||||||||