Instruction Set Architecture (ISA) design
Hint: If there are $X$ of some resource, then it takes $\log_2 X$ bits to encode which of them you chooses. This includes instructions, registers, and memory locations. If you are encoding $N$ copies of the resource, you will need $N\log_2 X$ bits. The instruction should contain an encoding of everything needed to specify it, including the instruction itself.

(Real life CPUs don't quite behave this way. For example, common instructions could have shorter length.)

Example: A computer has $956$ instructions. The instruction NOP takes $\lceil \log_2  956 \rceil = 10$ bits.

Another example: A computer has $13$, and $100$ I/O ports. The instruction IN , which reads a byte from the port into the accumulator, takes $\lceil \log_2 13 \rceil + \lceil \log_2 100 \rceil = 11$ bits.

Yet another example: A (useless) computer has a single instruction but $10000$ registers. The single instruction takes $10$ of them and does something really complicated. It takes $\lceil \log_2 1 \rceil + 10 \lceil \log_2 10000 \rceil = 140$ bits to encode.