summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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;
+}