「嵌入式」编写第一个RISC-V程序

RARS下载及启动

方便起见,使用RARS(一款汇编器和运行时模拟器)

还有一款 在线模拟器emulsiV,简单易上手,对指令的走向更加直观,但该网站目前好像不可用了 RARS – RISC-V Assembler and Runtime Simulator。

可以下载最新的稳定版本,当前为1.6 https://github.com/TheThirdOne/rars/releases/tag/v1.6

使用Java编写,所以还需要有Java环境

启动: java -jar rars1_6.jar

编写


以 这段复制数组内容的代码为例:

#将y[]中的值copy到x[]中
.data
x:
    .byte  0
    .space 13   
y:
    .byte '0','1','2','3','4','5','6','F','a','d','f',0
    .space 13 
       
.text
strcpy:
       la a0,x
       la a1,y
       addi sp,sp,-8
       sw   s3,0(sp)
       add  s3,zero,zero
L1:    
       add  t0,s3,a1
       lbu  t1,0(t0)
       add  t2,s3,a0
       sb   t1,0(t2)
       beq  t1,zero,L2
       addi s3,s3,1
       jal  zero,L1
L2:    
       lw   s3,0(sp)
       addi sp,sp,8
       jalr zero,0(ra)

再如1到100 数字之和:

# 设置寄存器 a0 为 1
li a0, 1
# 设置寄存器 a1 为 100
li a1, 100
# 设置寄存器 t0 为 0,用于累加和
li t0, 0

# 循环开始,使用寄存器 t1 存储循环变量
addi t1, zero, 0 # t1 = 0
loop:
    add t0, t0, a0   # 累加 a0 的值到 t0
    addi a0, a0, 1   # a0 自增 1
    addi t1, t1, 1   # t1 自增 1
    bne t1, a1, loop # 如果 t1 不等于 a1 则跳转回 loop

# 程序结束,t0 中存储了 1 到 100 的和

首先使用 li 指令将 1 和 100 分别存储到寄存器 a0 和 a1 中,然后使用 li 指令将寄存器 t0 的初始值设为 0,用于累加和。
接下来进入循环,使用寄存器 t1 存储循环变量,初始值设为 0。在每次循环中,使用 add 指令将 a0 的值加到 t0 中,
然后使用 addi 指令将 a0 加 1,t1 加 1,继续下一次循环。最后使用 bne 指令判断 t1 是否等于 a1,如果不相等则跳转回循环开始处,

继续循环。如果相等则跳出循环,程序结束,t0 中存储了 1 到 100 的和。

详细使用

RISC-V一共有32个寄存器

RARS-riscv模拟器使用介绍

备份地址:

单步调试,断点运行

指令

来自 RARS 汇编模拟器支持的RISC-V指令

常用基础指令:

Example Usage

中文描述

Description

add t1,t2,t3

加法:设 t1 为(t2 加 t3)

Addition: set t1 to (t2 plus t3)

addi t1,t2,-100

加法立即数:将 t1 设置为(t2 加上带符号的 12 位立即数)

Addition immediate: set t1 to (t2 plus signed 12-bit immediate)

sub t1,t2,t3

减法:将 t1 设置为(t2 减去 t3)

Subtraction: set t1 to (t2 minus t3)

mul t1,t2,t3

乘法:将t1设为t2*t3的低32位

Multiplication: set t1 to the lower 32 bits of t2*t3

p t1,t2,t3

除法:将 t1 设置为 t2/t3 的结果

Division: set t1 to the result of t2/t3

lw t1, -100(t2)

将 t1 设置为有效内存字地址的内容

Set t1 to contents of effective memory word address

sw t1, -100(t2)

Store word:将t1的内容存入有效内存字地址

Store word : Store contents of t1 into effective memory word address

beq t1,t2,label

Branch if equal : 如果 t1 和 t2 相等则分支到标签地址处的语句

Branch if equal : Branch to statement at label’s address if t1 and t2 are equal

bne t1,t2,label

Branch if not equal : 如果 t1 和 t2 不相等则分支到标签地址处的语句

Branch if not equal : Branch to statement at label’s address if t1 and t2 are not equal

blt t1,t2,label

Branch if less than:如果 t1 小于 t2,则分支到标签地址处的语句

Branch if less than: Branch to statement at label’s address if t1 is less than t2

bge t1,t2,label

Branch if greater than or equal:如果 t1 大于或等于 t2,则分支到标签地址处的语句

Branch if greater than or equal: Branch to statement at label’s address if t1 is greater than or equal to t2


常用伪指令:

Example Usage

中文描述

Description

la t1,label

加载地址:将 t1 设置为标签的地址

Load Address : Set t1 to label’s address

li t1,-100

立即加载:将 t1 设置为 12 位立即数(符号扩展)

Load Immediate : Set t1 to 12-bit immediate (sign-extended)

li t1,10000000

立即加载:将 t1 设置为 32 位立即数

Load Immediate : Set t1 to 32-bit immediate

mv t1,t2

MoVe:将 t1 设置为 t2 的内容

MoVe : Set t1 to contents of t2

neg t1,t2

NEGate :将 t1 设置为 t2 的否定

NEGate : Set t1 to negation of t2

j label

跳转:跳转到标签处的语句

Jump : Jump to statement at label

jr t0

跳转寄存器:跳转到 t0 中的地址

Jump Register: Jump to address in t0

nop

无操作

NO OPeration

ret

返回:从子程序返回

Return: return from a subroutine


RARS 汇编模拟器支持的RISC-V指令:

Example Usage

中文描述

Description

Example Usage

add t1,t2,t3

加法:设 t1 为(t2 加 t3)

Addition: set t1 to (t2 plus t3)

add t1,t2,t3

addi t1,t2,-100

加法立即数:将 t1 设置为(t2 加上带符号的 12 位立即数)

Addition immediate: set t1 to (t2 plus signed 12-bit immediate)

addi t1,t2,-100

and t1,t2,t3

按位与:将 t1 设置为 t2 和 t3 的按位与

Bitwise AND : Set t1 to bitwise AND of t2 and t3

and t1,t2,t3

andi t1,t2,-100

按位与立即数:将 t1 设置为 t2 的按位与和符号扩展的 12 位立即数

Bitwise AND immediate : Set t1 to bitwise AND of t2 and sign-extended 12-bit immediate

andi t1,t2,-100

auipc t1,10000

将高位立即数添加到 pc:将 t1 设置为(pc 加上高位 20 位立即数)

Add upper immediate to pc: set t1 to (pc plus an upper 20-bit immediate)

auipc t1,10000

beq t1,t2,label

Branch if equal : 如果 t1 和 t2 相等则分支到标签地址处的语句

Branch if equal : Branch to statement at label’s address if t1 and t2 are equal

beq t1,t2,label

bge t1,t2,label

Branch if greater than or equal:如果 t1 大于或等于 t2,则分支到标签地址处的语句

Branch if greater than or equal: Branch to statement at label’s address if t1 is greater than or equal to t2

bge t1,t2,label

bgeu t1,t2,label

Branch if greater than or equal to (unsigned):如果 t1 大于或等于 t2,则分支到标签地址处的语句(无符号解释)

Branch if greater than or equal to (unsigned): Branch to statement at label’s address if t1 is greater than or equal to t2 (with an unsigned interpretation)

