opcode = 3 bits |
src addr = 4bits |
destination addr = 4bits |
Total 11 bit instruction format (given)
total possible opcodes = 2^3= 8 opcodes
for 2-address instruction
we have 5 double operand addresses so means 5 codes are for this so, 8-5 = 3 opcodes left.
now,
for 1-address instruction we must have allote opcode among these 3 opcodes which are left.
let's say opcode is p for 1-address and 3 - p will be for 0-address
here for 1 -address we p X 2^4 = p X 16 instructions
also it is given 32 1-address instruction we can have
p will be 2 ( ie. 2 X 16 makes 32 1-addrees instruction)
for 0-address instruction
3 - p = 3-2 = 1 opcode for 0 address
1 X 2^4 X 2^4 = 1 X 16 X 16 = 256 zero-address instructions.
Note : Now I'm explaining in the simplest way possible.
you can think this problem like for 2-address instruction you fixed the src address and destination address ie just vary opcode bits 2^3 and subtract the given no of 2-address instructions.
for 1-address instruction you fixed only destination address thats why we did 2 X 2^4 , so we find the combination of first two fields.
for 0-address instruction nothing to fixed just do 1 X 2^4 X 2^4 every possible combination with 1 opcode.
I hope i am able to explained it in easiest way!