From 0a048a93ebdab87473fcb50bc647e84098693cd0 Mon Sep 17 00:00:00 2001 From: Yunsup Lee Date: Tue, 25 Feb 2014 03:44:34 -0800 Subject: [PATCH] add extensions to riscv-dis for better disassembly --- riscv/riscv-dis.cc | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/riscv/riscv-dis.cc b/riscv/riscv-dis.cc index fdeb69f..1b958df 100644 --- a/riscv/riscv-dis.cc +++ b/riscv/riscv-dis.cc @@ -7,16 +7,31 @@ // instruction. #include "disasm.h" +#include "extension.h" #include #include #include +#include using namespace std; -int main() +int main(int argc, char** argv) { string s; disassembler_t d; + std::function extension; + option_parser_t parser; + parser.option(0, "extension", 1, [&](const char* s){ + if (!extensions().count(s)) + fprintf(stderr, "unknown extension %s!\n", s), exit(-1); + extension = extensions()[s]; + + for (auto disasm_insn : extension()->get_disasms()) + d.add_insn(disasm_insn); + }); + + auto argv1 = parser.parse(argv); + while (getline(cin, s)) { for (size_t start = 0; (start = s.find("DASM(", start)) != string::npos; ) -- 2.30.2