In: Computer Science
What is the minimum number of bits for representing the opcode if there are 62 different instructions?
Please explain it, thanks.
Minimum number of bits = 6
Explanation:
An opcode is a part of the instruction that specifies the operation that will be performed by this.
If we have only two opcodes, then only one bit can be used for representation. Bit '0' for the first opcode and a bit '1' for the second opcode.
If we have 3 or 4 opcodes then two-bit can be used for representation as given below:
00, 01, 10, 11
So, 'n' bits can be used to represent the 2n opcode.
For 62 opcode, we need 6 bits to represent 26 = 64 opcode.
Five bits are not enough because five bits can be used to represent the 25 = 32 opcode only.
So, minimum number of bits required is 6.