summaryrefslogtreecommitdiff
path: root/progs/instr2opcode.c
blob: bbf9a91eed4a28c19f68b24013e2931a8d1c83c3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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;
}