bgeu t1,t2,label

blt t1,t2,label

Branch if less than:如果 t1 小于 t2,则分支到标签地址处的语句

Branch if less than: Branch to statement at label’s address if t1 is less than t2

blt t1,t2,label

bltu t1,t2,label

Branch if less than (unsigned):如果 t1 小于 t2,则分支到标签地址处的语句(无符号解释)

Branch if less than (unsigned): Branch to statement at label’s address if t1 is less than t2 (with an unsigned interpretation)

bltu t1,t2,label

bne t1,t2,label

Branch if not equal : 如果 t1 和 t2 不相等则分支到标签地址处的语句

Branch if not equal : Branch to statement at label’s address if t1 and t2 are not equal

bne t1,t2,label

csrrc t0, fcsr, t1

原子读取/清除 CSR:从 CSR 读取到 t0 并根据 t1 清除 CSR 的位

Atomic Read/Clear CSR: read from the CSR into t0 and clear bits of the CSR according to t1

csrrc t0, fcsr, t1

csrrci t0, fcsr, 10

立即原子读取/清除 CSR:从 CSR 读取到 t0 并根据常量清除 CSR 的位

Atomic Read/Clear CSR Immediate: read from the CSR into t0 and clear bits of the CSR according to a constant

csrrci t0, fcsr, 10

csrrs t0, fcsr, t1

原子读取/设置 CSR:从 CSR 读取到 t0 并将逻辑或 t1 读取到 CSR

Atomic Read/Set CSR: read from the CSR into t0 and logical or t1 into the CSR

csrrs t0, fcsr, t1

csrrsi t0, fcsr, 10

立即原子读取/设置 CSR:从 CSR 读取到 t0 并将逻辑或常量读取到 CSR

Atomic Read/Set CSR Immediate: read from the CSR into t0 and logical or a constant into the CSR

csrrsi t0, fcsr, 10

csrrw t0, fcsr, t1

原子读/写 CSR:从 CSR 读入 t0 并将 t1 写入 CSR

Atomic Read/Write CSR: read from the CSR into t0 and write t1 into the CSR

csrrw t0, fcsr, t1

csrrwi t0, fcsr, 10

原子读/写 CSR 立即:从 CSR 读取到 t0 并将常量写入 CSR

Atomic Read/Write CSR Immediate: read from the CSR into t0 and write a constant into the CSR

csrrwi t0, fcsr, 10

p t1,t2,t3

除法:将 t1 设置为 t2/t3 的结果

Division: set t1 to the result of t2/t3

p t1,t2,t3

pu t1,t2,t3

除法:使用无符号除法将 t1 设置为 t2/t3 的结果

Division: set t1 to the result of t2/t3 using unsigned pision

pu t1,t2,t3

ebreak

暂停执行

Pause execution

ebreak

ecall

发出系统调用:执行a7中值指定的系统调用

Issue a system call : Execute the system call specified by value in a7

ecall

fadd.d f1, f2, f3, dyn

浮动 ADD(64 位):将 f1 分配给 f2 + f3

Floating ADD (64 bit): assigns f1 to f2 + f3

fadd.d f1, f2, f3, dyn

fadd.s f1, f2, f3, dyn

浮动 ADD:将 f1 分配给 f2 + f3

Floating ADD: assigns f1 to f2 + f3

fadd.s f1, f2, f3, dyn

fclass.d t1, f1

对一个浮点数(64位)进行分类

Classify a floating point number (64 bit)

fclass.d t1, f1

fclass.s t1, f1

对一个浮点数进行分类

Classify a floating point number

fclass.s t1, f1

fcvt.d.s t1, f1, dyn

将 float 转换为 double:将 f2 的值分配给 f1

Convert a float to a double: Assigned the value of f2 to f1

fcvt.d.s t1, f1, dyn

fcvt.d.w f1, t1, dyn

从整数转换为双精度:将 t1 的值赋给 f1

Convert double from integer: Assigns the value of t1 to f1

fcvt.d.w f1, t1, dyn

fcvt.d.wu f1, t1, dyn

从无符号整数转换双精度数:将 t1 的值赋给 f1

Convert double from unsigned integer: Assigns the value of t1 to f1

fcvt.d.wu f1, t1, dyn

fcvt.s.d t1, f1, dyn

将双精度型转换为浮点型:将 f2 的值分配给 f1

Convert a double to a float: Assigned the value of f2 to f1

fcvt.s.d t1, f1, dyn

fcvt.s.w f1, t1, dyn

从整数转换为浮点数:将 t1 的值赋给 f1

Convert float from integer: Assigns the value of t1 to f1

fcvt.s.w f1, t1, dyn

fcvt.s.wu f1, t1, dyn

从无符号整数转换浮点数:将 t1 的值赋给 f1

Convert float from unsigned integer: Assigns the value of t1 to f1

fcvt.s.wu f1, t1, dyn

fcvt.w.d t1, f1, dyn

从双精度转换整数:将 f1 的值(四舍五入)分配给 t1

Convert integer from double: Assigns the value of f1 (rounded) to t1

fcvt.w.d t1, f1, dyn

fcvt.w.s t1, f1, dyn

从浮点数转换整数:将 f1 的值(四舍五入)赋值给 t1

Convert integer from float: Assigns the value of f1 (rounded) to t1

fcvt.w.s t1, f1, dyn

fcvt.wu.d t1, f1, dyn

从 double 转换未签名的整数:将 f1 的值(四舍五入)分配给 t1

Convert unsinged integer from double: Assigns the value of f1 (rounded) to t1

fcvt.wu.d t1, f1, dyn

fcvt.wu.s t1, f1, dyn

将浮点数转换为无符号整数:将 f1 的值(四舍五入)赋值给 t1

Convert unsinged integer from float: Assigns the value of f1 (rounded) to t1

fcvt.wu.s t1, f1, dyn

fp.d f1, f2, f3, dyn

浮动 DIVide(64 位):将 f1 分配给 f2 / f3

Floating DIVide (64 bit): assigns f1 to f2 / f3

fp.d f1, f2, f3, dyn

fp.s f1, f2, f3, dyn

浮动 DIVide:将 f1 分配给 f2 / f3

Floating DIVide: assigns f1 to f2 / f3

fp.s f1, f2, f3, dyn

fence 1, 1

确保围栏之前的 IO 和内存访问发生在不同线程查看的以下 IO 和内存访问之前

Ensure that IO and memory accesses before the fence happen before the following IO and memory accesses as viewed by a different thread

fence 1, 1

fence.i

确保指令存储器的存储对指令提取可见

Ensure that stores to instruction memory are visible to instruction fetches

fence.i

feq.d t1, f1, f2

Floating EQuals(64 位):如果 f1 = f2,则将 t1 设置为 1,否则将 t1 设置为 0

Floating EQuals (64 bit): if f1 = f2, set t1 to 1, else set t1 to 0

feq.d t1, f1, f2

feq.s t1, f1, f2

浮动相等:如果 f1 = f2,则将 t1 设置为 1,否则将 t1 设置为 0

Floating EQuals: if f1 = f2, set t1 to 1, else set t1 to 0

feq.s t1, f1, f2

fld f1, -100(t1)

从内存中加载一个 double

Load a double from memory

fld f1, -100(t1)

fle.d t1, f1, f2

