changeset 115:344cfc25afec

Added initial infrastructure for pragma autobranchlength (suggested by Ebonhand on irc)
author lost@l-w.ca
date Mon, 08 Aug 2011 23:00:27 -0600
parents 707eda49ad60
children 7b0716264251
files lwasm/instab.c lwasm/lwasm.h lwasm/pragma.c
diffstat 3 files changed, 41 insertions(+), 39 deletions(-) [+]
line wrap: on
line diff
--- a/lwasm/instab.c	Sun Aug 07 12:41:06 2011 -0600
+++ b/lwasm/instab.c	Mon Aug 08 23:00:27 2011 -0600
@@ -338,14 +338,14 @@
 	{ "asrd",		{	0x1047,	-1,		-1,		-1	},	insn_parse_inh,			insn_resolve_inh,				insn_emit_inh,				lwasm_insn_is6309},
 
 	{ "band",		{	0x1130,	-1,		-1,		-1	},	insn_parse_bitbit,		insn_resolve_bitbit,			insn_emit_bitbit,			lwasm_insn_is6309},
-	{ "bcc",		{	0x24,	-1,		-1,		-1	},	insn_parse_rel8,		insn_resolve_rel8,				insn_emit_rel8,				lwasm_insn_normal},
-	{ "bcs",		{	0x25,	-1,		-1,		-1	},	insn_parse_rel8,		insn_resolve_rel8,				insn_emit_rel8,				lwasm_insn_normal},
+	{ "bcc",		{	0x24,	-1,		0x24,	0x1024},insn_parse_rel8,		insn_resolve_rel8,				insn_emit_rel8,				lwasm_insn_normal},
+	{ "bcs",		{	0x25,	-1,		0x25,	0x1025},insn_parse_rel8,		insn_resolve_rel8,				insn_emit_rel8,				lwasm_insn_normal},
 	{ "beor",		{	0x1134,	-1,		-1,		-1	},	insn_parse_bitbit,		insn_resolve_bitbit,			insn_emit_bitbit,			lwasm_insn_is6309},
-	{ "beq",		{	0x27,	-1,		-1,		-1	},	insn_parse_rel8,		insn_resolve_rel8,				insn_emit_rel8,				lwasm_insn_normal},
-	{ "bge",		{	0x2c,	-1,		-1,		-1	},	insn_parse_rel8,		insn_resolve_rel8,				insn_emit_rel8,				lwasm_insn_normal},
-	{ "bgt",		{	0x2e,	-1,		-1,		-1	},	insn_parse_rel8,		insn_resolve_rel8,				insn_emit_rel8,				lwasm_insn_normal},
-	{ "bhi",		{	0x22,	-1,		-1,		-1	},	insn_parse_rel8,		insn_resolve_rel8,				insn_emit_rel8,				lwasm_insn_normal},
-	{ "bhs",		{	0x24,	-1,		-1,		-1	},	insn_parse_rel8,		insn_resolve_rel8,				insn_emit_rel8,				lwasm_insn_normal},
+	{ "beq",		{	0x27,	-1,		0x27,	0x1027},insn_parse_rel8,		insn_resolve_rel8,				insn_emit_rel8,				lwasm_insn_normal},
+	{ "bge",		{	0x2c,	-1,		0x2c,	0x102c},insn_parse_rel8,		insn_resolve_rel8,				insn_emit_rel8,				lwasm_insn_normal},
+	{ "bgt",		{	0x2e,	-1,		0x2e,	0x102e},insn_parse_rel8,		insn_resolve_rel8,				insn_emit_rel8,				lwasm_insn_normal},
+	{ "bhi",		{	0x22,	-1,		0x22,	0x1022},insn_parse_rel8,		insn_resolve_rel8,				insn_emit_rel8,				lwasm_insn_normal},
+	{ "bhs",		{	0x24,	-1,		0x24,	0x1024},insn_parse_rel8,		insn_resolve_rel8,				insn_emit_rel8,				lwasm_insn_normal},
 	{ "biand",		{	0x1131,	-1,		-1,		-1	},	insn_parse_bitbit,		insn_resolve_bitbit,			insn_emit_bitbit,			lwasm_insn_is6309},
 	{ "bieor",		{	0x1135,	-1,		-1,		-1	},	insn_parse_bitbit,		insn_resolve_bitbit,			insn_emit_bitbit,			lwasm_insn_is6309},
 	{ "bior",		{	0x1133, -1,		-1,		-1	},	insn_parse_bitbit,		insn_resolve_bitbit,			insn_emit_bitbit,			lwasm_insn_is6309},
