c.srai
Shift right arithmetical immediate
- Extension
- C
- XLEN
- RV32 and RV64
- Assembly (riscv-unified-db)
c.srai xd, shamt- Length
- 16-bit (compressed)
Encoding
RV64 form
| 1513 | 12 | 1110 | 97 | 62 | 10 | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 100 | nzuimm[5] | 01 | rs1′/rs2′ | nzuimm[4:0] | 01 | ||||||||||
Match 0x8401, mask 0xec03. Source: c.srai rd_rs1_p c_nzuimm6lo c_nzuimm6hi 1..0=1 15..13=4 11..10=1 in riscv-opcodes/extensions/rv64_c.
| Field | Bits | riscv-opcodes name |
|---|---|---|
| nzuimm[5] | 12 | c_nzuimm6hi |
| rs1′/rs2′ | 9:7 | rd_rs1_p |
| nzuimm[4:0] | 6:2 | c_nzuimm6lo |
RV32 form; listed in riscv-opcodes as a pseudo-op of c.srai
| 1513 | 1210 | 97 | 62 | 10 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 100 | 001 | rs1′/rs2′ | nzuimm[4:0] | 01 | |||||||||||
Match 0x8401, mask 0xfc03. Source: $pseudo_op rv64_c::c.srai c.srai rd_rs1_p c_nzuimm5 1..0=1 15..13=4 12..10=1 in riscv-opcodes/extensions/rv32_c.
| Field | Bits | riscv-opcodes name |
|---|---|---|
| rs1′/rs2′ | 9:7 | rd_rs1_p |
| nzuimm[4:0] | 6:2 | c_nzuimm5 |
Description
Arithmetic shift (the original sign bit is copied into the vacated upper bits) the value in xd right by shamt, and store the result in xd.
The xd register index should be used as xd+8 (registers x8-x15).
C.SRAI expands into srai xd, xd, shamt.
Description from riscv-unified-db, reformatted.
Operation
# shamt is between 0-63 X[creg2reg(xd)] = X[creg2reg(xd)] >>> shamt;
Pseudocode in riscv-unified-db’s IDL, quoted unchanged.