Practice question · Put in order
A jump instruction sits at address 40 and jumps to address 80. Instructions are 4 bytes long. Order what happens.
- The PC holds 40, so the CPU fetches the instruction stored at address 40
- The control unit decodes the instruction and finds it is a jump to 80
- The execute step writes 80 into the PC, replacing the 44
- The PC advances to 44
- The next fetch reads the instruction at address 80
Hints
- The PC advances during the fetch, long before anyone knows the instruction is a jump.
- The jump's new address can only be written once the instruction has been decoded and run.
Show the answer
- The PC holds 40, so the CPU fetches the instruction stored at address 40
- The PC advances to 44
- The control unit decodes the instruction and finds it is a jump to 80
- The execute step writes 80 into the PC, replacing the 44
- The next fetch reads the instruction at address 80
Why
The PC is advanced to 44 automatically during the fetch, because the hardware does not yet know what it has fetched. Only when the instruction executes is 44 overwritten with 80. This is the whole mechanism of a jump: no magic, just a later write to the same register.
Practise The Instruction Execution Cycle
The app has 8 more questions on this lesson, and keeps your place in the course. Computer Science I is free to start.
More questions on The Instruction Execution Cycle
- A program executes ADD R1, R2 followed by JMP 200. Order what the CPU does, from the start of the first…
- The program counter is incremented during the FETCH phase, before the instruction has even been decoded. Why…
- A buffer overflow that overwrites a return address can make a program execute the attacker's code. Which…