小于或等于浮动(64 位):如果 f1 <= f2,则将 t1 设置为 1,否则将 t1 设置为 0

Floating Less than or Equals (64 bit): if f1 <= f2, set t1 to 1, else set t1 to 0

fle.d t1, f1, f2

fle.s t1, f1, f2

浮动小于或等于:如果 f1 <= f2,则将 t1 设置为 1,否则将 t1 设置为 0

Floating Less than or Equals: if f1 <= f2, set t1 to 1, else set t1 to 0

fle.s t1, f1, f2

flt.d t1, f1, f2

小于浮动(64 位):如果 f1 < f2,则将 t1 设置为 1,否则将 t1 设置为 0

Floating Less Than (64 bit): if f1 < f2, set t1 to 1, else set t1 to 0

flt.d t1, f1, f2

flt.s t1, f1, f2

浮动小于:如果 f1 < f2,则将 t1 设置为 1,否则将 t1 设置为 0

Floating Less Than: if f1 < f2, set t1 to 1, else set t1 to 0

flt.s t1, f1, f2

flw f1, -100(t1)

从内存中加载一个浮点数

Load a float from memory

flw f1, -100(t1)

fmadd.d f1, f2, f3, f4, dyn

融合乘加(64 位):将 f2*f3+f4 分配给 f1

Fused Multiply Add (64 bit): Assigns f2*f3+f4 to f1

fmadd.d f1, f2, f3, f4, dyn

fmadd.s f1, f2, f3, f4, dyn

融合乘加:将 f2*f3+f4 分配给 f1

Fused Multiply Add: Assigns f2*f3+f4 to f1

fmadd.s f1, f2, f3, f4, dyn

fmax.d f1, f2, f3

Floating MAXimum(64 位):将 f1 分配给 f1 和 f3 中的较大者

Floating MAXimum (64 bit): assigns f1 to the larger of f1 and f3

fmax.d f1, f2, f3

fmax.s f1, f2, f3

Floating MAXimum:将 f1 分配给 f1 和 f3 中的较大者

Floating MAXimum: assigns f1 to the larger of f1 and f3

fmax.s f1, f2, f3

fmin.d f1, f2, f3

Floating MINimum(64 位):将 f1 分配给 f1 和 f3 中的较小者

Floating MINimum (64 bit): assigns f1 to the smaller of f1 and f3

fmin.d f1, f2, f3

fmin.s f1, f2, f3

Floating MINimum:将 f1 分配给 f1 和 f3 中较小的一个

Floating MINimum: assigns f1 to the smaller of f1 and f3

fmin.s f1, f2, f3

fmsub.d f1, f2, f3, f4, dyn

融合乘子:将 f2*f3-f4 分配给 f1

Fused Multiply Subatract: Assigns f2*f3-f4 to f1

fmsub.d f1, f2, f3, f4, dyn

fmsub.s f1, f2, f3, f4, dyn

融合乘子:将 f2*f3-f4 分配给 f1

Fused Multiply Subatract: Assigns f2*f3-f4 to f1

fmsub.s f1, f2, f3, f4, dyn

fmul.d f1, f2, f3, dyn

Floating MULtiply(64 位):将 f1 分配给 f2 * f3

Floating MULtiply (64 bit): assigns f1 to f2 * f3

fmul.d f1, f2, f3, dyn

fmul.s f1, f2, f3, dyn

Floating MULtiply:将 f1 分配给 f2 * f3

Floating MULtiply: assigns f1 to f2 * f3

fmul.s f1, f2, f3, dyn

fmv.s.x f1, t1

移动浮点数:从整数寄存器中移动表示浮点数的位

Move float: move bits representing a float from an integer register

fmv.s.x f1, t1

fmv.x.s t1, f1

移动浮点数:将表示浮点数的位移动到整数寄存器

Move float: move bits representing a float to an integer register

fmv.x.s t1, f1

fnmadd.d f1, f2, f3, f4, dyn

Fused Negate Multiply Add(64 位):将 -(f2*f3+f4) 分配给 f1

Fused Negate Multiply Add (64 bit): Assigns -(f2*f3+f4) to f1

fnmadd.d f1, f2, f3, f4, dyn

fnmadd.s f1, f2, f3, f4, dyn

Fused Negate Multiply Add:将 -(f2*f3+f4) 分配给 f1

Fused Negate Multiply Add: Assigns -(f2*f3+f4) to f1

fnmadd.s f1, f2, f3, f4, dyn

fnmsub.d f1, f2, f3, f4, dyn

融合取反乘法减法:将 -(f2*f3-f4) 赋值给 f1

Fused Negated Multiply Subatract: Assigns -(f2*f3-f4) to f1

fnmsub.d f1, f2, f3, f4, dyn

fnmsub.s f1, f2, f3, f4, dyn

融合取反乘法减法:将 -(f2*f3-f4) 赋值给 f1

Fused Negated Multiply Subatract: Assigns -(f2*f3-f4) to f1

fnmsub.s f1, f2, f3, f4, dyn

fsd f1, -100(t1)

将双精度存储到内存

Store a double to memory

fsd f1, -100(t1)

fsgnj.d f1, f2, f3

浮点符号注入(64位):将f2的符号位替换为f3的符号位赋值给f1

Floating point sign injection (64 bit): replace the sign bit of f2 with the sign bit of f3 and assign it to f1

fsgnj.d f1, f2, f3

fsgnj.s f1, f2, f3

浮点符号注入:将f2的符号位替换为f3的符号位赋值给f1

Floating point sign injection: replace the sign bit of f2 with the sign bit of f3 and assign it to f1

fsgnj.s f1, f2, f3

fsgnjn.d f1, f2, f3

浮点符号注入(反转64位):将f2的符号位替换为f3的相反符号位赋值给f1

Floating point sign injection (inverted 64 bit): replace the sign bit of f2 with the opposite of sign bit of f3 and assign it to f1

fsgnjn.d f1, f2, f3

fsgnjn.s f1, f2, f3

浮点符号注入(倒置):将f2的符号位替换为f3的相反符号位赋值给f1

Floating point sign injection (inverted): replace the sign bit of f2 with the opposite of sign bit of f3 and assign it to f1

fsgnjn.s f1, f2, f3

fsgnjx.d f1, f2, f3

浮点符号注入(xor 64 bit):将f2的符号位与f3的符号位异或赋值给f1

Floating point sign injection (xor 64 bit): xor the sign bit of f2 with the sign bit of f3 and assign it to f1

fsgnjx.d f1, f2, f3

fsgnjx.s f1, f2, f3

浮点符号注入(xor):将f2的符号位与f3的符号位异或赋值给f1

Floating point sign injection (xor): xor the sign bit of f2 with the sign bit of f3 and assign it to f1

fsgnjx.s f1, f2, f3

fsqrt.d f1, f2, dyn

浮动平方根(64 位):将 f1 分配给 f2 的平方根

Floating SQuare RooT (64 bit): Assigns f1 to the square root of f2

fsqrt.d f1, f2, dyn

fsqrt.s f1, f2, dyn

浮动平方根:将 f1 分配给 f2 的平方根

Floating SQuare RooT: Assigns f1 to the square root of f2

fsqrt.s f1, f2, dyn

fsub.d f1, f2, f3, dyn

浮动减法(64 位):将 f1 分配给 f2 - f3

