sll

sll

RISC-V 汇编 参考

lyszt.net 更详细地介绍了 sll 和其他 RISC-V 指令。

编码格式

R
31–25funct7
24–20rs2
19–15rs1
14–12funct3
11–7rd
6–0opcode
I
31–20imm[11:0]
19–15rs1
14–12funct3
11–7rd
6–0opcode
S
31–25imm[11:5]
24–20rs2
19–15rs1
14–12funct3
11–7imm[4:0]
6–0opcode
B
31–25imm[12,10:5]
24–20rs2
19–15rs1
14–12funct3
11–7imm[4:1,11]
6–0opcode
U
31–12imm[31:12]
11–7rd
6–0opcode
J
31–12imm[20,10:1,11,19:12]
11–7rd
6–0opcode

描述

将寄存器的位向左移位。在 sll rd, rs1, rs2 中,rs1 中的值向左移动 rs2 低五位所保存的位数,空出的位置用零填充。移位一位会使值翻倍,越过左端的位会被丢弃。

官方定义

RISC-V Instruction Set Manual

RV32I 定义了几种算术 R 型操作。所有操作都将 rs1 and rs2 寄存器作为源操作数读取,并将结果写入寄存器 rd。funct7 and funct3 字段选择操作的类型。

SLL、SRL 和 SRA 对寄存器 rs1 中的值执行逻辑左移、逻辑右移和算术右移,移位量由寄存器 rs2 的低 5 位保存。