QEMU: 使用 Decodetree 新增 RISC-V 指令
⚠️ 本文所使用的 QEMU 版本為:v4.2.0 在之前的文章中 (Part 1., Part 2.) 我們提到了如何使用 Decodetree 來定義指令的 decoder。本篇文章就實際使用 Decodetree 來定義一個 QEMU RISC-V 目前尚未支援的指令 - B(itmanip) Extension 中的 pcnt 指令,並實做其行為。 pcnt 指令 pcnt 指令的定義如下: This instruction counts the number of 1 bits in a register. This operations is known as population count, popcount, sideways sum, bit summation, or Hamming weight. 其指令格式為: 1 2 3 | 1 0 9 8 7 6 5 | 4 3 2 1 0 | 9 8 7 6 5 | 4 3 2 | 1 0 9 8 7 | 6 5 4 3 2 1 0 | |===========================================================================| | 0110000 | 00010 | rs1 | 001 | rd | 0010011 | PCNT 安裝 toolchain 由於 B Extension 尚未正式定稿 (Draft),因此必須至 riscv-bitmanip repo 下載 toolchain,並依照該 repo 的指示安裝: ...