Floating SUBtract (64 bit): assigns f1 to f2 - f3

fsub.d f1, f2, f3, dyn

fsub.s f1, f2, f3, dyn

浮动减法:将 f1 分配给 f2 - f3

Floating SUBtract: assigns f1 to f2 - f3

fsub.s f1, f2, f3, dyn

fsw f1, -100(t1)

将浮点数存储到内存中

Store a float to memory

fsw f1, -100(t1)

jal t1, target

跳转和链接:将 t1 设置为程序计数器(返回地址),然后跳转到目标地址处的语句

Jump and link : Set t1 to Program Counter (return address) then jump to statement at target address

jal t1, target

jalr t1, t2, -100

跳转和链接寄存器:将 t1 设置为程序计数器(返回地址),然后跳转到 t2 + 立即数处的语句

Jump and link register: Set t1 to Program Counter (return address) then jump to statement at t2 + immediate

jalr t1, t2, -100

lb t1, -100(t2)

将 t1 设置为有效内存字节地址的符号扩展 8 位值

Set t1 to sign-extended 8-bit value from effective memory byte address

lb t1, -100(t2)

lbu t1, -100(t2)

将 t1 设置为从有效内存字节地址开始的零扩展 8 位值

Set t1 to zero-extended 8-bit value from effective memory byte address

lbu t1, -100(t2)

lh t1, -100(t2)

将 t1 设置为有效内存半字地址的符号扩展 16 位值

Set t1 to sign-extended 16-bit value from effective memory halfword address

lh t1, -100(t2)

lhu t1, -100(t2)

将 t1 设置为有效内存半字地址的零扩展 16 位值

Set t1 to zero-extended 16-bit value from effective memory halfword address

lhu t1, -100(t2)

lui t1,10000

加载高立即数:将 t1 设置为 20 位后跟 12 个 0

Load upper immediate: set t1 to 20-bit followed by 12 0s

lui t1,10000

lw t1, -100(t2)

将 t1 设置为有效内存字地址的内容

Set t1 to contents of effective memory word address

lw t1, -100(t2)

mul t1,t2,t3

乘法:将t1设为t2*t3的低32位

Multiplication: set t1 to the lower 32 bits of t2*t3

mul t1,t2,t3

mulh t1,t2,t3

乘法:使用有符号乘法将 t1 设置为 t2*t3 的高 32 位

Multiplication: set t1 to the upper 32 bits of t2*t3 using signed multiplication

mulh t1,t2,t3

mulhsu t1,t2,t3

乘法:将 t1 设置为 t2*t3 的高 32 位,其中 t2 是有符号的,t3 是无符号的

Multiplication: set t1 to the upper 32 bits of t2*t3 where t2 is signed and t3 is unsigned

mulhsu t1,t2,t3

mulhu t1,t2,t3

乘法:使用无符号乘法将 t1 设置为 t2*t3 的高 32 位

Multiplication: set t1 to the upper 32 bits of t2*t3 using unsigned multiplication

mulhu t1,t2,t3

or t1,t2,t3

按位或:将 t1 设置为 t2 和 t3 的按位或

Bitwise OR : Set t1 to bitwise OR of t2 and t3

or t1,t2,t3

ori t1,t2,-100

按位或立即数:将 t1 设置为 t2 和符号扩展的 12 位立即数的按位或

Bitwise OR immediate : Set t1 to bitwise OR of t2 and sign-extended 12-bit immediate

ori t1,t2,-100

rem t1,t2,t3

余数:将 t1 设置为 t2/t3 的余数

Remainder: set t1 to the remainder of t2/t3

rem t1,t2,t3

remu t1,t2,t3

余数:使用无符号除法将 t1 设置为 t2/t3 的余数

Remainder: set t1 to the remainder of t2/t3 using unsigned pision

remu t1,t2,t3

sb t1, -100(t2)

Store byte : 将t1的低8位存入有效内存字节地址

Store byte : Store the low-order 8 bits of t1 into the effective memory byte address

sb t1, -100(t2)

sh t1, -100(t2)

Store halfword : 将t1的低16位存入有效内存半字地址

Store halfword : Store the low-order 16 bits of t1 into the effective memory halfword address

sh t1, -100(t2)

sll t1,t2,t3

左移逻辑:将 t1 设置为将 t2 左移 t3 的低 5 位中的值指定的位数的结果

Shift left logical: Set t1 to result of shifting t2 left by number of bits specified by value in low-order 5 bits of t3

sll t1,t2,t3

slli t1,t2,10

左移逻辑:将 t1 设置为将 t2 左移 immediate 指定的位数的结果

Shift left logical : Set t1 to result of shifting t2 left by number of bits specified by immediate

slli t1,t2,10

slt t1,t2,t3

设置小于:如果 t2 小于 t3,则将 t1 设置为 1,否则将 t1 设置为 0

Set less than : If t2 is less than t3, then set t1 to 1 else set t1 to 0

slt t1,t2,t3

slti t1,t2,-100

设置小于立即数:如果 t2 小于符号扩展的 12 位立即数,则将 t1 设置为 1,否则将 t1 设置为 0

Set less than immediate : If t2 is less than sign-extended 12-bit immediate, then set t1 to 1 else set t1 to 0

slti t1,t2,-100

sltiu t1,t2,-100

设置小于无符号立即数:如果 t2 小于使用无符号比较进行符号扩展的 16 位立即数,则将 t1 设置为 1,否则将 t1 设置为 0

Set less than immediate unsigned : If t2 is less than sign-extended 16-bit immediate using unsigned comparison, then set t1 to 1 else set t1 to 0

sltiu t1,t2,-100

sltu t1,t2,t3

设置小于:如果使用无符号比较 t2 小于 t3,则将 t1 设置为 1,否则将 t1 设置为 0

Set less than : If t2 is less than t3 using unsigned comparision, then set t1 to 1 else set t1 to 0

sltu t1,t2,t3

sra t1,t2,t3

右移算法:将 t1 设置为将 t2 符号扩展右移的结果,其位数由 t3 的低 5 位中的值指定

Shift right arithmetic: Set t1 to result of sign-extended shifting t2 right by number of bits specified by value in low-order 5 bits of t3

sra t1,t2,t3

srai t1,t2,10

右移算术:将 t1 设置为将 t2 符号扩展右移立即数指定的位数的结果

Shift right arithmetic : Set t1 to result of sign-extended shifting t2 right by number of bits specified by immediate

srai t1,t2,10

srl t1,t2,t3

右移逻辑:将 t1 设置为将 t2 右移 t3 的低 5 位中的值指定的位数的结果

Shift right logical: Set t1 to result of shifting t2 right by number of bits specified by value in low-order 5 bits of t3

srl t1,t2,t3

srli t1,t2,10

右移逻辑:将 t1 设置为将 t2 右移 immediate 指定的位数的结果

Shift right logical : Set t1 to result of shifting t2 right by number of bits specified by immediate

srli t1,t2,10

sub t1,t2,t3

减法:将 t1 设置为(t2 减去 t3)

Subtraction: set t1 to (t2 minus t3)

sub t1,t2,t3

sw t1, -100(t2)

Store word:将t1的内容存入有效内存字地址

Store word : Store contents of t1 into effective memory word address

sw t1, -100(t2)

uret

从处理中断或异常返回(到 uepc)

Return from handling an interrupt or exception (to uepc)

