#概要
risc-vの命令セット、調べてみた。
#命令セット
命令 | 意味 |
---|---|
lui rd, imm | rd = imm << 12, pc++ |
auipc rd, imm | rd = pc + (imm << 12), pc++ |
jal rd, imm | rd = pc + 1, pc += imm |
jalr rd, rs1, imm | rd = pc + 1, pc = rs1 + imm |
beq rs1, rs2, pc + imm | if (rs1 == rs2) then pc += imm else pc++ |
bne rs1, rs2, pc + imm | if (rs1 != rs2) then pc += imm else pc++ |
blt rs1, rs2, pc + imm | if (rs1 < rs2) then pc += imm else pc++ |
bge rs1, rs2, pc + imm | if (rs1 >= rs2) then pc += imm else pc++ |
bltu rs1, rs2, pc + imm | if (rs1 < rs2) then pc += imm else pc++ |
bgeu rs1, rs2, pc + imm | if (rs1 >= rs2) then pc += imm else pc++ |
lb rd, offset(rs1) | rd = mem[rs1 + offset], pc++ |
lh rd, offset(rs1) | rd = mem[rs1 + offset], pc++ |
lw rd, offset(rs1) | rd = mem[rs1 + offset], pc++ |
lbu rd, offset(rs1) | rd = mem[rs1 + offset], pc++ |
lhu rd, offset(rs1) | rd = mem[rs1 + offset] |
sb rs2, offset(rs1) | mem[rs1 + offset] = rs2, pc++ |
sh rs2, offset(rs1) | mem[rs1 + offset] = rs2, pc++ |
sw rs2, offset(rs1) | mem[rs1 + offset] = rs2, pc++ |
addi rd, rs1, imm | rd = rs1 + imm, pc++ |
slti rd, rs1, imm | rd = (rs1 < imm) ? 1 : 0, pc++ |
sltiu rd, rs1, imm | rd = (rs1 < imm) ? 1 : 0, pc++ |
xori rd, rs1, imm | rd = rs1 ^ imm, pc++ |
ori rd, rs1, imm | rd = rs1 |imm, pc++ |
andi rd, rs1, imm | rd = rs1 & imm, pc++ |
slli rd, rs1, imm | rd = rs1 << imm, pc++ |
srli rd, rs1, imm | rd = rs1 >> imm, pc++ |
srai rd, rs1, imm | rd = rs1 >>> imm, pc++ |
add rd, rs1, rs2 | rd = rs1 + rs2, pc++ |
sub rd, rs1, rs2 | rd = rs1 - rs2, pc++ |
sll rd, rs1, rs2 | rd = rs1 << rs2, pc++ |
slt rd, rs1, rs2 | rd = (rs1 < rs2) ? 1 : 0, pc++ |
sltu rd, rs1, rs2 | rd = (rs1 < rs2) ? 1 : 0, pc++ |
xor rd, rs1, rs2 | rd = rs1 ^ rs2, pc++ |
srl rd, rs1, rs2 | rd = rs1 >> rs2, pc++ |
sra rd, rs1, rs2 | rd = rs1 >>> rs2, pc++ |
or rd, rs1, rs2 | rd = rs1 |rs2, pc++ |
and rd, rs1, rs2 | rd = rs1 & rs2, pc++ |
以上。