The ALU and the Op Code
The fourteenth intro changes how you look at numbers: a number can be not only data but an order. The experiment uses an ALU and an OPCODE toggle.
Experiment: same numbers, different answers
The ALU inputs carry the numbers 7 and 3, and they never change. The OPCODE toggle chooses the action: 0 — addition, 1 — subtraction. At 0 the ALU always outputs 10, at 1 always 4. What changed the result was not the inputs but the op code.
The rule: an operation is a number too
An op code is a number that tells the ALU what to do: 0 — add, 1 — subtract, and further codes for AND, OR and shifts. In this course's processor an instruction fits one byte: the upper four bits are the op code, the lower four are the operand. One byte carries both what to do and what to do it with.
Transfer: predict the result
The toggle is in position 1, the ALU computes 7 and 3. The answer without clicking: 4 — code 1 orders subtraction. The same 7 and 3 with code 0 would give 10: the result depends on the op code, and multiplication is not among the toggle's positions.
Where it is used
On this level you will build an ALU with seven operations: a decoder turns the op code into a selection, and multiplexors route the right result out. When you reach the processor, every instruction in ROM will be such a number-order: op code + operand.