CS 233 Study Guide - Midterm Guide: Program Counter
Document Summary
Mips control ow instructions: jumps, branches, and loops. So far, only considered sequences of arithmetic instructions. Program counter is incremented by 4 each cycle. We need ways to control which instruction is executed next. Unconditional control ow transfer always taken, much like a goto statement in c j target_label. Uses a label to tell where in the code to jump to: This code is an in nite loop since the j instruction tells it to jump back to the label. To encode jumps we use the j-type instruction format: But, not quite long enough to specify a whole 32-bit pc. Last two bits are always 00, because pc value is always word aligned. 4 most signi cant bits come from existing pc value. Top 4 bits coming from current pc means: Can only jump within current region with a j instruction. A 26-bit address eld lets you jump to any address from 0 to 2^28.