RISC-V Assembly Language - Instructions Size

How many bytes in an assembly language instruction in RISC-V 64-bit architecture?

In a 64-bit RISC-V architecture (RV64), a standard assembly instruction is 4 bytes (32 bits) long.

Even though the architecture uses 64-bit registers to process 64-bit data and memory addresses, the instruction encoding length remains independent of the register width.

However, the exact size can vary depending on whether specific extensions are used:

  1. Standard Instructions (Base ISA)

    • Size: 4 bytes (32 bits)

    • Behavior: All base instructions (like arithmetic, loads, stores, and branches) fit into this fixed size.

  2. Compressed Instructions (The "C" Extension)

    • Size: 2 bytes (16 bits)

    • Behavior: If the processor supports the RISC-V Compressed (C) extension (which is widely implemented to reduce code size), common instructions can be compressed into a 2-byte format.

  3. Variable-Length Instructions (Future/Custom Extensions)

    • Size: 6 bytes, 8 bytes, or longer (Multiples of 16-bits)

    • Behavior: The RISC-V specification natively supports variable-length instruction encoding. While standard extensions stick to 2 or 4 bytes, custom or future extensions can define instructions that span 48 bits, 64 bits, or more.

Links

RISC-V (Wikipedia)

RISC-V Instruction Set Explanation

RISC-V Instruction Formats