【发布时间】:2017-03-24 13:22:23
【问题描述】:
我想在 RISCV ISA 中添加新指令,我按照以下步骤操作:
模拟新指令。向模拟器添加指令需要两个步骤:
- 在文件
riscv/insns/<new_instruction_name>.h中描述指令的功能行为。检查该目录中的其他说明作为起点。- 将操作码和操作码掩码添加到
riscv/opcodes.h。或者,将其添加到 riscv-opcodes 包中,它会为您执行此操作:$ cs ../riscv-opcodes;vi opcodes // add a line for the new instruction;make install- 重建求和器。
我编写了简单的汇编代码来测试:
.file "hello.c"
.text
.align 2
.globl main
.type main, @function
main:
li a0, 2
mac a1, a2, a3
add a0, a0, a1
.size main, .-main
.ident "GCC: (GNU)5.2.
但它无法识别新指令 (mac a1,a2,a3) 并显示错误消息:
$ riscv64-unknown-elf-gcc hello.s
...
hello.s:8: Error:unrecognized opcode `mac a1,a2,a3'
我该怎么办?
【问题讨论】:
-
请发布文本而不是屏幕截图。您需要更改
riscv/riscv-tools的汇编程序,消息“Error: unrecognized opcode `mac a1,a2,a3'”来自它。该列表在riscv/riscv-opcodes/中,实际错误消息来自 riscv-binutils - gas github.com/riscv/riscv-binutils-gdb/blob/master/gas/config/… -
下次我会发文字而不是截图。谢谢你的通知
-
发布相关外部资源的确切链接也可能有所帮助(github.com/riscv/riscv-isa-sim#simulating-a-new-instruction,不是文本的部分屏幕截图)。我修复了这个问题的图像->文本转换。