Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

SRL, SRA and immediate forms

srl  rd, rs1, rs2      # logical: insert zeroes
sra  rd, rs1, rs2      # arithmetic: replicate sign bit
srli rd, rs1, shamt
srai rd, rs1, shamt

Use logical right shift for unsigned values and arithmetic right shift when you intend signed sign propagation.

x86 connection: SRL corresponds to shr; SRA corresponds to sar. RISC-V shifts do not expose the shifted-out bit through a carry flag.