@@ -353,19 +353,19 @@
 	{ "bitb",		{	0xd5,	0xe5,	0xf5,	0xc5},	insn_parse_gen8,		insn_resolve_gen8,				insn_emit_gen8,				lwasm_insn_normal},
 	{ "bitd",		{	0x1095,	0x10a5,	0x10b5,	0x1085},insn_parse_gen16,		insn_resolve_gen16,				insn_emit_gen16,			lwasm_insn_is6309},
 	{ "bitmd",		{	0x113c, -1,		-1,		0x113c},insn_parse_imm8,		insn_resolve_imm8,				insn_emit_imm8,				lwasm_insn_is6309},
-	{ "ble",		{	0x2f,	-1,		-1,		-1	},	insn_parse_rel8,		insn_resolve_rel8,				insn_emit_rel8,				lwasm_insn_normal},
-	{ "blo",		{	0x25,	-1,		-1,		-1	},	insn_parse_rel8,		insn_resolve_rel8,				insn_emit_rel8,				lwasm_insn_normal},
-	{ "bls",		{	0x23,	-1,		-1,		-1	},	insn_parse_rel8,		insn_resolve_rel8,				insn_emit_rel8,				lwasm_insn_normal},
-	{ "blt",		{	0x2d,	-1,		-1,		-1	},	insn_parse_rel8,		insn_resolve_rel8,				insn_emit_rel8,				lwasm_insn_normal},
-	{ "bmi",		{	0x2b,	-1,		-1,		-1	},	insn_parse_rel8,		insn_resolve_rel8,				insn_emit_rel8,				lwasm_insn_normal},
-	{ "bne",		{	0x26, 	-1,		-1,		-1	},	insn_parse_rel8,		insn_resolve_rel8,				insn_emit_rel8,				lwasm_insn_normal},
+	{ "ble",		{	0x2f,	-1,		0x2f,	0x102f},insn_parse_rel8,		insn_resolve_rel8,				insn_emit_rel8,				lwasm_insn_normal},
+	{ "blo",		{	0x25,	-1,		0x25,	0x1025},insn_parse_rel8,		insn_resolve_rel8,				insn_emit_rel8,				lwasm_insn_normal},
+	{ "bls",		{	0x23,	-1,		0x23,	0x1023},insn_parse_rel8,		insn_resolve_rel8,				insn_emit_rel8,				lwasm_insn_normal},
+	{ "blt",		{	0x2d,	-1,		0x2d,	0x102d},insn_parse_rel8,		insn_resolve_rel8,				insn_emit_rel8,				lwasm_insn_normal},
+	{ "bmi",		{	0x2b,	-1,		0x2b,	0x102b},insn_parse_rel8,		insn_resolve_rel8,				insn_emit_rel8,				lwasm_insn_normal},
+	{ "bne",		{	0x26, 	-1,		0x26,	0x1026},insn_parse_rel8,		insn_resolve_rel8,				insn_emit_rel8,				lwasm_insn_normal},
 	{ "bor",		{	0x1132,	-1,		-1,		-1	},	insn_parse_bitbit,		insn_resolve_bitbit,			insn_emit_bitbit,			lwasm_insn_is6309},
