Explain the machine instruction cycle.


Teaching Note:

This should include the role of data bus and address bus.


Sample Questions - FORMER CURRICULUM:

4. Describe how the computer carries out a machine instruction. [4 marks]

Address Bus & Data Bus

Before getting into the machine instruction cycle, a bit on the teaching note point - reacalling that we already looked briefly at the data bus and the address bus in 2.1.1.

So recall that the address bus is the path through which the CPU goes to specific addresses in memory to fetch stuff from RAM, or specify where in RAM to store stuff (it is therefore-unidirectional).

Once at that RAM address, the data that is found there is returned to the CPU via the data bus, or likewise data to be saved to RAM travels through the data bus (it is therefore bi-directional). (Note that the data bus is sometimes referred to as the memory bus.)

A good, concise link about the address bus and the data bus. (Note that the two of these together are sometimes referred to as the memory bus system.)


Machine Instruction Cycle

At a basic level, the machine instruction cycle is typically stated as:


Bit it can help to include an optional step for when what is fetched is an address - which is often the case. So there are really two possibilities as the cycle cycles:

A. When what is fetched is actually an address:

- fetch (from the RAM, found via the address bus, brought back via the data bus)

- decode (and realize that what was fetched was an address)

- fetch the data at the address which was just fetched

- decode (this will now be data/instructions, rather than an address)

- execute

- store result

(perform next fetch)

B. When what is fetched is data or instructions

- fetch (from the RAM, found via the address bus, brought back via the data bus)

- decode

- execute

- store result

(perform next fetch)


Now a bit more about each part of the cycle, without going into too many details, but not as detailed as the following video.

fetch - going to get data or instruction from the RAM and bringing them back to the CPU, remembering, particularly since busses are mentioned in the teaching note: from the RAM via the address bus, brought back via the data bus

decode - figure out what the instruction is, and how the particular CPU can execute such an instruction (such as ADD)

execute - that's where the Control Unit shuffles things into Arithmetic Logic Unit, the calculation is done, and the result is shuffled out of it

store result - this may or may not be storing a final result to secondary storage, rather usually it's just storing the partial result which has just been accomplished, such as adding a number to an ongoing calculation


The above is all you really should need to know for this assessment statement. But to help you put it all together, feel free to look through the following video, which goes to a level that is for sure beyond what you need for IB CS.


And for the fine details, here you go, if you so choose...

(*** Note that there is a strange video editing glitch where the screen goes black for a bunch of seconds, but nothing is missed, so when it happens, at around the 6 minute mark, fast forward to around the 7:22 mark.)

** And also note that the following diagrams and video are "to be taken with a grain of salt", meaning that they give general indicaitons of how things work, without always being true to the actual functioning at a logic gate level.

A good companion to some of this would be the PBS Crash Course CS videos, in around # 5 in the series.

(JSR: Could, at this point, download a simple computer from Minecraft Redstone and mirror using it with the diagram explanation video above)



These diagrams break the fetch and execute cycle into the specifics of just what is going on.

It may be useful to keep the full CPU diagram from 2.1.1 open in a tab for reference when looking through this for the big picture. Though note that there are extra registers here, not in that diagram. But a reminder, here are a quick summary diagram: