16,591 views
16 votes
16 votes
Consider the hypothetical processor is supports both 2 address and one address instructions.It has 128 word memory A 16-bit instruction is placed in the one memory word.

Q1.What is the range of two address and one address instructions are supported.

A)1 to 3 and 128 to 364 B)1 to 3 and 128 to 384 C) 0 to 4 and 120 to 380 D) 0 to 3 and 64 to 256

Q2.If two 2-address instructions are already existed.How many one address instructions can be supported ?

A)128 B)2 C)256 D)32

5 Answers

Best answer
9 votes
9 votes

Part 2 :

128 word memory so 128 = 27 hence opcode is 2 bits [ total 16 bits among these bits 7 bits for 2 address, 7 bits for 1 address rest 16-14=2 bits for opcode ]

16-bit instruction is placed in the one memory word. so 216 possible encoding .

Given, two 2-address instructions are already existed.

No. of encoding for 2 address instructions =  2 *  27 * 27  = 215

No. of encoding for 1 address instructions = ( 216 -  215  ) * 27 = 21 * 27 = 28

so one address instructions can be supported  is 28 = 256 which is option C .

-----------------------

For part 1 

with 7 bits possible range 27 = 128 

number of 1 address instruction 256 .

128 + 256 = 384 

so range is posible 128 to 384

7 bits for 2 address and 1 address instructions,  so 7 < 8 <23  hence max possible  up to 3 bits .

range of two address and one address instructions are supported is 1 to 3 and 128 to 384 .

which is option B .

selected by
7 votes
7 votes

instruction size 16 bit.

memory 128 word -> 128=2^7 so address field size is 7 bit.

Part-2. Option C

<-----------------16 bit------------------> 

2 bit 7 bit 7 bit

exited instruction is two address field and size of one address field is 7 bit so 7+7=14 bit required for address field in two address field instruction now remaining 2 bit because the instruction is 16 bit -14 bit =2 bit

so the opcode is 2 bit, the total number of operation can be supported is 2^2=4 for two address field instruction.

but given that there is only 2 two address field instruction. so free opcode is 4-2=2 we can use it for one address field instruction.

free opcode is 2 7-bit opcode 7-bit address field

how many one address field instructions, one address field requires 7 bit for address field and instruction is 16 bit so remaining bits are 9 bits but 2 bits used for 2 address field instruction but above we can see there is 2 free opcode in 2 address field instruction. 

remaining  7 bits plus 2 free opcodes by this we can calculate the total number of one address instruction are 2*2^7=256 so answer is 256 one address field instruction

Part-1 Option B is correct.

checking options

A). 1 to 3 and 128 to 364

In the Part-2 answer, we can see there are 4 two address field instruction can be supported but given range 1 to 3 so

 when 1 two address field instruction remaining free opcode is 3 so number of one address instruction can be 3*2^7= 384

when 2 free opcodes 2, 2*2^7=256

when 3 free opcodes 1,1*2^7=128

so the range of one address instruction should be 128 to 384 but given 128-364 so it fails.

 

B). its correct explanation above.

 

 

 

4 votes
4 votes

Part 1: (B) 1 to 3 Two-Address and 128 to 384 One-Address

By Expanding Opcode Technique as explained here 

If there are $n$ Two- Address instructions then no. of encodings possible $=n*2^7*2^7=2^{14}n$

Then number of encodings possible for One Address instructions will be $=2^{16}-2^{14}n$

and number of one address instructions will be $=\frac{2^{16}-2^{14}n}{2^7}=2^9-2^7n=2^7(4-n)=128(4-n)$ 

Now $n$ can have minimum value $1$ and maximum value $3$ (Not $0$ because in Part 2 it has been mentioned that 2 address instruction already exist, not $4$ as then no. of 1 Address instructions would be 0 as per above formulae)

So range of Two-Address Instruction :- 1 to 3

Range of one Address instructions :- $128(4-3)$ to $128(4-1)$=$128*1$ to $128*3$=128 to 384

Part 2 : No. of One Address Instruction supported$=384-128=256$

Hence (C)

edited by
0 votes
0 votes

PART 1

no of combination =2^2 // 2 opcode bits

range of 1-address instruction

1×2^7  to (4-1)× 2^7  = 128 to 384

 

range of 2-address instruction

1  to (4-1) = 1 to 3

Answer B

Answer:

Related questions

4 votes
4 votes
3 answers
1