Welcome to the Heart of the Machine!

Ever wondered how a computer actually "understands" a line of code? It doesn't see your Python or Java; instead, it sees a series of 1s and 0s called machine code. In this guide, we are going to look at the Instruction Format—the secret recipe the computer uses to decode those numbers into actions. Don't worry if this seems like a lot of technical detail at first; we'll break it down bit by bit (pun intended!).

1. The Processor Instruction Set

Every type of processor (CPU) has its own "vocabulary." This vocabulary is called the processor instruction set. It is a complete list of all the basic commands that a specific CPU can carry out.

Important Point: Instruction sets are processor-specific. This means an instruction written for an ARM processor (like the one in many smartphones) won't work on an Intel processor (like the one in many laptops). It’s like trying to give directions in French to someone who only speaks Japanese!

Did you know? Because the instruction set is built into the hardware, it defines what the computer is capable of doing at its most basic level.

Key Takeaway:

The instruction set is the unique "language" of a specific CPU. Programs must eventually be translated into these specific instructions to run.


2. The Anatomy of an Instruction

Just like a sentence has a verb and a noun (e.g., "Eat the apple"), a computer instruction has two main parts:

A. The Opcode (The "What")

Short for "Operation Code," the opcode tells the CPU what to do. Examples include commands like ADD, LOAD, or STORE.

B. The Operand (The "Who/Where")

The operand tells the CPU what data to use or where to find it. An instruction might have one operand, several, or even none at all.

C. Addressing Mode (The "How")

The addressing mode is a part of the instruction that tells the CPU how to interpret the operand. Is the operand the actual number we want to use, or is it a "map" telling us where to go find the number?

Analogy: The Cooking Instruction
Imagine a recipe says: "Chop the carrot."
Opcode: Chop (The action)
Operand: The carrot (The item being acted upon)

Quick Review:

Machine Code vs. Assembly Language
Machine Code: Instructions expressed in binary (1s and 0s). This is what the hardware actually processes.
Assembly Language: A more human-friendly version where opcodes are replaced by short words called mnemonics (like ADD or SUB).


3. Addressing Modes: Finding the Data

This is often the part students find trickiest, but you can think of it as different ways of receiving a gift. In the Oxford AQA syllabus, you need to know three specific modes:

I. Immediate Addressing

The operand is the actual value to be used. There is no hunting for data; it's right there in the instruction.
Example: ADD 10 (This means literally "add the number 10").
Analogy: Someone hands you $10 cash. You have the money immediately.

II. Direct Addressing

The operand is the memory address or register number where the data is stored. The CPU has to go to that location to "fetch" the value.
Example: LOAD 100 (This means "go to memory address 100 and get the value stored there").
Analogy: Someone hands you a key to Locker #100. The "gift" is inside the locker.

III. Indirect Addressing

This is like a treasure hunt. The operand is a register that contains the address of the data. You look in the register, find a memory address, and then go to that memory address to get the value.
Analogy: You open a drawer (the register) and find a note that says "The gold is in the garden." You then have to go to the garden to get the gold.

Common Mistake to Avoid:

Don't confuse Direct and Indirect! In Direct, the instruction tells you exactly where the data is. In Indirect, the instruction tells you where to find a "pointer" or a "signpost" that points to the data.


4. Instruction Formats and Bit Allocation

In machine code, every instruction is a string of bits. How those bits are split up depends on the instruction type. For example, a 32-bit ARM processor instruction might be split like this:

  • Opcode: 4 bits (allowing for \(2^4 = 16\) different operations).
  • Addressing Mode: 1 bit (to toggle between different modes).
  • Operands: The remaining bits are used to identify registers or values.

Don't worry if this seems complex: You don't need to memorize specific bit-layouts for exams! Just remember that the format (how the 1s and 0s are grouped) changes depending on whether the computer is doing math, moving data, or jumping to a different part of the program.

Key Takeaway:

The total number of bits for an instruction is fixed (e.g., 32 bits), but the "slices of the pie" given to the opcode and operands can vary depending on the instruction type.


Summary Checklist

Before moving on, make sure you can answer these:
What is an opcode? (The command/action).
What is an operand? (The data or address).
What is a mnemonic? (A word like ADD used in Assembly).
Can you explain Immediate vs. Direct addressing? (Value vs. Location).
Why are instruction sets "processor-specific"? (Different hardware understands different binary patterns).