uret

wfi

等待中断

Wait for Interrupt

wfi

xor t1,t2,t3

按位异或:将 t1 设置为 t2 和 t3 的按位异或

Bitwise XOR : Set t1 to bitwise XOR of t2 and t3

xor t1,t2,t3

xori t1,t2,-100

按位异或立即数:将 t1 设置为 t2 和符号扩展的 12 位立即数的按位异或

Bitwise XOR immediate : Set t1 to bitwise XOR of t2 and sign-extended 12-bit immediate

xori t1,t2,-100

Supported psuedo-instructions (支持的伪指令)

Supported psuedo-instructions (支持的伪指令)

Supported psuedo-instructions (支持的伪指令)

Supported psuedo-instructions (支持的伪指令)

Example Usage

中文描述

Description

Example Usage

addi t1,t2,%lo(label)

Load Lower Address : 设置 t1 到 t2 + 低 12 位标签地址

Load Lower Address : Set t1 to t2 + lower 12-bit label’s address

addi t1,t2,%lo(label)

b label

Branch : 无条件分支到标签处的语句

Branch : Branch to statement at label unconditionally

b label

beqz t1,label

Branch if EQual Zero :如果 t1 == 0 则分支到标签处的语句

Branch if EQual Zero : Branch to statement at label if t1 == 0

beqz t1,label

bgez t1,label

Branch if Greater than or Equal to Zero :如果 t1 >= 0,则分支到标签处的语句

Branch if Greater than or Equal to Zero : Branch to statement at label if t1 >= 0

bgez t1,label

bgt t1,t2,label

Branch if Greater Than :如果 t1 > t2 则分支到标签处的语句

Branch if Greater Than : Branch to statement at label if t1 > t2

bgt t1,t2,label

bgtu t1,t2,label

Branch if Greater Than Unsigned:如果 t1 > t2(无符号比较)则分支到标签处的语句

Branch if Greater Than Unsigned: Branch to statement at label if t1 > t2 (unsigned compare)

bgtu t1,t2,label

bgtz t1,label

Branch if Greater Than:如果 t1 > 0,则分支到标签处的语句

Branch if Greater Than: Branch to statement at label if t1 > 0

bgtz t1,label

ble t1,t2,label

Branch if Less or Equal :如果 t1 <= t2 则分支到标签处的语句

Branch if Less or Equal : Branch to statement at label if t1 <= t2

ble t1,t2,label

bleu t1,t2,label

Branch if Less or Equal Unsigned:如果 t1 <= t2(无符号比较),则分支到标签处的语句

Branch if Less or Equal Unsigned : Branch to statement at label if t1 <= t2 (unsigned compare)

bleu t1,t2,label

blez t1,label

Branch if Less than or Equal to Zero:如果 t1 <= 0,则分支到标签处的语句

Branch if Less than or Equal to Zero : Branch to statement at label if t1 <= 0

blez t1,label

bltz t1,label

如果小于零则分支:如果 t1 < 0,则分支到标签处的语句

Branch if Less Than Zero : Branch to statement at label if t1 < 0

bltz t1,label

bnez t1,label

Branch if Not Equal Zero:如果 t1 != 0,则分支到标签处的语句

Branch if Not Equal Zero : Branch to statement at label if t1 != 0

bnez t1,label

call label

CALL:调用远处的子程序

CALL: call a far-away subroutine

call label

csrc t1, fcsr

清除控制和状态寄存器中的位

Clear bits in control and status register

csrc t1, fcsr

csrci fcsr, 100

清除控制和状态寄存器中的位

Clear bits in control and status register

csrci fcsr, 100

csrr t1, fcsr

读取控制和状态寄存器

Read control and status register

csrr t1, fcsr

csrs t1, fcsr

设置控制和状态寄存器中的位

Set bits in control and status register

csrs t1, fcsr

csrsi fcsr, 100

设置控制和状态寄存器中的位

Set bits in control and status register

csrsi fcsr, 100

csrw t1, fcsr

写控制和状态寄存器

Write control and status register

csrw t1, fcsr

csrwi fcsr, 100

写控制和状态寄存器

Write control and status register

csrwi fcsr, 100

fabs.d f1, f2

将 f1 设置为 f2 的绝对值(64 位)

Set f1 to the absolute value of f2 (64 bit)

fabs.d f1, f2

fabs.s f1, f2

将 f1 设置为 f2 的绝对值

Set f1 to the absolute value of f2

fabs.s f1, f2

fadd.d f1, f2, f3

浮动 ADD(64 位):将 f1 分配给 f2 + f3

Floating ADD (64 bit): assigns f1 to f2 + f3

fadd.d f1, f2, f3

fadd.s f1, f2, f3

浮动 ADD:将 f1 分配给 f2 + f3

Floating ADD: assigns f1 to f2 + f3

fadd.s f1, f2, f3

fcvt.d.s f1, f2

将float转为double:将f2的值赋值给f1

Convert float to double: Assigned the value of f2 to f1

fcvt.d.s f1, f2

fcvt.d.w f1, t1

从有符号整数转换双精度数:将 t1 的值赋给 f1

Convert double from signed integer: Assigns the value of t1 to f1

fcvt.d.w f1, t1

fcvt.d.wu f1, t1

从无符号整数转换双精度数:将 t1 的值赋给 f1

Convert double from unsigned integer: Assigns the value of t1 to f1

fcvt.d.wu f1, t1

fcvt.s.d f1, f2

double转float:将f2的值赋值给f1

Convert double to float: Assigned the value of f2 to f1

fcvt.s.d f1, f2

fcvt.s.w f1, t1

从有符号整数转换浮点数:将 t1 的值赋给 f1

Convert float from signed integer: Assigns the value of t1 to f1

fcvt.s.w f1, t1

fcvt.s.wu f1, t1

从无符号整数转换浮点数:将 t1 的值赋给 f1

Convert float from unsigned integer: Assigns the value of t1 to f1

fcvt.s.wu f1, t1

fcvt.w.d t1, f1

从双精度转换有符号整数:将 f1 的值(四舍五入)分配给 t1

Convert signed integer from double: Assigns the value of f1 (rounded) to t1

fcvt.w.d t1, f1

fcvt.w.s t1, f1

从浮点数转换有符号整数:将 f1 的值(四舍五入)赋值给 t1

Convert signed integer from float: Assigns the value of f1 (rounded) to t1

fcvt.w.s t1, f1

fcvt.wu.d t1, f1

从双精度转换无符号整数:将 f1 的值(四舍五入)分配给 t1

Convert unsigned integer from double: Assigns the value of f1 (rounded) to t1

fcvt.wu.d t1, f1

fcvt.wu.s t1, f1

从浮点数转换无符号整数:将 f1 的值(四舍五入)赋值给 t1

Convert unsigned integer from float: Assigns the value of f1 (rounded) to t1

fcvt.wu.s t1, f1

fp.d f1, f2, f3

浮动 DIVide(64 位):将 f1 分配给 f2 / f3

Floating DIVide (64 bit): assigns f1 to f2 / f3

fp.d f1, f2, f3

fp.s f1, f2, f3

浮动 DIVide:将 f1 分配给 f2 / f3

Floating DIVide: assigns f1 to f2 / f3

fp.s f1, f2, f3

fge.d t1, f2, f3

