Instruction Sets

Instruction Sets
The processor (CPU) recognises a particular set of instructions that it follows when it
runs a program. The instruction set is really just a set of numbers – (binary
The CPU contains special circuitry that converts the number into a particular action.
For example the number 1 may load data into the CPU; the number 2 may load data
from a particular address in memory into the CPU; the number 3 may save the data in
the CPU to an address in memory and so on.
Each instruction may be followed by one or more other numbers, for example –
instruction 1 loads data – the data is the number following the instruction; instruction
2 is followed by an address in memory (this is another number).
A program can be very confusing – if you start in the wrong place you might be trying
to interpret a piece of data – the CPU needs to keep track of where the program is and
interpret the instructions in the proper order. To do this the CPU must have its own
memory. The CPU uses special registers to hold information.
Special Registers
1. The Accumulator (AC) this holds data. Whenever data is brought into the
CPU it goes into the Accumulator. Some instructions will add or subtract
incoming data to the existing contents of the Accumulator.
2. The Program Counter (PC) contains the address of the next instruction –
each time an instruction is carried out the Program Counter is incremented
(increased –sometimes by 1 sometimes by 2 etc)
3. Instruction Register (IR) this holds the last or current instruction to be
decoded and executed.
4. Memory Data Register (MDR) and the Memory Address Register (MAR)
are the links between the CPU and the main memory. Any request to load or
save data must be done through these two registers. The Memory Data
Register contains the data that is to be transferred and the Memory Address
Register is the address in memory where the transferred will be carried out.
5. Status Register contains special bits that are set/reset when a particular event
occurs. A test for an event can be carried out by inspecting this register.
6. Stack Pointer – a register that points to a special area of memory where
system information is stored before a programs jumps. This is an important
register since the computer often gets interrupted and has to give its attention
to another device before continuing with your program.
Fetch-Execute Cycle
to execute?
Fetch next instruction
Decode instruction
Execute instruction
Any interrupts?
Transfer control to the interrupt
handling program
What Happens During the Fetch Phase?
1. The Program Counter contains the memory address of the next instruction.
2. This is passed to the Memory Address Register so that the contents of that
memory address can be read.
3. The contents of that memory address are passed to the Memory Data Register.
4. This register now contains the instruction and must be passed to the Current
Instruction Register so that it can be Decoded
What Happens During the Decode Phase?
1. The Current Instruction Register uses special circuitry to decode the
2. The Program Counter in incremented so that it points to the next instruction.
What Happens During the Execute Phase?
1. Data may move between registers and the Accumulator etc
2. Data may need to be read or stored in memory, in which case the Memory
Address Register and the Memory Data Register will be involved again.
System Bus
As the program is running the CPU controls the movement of data etc. The system
bus is made up of 3 main parts.
Data Bus all the data travels via the Data Bus this may be a width of 64-bit
depending on the computer.
Address Bus contains the memory location information often 32-bits wide.
Control Bus the CPU needs to control all the devices connected to the CPU. It does
this via the Control Bus. One of the major tasks of the Control Unit is to keep time.
(Not the Date and Time) but more like a conductor in an orchestra.