Search code examples
computer-sciencecpu-architecturecpu-registersinstruction-set

Finding maximum number of register counts from instruction size, op-code size, and number of operands


I've been trying to wrap my head around how to achieve the answer. I'd like to say I did my own research but either I'm not searching the right questions or I'm blind. Can someone please explain the logic behind finding the answer? I am at a loss.

Enter the register counts:

16 bit instruction, 5-bit opcode, maximum register count with 2 operands

16 bit instruction, 8-bit opcode, maximum register count with 2 operands


Solution

  • It's just arithmetic. 16 bits total, 5 are used for the opcode, leaving 11. Dividing 11 by two shows that if you need two operands, each one can have at most 5 bits to represent it, and you'll have 1 bit left over for something else. With 5 bits you can address 2^5=32 registers.

    Now you do the other one.