浮动大于或等于(64 位):如果 f1 >= f2,则将 t1 设置为 1,否则将 t1 设置为 0

Floating Greater Than or Equal (64 bit): if f1 >= f2, set t1 to 1, else set t1 to 0

fge.d t1, f2, f3

fge.s t1, f2, f3

浮动大于或等于:如果 f1 >= f2,则将 t1 设置为 1,否则将 t1 设置为 0

Floating Greater Than or Equal: if f1 >= f2, set t1 to 1, else set t1 to 0

fge.s t1, f2, f3

fgt.d t1, f2, f3

浮动大于(64 位):如果 f1 > f2,则将 t1 设置为 1,否则将 t1 设置为 0

Floating Greater Than (64 bit): if f1 > f2, set t1 to 1, else set t1 to 0

fgt.d t1, f2, f3

fgt.s t1, f2, f3

浮动大于:如果 f1 > f2,则将 t1 设置为 1,否则将 t1 设置为 0

Floating Greater Than: if f1 > f2, set t1 to 1, else set t1 to 0

fgt.s t1, f2, f3

fld f1,(t2)

Load Word:将f1设置为从有效内存字地址开始的64位值

Load Word: Set f1 to 64-bit value from effective memory word address

fld f1,(t2)

fld f1,-100

Load Word:将f1设置为从有效内存字地址开始的64位值

Load Word: Set f1 to 64-bit value from effective memory word address

fld f1,-100

fld f1,10000000,t3

Load Word:使用 t3 作为临时地址,将 f1 设置为有效内存字地址的 64 位值

Load Word: Set f1 to 64-bit value from effective memory word address using t3 as a temporary

fld f1,10000000,t3

fld f1,label, t3

Load Word:使用 t3 作为临时地址,将 f1 设置为有效内存字地址的 64 位值

Load Word: Set f1 to 64-bit value from effective memory word address using t3 as a temporary

fld f1,label, t3

flw f1,%lo(label)(t2)

从地址加载

Load from Address

flw f1,%lo(label)(t2)

flw f1,(t2)

加载字协处理器 1:将 f1 设置为有效内存字地址的 32 位值

Load Word Coprocessor 1 : Set f1 to 32-bit value from effective memory word address

flw f1,(t2)

flw f1,-100

加载字协处理器 1:将 f1 设置为有效内存字地址的 32 位值

Load Word Coprocessor 1 : Set f1 to 32-bit value from effective memory word address

flw f1,-100

flw f1,10000000,t3

加载字协处理器 1:使用 t3 作为临时地址,将 f1 设置为有效内存字地址的 32 位值

Load Word Coprocessor 1 : Set f1 to 32-bit value from effective memory word address using t3 as a temporary

flw f1,10000000,t3

flw f1,label, t3

加载字协处理器 1:使用 t3 作为临时地址,将 f1 设置为有效内存字地址的 32 位值

Load Word Coprocessor 1 : Set f1 to 32-bit value from effective memory word address using t3 as a temporary

flw f1,label, t3

flwd f1,%lo(label)(t2)

从地址加载

Load from Address

flwd f1,%lo(label)(t2)

fmadd.d f1, f2, f3, f4

融合乘加(64 位):将 f2*f3+f4 分配给 f1

Fused Multiply Add (64 bit): Assigns f2*f3+f4 to f1

fmadd.d f1, f2, f3, f4

fmadd.s f1, f2, f3, f4

融合乘加:将 f2*f3+f4 分配给 f1

Fused Multiply Add: Assigns f2*f3+f4 to f1

fmadd.s f1, f2, f3, f4

fmsub.d f1, f2, f3, f4

融合乘法减法(64 位):将 f2*f3-f4 分配给 f1

Fused Multiply Subatract (64 bit): Assigns f2*f3-f4 to f1

fmsub.d f1, f2, f3, f4

fmsub.s f1, f2, f3, f4

融合乘子:将 f2*f3-f4 分配给 f1

Fused Multiply Subatract: Assigns f2*f3-f4 to f1

fmsub.s f1, f2, f3, f4

fmul.d f1, f2, f3

Floating MULtiply(64 位):将 f1 分配给 f2 * f3

Floating MULtiply (64 bit): assigns f1 to f2 * f3

fmul.d f1, f2, f3

fmul.s f1, f2, f3

Floating MULtiply:将 f1 分配给 f2 * f3

Floating MULtiply: assigns f1 to f2 * f3

fmul.s f1, f2, f3

fmv.d f1, f2

将 f2 的值移动到 f1(64 位)

Move the value of f2 to f1 (64 bit)

fmv.d f1, f2

fmv.s f1, f2

将 f2 的值移动到 f1

Move the value of f2 to f1

fmv.s f1, f2

fmv.w.x t1, f1

移动浮点数(新助记符):从整数寄存器中移动表示浮点数的位

Move float (New mnemonic): move bits representing a float from an integer register

fmv.w.x t1, f1

fmv.x.w t1, f1

移动浮点数(新助记符):将表示浮点数的位移动到整数寄存器

Move float (New mnemonic): move bits representing a float to an integer register

fmv.x.w t1, f1

fneg.d f1, f2

将 f1 设置为 f2 的否定(64 位)

Set f1 to the negation of f2 (64 bit)

fneg.d f1, f2

fneg.s f1, f2

将 f1 设置为 f2 的否定

Set f1 to the negation of f2

fneg.s f1, f2

fnmadd.d f1, f2, f3, f4

Fused Negate Multiply Add(64 位):将 -(f2*f3+f4) 分配给 f1

Fused Negate Multiply Add (64 bit): Assigns -(f2*f3+f4) to f1

fnmadd.d f1, f2, f3, f4

fnmadd.s f1, f2, f3, f4

Fused Negate Multiply Add:将 -(f2*f3+f4) 分配给 f1

Fused Negate Multiply Add: Assigns -(f2*f3+f4) to f1

fnmadd.s f1, f2, f3, f4

fnmsub.d f1, f2, f3, f4

融合取反乘法减法(64 位):将 -(f2*f3-f4) 分配给 f1

Fused Negated Multiply Subatract (64 bit): Assigns -(f2*f3-f4) to f1

fnmsub.d f1, f2, f3, f4

fnmsub.s f1, f2, f3, f4

融合取反乘法减法:将 -(f2*f3-f4) 赋值给 f1

Fused Negated Multiply Subatract: Assigns -(f2*f3-f4) to f1

fnmsub.s f1, f2, f3, f4

frcsr t1

读取 FP 控制/状态寄存器

Read FP control/status register

frcsr t1

frflags t1

读取 FP 异常标志

Read FP exception flags

frflags t1

frrm t1

读取 FP 舍入模式

Read FP rounding mode

frrm t1

frsr t1

frcsr t1 的别名

Alias for frcsr t1

frsr t1

fscsr t1

写 FP 控制/状态寄存器

Write FP control/status register

fscsr t1

fscsr t1, t2

交换 FP 控制/状态寄存器

Swap FP control/status register

fscsr t1, t2

fsd f1,(t2)

Store Word:将f1中的64位值存储到有效内存字地址

Store Word: Store 64-bit value from f1 to effective memory word address

fsd f1,(t2)

fsd f1,-100

Store Word:将f1中的64位值存储到有效内存字地址

Store Word: Store 64-bit value from f1 to effective memory word address

