in CO and Architecture recategorized by
3,075 views
25 votes
25 votes
Using an expanding opcode encoding for instructions, is it possible to encode all of the following in an instruction format shown in the below figure. Justify your answer.
$$\begin{array}{ll} \text{14} & \text{double address instructions} \\  \text{127} & \text{single address instructions} \\   \text{60} & \text{no address (zero address) instructions} \\ \end{array}$$ $$\begin{array}{|c|c|c|} \leftarrow4\text{ bits}\rightarrow& \leftarrow6\text{ bits}\rightarrow & \leftarrow6\text{ bits}\rightarrow  \\ \hline \text{Opcode}& \underset{\text{Address}}{\text{Operand 1}}& \underset{\text{Address}}{\text{Operand 2}} \\\hline \end{array}$$
in CO and Architecture recategorized by
3.1k views

1 comment

@Arjun sir

I have a doubt that here 14 double address instructions mean that 14 operations(opcodes) ?

Is saying that there is an instruction same as saying that there is an operation?
0
0

3 Answers

30 votes
30 votes
Best answer
$4$ bits are for the opcode so number of $2$ address instructions will be $2^4 =16-$ so $14$ double instructions are possible.

But out of $16$ only $14$ are used so $2$ are still left which can be used for $1$ address instruction. For $1$ address instruction we can use not only the $2$ left over but also the $6$ bits of operand $1$ (to make it one address) $-$ so $6$ bits that is $64.$ So, total $2\times 64$ single address instructions can be supported $-$ So, $127$ single instructions are possible

But out of $128,127$ are used so $1$ left which can be used for zero-address instruction. To make number of zero address we can use the operand $2$ address (we already included operand 1 address)  $- 6$ bits. So, total number possible is $64.$ So,
total $1\times 64 = 64$ zero address instructions are possible.

So, all encoding are possible.
edited by

4 Comments

Thank you for the clear explanation @Gokulnath

0
0
In the question it says, that 4 bits are available for opcode. Now,in the answer it is said "But out of 128,127 are used so 1 is  left which can be used for zero-address instruction", so for the one combination that is used for the zero-address instructions the 4 opcode bits will be the same as, the other 63 combinations used for 1 address instruction.

How will CU differntiate between these instructions if opcode bits are same? CU decides the type of instruction by looking ar the opcode bits , am I wrong?
0
0
expanding opcodes is very well explained in their NPTEL lectures by IIT Madras, Professor V Kamakoti
0
0
29 votes
29 votes

There are 14 two-address instructions which consume 14*26*26 =  combinations 

There are 127 one-address instructions which consume 127*26 =  combinations 

There are 60 zero-address instructions which consume 60 combinations 

Total number of combinations consumed = 57344 + 8128 + 60 = 65532

We have a total of 216 = 65536 combinations  which is >65532 

So it is possible to encode all these instructions using the given instructions format ... Infact we will have 4 extra combinations ... 

1 comment

Thank you for amazing explanation.
0
0
1 vote
1 vote

Related questions