Any CPU is designed from the ground up to support a particular instruction set.

An instruction set is a set of hard-coded operations that the CPU can perform.

Each operation a computer can perform is uniquely represented by an opcode.

codes

Each instruction consists of an opcode.

Depending on the instruction, it may or may not include operands.

Once the complete instruction has been fetched, it needs to be decoded.

This is the process where the CPU separates the opcode and any operands.

Once the instruction has been decoded, it will be executed.

The exact behavior of the CPU will depend on the operation.

An addition operation will sum two values together.

A jump operation will calculate where in the program to jump to.

A compare operation will compare two values.

A NOP operation will sit idle, as NOP stands for No Operation.

Most instructions will then output the result of the operation.

This output can go to the processor registers and, if necessary, to system RAM.

Each of these operations takes a single clock cycle to complete.

Illegal Opcodes

Each CPU architecture has its specific list of opcodes published by the manufacturer.

In some cases, the manufacturer also includes undocumented opcodes.

These are referred to as illegal opcodes.

Illegal opcodes, while undocumented, will perform the same function every time theyre called.

As undocumented and non-standard features, though, updates to the CPU architecture can simply remove them.

Some early computer games on the Apple II relied on specific illegal opcodes.

Some illegal opcodes are simply meant as debugging tools and error handlers.

The x86 instruction set contains a large number of undocumented illegal opcodes.

Compilers and Assembly

Most programs are written in high-level languages.

These are relatively easy to read, often using English words or shorthand to minimize learning curves.

For a computer to execute these programs, they need to be compiled.

A compiler is basically a translator.

It takes the high-level code and converts it into computer code, the instructions that the CPU can understand.

NOP is an example of assembly shorthand.

Conclusion

An instruction set is a list of official functions that a CPU architecture can run.

It is a list of operations that can be performed.

These operations are hard-coded into the CPU and called using their respective opcodes.