RISC-V Reference Card
RISC-V Reference Card
1
Pseudo Instructions
Pseudoinstruction Base Instruction(s) Meaning
la rd, symbol addi rd, rd, symbol[11:0] Load address
l{b|h|w|d} rd, symbol l{b|h|w|d} rd, symbol[11:0](rd) Load global
s{b|h|w|d} rd, symbol, rt s{b|h|w|d} rd, symbol[11:0](rt) Store global
fl{w|d} rd, symbol, rt fl{w|d} rd, symbol[11:0](rt) Floating-point load global
fs{w|d} rd, symbol, rt fs{w|d} rd, symbol[11:0](rt) Floating-point store global
nop addi x0, x0, 0 No operation
li rd, immediate Myriad sequences Load immediate
mv rd, rs addi rd, rs, 0 Copy register
not rd, rs xori rd, rs, -1 One’s complement
neg rd, rs sub rd, x0, rs Two’s complement
seqz rd, rs sltiu rd, rs, 1 Set if = zero
snez rd, rs sltu rd, x0, rs Set if 6= zero
sltz rd, rs slt rd, rs, x0 Set if < zero
sgtz rd, rs slt rd, x0, rs Set if > zero
beqz rs, o↵set beq rs, x0, o↵set Branch if = zero
bnez rs, o↵set bne rs, x0, o↵set Branch if 6= zero
blez rs, o↵set bge x0, rs, o↵set Branch if zero
bgez rs, o↵set bge rs, x0, o↵set Branch if zero
bltz rs, o↵set blt rs, x0, o↵set Branch if < zero
bgtz rs, o↵set blt x0, rs, o↵set Branch if > zero
bgt rs, rt, o↵set blt rt, rs, o↵set Branch if >
ble rs, rt, o↵set bge rt, rs, o↵set Branch if
bgtu rs, rt, o↵set bltu rt, rs, o↵set Branch if >, unsigned
bleu rs, rt, o↵set bgeu rt, rs, o↵set Branch if , unsigned
j o↵set jal x0, o↵set Jump
jal o↵set jal x1, o↵set Jump and link
jr rs jalr x0, rs, 0 Jump register
jalr rs jalr x1, rs, 0 Jump and link register
ret jalr x0, x1, 0 Return from subroutine
ALU Control
ALU Control Lines Function
0000 AND
0001 OR
0010 add
0110 subtract
opcode ALUOp Operation funct7 funct3 ALU Action ALU Control Input
lw 00 load word xxxxxxx xxx add 0010
sw 00 store word xxxxxxx xxx add 0010
beq 01 branch if equal xxxxxxx xxx subtract 0110
R-Type 10 add 0000000 000 add 0010
R-Type 10 sub 0100000 000 subtract 0110
R-Type 10 and 0000000 - AND 0000
R-Type 10 or 0000000 110 OR 0001