ISA & Assembly
The RISC-V instruction "slli t0, a0, 3" makes t0 how many times the value of a0 (ignoring overflow)?
- A8 times
- B3 times
- 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.