RISCV - 1 RV32/64G指令集清单
发布人:shili8
发布时间:2025-01-24 16:50
阅读次数:0
**RISC-V 指令集清单**
RISC-V 是一种开源的、自由的 CPU 构架,旨在成为一种通用的计算机指令集。它由 University of California, Berkeley 的 David Patterson 和 his team 开发。RISC-V 的目标是提供一个高性能、低功耗和易于实现的 CPU 构架。
**RV32/64G 指令集清单**
RV32/64G 是 RISC-V 的一部分,指的是32 位或64 位的通用指令集。下面是 RV32/64G 指令集清单:
### **整数运算**
* `add`: 加法
riscv add x1, x2, x3 # x1 = x2 + x3
* `sub`: 减法
riscv sub x1, x2, x3 # x1 = x2 - x3
* `mul`: 乘法
riscv mul x1, x2, x3 # x1 = x2 * x3
* `div`:除法
riscv div x1, x2, x3 # x1 = x2 / x3
* `rem`: 取余数
riscv rem x1, x2, x3 # x1 = x2 % x3
### **移位运算**
* `sll`: 左移位
riscv sll x1, x2,3 # x1 = x2 << 3
* `srl`: 右移位
riscv srl x1, x2,3 # x1 = x2 >>3
* `sra`: 有符号右移位
riscv sra x1, x2,3 # x1 = x2 >>>3
### **比较运算**
* `slt`: 小于
riscv slt x1, x2, x3 # x1 = (x2 < x3) ?1 :0
* `sltu`: 无符号小于
riscv sltu x1, x2, x3 # x1 = (x2 < x3) ?1 :0
* `sgt`: 大于
riscv sgt x1, x2, x3 # x1 = (x2 > x3) ?1 :0
* `sgtu`: 无符号大于
riscv sgtu x1, x2, x3 # x1 = (x2 > x3) ?1 :0
### **逻辑运算**
* `and`: 与
riscv and x1, x2, x3 # x1 = x2 & x3
* `or`: 或
riscv or x1, x2, x3 # x1 = x2 | x3
* `xor`: 异或
riscv xor x1, x2, x3 # x1 = x2 ^ x3
### **控制流**
* `beq`: 等于
riscv beq x1, x2,10 # if (x1 == x2) goto10
* `bne`: 不等于
riscv bne x1, x2,10 # if (x1 != x2) goto10
* `blt`: 小于
riscv blt x1, x2,10 # if (x1 < x2) goto10
* `bge`: 大于等于
riscv bge x1, x2,10 # if (x1 >= x2) goto10
### **跳转**
* `j**: 直接跳转到指定地址
riscv j10 # goto10
* `jr`: 返回到上一个函数的返回地址
riscv jr ra # return to the previous function's return address
### **系统调用**
* `ecall`: 系统调用
riscv ecall # system call
* `ebreak**: 中断系统调用
riscv ebreak # interrupt system call
### **异常处理**
* `mret**: 从中断返回到用户模式
riscv mret # return from interrupt to user mode
* `msr`: 写入异常状态寄存器
riscv msr x1, x2 # write to exception state register
### **内存管理**
* `lw**:读取字节
riscv lw x1,0(x2) # load byte from memory
* `sw**: 写入字节
riscv sw x1,0(x2) # store byte to memory
### **内存访问**
* `ld`: 加载字
riscv ld x1,0(x2) # load word from memory
* `sd**: 存储字
riscv sd x1,0(x2) # store word to memory
### **内存访问**
* `ldl`: 加载长整数
riscv ldl x1,0(x2) # load long integer from memory
* `sdl**: 存储长整数
riscv sdl x1,0(x2) # store long integer to memory
### **内存访问**
* `ldq`: 加载双字
riscv ldq x1,0(x2) # load double word from memory
* `sq**: 存储双字
riscv sq x1,0(x2) # store double word to memory
### **内存访问**
* `ldd`: 加载四字
riscv ldd x1,0(x2) # load quad word from memory
* `sdd**: 存储四字
riscv sdd x1,0(x2) # store quad word to memory
### **内存访问**
* `ldi`: 加载指针
riscv ldi x1,0(x2) # load pointer from memory
* `sti**: 存储指针
riscv sti x1,0(x2) # store pointer to memory
### **内存访问**
* `ldp`: 加载双指针
riscv ldp x1, x2,0(x3) # load double pointer from memory
* `sdp**: 存储双指针
riscv sdp x1, x2,0(x3) # store double pointer to memory
### **内存访问**
* `ldq`: 加载四指针
riscv ldq x1, x2, x3,0(x4) # load quad pointer from memory
* `sq**: 存储四指针
riscv sq x1, x2, x3,0(x4) # store quad pointer to memory
### **内存访问**
* `ldi`: 加载双字指针
riscv ldi x1, x2,0(x3) # load double word pointer from memory
* `sti**: 存储双字指针
riscv sti x1, x2,0(x3) # store double word pointer to memory
### **内存访问**
* `ldd`: 加载四字指针
riscv ldd x1, x2, x3,0(x4) # load quad word pointer from memory
* `sdd**: 存储四字指针
riscv sdd x1, x2, x3,0(x4) # store quad word pointer to memory