-	{ "bpl",		{	0x2a,	-1,		-1,		-1	},	insn_parse_rel8,		insn_resolve_rel8,				insn_emit_rel8,				lwasm_insn_normal},
-	{ "bra",		{	0x20,	-1,		-1,		-1	},	insn_parse_rel8,		insn_resolve_rel8,				insn_emit_rel8,				lwasm_insn_normal},
-	{ "brn",		{	0x21,	-1,		-1,		-1	},	insn_parse_rel8,		insn_resolve_rel8,				insn_emit_rel8,				lwasm_insn_normal},
-	{ "bsr",		{	0x8d,	-1,		-1,		-1	},	insn_parse_rel8,		insn_resolve_rel8,				insn_emit_rel8,				lwasm_insn_normal},
-	{ "bvc",		{	0x28,	-1,		-1,		-1	},	insn_parse_rel8,		insn_resolve_rel8,				insn_emit_rel8,				lwasm_insn_normal},
-	{ "bvs",		{	0x29,	-1,		-1,		-1	},	insn_parse_rel8,		insn_resolve_rel8,				insn_emit_rel8,				lwasm_insn_normal},
+	{ "bpl",		{	0x2a,	-1,		0x2a,	0x102a},insn_parse_rel8,		insn_resolve_rel8,				insn_emit_rel8,				lwasm_insn_normal},
+	{ "bra",		{	0x20,	-1,		0x20,	0x16},	insn_parse_rel8,		insn_resolve_rel8,				insn_emit_rel8,				lwasm_insn_normal},
+	{ "brn",		{	0x21,	-1,		0x21,	0x1021},insn_parse_rel8,		insn_resolve_rel8,				insn_emit_rel8,				lwasm_insn_normal},
+	{ "bsr",		{	0x8d,	-1,		0x8d,	0x17},	insn_parse_rel8,		insn_resolve_rel8,				insn_emit_rel8,				lwasm_insn_normal},
+	{ "bvc",		{	0x28,	-1,		0x28,	0x1028},insn_parse_rel8,		insn_resolve_rel8,				insn_emit_rel8,				lwasm_insn_normal},
+	{ "bvs",		{	0x29,	-1,		0x29,	0x1029},	insn_parse_rel8,		insn_resolve_rel8,				insn_emit_rel8,				lwasm_insn_normal},
 
 	{ "clr",		{	0x0f,	0x6f,	0x7f,	-1	},	insn_parse_gen0,		insn_resolve_gen0,				insn_emit_gen0,				lwasm_insn_normal},
 	{ "clra",		{	0x4f,	-1,		-1,		-1	},	insn_parse_inh,			insn_resolve_inh,				insn_emit_inh,				lwasm_insn_normal},
@@ -423,25 +423,25 @@
 	{ "jmp",		{	0x0e,	0x6e,	0x7e,	-1	},	insn_parse_gen0,		insn_resolve_gen0,				insn_emit_gen0,				lwasm_insn_normal},
 	{ "jsr",		{	0x9d,	0xad,	0xbd,	-1	}, 	insn_parse_gen0,		insn_resolve_gen0,				insn_emit_gen0,				lwasm_insn_normal},
 	
