retagged by
10,898 views
20 votes
20 votes

A CPU is designed to have 58 three-address instructions and 25 two-address instructions. The CPU is able to address a maximum of 16 memory locations. The length of machine code is the same for all instructions. If the list of the machine codes is obtained by using the expanding opcode technique, answer the following questions:

i) Determine the maximum number of bits allocated for each address fields

ii) Determine the minimum number of bits allocated for the opcode field of threeaddress instructions

iii) Determine the minimum number of bits allocated for the opcode field of twoaddress instructions

iv) Determine the length of the machine code

v) List the machine codes

Detailed explanation would be helpful 

retagged by

2 Answers

Best answer
30 votes
30 votes

In such questions we should start calculation from higher order address formats meaning the address formats which allows more no of address fields in an instruction.

In fixed instruction format :

Instruction size will remain the same but to accomodate different types of address formats like 1 address instruction format, 2 address instruction format etc . we need to vary the opcode size accordingly which is known as expand opcode technique..

So let us see how to use it here..

Answer to 1) part : It is obvious that for 1 address instruction we will have one address field hence no of bits required for address = 4 bits as we have 16 memory locations ..So log216  = 4 bits required for address field..

Answer to 2) part :  As mentioned there are 4 bits required for address..So in a 3 address instruction as we have 3 address fields , so we will have 12 bits for address in an instruction.

.And there are 58 3 address instructions so no of bits required for opcode = ceil (log2(58))

                                                                                                           = 6

So instruction size  =   6 + 12  =  18.

But using 6 bits of opcode we can have 64 3 address instructions..So we have 6 unused combinations of opcodes which we can utilise for 2 address instructions using expanded opcode technique..

Answer to 3) :

So for each of the 6 unused combinations mentioned one address field will be appended to opcode field so we have 2 address fields in an instruction instead of 3..

So for each one of 6 unused opcodes, no of 2 address instructions = No of addresses 

                                                                                                  = 16

So total no of 2 address instructions possible   =   6 * 16  =  96

But anyways no of bits required for opcode of 2 address instruction = Opcode in 3 address  + 1 address field

                                                                                                  =  6 + 4  =  10

Answer to 4) :

Length of machine code is nothing but size of an instruction and hence it is 6 + 12   =  18 bits for all be it 3 address or 2 address instruction..

selected by
0 votes
0 votes
assuming you have solved other example. the minimum bits for opcode should be 6 as it support 58 3 address. 16 memorry so 4 bit each address/

1- 4 bit

2- 6 bit

3- 10 bit

4- 6+4+4+4 = 18

5-  can't know what to list but will go with  opcode adress adress adress

Related questions

0 votes
0 votes
1 answer
1
A_i_$_h asked Sep 15, 2017
1,601 views
Can someone suggest a good video or link for ""expanding opcode technique""
2 votes
2 votes
0 answers
3