20

Computer Instructions

What is an instruction?

An instruction (or machine instruction) is a sequence of bits like this one:

+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
| 0 | 1 | 1 | 0 | 1 | 0 | 1 | 1 | 1 | 0 | 0 | 1 | 0 | 0 | 0 | 1 |
+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+

that tells the CPU what action to take (e.g., calculate something, copy data to RAM, fetch data from RAM, make a decision, etc.)

An instruction has 2 parts: the opcode (= operation code) and $0$ or more operands (data affected by the operation.)

   Opcode                             Operand #1                 
+---+---+---+---+    +---+---+---+---+---+---+---+---+---+---+---+---+
| 0 | 1 | 1 | 0 |    | 1 | 0 | 1 | 1 | 1 | 0 | 0 | 1 | 0 | 0 | 0 | 1 |
+---+---+---+---+    +---+---+---+---+---+---+---+---+---+---+---+---+