RISC-V Assembly
Read and write RISC-V assembly, from your first instruction up to functions and memory. It ships with a simulator that runs in the browser.
Open in Lux SimulatorLessons
Reference
Arithmetic
add
Add two registers together.sub
Subtract one register from another.addi
Add a small constant to a register.mul
Multiply, keeping the low 32 bits.mulh
High 32 bits of a signed product.div
Signed integer division.divu
Unsigned integer division.rem
Signed remainder (modulo).remu
Unsigned remainder.neg
Flip the sign of a number.Bitwise logic
Shifts
Compare & set
Memory
lw
Load a 32-bit word from memory.lh
Load a 16-bit halfword (signed).lb
Load one byte (signed).lhu
Load a 16-bit halfword (unsigned).lbu
Load one byte (unsigned).sw
Store a 32-bit word to memory.sh
Store the low 16 bits.sb
Store the low 8 bits.la
Load the address of a label.li
Load any constant into a register.mv
Copy one register to another.Branches
beq
Jump if two registers are equal.bne
Jump if two registers differ.blt
Jump if less than (signed).bge
Jump if greater or equal (signed).bltu
Jump if less than (unsigned).bgeu
Jump if greater or equal (unsigned).beqz
Jump if the register is zero.bnez
Jump if the register is non-zero.bgt
Jump if greater than (signed).ble
Jump if less or equal (signed).