ISA & Assembly

What is the main advantage of making instructions a fixed length?

  1. AInstruction boundaries are known immediately, making it easy to decode several instructions at once
  2. BEvery instruction is shorter than variable-length ones, so programs always get smaller
  3. CThe number of instruction types can grow without limit
Show answer and explanation

Answer: A. Instruction boundaries are known immediately, making it easy to decode several instructions at once

With fixed length, the nth instruction always starts at byte 4n, so many instructions can be fetched and decoded in parallel. This especially helps superscalar CPUs that issue several instructions per cycle. On the other hand, common instructions cannot be made shorter, so code tends to be larger than with variable-length encodings. The RISC-V C extension adds 16-bit instructions to offset this weakness.

  • A. Correct. The decoder becomes simpler.
  • B. Variable-length encodings, which can shorten common instructions, usually give smaller code.
  • C. A fixed number of bits limits how many instructions can be encoded.
Practice this topic Back to topic

More ISA & Assembly questions

  1. In RISC-V instructions, each register field (rd, rs1, rs2) is 5 bits wide. Why?
  2. The immediate of RISC-V addi is a 12-bit signed integer. What range can it represent?
  3. In RISC-V, what is the usual way to put a 32-bit constant that does not fit in a 12-bit immediate (e.g. 0x12345678) into a register?
  4. To build the constant 0x12345FFF in RISC-V with lui and addi, which pair is correct?
  5. What does the RISC-V auipc instruction (add upper immediate to PC) do?