fsd f1,-100

fsd f1,10000000,t3

Store Word:将64位值从f1存储到有效内存字地址,使用t3作为临时地址

Store Word: Store 64-bit value from f1 to effective memory word address using t3 as a temporary

fsd f1,10000000,t3

fsd f1,label, t3

Store Word:将64位值从f1存储到有效内存字地址,使用t3作为临时地址

Store Word: Store 64-bit value from f1 to effective memory word address using t3 as a temporary

fsd f1,label, t3

fsflags t1

写入 FP 异常标志

Write FP exception flags

fsflags t1

fsflags t1, t2

交换 FP 异常标志

Swap FP exception flags

fsflags t1, t2

fsflagsi 100

立即写入 FP 异常标志

Write FP exception flags, immediate

fsflagsi 100

fsflagsi t1, 100

立即交换 FP 异常标志

Swap FP exception flags, immediate

fsflagsi t1, 100

fsqrt.d f1, f2

浮动平方根(64 位):将 f1 分配给 f2 的平方根

Floating SQuare RooT (64 bit): Assigns f1 to the square root of f2

fsqrt.d f1, f2

fsqrt.s f1, f2

浮动平方根:将 f1 分配给 f2 的平方根

Floating SQuare RooT: Assigns f1 to the square root of f2

fsqrt.s f1, f2

fsrm t1

写入 FP 舍入模式

Write FP rounding mode

fsrm t1

fsrm t1, t2

交换 FP 舍入模式

Swap FP rounding mode

fsrm t1, t2

fsrmi 100

写入 FP 舍入模式,立即数

Write FP rounding mode, immediate

fsrmi 100

fsrmi t1, 100

交换 FP 舍入模式,立即数

Swap FP rounding mode, immediate

fsrmi t1, 100

fssr t1

fscsr t1 的别名

Alias for fscsr t1

fssr t1

fssr t1, t2

fscsr t1、t2 的别名

Alias for fscsr t1, t2

fssr t1, t2

fsub.d f1, f2, f3

浮动减法(64 位):将 f1 分配给 f2 - f3

Floating SUBtract (64 bit): assigns f1 to f2 - f3

fsub.d f1, f2, f3

fsub.s f1, f2, f3

浮动减法:将 f1 分配给 f2 - f3

Floating SUBtract: assigns f1 to f2 - f3

fsub.s f1, f2, f3

fsw f1,(t2)

Store Word Coprocessor 1 : 将 f1 的 32 位值存储到有效内存字地址

Store Word Coprocessor 1 : Store 32-bit value from f1 to effective memory word address

fsw f1,(t2)

fsw f1,-100

Store Word Coprocessor 1 : 将 f1 的 32 位值存储到有效内存字地址

Store Word Coprocessor 1 : Store 32-bit value from f1 to effective memory word address

fsw f1,-100

fsw f1,10000000,t3

存储字协处理器 1:将 f1 的 32 位值存储到有效内存字地址,使用 t3 作为临时地址

Store Word Coprocessor 1 : Store 32-bit value from f1 to effective memory word address using t3 as a temporary

fsw f1,10000000,t3

fsw f1,label, t3

存储字协处理器 1:将 f1 的 32 位值存储到有效内存字地址,使用 t3 作为临时地址

Store Word Coprocessor 1 : Store 32-bit value from f1 to effective memory word address using t3 as a temporary

fsw f1,label, t3

j label

跳转:跳转到标签处的语句

Jump : Jump to statement at label

j label

jal label

Jump And Link:跳转到标号处的语句并将返回地址设置为ra

Jump And Link: Jump to statement at label and set the return address to ra

jal label

jalr t0

Jump And Link Register:跳转到t0中的地址并将返回地址设置为ra

Jump And Link Register: Jump to address in t0 and set the return address to ra

jalr t0

jalr t0, -100

Jump And Link Register:跳转到t0中的地址并将返回地址设置为ra

Jump And Link Register: Jump to address in t0 and set the return address to ra

jalr t0, -100

jr t0

跳转寄存器:跳转到 t0 中的地址

Jump Register: Jump to address in t0

jr t0

jr t0, -100

跳转寄存器:跳转到 t0 中的地址

Jump Register: Jump to address in t0

jr t0, -100

la t1,label

加载地址:将 t1 设置为标签的地址

Load Address : Set t1 to label’s address

la t1,label

lb t1,(t2)

加载字节:将 t1 设置为有效内存字节地址的符号扩展 8 位值

Load Byte : Set t1 to sign-extended 8-bit value from effective memory byte address

lb t1,(t2)

lb t1,-100

加载字节:将 $1 设置为有效内存字节地址的符号扩展 8 位值

Load Byte : Set $1 to sign-extended 8-bit value from effective memory byte address

lb t1,-100

lb t1,10000000

加载字节:将 $t1 设置为有效内存字节地址的符号扩展 8 位值

Load Byte : Set $t1 to sign-extended 8-bit value from effective memory byte address

lb t1,10000000

lb t1,label

加载字节:将 $t1 设置为有效内存字节地址的符号扩展 8 位值

Load Byte : Set $t1 to sign-extended 8-bit value from effective memory byte address

lb t1,label

lbu t1,(t2)

加载无符号字节:将 $t1 设置为有效内存字节地址的零扩展 8 位值

Load Byte Unsigned : Set $t1 to zero-extended 8-bit value from effective memory byte address

lbu t1,(t2)

lbu t1,-100

加载无符号字节:将 $t1 设置为有效内存字节地址的零扩展 8 位值

Load Byte Unsigned : Set $t1 to zero-extended 8-bit value from effective memory byte address

lbu t1,-100

lbu t1,10000000

Load Byte Unsigned:将 t1 设置为有效内存字节地址的零扩展 8 位值

Load Byte Unsigned : Set t1 to zero-extended 8-bit value from effective memory byte address

lbu t1,10000000

lbu t1,label

Load Byte Unsigned:将 t1 设置为有效内存字节地址的零扩展 8 位值

Load Byte Unsigned : Set t1 to zero-extended 8-bit value from effective memory byte address

lbu t1,label

lh t1,(t2)

加载半字:将 t1 设置为有效内存半字地址的符号扩展 16 位值

Load Halfword : Set t1 to sign-extended 16-bit value from effective memory halfword address

lh t1,(t2)

lh t1,-100

加载半字:将 t1 设置为有效内存半字地址的符号扩展 16 位值

Load Halfword : Set t1 to sign-extended 16-bit value from effective memory halfword address

lh t1,-100

lh t1,10000000

加载半字:将 t1 设置为有效内存半字地址的符号扩展 16 位值

Load Halfword : Set t1 to sign-extended 16-bit value from effective memory halfword address

lh t1,10000000

lh t1,label

加载半字:将 t1 设置为有效内存半字地址的符号扩展 16 位值

Load Halfword : Set t1 to sign-extended 16-bit value from effective memory halfword address

lh t1,label

lhu t1,(t2)

加载无符号半字:将 t1 设置为有效内存半字地址的零扩展 16 位值

Load Halfword Unsigned : Set t1 to zero-extended 16-bit value from effective memory halfword address

lhu t1,(t2)

lhu t1,-100

加载无符号半字:将 t1 设置为有效内存半字地址的零扩展 16 位值

Load Halfword Unsigned : Set t1 to zero-extended 16-bit value from effective memory halfword address

