RISC-V Assembly
Write and run RISC-V assembly in the browser. Start with a single instruction and work up to functions and memory. The assembler and simulator both run in the browser.
Lessons
Countries
Country
Brazil
Is Brazil producing chips? Brazil designs chips, from the RISC-V microcontroller BlueMacaw to research cores such as NoX, while domestic fabrication depends on foreign foundries. The state-owned fab CEITEC was dissolved by decree in 2020.
Read the entryCountryUkraine
Does Ukraine produce chips? Ukraine has no chip factory. The country is building a fabless industry that designs chips at home and has them manufactured abroad, on top of Europe's largest titanium reserves.
Read the entryReference
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.bltz
Jump if the register is negative.bgez
Jump when the register holds zero or a positive value.bgtz
Jump if the register is positive.blez
Jump when the register holds zero or a negative value.bgt
Jump if greater than (signed).ble
Jump if less or equal (signed).Jumps & functions
System
ecall
Ask the system to do something.nop
Do nothing for one instruction.ebreak
Stop the program at a breakpoint.mret
Return from a trap handler.wfi
Wait until an interrupt arrives.csrrw
Exchange the contents of a register with a control register.csrrs
Read a control register and set selected bits in it.csrrc
Read a control register and clear bits in it.csrrwi
Write a constant into a control register and read the old value.csrrsi
Read a control register and set bits from a constant.csrrci
Read a control register and clear bits from a constant.csrr
Read a control register.csrw
Write a register into a control register.csrs
Set bits in a control register.csrc
Clear bits in a control register.csrwi
Write a constant into a control register.csrsi
Set bits in a control register from a constant.csrci
Clear bits in a control register from a constant.