**Question 1**

- 199 instructions are given. To compute opcode bit, given bits are compared with formula 2
^{n}. It is founded that replacing n with 9 is satisfying our current requirement due to which 8 bits are enough for opcode (2^{8}>= 199). - Subtract opcode bits from bits in the word to obtain address part bits i.e. Bits in a word (24) – (8) Opcode bits. Hence, 16 bits are left for address part.
- To compute maximum size, address part bits are used in 2
^{n}where n is addresseded part bits. Hence, total memory size is 2^{16}= 65536. - In One Word, 011111111111111111111111 i.e. 2
^{23}– 1 is the largest bit that can be accommodated.

**Question 2**

- For Immediate Mode, Accumulator will take value 900 (ADD 900).
- Immediate AC value is used as a memory address in order to obtain the AC value of Direct Mode i.e. 1000.
- Similarly, AC value in direct Mode used as the memory address for indirect addressing mode to obtain the AC value i.e. 500.
- AC value in indexed mode is 500 because base register value i.e. 100 is added in Immediate Mode AC value in order to identify the memory address. At 1000 memory address, 500 value is present which is stored as AC value in indexed mode.

**Question 3**

Given Equation is F = (A-B) * (C*D+E)

**2-address machine instruction Code **

MOV M1, A [: - ‘A’ value is moved in register M1]

SUB M1, B [: - ‘B’ value is subtracted from value present in M1 i.e. ‘A’]

MOV F, M1 [: - ‘A - B’ value is moved to F register]

MOV M1, C [: - ‘C’ value moved to M1 register]

MUL M1, D [: - ‘D’ value is multiplied with M1 value i.e. ‘C’ value]

ADD M1, E [: - ‘E’ value is added after multiplication in M1]

MUL F, M1 [: - In the last, total value of M1 is multiplied with F value i.e. ‘A – B’]

**1-address machine instruction code: - **

LOAD A [: - ‘A’ value is loaded in register]

SUB B [: - ‘B’ value is subtracted from ‘A’]

STORE M1 [: - Stored subtracted value in M1 Register]

LOAD C [: - ‘C’ value is loaded in register]

MUL D [: - with ‘C’, ‘D’ value is multiplied]

ADD E [: - Added ‘E’ Value in ‘C*D’ value]

MUL M1 [: - Final value obtained from above is multiplied with the stored value of M1]

**0-address instruction machine code: - **

PUSH B [: - ‘B’ Value is entered in machine]

PUSH A [: - ‘A’ value is entered in machine]

SUB [: - ‘B’ value is subtracted from ‘A’ value]

PUSH C [: - ‘C’ value is entered in machine]

PUSH D [: - ‘D’ value is entered in machine]

MUL [: - Multiply ‘D’ vale with ‘C’ value]

PUSH E [: - ‘E’ value is entered in machine]

ADD [: - Added ‘E’ value in ‘C * D’]

MUL [: - Multiplied ‘C*D+E’ value with ‘A – B’]

POP [: - Extracted Solution i.e. (A – B) * (C * D + E)

**Question 4**

Given Instruction Length is 10 bits.

Address Field Size is 3 bits.

**Calculation for 2-address instruction,**

To get 2-address instruction, we have used 2 address field of 3 bits: -

Opcode bits = Instruction length [10 bits] – address bits [6 bits]

Opcode bits = 4 bits.

Total instruction formed from 4 bits opcode are 2^{4} = 16 in which 15 instructions are already used.

**Calculation 1-address instructions,**

To get 1-address instruction, we have used 1 address field of 3 bits: -

Opcode bits = Instruction length [10 bits] – address bits [3 bits]

Opcode Bits = 7 bits

Total instruction formed from 7 bits opcode are 2^{7} = 128 in which 7 instructions are already used.

**Calculations for 0-address instructions, **

To obtain opcode bits, no address bits are used.

Opcode bits = Instruction length [10 bits] – address bits [0 bits]

Opcode Bits = 10 bits

Still, 0-address instruction is able to accommodate possible instruction as shown below: -

There are 10 bits, so total instruction formed are 2^{10} including 2-address instruction and 1-address instruction.

Total Instruction = 2^{10 }= 1024.

2-address instruction = 15

1-address instruction = 7

0-address instruction = 1024 – 15 – 7 = 1002.

Suitable total number of zero-address instruction is 1002.