248 views
A computer has $32$ bit instructions and $12$ bit addresses.
If there are $250$ two-address instructions, the number of one-address instructions that can be formulated are ______.

32 bit instructions - totally $2^{32}$ possible encodings (encodings with only address part being different are not separate instructions).

No. of encodings taken by 250 two address instructions $= 250 \times 2^{12} \times 2^{12}$.

Since nothing is given I assume no 0 address instructions and hence $2^{32} - 250 \times 2^{12} \times 2^{12}$ encodings are available for 1 address instructions. But of these $2^{12}$ of them are same due to address part. So, total number of 1 address instructions possible is

$\frac{2^{32} - 250 \times 2^{12} \times 2^{12}}{2^{12}} \\= 2^{20} - 250 \times 2^{12} \\= (250+6) \times 2^{12} - 250 \times 2^{12} \\= 6 \times 2^{12} \\= 2^{14}+ 2^13 \\= 16,384+8,192=24,576$
by

why the answer is not 6 ? please explain . instruction is of type opcode(8bits) address1(12bits) address2(12bits). i dont think we have to permute on address part . bcoz opcode is the one decide what type of instrcution it is not the address. Risc instrcution are of type opcode +mode+address for a instrcution.
@Arjun Sir,

what do u want to say from this line,( encoding with only address part being different are not separate instructions)?
instruction is 32 bit , among them 8 bit opcode, 12 bit for address 1 , 12 bit for address 2 .
total 2^8 =256 combinations are there, among them 250 two address instructions , then 256-250= 6 combinations are used for one address instructions .
now  maximum number of one address instructions are 6* 2^12 = 24, 576
by

edited by
It should be 6*(2^(20-6))

= 6*(2^14) = 98304 right ?

Since .. 32-12 = 20 bits available to make use for opcodes

out of 20 , 6 bits need to be fixed , so that they dont clash with the two address instructions .. so , 14 bit can be varied ..

Please clarify if my understanding is correct .
@bikram sir , why are we not considering the 12 bit for address 1 that we have in the instruction for one address instructions combination and considering only the combinations left in the 8 bits opcode field for the same?

Opcode decide what type of instruction it is not the address, that's why we are not considering the 12 bit for address 1.

 8 12 12 Opcode Operand1 Operand2

Opcode = 8bits because total size = 32bits.

Opcode specifies how many different operations can be performed. In Layman's terms, you can think that Opcode tells you how many different instructions can be there.

See the last part of the answer for difference between an instruction and an instruction encoding

Here, Opcode = 8bits => 256 different instructions can exist.

250 of those are already taken by 2 Add. Instructions. (binary operations)

Hence, we're left with just 6 different instructions for unary operations (ie 1 Address Instructions)

Here, in the operand field, we still get 12 bits. This means $2^{12}$ different operands can be fused with 6 different instruction formats.

=> Encodings possible = $6*2^{12}$

=> $24,576$ (Answer)

### Instructions vs Instruction Encoding

An instruction is a command.

An instruction encoding is the whole instruction specifically stated.
ie, multiply 2 and 3. Or, Load #666 in R2.

instructions that can be formulated are

If I have one instruction, say, ADD and two 12-bit operands

I can formulate various instructions like:

• 2 + 3
• 99 + 75
• 169 + 48

Each such "formulation" or an "instance" will be an encoding.

But all these are not distinct instructions because it's just addition.

Opcode specifies the type of instruction. Length of Opcode decides the number of instructions you can have.

Length of the whole instruction decides how many different formulations/encodings you can have.

1 vote