The RISC-V base instruction set
The RISC-V base instruction set is composed of just 47 instructions. Eight are system instructions that perform system calls and access performance counters. The remaining 39 instructions fall into the categories of computational instructions, control flow instructions, and memory access instructions. We will examine each of these categories in turn.
Computational instructions
All the computational instructions except lui
and auipc
use the three-operand form. The first operand is the destination register, the second is a source register, and the third is either a second source register or an immediate value. Instruction mnemonics using an immediate value (except for auipc
) end with the letter i
. These are the instructions and their functions:
add
,addi
,sub
: Perform addition and subtraction. The immediate value in theaddi
instruction is a 12-bit signed value. Thesub
instruction subtracts the second source operand from the first...