srai
Shift right arithmetic immediate
Shifts the second register right by an immediate amount, filling with the sign bit, and stores the result in the first.
Used in
- Arithmetic, logic and bitsRISC-V assembly
- Flappy ASMRISC-V assembly
Forms
srai , ,
Operands
t1- Any integer register,
x0tox31, or its named alias, such aszero,t0ort6. t2- An integer register. It may be the same register as
t1. imm6- An unsigned shift count or bit number:
0to63in RV64, or0to31in RV32.
This example runs on RV64.
.text
li t0, 13
# t0=13, immediate 2; srai writes 3 to t2.
srai t2, t0, 2