changeset 350:f5666775d76f

Even more pseudo ops
author lost@starbug
date Sat, 27 Mar 2010 22:59:15 -0600
parents dcd2978a7d18
children 4dba8c7e242c
files lwasm/instab.c lwasm/pseudo.c
diffstat 2 files changed, 46 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/lwasm/instab.c	Sat Mar 27 22:44:46 2010 -0600
+++ b/lwasm/instab.c	Sat Mar 27 22:59:15 2010 -0600
@@ -97,6 +97,13 @@
 extern RESOLVEFUNC(pseudo_resolve_zmq);
 extern EMITFUNC(pseudo_emit_zmq);
 
+extern PARSEFUNC(pseudo_parse_org);
+#define pseudo_resolve_org NULL
+#define pseudo_emit_org NULL
+
+extern PARSEFUNC(pseudo_parse_equ);
+#define pseudo_resolve_equ NULL
+#define pseudo_emit_equ NULL
 
 instab_t instab[] =
 {
@@ -357,11 +364,11 @@
 	{ "tste",		{	0x114d,	-1,		-1,		-1	},	insn_parse_inh,			insn_resolve_inh,				insn_emit_inh,				lwasm_insn_is6309},
 	{ "tstf",		{	0x115d,	-1,		-1,		-1	},	insn_parse_inh,			insn_resolve_inh,				insn_emit_inh,				lwasm_insn_is6309},
 	{ "tstw",		{	0x105d,	-1,		-1,		-1	},	insn_parse_inh,			insn_resolve_inh,				insn_emit_inh,				lwasm_insn_is6309},
-
+*/
 	{ "org",		{	-1, 	-1, 	-1, 	-1 },	pseudo_parse_org,		pseudo_resolve_org,				pseudo_emit_org,			lwasm_insn_normal},
-
 	{ "equ",		{	-1, 	-1, 	-1, 	-1 },	pseudo_parse_equ,		pseudo_resolve_equ,				pseudo_emit_equ,			lwasm_insn_setsym},
 	{ "=",			{	-1, 	-1, 	-1, 	-1 },	pseudo_parse_equ,		pseudo_resolve_equ,				pseudo_emit_equ,			lwasm_insn_setsym},
+/*
 	{ "extern",		{	-1, 	-1, 	-1, 	-1 },	pseudo_parse_extern,	pseudo_resolve_extern,			pseudo_emit_extern,			lwasm_insn_setsym},
 	{ "external",	{	-1, 	-1, 	-1, 	-1 },	pseudo_parse_extern,	pseudo_resolve_extern,			pseudo_emit_extern,			lwasm_insn_setsym},
 	{ "import",		{	-1, 	-1, 	-1, 	-1 },	pseudo_parse_extern,	pseudo_resolve_extern,			pseudo_emit_extern,			lwasm_insn_setsym},
--- a/lwasm/pseudo.c	Sat Mar 27 22:44:46 2010 -0600
+++ b/lwasm/pseudo.c	Sat Mar 27 22:59:15 2010 -0600
@@ -506,3 +506,40 @@
 	for (i = 0; i < l -> len; i++)
 		lwasm_emit(l, 0);	
 }
+
+PARSEFUNC(pseudo_parse_org)
+{
+	lw_expr_t e;
+	
+	e = lwasm_parse_expr(as, p);
+	if (!e)
+	{
+		lwasm_register_error(as, l, "Bad operand");
+		return;
+	}
+	
+	lw_expr_destroy(l -> addr);
+	l -> addr = e;
+	l -> len = 0;
+}
+
+PARSEFUNC(pseudo_parse_equ)
+{
+	lw_expr_t e;
+	
+	if (!(l -> sym))
+	{
+		lwasm_register_error(as, l, "Missing symbol");
+		return;
+	}
+	
+	e = lwasm_parse_expr(as, p);
+	if (!e)
+	{
+		lwasm_register_error(as, l, "Bad operand");
+		return;
+	}
+	
+	register_symbol(as, l, l -> sym, e, symbol_flag_none);
+	l -> symset = 1;
+}