In: Computer Science
In a computer instruction format, the instruction length is 16 bits and the size of an address field is 4 bits. Is it possible to have: 15 instructions with 3 addresses, 14 instructions with 2 addresses, 31 instructions with one address, and 16 instructions with zero addresses, using this format? Justify your answer.
The above question belongs to the computer architecture and organisation sector of computer science.
Note: Since nothing is mentioned about the addressing modes etc. So we take bare minimum while forming the instructions.
An instruction is primarily composed of two things:
1. The instruction opcode i.e the operation code for the instruction
2. The address of the operand that the instruction is supposed to work upon
The amount of Instruction Bit or length of instruction must be greater than the bits required to represent the above two quantities.
Now Let us examine the cases one by one:
1.) 15 instruction with 3 addresses
To represent uniquely 15 instructions we need at least 4 bits since 2^4 = 16 and 2^3 = 8 so in order to represent 15 opcode we must use 4 bits.
To represent 3 addresses we use 4 bit each i.e 4*3 = 12 bits
Adding the above two quantities = 12+4 =16 bits
Since the instruction length is also 16 it is a valid condition
2.) 14 instruction with 2 addresses
To represent 14 instruction we need 4 bits using the same argument as above.
To represent 2 addresses we need 4 bit each i.e 2*4 = 8 bits
Adding the two = 8+4 = 12 bits
Since 12<16 so the organisation is valid.
3.) 31 instruction using 1 address
To represent 31 instruction we need 5 bits as 2^4=16 and 2^5 = 32 so 5 bits will suffice.
To represent a single address 4 bits are enough
Adding the two we have 9 bits
9<16 the instruction is valid
4.) 16 instruction with 0 address
To represent 16 instruction we need 4 bit as 2^4 = 16
To represent 0 address we have 0 bits
Adding the two 4 bits
Since 4<16 the organisation is valid.
Note : In above question the remaining bits are filled by zeros on the LHS.
Hope the above effort helps to solve your query.
Thanks and regards!!!!!
Any suggestion or question is welcomed in the comment box.