ISA & Assembly

The RISC-V instruction "slli t0, a0, 3" makes t0 how many times the value of a0 (ignoring overflow)?

  1. A8 times
  2. B3 times
  3. C6 times
Show answer and explanation

Answer: A. 8 times

slli (shift left logical immediate) shifts a register left by the given number of bits and fills the vacated low bits with zeros. In binary, shifting left one bit doubles a value, so three bits multiply by 2^3 = 8. Shifts are often faster than multiply instructions, so compilers replace multiplication by powers of two with shifts. They are also common when computing array element addresses.

  • A. Correct. Shifting left 3 bits multiplies by 2^3.
  • B. 3 is the shift amount, not the factor.
  • C. Each shift doubles the value, so the factors multiply.
Practice this topic Back to topic

More ISA & Assembly questions

  1. a0 holds the start address of an int (4-byte) array a, and a1 holds an index i. What does the code above load into a2?
  2. Which statement is correct about designs like x86, where an arithmetic instruction such as "add eax, [rbx]" can use a memory value directly?
  3. How do today's high-performance x86 CPUs execute complex instructions internally?
  4. What instructions does the RISC-V M extension add to the base integer instruction set?
  5. What is the main purpose of the RISC-V C extension (compressed instructions)?