assemblyarchitecturecpu-architectureinstruction-setmachine-instruction

How many bits are needed to represent an instruction in a computer?


How many bits are needed to represent an instruction in a computer that has 53 different instructions, all of which are two addresses, when the computer has 65000-word memory ?


Solution

  • Don't know if I got you right, "all of which are two addresses"

    Let's assume the wanted instruction may look like this <Instruction ><Operator1><Operator2>

    you say there's 53 instructions, so let's create a list, and check how many bits are used:

    number   instruction
    00000000 operation1
    00000001 operation2
    00000010 operation3
    ...
    00110100 operation52
    00110101 operation53
    

    as you see, only 6 bits of the eight are used, which makes sense, 2**6 = 64
    to address 65000 words, you need 16 bit (2**16=65536)

    to encode an instruction with 2 operants, 16 bit each, you'd need

    6 (for the instruction) +16 (op1) +16 (op2) = 38 bit