changeset 53:493cb8ea50a0

Added rm[dq], zm[bdq]
author lost
date Sun, 04 Jan 2009 20:28:30 +0000
parents b9856da2674a
children 360d53062bb9
files src/instab.c src/pseudo.c
diffstat 2 files changed, 94 insertions(+), 60 deletions(-) [+]
line wrap: on
line diff
--- a/src/instab.c	Sun Jan 04 20:16:38 2009 +0000
+++ b/src/instab.c	Sun Jan 04 20:28:30 2009 +0000
@@ -44,6 +44,11 @@
 extern OPFUNC(pseudo_org);
 extern OPFUNC(pseudo_equ);
 extern OPFUNC(pseudo_rmb);
+extern OPFUNC(pseudo_rmd);
+extern OPFUNC(pseudo_rmq);
+extern OPFUNC(pseudo_zmb);
+extern OPFUNC(pseudo_zmd);
+extern OPFUNC(pseudo_zmq);
 extern OPFUNC(pseudo_include);
 
 instab_t instab[] =
@@ -294,6 +299,12 @@
 	{ "=",		{ -1, -1, -1, -1 },	pseudo_equ },
 
 	{ "rmb", 	{ -1, -1, -1, -1 }, pseudo_rmb },
+	{ "rmd", 	{ -1, -1, -1, -1 }, pseudo_rmd },
+	{ "rmq", 	{ -1, -1, -1, -1 }, pseudo_rmq },
+
+	{ "zmb", 	{ -1, -1, -1, -1 }, pseudo_rmb },
+	{ "zmd", 	{ -1, -1, -1, -1 }, pseudo_rmd },
+	{ "zmq", 	{ -1, -1, -1, -1 }, pseudo_rmq },
 
 	{ "include", { -1, -1, -1, -1 }, pseudo_include },
 
--- a/src/pseudo.c	Sun Jan 04 20:16:38 2009 +0000
+++ b/src/pseudo.c	Sun Jan 04 20:28:30 2009 +0000
@@ -148,110 +148,133 @@
 	l -> nocodelen = rval;
 	as -> addr += rval;
 }
