user1066886
user1066886

Reputation: 202

Determining how many bits an instruction takes

The question states

You are designing the instruction set for a new type of computer. The computer has 60 instructions, 16 general-purpose registers. It supports a byte-addressable memory of up-to 27MB. Answer the following questions.
(a) For a 3-operand instruction that only uses register addressing mode, how long (number of bits) should the instruction be?
(b) For a 4-operand instruction, in which one of the operands is a memory location with direct addressing mode, how long (number of bits) should the instruction be?

I figure for part a, you just do 2^x >= 60 and do a log_2 from there to determine x for the instructions. Similarly, 2^x >= 16 for the general purpose registers. I'm not really sure what the difference between 3-operand instruction and 4-operand instruction is, though, and how this factors into the total bits. Additionally I'm not sure how to derive the bits needed to represent the memory location. Is the answer to (a) just 6 (from the first log) + 4 (from the second log) = 10 bits needed to represent?

Upvotes: 0

Views: 5684

Answers (1)

Neeleshkumar S
Neeleshkumar S

Reputation: 776

For the first, the instruction consists of an opcode and 3 operands that are registers. So, the Bits needed will be 6(OPCode) + 3(3 Registers in the instruction) x 4(Since there are 16 registers, we need 4 bits to represent them.) => 18 bits + 1 or more bit(for operand or opcode information)

For the second, as the question states it's a 4 operand instruction and one is a memory operand, we need to find the bits needed to address the memory operand. Since we can address upto 27 MB, we can split the bits as 2^5(for 27), 2^20(for 1M) and 2^3(for Bytes) => 28 Bits for the Memory Operand itself. The calculation remains similar for the rest of the bits as well So we sum up the bits as 28 + 6 + 4 + 4 + 4 => 46 bits + 1 or more bit(for operand or opcode information)

Hope it solves your problem

Upvotes: 1

Related Questions