lhu t1,-100

lhu t1,10000000

加载无符号半字:将 t1 设置为有效内存半字地址的零扩展 16 位值

Load Halfword Unsigned : Set t1 to zero-extended 16-bit value from effective memory halfword address

lhu t1,10000000

lhu t1,label

加载无符号半字:将 t1 设置为有效内存半字地址的零扩展 16 位值

Load Halfword Unsigned : Set t1 to zero-extended 16-bit value from effective memory halfword address

lhu t1,label

li t1,-100

立即加载:将 t1 设置为 12 位立即数(符号扩展)

Load Immediate : Set t1 to 12-bit immediate (sign-extended)

li t1,-100

li t1,10000000

立即加载:将 t1 设置为 32 位立即数

Load Immediate : Set t1 to 32-bit immediate

li t1,10000000

lui t1,%hi(label)

Load Upper Address : 将 t1 设置为标签的高 20 位地址

Load Upper Address : Set t1 to upper 20-bit label’s address

lui t1,%hi(label)

lw t1,%lo(label)(t2)

从地址加载

Load from Address

lw t1,%lo(label)(t2)

lw t1,(t2)

加载字:将 t1 设置为有效内存字地址的内容

Load Word : Set t1 to contents of effective memory word address

lw t1,(t2)

lw t1,-100

加载字:将 t1 设置为有效内存字地址的内容

Load Word : Set t1 to contents of effective memory word address

lw t1,-100

lw t1,10000000

加载字:将 t1 设置为有效内存字地址的内容

Load Word : Set t1 to contents of effective memory word address

lw t1,10000000

lw t1,label

加载字:将 t1 设置为标签地址处内存字的内容

Load Word : Set t1 to contents of memory word at label’s address

lw t1,label

mv t1,t2

MoVe:将 t1 设置为 t2 的内容

MoVe : Set t1 to contents of t2

mv t1,t2

neg t1,t2

NEGate :将 t1 设置为 t2 的否定

NEGate : Set t1 to negation of t2

neg t1,t2

nop

无操作

NO OPeration

nop

not t1,t2

按位非(位反转)

Bitwise NOT (bit inversion)

not t1,t2

rdcycle t1

从循环中读取

Read from cycle

rdcycle t1

rdcycleh t1

从 cycleh 读取

Read from cycleh

rdcycleh t1

rdinstret t1

从instret读取

Read from instret

rdinstret t1

rdinstreth t1

从 instreth 读取

Read from instreth

rdinstreth t1

rdtime t1

从时间读

Read from time

rdtime t1

rdtimeh t1

从时间读取

Read from timeh

rdtimeh t1

ret

返回:从子程序返回

Return: return from a subroutine

ret

sb t1,(t2)

Store Byte : 将t1的低8位存入有效内存字节地址

Store Byte : Store the low-order 8 bits of t1 into the effective memory byte address

sb t1,(t2)

sb t1,-100

Store Byte : 将$t1的低8位存入有效内存字节地址

Store Byte : Store the low-order 8 bits of $t1 into the effective memory byte address

sb t1,-100

sb t1,10000000,t2

Store Byte : 将$t1的低8位存入有效内存字节地址

Store Byte : Store the low-order 8 bits of $t1 into the effective memory byte address

sb t1,10000000,t2

sb t1,label,t2

Store Byte : 将$t1的低8位存入有效内存字节地址

Store Byte : Store the low-order 8 bits of $t1 into the effective memory byte address

sb t1,label,t2

seqz t1,t2

将 EQual 设置为零:如果 t2 == 0,则将 t1 设置为 1,否则为 0

Set EQual to Zero : if t2 == 0 then set t1 to 1 else 0

seqz t1,t2

sgt t1,t2,t3

设置大于:如果 t2 大于 t3,则将 t1 设置为 1,否则为 0

Set Greater Than : if t2 greater than t3 then set t1 to 1 else 0

sgt t1,t2,t3

sgtu t1,t2,t3

设置大于无符号:如果 t2 大于 t3(无符号比较)则将 t1 设置为 1,否则为 0

Set Greater Than Unsigned : if t2 greater than t3 (unsigned compare) then set t1 to 1 else 0

sgtu t1,t2,t3

sgtz t1,t2

设置大于零:如果 t2 > 0,则将 t1 设置为 1,否则为 0

Set Greater Than Zero : if t2 > 0 then set t1 to 1 else 0

sgtz t1,t2

sh t1,(t2)

Store Halfword : 将$1的低16位存入有效内存半字地址

Store Halfword : Store the low-order 16 bits of $1 into the effective memory halfword address

sh t1,(t2)

sh t1,-100

Store Halfword : 将$t1的低16位存入有效内存半字地址

Store Halfword : Store the low-order 16 bits of $t1 into the effective memory halfword address

sh t1,-100

sh t1,10000000,t2

Store Halfword : 将t1的低16位以t2为临时存储到有效内存半字地址

Store Halfword : Store the low-order 16 bits of t1 into the effective memory halfword address using t2 as a temporary

sh t1,10000000,t2

sh t1,label,t2

Store Halfword : 将t1的低16位以t2为临时存储到有效内存半字地址

Store Halfword : Store the low-order 16 bits of t1 into the effective memory halfword address using t2 as a temporary

sh t1,label,t2

sltz t1,t2

设置小于零:如果 t2 < 0,则将 t1 设置为 1,否则为 0

Set Less Than Zero : if t2 < 0 then set t1 to 1 else 0

sltz t1,t2

snez t1,t2

设置不等于零:if t2 != 0 then set t1 to 1 else 0

Set Not Equal to Zero : if t2 != 0 then set t1 to 1 else 0

snez t1,t2

sw t1,(t2)

Store Word : 将 t1 的内容存入有效内存字地址

Store Word : Store t1 contents into effective memory word address

sw t1,(t2)

sw t1,-100

Store Word : 将$t1内容存入有效内存字地址

Store Word : Store $t1 contents into effective memory word address

sw t1,-100

sw t1,10000000,t2

Store Word:将$t1的内容存储到有效的内存字地址中,使用t2作为临时地址

Store Word : Store $t1 contents into effective memory word address using t2 as a temporary

sw t1,10000000,t2

sw t1,label,t2

Store Word:将$t1 的内容存储到标签地址处的内存字中,使用t2 作为临时地址

Store Word : Store $t1 contents into memory word at label’s address using t2 as a temporary

sw t1,label,t2

tail label

TAIL call:尾调用(call without saved return address)a far-away subroutine

TAIL call: tail call (call without saving return address)a far-away subroutine

tail label

文章来源:https://dashen.tech/2022/09/22/%E7%BC%96%E5%86%99%E7%AC%AC%E4%B8%80%E4%B8%AARISC-V%E7%A8%8B%E5%BA%8F/

展开阅读全文

页面更新:2024-02-27

标签:寄存器   字节   分支   指令   嵌入式   语句   符号   加载   内存   标签   地址   程序

1 2 3 4 5

上滑加载更多 ↓
推荐阅读:
友情链接:
更多:

本站资料均由网友自行发布提供,仅用于学习交流。如有版权问题,请与我联系,QQ:4156828  

© CopyRight 2020-2024 All Rights Reserved. Powered By 71396.com 闽ICP备11008920号-4
闽公网安备35020302034903号

Top