-	{ "lbcc",		{	0x1024,	-1,		-1,		-1	},	insn_parse_rel16,		insn_resolve_rel16,				insn_emit_rel16,			lwasm_insn_normal},
-	{ "lbcs",		{	0x1025,	-1,		-1,		-1	},	insn_parse_rel16,		insn_resolve_rel16,				insn_emit_rel16,			lwasm_insn_normal},
-	{ "lbeq",		{	0x1027,	-1,		-1,		-1	},	insn_parse_rel16,		insn_resolve_rel16,				insn_emit_rel16,			lwasm_insn_normal},
-	{ "lbge",		{	0x102c,	-1,		-1,		-1	},	insn_parse_rel16,		insn_resolve_rel16,				insn_emit_rel16,			lwasm_insn_normal},
-	{ "lbgt",		{	0x102e,	-1,		-1,		-1	},	insn_parse_rel16,		insn_resolve_rel16,				insn_emit_rel16,			lwasm_insn_normal},
-	{ "lbhi",		{	0x1022,	-1,		-1,		-1	},	insn_parse_rel16,		insn_resolve_rel16,				insn_emit_rel16,			lwasm_insn_normal},
-	{ "lbhs",		{	0x1024,	-1,		-1,		-1	},	insn_parse_rel16,		insn_resolve_rel16,				insn_emit_rel16,			lwasm_insn_normal},
-	{ "lble",		{	0x102f,	-1,		-1,		-1	},	insn_parse_rel16,		insn_resolve_rel16,				insn_emit_rel16,			lwasm_insn_normal},
-	{ "lblo",		{	0x1025,	-1,		-1,		-1	},	insn_parse_rel16,		insn_resolve_rel16,				insn_emit_rel16,			lwasm_insn_normal},
-	{ "lbls",		{	0x1023,	-1,		-1,		-1	},	insn_parse_rel16,		insn_resolve_rel16,				insn_emit_rel16,			lwasm_insn_normal},
-	{ "lblt",		{	0x102d, -1,		-1,		-1	},	insn_parse_rel16,		insn_resolve_rel16,				insn_emit_rel16,			lwasm_insn_normal},
-	{ "lbmi",		{	0x102b,	-1,		-1,		-1	},	insn_parse_rel16,		insn_resolve_rel16,				insn_emit_rel16,			lwasm_insn_normal},
-	{ "lbne",		{	0x1026,	-1,		-1,		-1	},	insn_parse_rel16,		insn_resolve_rel16,				insn_emit_rel16,			lwasm_insn_normal},
-	{ "lbpl",		{	0x102a,	-1,		-1,		-1	},	insn_parse_rel16,		insn_resolve_rel16,				insn_emit_rel16,			lwasm_insn_normal},
-	{ "lbra",		{	0x16,	-1,		-1,		-1	},	insn_parse_rel16,		insn_resolve_rel16,				insn_emit_rel16,			lwasm_insn_normal},
-	{ "lbrn",		{	0x1021,	-1,		-1,		-1	},	insn_parse_rel16,		insn_resolve_rel16,				insn_emit_rel16,			lwasm_insn_normal},
-	{ "lbsr",		{	0x17,	-1,		-1,		-1	},	insn_parse_rel16,		insn_resolve_rel16,				insn_emit_rel16,			lwasm_insn_normal},
-	{ "lbvc",		{	0x1028,	-1,		-1,		-1	},	insn_parse_rel16,		insn_resolve_rel16,				insn_emit_rel16,			lwasm_insn_normal},
-	{ "lbvs",		{	0x1029,	-1,		-1,		-1	},	insn_parse_rel16,		insn_resolve_rel16,				insn_emit_rel16,			lwasm_insn_normal},
+	{ "lbcc",		{	0x1024,	-1,		0x24,	0x1024},insn_parse_rel16,		insn_resolve_rel16,				insn_emit_rel16,			lwasm_insn_normal},
+	{ "lbcs",		{	0x1025,	-1,		0x25,	0x1025},insn_parse_rel16,		insn_resolve_rel16,				insn_emit_rel16,			lwasm_insn_normal},
+	{ "lbeq",		{	0x1027,	-1,		0x27,	0x1027},insn_parse_rel16,		insn_resolve_rel16,				insn_emit_rel16,			lwasm_insn_normal},
+	{ "lbge",		{	0x102c,	-1,		0x2c,	0x102c},insn_parse_rel16,		insn_resolve_rel16,				insn_emit_rel16,			lwasm_insn_normal},
+	{ "lbgt",		{	0x102e,	-1,		0x2e,	0x102e},insn_parse_rel16,		insn_resolve_rel16,				insn_emit_rel16,			lwasm_insn_normal},
+	{ "lbhi",		{	0x1022,	-1,		0x22,	0x1022},insn_parse_rel16,		insn_resolve_rel16,				insn_emit_rel16,			lwasm_insn_normal},
+	{ "lbhs",		{	0x1024,	-1,		0x24,	0x1024},insn_parse_rel16,		insn_resolve_rel16,				insn_emit_rel16,			lwasm_insn_normal},
+	{ "lble",		{	0x102f,	-1,		0x2f,	0x102f},insn_parse_rel16,		insn_resolve_rel16,				insn_emit_rel16,			lwasm_insn_normal},
+	{ "lblo",		{	0x1025,	-1,		0x25,	0x1025},insn_parse_rel16,		insn_resolve_rel16,				insn_emit_rel16,			lwasm_insn_normal},
+	{ "lbls",		{	0x1023,	-1,		0x23,	0x1023},insn_parse_rel16,		insn_resolve_rel16,				insn_emit_rel16,			lwasm_insn_normal},
+	{ "lblt",		{	0x102d, -1,		0x2d,	0x102d},insn_parse_rel16,		insn_resolve_rel16,				insn_emit_rel16,			lwasm_insn_normal},
+	{ "lbmi",		{	0x102b,	-1,		0x2b,	0x102b},insn_parse_rel16,		insn_resolve_rel16,				insn_emit_rel16,			lwasm_insn_normal},
+	{ "lbne",		{	0x1026,	-1,		0x26,	0x1026},insn_parse_rel16,		insn_resolve_rel16,				insn_emit_rel16,			lwasm_insn_normal},
+	{ "lbpl",		{	0x102a,	-1,		0x2a,	0x102a},insn_parse_rel16,		insn_resolve_rel16,				insn_emit_rel16,			lwasm_insn_normal},
+	{ "lbra",		{	0x16,	-1,		0x20,	0x16},	insn_parse_rel16,		insn_resolve_rel16,				insn_emit_rel16,			lwasm_insn_normal},
+	{ "lbrn",		{	0x1021,	-1,		0x21,	0x1021},insn_parse_rel16,		insn_resolve_rel16,				insn_emit_rel16,			lwasm_insn_normal},
+	{ "lbsr",		{	0x17,	-1,		0x8d,	0x17},	insn_parse_rel16,		insn_resolve_rel16,				insn_emit_rel16,			lwasm_insn_normal},
+	{ "lbvc",		{	0x1028,	-1,		0x28,	0x1028},insn_parse_rel16,		insn_resolve_rel16,				insn_emit_rel16,			lwasm_insn_normal},
+	{ "lbvs",		{	0x1029,	-1,		0x29,	0x1029},insn_parse_rel16,		insn_resolve_rel16,				insn_emit_rel16,			lwasm_insn_normal},
 	{ "lda",		{	0x96,	0xa6,	0xb6,	0x86},	insn_parse_gen8,		insn_resolve_gen8,				insn_emit_gen8,				lwasm_insn_normal},
 	{ "ldb",		{	0xd6,	0xe6,	0xf6,	0xc6},	insn_parse_gen8,		insn_resolve_gen8,				insn_emit_gen8,				lwasm_insn_normal},
 	{ "ldbt",		{	0x1136,	-1,		-1,		-1	},	insn_parse_bitbit,		insn_resolve_bitbit,			insn_emit_bitbit,			lwasm_insn_is6309},
