summaryrefslogtreecommitdiff
path: root/opcode-gen.c
diff options
context:
space:
mode:
Diffstat (limited to 'opcode-gen.c')
-rw-r--r--opcode-gen.c30
1 files changed, 18 insertions, 12 deletions
diff --git a/opcode-gen.c b/opcode-gen.c
index 3091e05..be0028c 100644
--- a/opcode-gen.c
+++ b/opcode-gen.c
@@ -8,7 +8,7 @@ struct instruction {
char *mne; /* Mnemonic. */
char *desc; /* Description */
char *com; /* Comment. */
- uint8_t op[10]; /* Opcodes. */
+ uint8_t op[11]; /* Opcodes. */
};
struct opcode {
@@ -44,6 +44,7 @@ const char *ams[] = { /* Addressing modes. */
"IY ",
"AB ",
"REL ",
+ "B ",
"IMP "
};
@@ -58,6 +59,7 @@ enum am {
INDY, /* Indirect Indexed. */
ABS, /* Absolute. */
REL, /* Relative to Program Counter. */
+ BREG, /* B Register. */
IMPL, /* Implied. */
/* Part of Base Extension. */
ABSX, /* Absolute, Indexed with X. */
@@ -71,7 +73,7 @@ enum am {
EIND, /* Effective Address Register, Indirect. */
};
-static const char *addrmodes[10] = {
+static const char *addrmodes[11] = {
[IMM ] = "IMM",
[ZM ] = "ZM",
[ZMX ] = "ZMX",
@@ -81,10 +83,11 @@ static const char *addrmodes[10] = {
[INDY] = "INDY",
[ABS ] = "ABS",
[REL ] = "REL",
+ [BREG] = "BREG",
[IMPL] = "IMPL"
};
-static const char *amcom[10] = {
+static const char *amcom[11] = {
[IMM ] = "Immediate.",
[ZM ] = "Zero Matrix.",
[ZMX ] = "Zero Marrix, Indexed with X.",
@@ -94,10 +97,11 @@ static const char *amcom[10] = {
[INDY] = "Indirect Indexed.",
[ABS ] = "Absolute.",
[REL ] = "Relative.",
+ [BREG] = "B Register.",
[IMPL] = "Implied."
};
-static const char *am_tok[10] = {
+static const char *am_tok[11] = {
[IMM ] = "#",
[ZM ] = "zm",
[ZMX ] = "zmx",
@@ -107,6 +111,7 @@ static const char *am_tok[10] = {
[INDY] = "indy",
[ABS ] = "a",
[REL ] = "rel",
+ [BREG] = "B"
};
int get_instcount(list *l) {
@@ -121,7 +126,7 @@ inst *make_inst(opcode *opc, char *mne, char *desc, char *com) {
ins->desc = desc;
ins->com = com;
- for (int i = 0; i < 10; i++) {
+ for (int i = 0; i < 11; i++) {
ins->op[i] = 0xFF;
}
@@ -170,13 +175,13 @@ void free_opcodes() {
void print_optable(list *l, int maxop) {
int i = 0;
- puts("static const uint8_t opcodes[OPNUM][10] = {");
- puts("\t/*\t IMM\t ZM ZMX ZMY IND INDX INDY ABS REL IMPL*/");
+ puts("static const uint8_t opcodes[OPNUM][11] = {");
+ puts("\t/*\t IMM\t ZM ZMX ZMY IND INDX INDY ABS REL B IMPL*/");
while (l) {
inst *ins = l->inst;
printf("\t[%s] = {", ins->mne);
- for (int j = 0; j < 10; j++) {
- printf("0x%02X%s", ins->op[j], (j < 9) ? ", " : "}");
+ for (int j = 0; j < 11; j++) {
+ printf("0x%02X%s", ins->op[j], (j < 10) ? ", " : "}");
}
putchar((l->next) ? ',' : ' ');
printf(" /* %s */\n", ins->mne);
@@ -212,6 +217,7 @@ opcode *lex_value(char *str, int op) {
case 'A': opc->am = IMPL; break;
case '#': opc->am = IMM ; break;
case 'a': opc->am = ABS ; break;
+ case 'B': opc->am = BREG; break;
case 'r': opc->am = REL ; i += 2; break;
case 'z':
switch (str[i+2]) {
@@ -326,13 +332,13 @@ void print_mneenum(list *l, char *name) {
inst *ins = l->inst;
putchar('\t');
printf("%s = ", ins->mne);
- if (i < 100 && inst_count >= 100) {
+ /*if (i < 100 && inst_count >= 100) {
putchar(' ');
}
if (i < 10 && inst_count >= 10) {
putchar(' ');
- }
- printf("%i", i);
+ }*/
+ printf("%3i", i);
putchar((l->next) ? ',' : ' ');
putchar('\n');
i++;