### 1 comment

## 4 Answers

But 5 are being used. So 3 are free.

We use these 3 for 1-address instruction by using 4 bits of 1 of the addresses i.e. 3*16=48

Now out of 48 1-address instructions, 32 are being used. So we are left with 16.

Again use these 16 for 0-address instruction by using 4 bits of address i.e. 16*16=256

### 3 Comments

Coz out of 11 bits, 7 bits are fixed.

**How? **

- While considering, for two-address instructions, we were left with 3 bits. So, we could have 8 combinations. From, those 8 combinations, we have assigned 5 combinations to two-address instructions. Now, we are left with 3 combinations.
- While considering, for one-address instructions, we were left with 7 bits (to be precised), therefore, we could have $2^7$ (128) combinations. BUT BUT, you might include the two-address instructions. So, we have $2^4$ * 3 (these are 3 combinations which were left in two-address instructions) = 48. But, we need only 32, therefore we are left with 16 combinations.

Now, coming to zero-address instructions, we don't have any address field, therefore, we can write $2^{11}$ combinations. BUT again, we might include one-address and two-address instructions, * therefore out of 11 bits, we have used 7 bits (this is important) - coz we have counted them while calculating one-address instructions (those 16 combinations which were left). *Hence, $2^{4}$ * 16 = 256.

2-address instruction:

$opcode=3\ bits$ | $address=4\ bits$ | $address=4\ bits$ |

Total number of instruction: $2^3=8$ in which $5$ are $2-address\ instruction$. Therefore number of free opcodes=3

1-address instruction:

$opcode=7\ bits$ | $address=4\ bits$ |

Total number of 1-address instruction possible: $3\times 2^4=48$. But only $'32'$ $1-address\ instructions$ are given. Hence $'16'$ instruction are free.

0-address instructions:

$opcode=11\ bits$ |

Total number of $0-address\ instructions$: $16\times 2^4=256$

$Ans: 256$

$Note:$

- Identify the primitive instruction.Primitive instruction: smallest opcode.
- Identify the total number of instructions possible in the CPU.
- Identify the free opcodes after allocating primitive instruction.
- Calculate the derived instruction by multiplying the free opcodes with a decoded form of a address field.

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!