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?
ceiling(log2(N))rather than try to find the power of 2 greater than it and then doing log2. I.e.log2(60)is going to be ~ 5.9,ceiling(5.9)is 6, so you know you need 6 bits. Easier than figuring out that 64 is the next power of 2 greater than 60 and doinglog2of that. Although, eventually you'll be able to pull these numbers off the top of your head, programmaticallyceiling(log2(N))is the better method. - rjp