diff lwasm/insn_indexed.c @ 230:0df2a39a268c

Added --6809/--6309 switches and some cleanups in error reporting
author lost
date Fri, 12 Jun 2009 03:18:32 +0000
parents bae1e3ecdce1
children
line wrap: on
line diff
--- a/lwasm/insn_indexed.c	Fri Jun 12 01:31:18 2009 +0000
+++ b/lwasm/insn_indexed.c	Fri Jun 12 03:18:32 2009 +0000
@@ -35,8 +35,10 @@
 
 void insn_indexed_aux(asmstate_t *as, lwasm_line_t *l, const char **p, int *b1, int *b2, int *b3)
 {
+	struct opvals { char *opstr; int pb; };
+	
 	static const char *regs = "X  Y  U  S  W  PCRPC ";
-	static const struct { char *opstr; int pb; } simpleindex[] =
+	static const struct opvals simpleindex[] =
 	{
 		{",x", 0x84},		{",y", 0xa4},		{",u", 0xc4},		{",s", 0xe4},
 		{",x+", 0x80},		{",y+", 0xa0},		{",u+", 0xc0},		{",s+", 0xe0},
@@ -64,12 +66,47 @@
 		
 		{ "", -1 }
 	};
+
+	static const char *regs9 = "X  Y  U  S     PCRPC ";
+	static const struct opvals simpleindex9[] =
+	{
+		{",x", 0x84},		{",y", 0xa4},		{",u", 0xc4},		{",s", 0xe4},
+		{",x+", 0x80},		{",y+", 0xa0},		{",u+", 0xc0},		{",s+", 0xe0},
+		{",x++", 0x81},		{",y++", 0xa1},		{",u++", 0xc1},		{",s++", 0xe1},
+		{",-x", 0x82},		{",-y", 0xa2},		{",-u", 0xc2},		{",-s", 0xe2},
+		{",--x", 0x83},		{",--y", 0xa3},		{",--u", 0xc3},		{",--s", 0xe3},
+		{"a,x", 0x86},		{"a,y", 0xa6},		{"a,u", 0xc6},		{"a,s", 0xe6},
+		{"b,x", 0x85},		{"b,y", 0xa5},		{"b,u", 0xc5},		{"b,s", 0xe5},
+		{"d,x", 0x8b},		{"d,y", 0xab},		{"d,u", 0xcb},		{"d,s", 0xed},
+		
+		{"[,x]", 0x94},		{"[,y]", 0xb4},		{"[,u", 0xd4},		{"[,s]", 0xf4},
+		{"[,x++]", 0x91},	{"[,y++]", 0xb1},	{"[,u++]", 0xd1},	{"[,s++]", 0xf1},
+		{"[,--x]", 0x93},	{"[,--y]", 0xb3},	{"[,--u]", 0xd3},	{"[,--s]", 0xf3},
+		{"[a,x]", 0x96},	{"[a,y]", 0xb6},	{"[a,u]", 0xd6},	{"[a,s]", 0xf6},
+		{"[b,x]", 0x95},	{"[b,y]", 0xb5},	{"[b,u]", 0xd5},	{"[b,s]", 0xf5},
+		{"[d,x]", 0x9b},	{"[d,y]", 0xbb},	{"[d,u]", 0xdb},	{"[d,s]", 0xfd},
+		
+		{ "", -1 }
+	};
 	char stbuf[25];
 	int i, j, rn;
 	int f8 = 0, f16 = 0, f0 = 0;
 	int r, v;
 	int indir = 0;
 	int fs8 = 0, fs16 = 0;
+	const struct opvals *simples;
+	const char *reglist;
+	
+	if (as -> no6309)
+	{
+		simples = simpleindex9;
+		reglist = regs9;
+	}
+	else
+	{
+		simples = simpleindex;
+		reglist = regs;
+	}
 	
 	// initialize output bytes
 	*b1 = *b2 = *b3 = -1;
@@ -88,14 +125,14 @@
 	if (!*((*p) + i) || isspace(*((*p) + i)))
 	{
 		// do simple lookup
-		for (j = 0; simpleindex[j].opstr[0]; j++)
+		for (j = 0; simples[j].opstr[0]; j++)
 		{
-			if (!strcasecmp(stbuf, simpleindex[j].opstr))
+			if (!strcasecmp(stbuf, simples[j].opstr))
 				break;
 		}
-		if (simpleindex[j].opstr[0])
+		if (simples[j].opstr[0])
 		{
-			*b1 = simpleindex[j].pb;
+			*b1 = simples[j].pb;
 			(*p) += i;
 			return;
 		}
@@ -189,7 +226,7 @@
 	}
 	
 	// now get the register
-	rn = lwasm_lookupreg3(regs, p);
+	rn = lwasm_lookupreg3(reglist, p);
 	if (rn < 0)
 	{
 		*b1 = 0;