Instruction Formats and Opcodes
What You'll Learn
You'll learn how machine instructions are structured into fields, with opcodes specifying what operation to perform and operands specifying where to find the data.
The Structure of an Instruction
Every machine instruction is like a tiny command written in binary. To make sense of this command, the CPU needs to know two things:
- What operation to perform (add, subtract, load, jump, etc.)
- What data to use (which registers or memory addresses)
This is where instruction formats come in—they divide each instruction into distinct fields.
The Opcode Field
The opcode (operation code) is the field that tells the CPU which operation to execute. Think of it as the verb in a sentence: "ADD," "LOAD," "STORE," "JUMP."
For example, in a simple instruction, the first few bits might be the opcode:
0010might mean "ADD"0101might mean "LOAD"1000might mean "JUMP"
The Operand Fields
The remaining fields specify the operands—the locations of data the operation needs. These might be:
- Register numbers (e.g., "use register 3 and register 5")
- Memory addresses
- Immediate values (small constants embedded in the instruction itself)
Analogy
Think of an instruction like a recipe step: "Mix (opcode) ingredients from bowl 2 and bowl 5 (operands), put result in bowl 2."
Why This Matters
During the decode stage of the instruction cycle, the Control Unit examines the opcode field to determine what circuitry to activate, and reads the operand fields to route the correct data through the CPU's data paths.
Key Takeaway: An instruction is divided into fields—the opcode specifies the operation, and the operand fields specify where the data comes from and where results go.