8 |
12 |
12 |
Opcode |
Operand1 |
Operand2 |
Opcode = 8bits because total size = 32bits.
Opcode specifies how many different operations can be performed. In Layman's terms, you can think that Opcode tells you how many different instructions can be there.
See the last part of the answer for difference between an instruction and an instruction encoding
Here, Opcode = 8bits => 256 different instructions can exist.
250 of those are already taken by 2 Add. Instructions. (binary operations)
Hence, we're left with just 6 different instructions for unary operations (ie 1 Address Instructions)
Here, in the operand field, we still get 12 bits. This means $2^{12}$ different operands can be fused with 6 different instruction formats.
=> Encodings possible = $6*2^{12}$
=> $24,576$ (Answer)
Instructions vs Instruction Encoding
An instruction is a command.
Like, multiply, add, move, load, store, increment.
An instruction encoding is the whole instruction specifically stated.
ie, multiply 2 and 3. Or, Load #666 in R2.
instructions that can be formulated are
If I have one instruction, say, ADD and two 12-bit operands
I can formulate various instructions like:
Each such "formulation" or an "instance" will be an encoding.
But all these are not distinct instructions because it's just addition.
Opcode specifies the type of instruction. Length of Opcode decides the number of instructions you can have.
Length of the whole instruction decides how many different formulations/encodings you can have.