Learn RISC-V 64-bit (RV64)

Interactive tutorial and reference for the RV64I base ISA and extensions

What is RISC-V 64-bit (RV64)?

RISC-V is an open standard instruction set architecture (ISA) based on reduced instruction set computing (RISC) principles. RV64 is the 64-bit version, supporting 64-bit registers, addresses, and data types. It is widely used in modern processors for its simplicity, extensibility, and open ecosystem.

This tutorial covers the basics and lets you interactively explore and test your knowledge!

Instruction Formats

TypeFieldsDescription
R-typeopcode, rd, funct3, rs1, rs2, funct7Register-register operations
I-typeopcode, rd, funct3, rs1, imm[11:0]Immediate, loads, jalr, system
S-typeopcode, imm[4:0], funct3, rs1, rs2, imm[11:5]Stores
B-typeopcode, imm[11], imm[4:1], funct3, rs1, rs2, imm[10:5], imm[12]Branches
U-typeopcode, rd, imm[31:12]LUI, AUIPC
J-typeopcode, rd, imm[20|10:1|11|19:12]JAL

RV64I adds 64-bit operations and immediate fields are sign-extended to 64 bits where applicable.

Core Integer Instructions (RV64I)

NameFormatDescription
ADD, SUBRrd = rs1 + rs2 / rd = rs1 - rs2
SLL, SRL, SRARShift left/right logical/arithmetic
SLT, SLTURSet if less than (signed/unsigned)
AND, OR, XORRBitwise logic
ADDI, SLLI, SRLI, SRAIIImmediate arithmetic/shift
SLTI, SLTIUISet if less than immediate
ANDI, ORI, XORIIImmediate bitwise logic
LB/LH/LW/LWU/LDILoad byte/half/word/word unsigned/double
SB/SH/SW/SDSStore byte/half/word/double
BEQ/BNE/BLT/BGE/BLTU/BGEUBConditional branches
LUI/AUIPCULoad upper immediate / Add upper immediate to PC
JAL/JALRJ/IJump and link / Jump and link register
ECALL/EBREAKISystem call / Break
64-bit only: ADDIW, SLLIW, SRLIW, SRAIWR/IWord (32-bit) arithmetic/shift, sign-extended to 64 bits

Standard Extensions

RV64M (Multiply/Divide)

RV64A (Atomic)

RV64F/D (Floating Point)

RV64C (Compressed)

Register ABI (RV64)

RegisterABI NameDescription
x0zeroZero constant
x1raReturn address
x2spStack pointer
x3gpGlobal pointer
x4tpThread pointer
x5-x7t0-t2Temporaries
x8s0/fpSaved/frame pointer
x9s1Saved register
x10-x11a0-a1Function args/return values
x12-x17a2-a7Function args
x18-x27s2-s11Saved registers
x28-x31t3-t6Temporaries

Floating Point Registers

Quiz Yourself!

What does the ADD instruction do in RV64?
Which register is the stack pointer?
What is the difference between LD and LWU?