I found the following question on a different site:
A processor has 64 registers and uses 16-bit instruction format. It has two types of instructions: I-type and R-type. Each I-type instruction contains an opcode, a register name, and a 4-bit immediate value. Each R-type instruction contains an opcode and two register names. If there are 8 distinct I-type opcodes, then the maximum number of distinct R-type opcodes is _______ .
Note – This question was Numerical Type.
The author claims the correct answer is 14. I do not understand why. Here is my reasoning. For an I-type instruction, we have 6 bits for the register and 4 bits for the immediate value. That leaves 6 bits left over for the opcode. That means that we should have 2^6 = 64 opcodes which means we have 64 - 8 = 56 R-type opcodes.
Another way to look at this problem is to say that an R-type instruction needs 12 bits for two register specifications. This leaves 4 bits for the opcode. Hence, there are 16 R-type opcodes. I am not sure about what happens because some of the I-opcodes overlap.
Hence, I am not sure what the right answer is, or how to get it?
Now for an R-type Opcode, I see
1-bit for a flag to specify if it is I or R format 12-bits to specify two registers
3-bits for the opcode
Now, I am seeing 8 different R opcodes because 2^3 = 8.