summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Turner <mattst88@gmail.com>2009-03-28 20:38:14 +0000
committerMatt Turner <mattst88@gmail.com>2009-03-28 20:38:14 +0000
commit48bd43a2134235f3394f79a76ba63b2e1c870bf9 (patch)
tree240ef92fc5557d7f991f82aaa10881b6d2b3a78f
parent3c3691ab820d2b971c595e4c6d544fe1af2a4921 (diff)
Add test program to get opcode from instruction name
git-svn-id: svn://mattst88.com/svn/annotator/trunk@4 b9d43f0c-d947-41e4-9d27-581b740e5c48
-rw-r--r--progs/instr2opcode.c28
1 files changed, 28 insertions, 0 deletions
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 <stdio.h>
+#include <string.h>
+
+#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;
+}