--- a/lwasm/lwasm.h	Sun Aug 07 12:41:06 2011 -0600
+++ b/lwasm/lwasm.h	Mon Aug 08 23:00:27 2011 -0600
@@ -79,7 +79,8 @@
 	PRAGMA_IMPORTUNDEFEXPORT = 0x0010,	// imports symbol if undefined upon export
 	PRAGMA_PCASPCR = 0x0020,			// treats ,PC as ,PCR instead of constant offset
 	PRAGMA_SHADOW = 0x0040,				// allow macros to shadow builtin operations
-	PRAGMA_NOLIST = 0x0080				// don't show line in listing
+	PRAGMA_NOLIST = 0x0080,				// don't show line in listing
+	PRAGMA_AUTOBRANCHLENGTH = 0x0100	// automatically select proper length for relative branches
 };
 
 
--- a/lwasm/pragma.c	Sun Aug 07 12:41:06 2011 -0600
+++ b/lwasm/pragma.c	Mon Aug 08 23:00:27 2011 -0600
@@ -54,6 +54,7 @@
 	{ "pcaspcr", "nopcaspcr", PRAGMA_PCASPCR },
 	{ "shadow", "noshadow", PRAGMA_SHADOW },
 	{ "nolist", "list", PRAGMA_NOLIST },
+	{ "autobranchlength", "noautobranchlength", PRAGMA_AUTOBRANCHLENGTH },
 	{ 0, 0, 0}
 };