[残卷]RISC-V 指令集
CALCULATE
ADD
- e.g.
ADD x1 x0 x0
meansx1 = x0 + x0
ADDI
- e.g.
ADDI x1 x0 0x11
meansx1 = x0 + 3 (DEC)
- The difference is that ADDI is used for numerical, while ADD is used for registers (or variable we can say)
- Normally, we can discover
ADDI sp sp -32
at the beginning of the program. It’s used for allocate memory for the main program.sp
is the pointer of a stack, use to record the runtime memory stack.
MEMORY
la
la
means load address- e.g.
la x1 VAL
VAL’s address is at0x100
, and it’s value is0x11
thenx1 = 0x100
- equal to
lui t0, SYMBOL[31:12]
addi t0, t0, SYMBOL[11:0]
lw
lw
means load word- e.g.
lw x2 VAL
causesx2 = 0x11
sw
sw
means save word- e.g.
sw x3 0(x1)
will causex3 = 0x11
andx3 = x2
li
li
means load immediate- e.g.
li a0 VAL
meansa0 = VAL = 0x114514
for example
the Point is that L means load, S means save. a|b|h|w|d means address, byte, half word, word or double word.
Branch
beq
beq x1 x2 Label1
meansif(x1 == x2) goto Label1
Others
AUIPC
AUIPC
means add an immediate number to pce.g.
auipc x28 65536
means