OK. I've come up with something. In order to do that type of encoding, you need variable OpCode lengths.
2 address instructions:
| 10 OpCode 8 | 7 Address A 4 | 3 Address B 0 | -> 3 bits + 4 bits + 4 bits = 11 bits
OK. Encode five instructions with 3 bits:
111, 110, 101, 100, 011
1 address instructions:
| 10 OpCode 4 | 3 Address 0 | -> 7 bits + 4 bits = 11 bits
Now comes the interesting part:
We can only use instructions having the high bits: 010, 001, 000
That means:
An instruction like: 11111111111 cannot exist as an one address instruction anymore - the computer couldn't tell the difference between 111 1111 1111 as a two address instruction and 1111111 1111 being an one address instruction.
Therefore only instructions like 010XXXX XXXX, 001XXXX XXXX and 000XXXX XXXX are allowed here. There are 48 of them available: 010XXXX + 001XXXX + 000XXXX = 48 since 2^4 + 2^4 + 2^4 = 48.
This is now causing an issue: Now we are unable to tell the difference between an one address instruction and a zero address instruction - all two and one address instructions start with one of the 2^3 options in their high bits - so we need more encoding.
Let's say, one address instructions are now only allowed to have an OpCode like: 010XXXX, 001XXXX or 0001XXX.
That means: There are now only 010XXXX + 001XXXX + 0001XXX = 2^4 + 2^4 + 2^3 = 40 options available.
Perfect! We only need 40 one address instructions.
OK. Now let's encode our zero address instructions which can only start with 0000 in their high bits.
We have no address in our instruction anymore, so the entire instruction can be an OpCode but since we are only able to use: 0000 XXXX XXX we only have 2^7 = 128 OpCodes left.
So we can encode 128 zero address instructions, if there is no added immediate.
And that's hopefully the answer of that question - otherwise, ignore this post: I just did some research and maths for 2 hours and had no class about it.
EDIT: My brain feels damaged now.
@Vandal85 could you please post here if this answer is correct, when you've talked about the question in class?