From 48bd43a2134235f3394f79a76ba63b2e1c870bf9 Mon Sep 17 00:00:00 2001 From: Matt Turner Date: Sat, 28 Mar 2009 20:38:14 +0000 Subject: Add test program to get opcode from instruction name git-svn-id: svn://mattst88.com/svn/annotator/trunk@4 b9d43f0c-d947-41e4-9d27-581b740e5c48 --- progs/instr2opcode.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 progs/instr2opcode.c (limited to 'progs') diff --git a/progs/instr2opcode.c b/progs/instr2opcode.c new file mode 100644 index 0000000..bbf9a91 --- /dev/null +++ b/progs/instr2opcode.c @@ -0,0 +1,28 @@ +#include +#include + +#include "alpha.h" + +int main(int argc, char * argv[]) { + int i; + int found = 0; + + if (argc < 2) { + fputs("Must enter an instruction to search for.\n", stderr); + return -1; + } + + for (i = 0; i < alpha_num_opcodes; i++) { + if (strcasecmp(alpha_opcodes[i].name, argv[1]) == 0) { + printf("%3d: %18s - opcode %#04X\n", i, alpha_opcodes[i].name, AXP_OP(alpha_opcodes[i].opcode)); + found = 1; + } + } + + if (!found) { + puts("Sorry, instruction not found."); + return -1; + } + + return 0; +} -- cgit v1.2.3