-/*
-void pseudo_rmd(asmstate_t *as, sourceline_t *cl, char **optr)
+
+OPFUNC(pseudo_rmd)
 {
-	int rval, v1;
+	int rval;
+	lwasm_expr_stack_t *s;
 	
-	rval = eval_expr(as, cl, optr, &v1);
-	if (rval < 0)
+	s = lwasm_evaluate_expr(as, l, *p, NULL);
+	if (!s)
 	{
-		errorp1(ERR_FORWARD);
-		return;
-	}
-	if (v1 < 0)
-	{
-		errorp1(ERR_BADOPER);
+		register_error(as, l, 1, "Bad expression");
 		return;
 	}
-	cl -> len = v1 * 2;
-	cl -> nocode = 1;
-}
-
-void pseudo_rmq(asmstate_t *as, sourceline_t *cl, char **optr)
-{
-	int rval, v1;
-	
-	rval = eval_expr(as, cl, optr, &v1);
-	if (rval < 0)
+	if (!lwasm_expr_is_constant(s))
 	{
-		errorp1(ERR_FORWARD);
+		register_error(as, l, 1, "Illegal incomplete reference (pass 1)");
+		lwasm_expr_stack_free(s);
 		return;
 	}
-	if (v1 < 0)
-	{
-		errorp1(ERR_BADOPER);
-		return;
-	}
-	cl -> len = v1 * 4;
-	cl -> nocode = 1;
+	rval = lwasm_expr_get_value(s) * 2;
+	lwasm_expr_stack_free(s);
+	l -> nocodelen = rval;
+	as -> addr += rval;
 }
 
-void pseudo_zmb(asmstate_t *as, sourceline_t *cl, char **optr)
+OPFUNC(pseudo_rmq)
 {
-	int rval, v1;
+	int rval;
+	lwasm_expr_stack_t *s;
 	
-	rval = eval_expr(as, cl, optr, &v1);
-	if (rval < 0)
+	s = lwasm_evaluate_expr(as, l, *p, NULL);
+	if (!s)
 	{
-		errorp1(ERR_FORWARD);
+		register_error(as, l, 1, "Bad expression");
 		return;
 	}
-	if (v1 < 0)
+	if (!lwasm_expr_is_constant(s))
 	{
-		errorp1(ERR_BADOPER);
+		register_error(as, l, 1, "Illegal incomplete reference (pass 1)");
+		lwasm_expr_stack_free(s);
 		return;
 	}
-	while (v1--)
-		emit(0);
+	rval = lwasm_expr_get_value(s) * 4;
+	lwasm_expr_stack_free(s);
+	l -> nocodelen = rval;
+	as -> addr += rval;
 }
 
-void pseudo_zmd(asmstate_t *as, sourceline_t *cl, char **optr)
+OPFUNC(pseudo_zmb)
 {
-	int rval, v1;
+	int rval;
+	lwasm_expr_stack_t *s;
 	
-	rval = eval_expr(as, cl, optr, &v1);
-	if (rval < 0)
+	s = lwasm_evaluate_expr(as, l, *p, NULL);
+	if (!s)
 	{
-		errorp1(ERR_FORWARD);
+		register_error(as, l, 1, "Bad expression");
 		return;
 	}
-	if (v1 < 0)
+	if (!lwasm_expr_is_constant(s))
 	{
-		errorp1(ERR_BADOPER);
+		register_error(as, l, 1, "Illegal incomplete reference (pass 1)");
+		lwasm_expr_stack_free(s);
 		return;
 	}
-	while (v1--)
+	rval = lwasm_expr_get_value(s);
+	lwasm_expr_stack_free(s);
+	while (rval-- > 0)
 	{
-		emit(0);
-		emit(0);
+		lwasm_emit(as, l, 0);
 	}
 }
 
-void pseudo_zmq(asmstate_t *as, sourceline_t *cl, char **optr)
+OPFUNC(pseudo_zmd)
 {
-	int rval, v1;
+	int rval;
+	lwasm_expr_stack_t *s;
 	
-	rval = eval_expr(as, cl, optr, &v1);
-	if (rval < 0)
+	s = lwasm_evaluate_expr(as, l, *p, NULL);
+	if (!s)
 	{
-		errorp1(ERR_FORWARD);
+		register_error(as, l, 1, "Bad expression");
 		return;
 	}
-	if (v1 < 0)
+	if (!lwasm_expr_is_constant(s))
 	{
-		errorp1(ERR_BADOPER);
+		register_error(as, l, 1, "Illegal incomplete reference (pass 1)");
+		lwasm_expr_stack_free(s);
 		return;
 	}
-	while (v1--)
+	rval = lwasm_expr_get_value(s);
+	lwasm_expr_stack_free(s);
+	while (rval-- > 0)
 	{
-		emit(0);
-		emit(0);
-		emit(0);
-		emit(0);
+		lwasm_emit(as, l, 0);
+		lwasm_emit(as, l, 0);
 	}
 }
 
+OPFUNC(pseudo_zmq)
+{
+	int rval;
+	lwasm_expr_stack_t *s;
+	
+	s = lwasm_evaluate_expr(as, l, *p, NULL);
+	if (!s)
+	{
+		register_error(as, l, 1, "Bad expression");
+		return;
+	}
+	if (!lwasm_expr_is_constant(s))
+	{
+		register_error(as, l, 1, "Illegal incomplete reference (pass 1)");
+		lwasm_expr_stack_free(s);
+		return;
+	}
+	rval = lwasm_expr_get_value(s);
+	lwasm_expr_stack_free(s);
+	while (rval-- > 0)
+	{
+		lwasm_emit(as, l, 0);
+		lwasm_emit(as, l, 0);
+		lwasm_emit(as, l, 0);
+		lwasm_emit(as, l, 0);
+	}
+}
+
+/*
 void pseudo_end(asmstate_t *as, sourceline_t *cl, char **optr)
 {
 	int rval, v1;