Opcode

An opcode (abbreviated from operation code, also known as instruction machine code, instruction code, instruction syllable, instruction parcel or opstring) is the portion of a machine language instruction that specifies the operation to be performed.

A machine instruction usually has:

Example

In a simplified assembly-like instruction:

ADD R1, R2

ADD → opcode (tells CPU to perform addition) R1, R2 → operands (the values/registers being used)

What opcodes do

Opcodes control all low-level operations, like:

Why they matter

Example: x86 Machine Code

Here’s a simple assembly instruction:

MOV EAX, 1

Machine code (in hex):

B8 01 00 00 00

Breakdown:

B8 → opcode (means “move immediate value into EAX”) 01 00 00 00 → operand (the number 1, stored in little-endian format)

So the CPU reads:

“Take the value 1 and put it into register EAX”

Another Example

ADD EAX, EBX

Machine code:

01 D8

Breakdown:

01 → opcode for ADD D8 → specifies registers (EAX and EBX)

What It Looks Like in Memory

A program in memory is just a sequence of bytes:

B8 01 00 00 00 01 D8

The CPU reads byte by byte:

Key Insight