changeset 80:8929e1ee99cf

Checkpointing deployment of non-constant expression handling
author lost
date Sat, 10 Jan 2009 07:18:59 +0000
parents d0ce3f5f6797
children b6b1e79cc277
files src/insn_bitbit.c src/insn_logicmem.c
diffstat 2 files changed, 8 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/src/insn_bitbit.c	Sat Jan 10 07:09:14 2009 +0000
+++ b/src/insn_bitbit.c	Sat Jan 10 07:18:59 2009 +0000
@@ -30,13 +30,14 @@
 #include "instab.h"
 #include "expr.h"
 
+// these instructions cannot tolerate external references
 OPFUNC(insn_bitbit)
 {
 	int r;
 	lwasm_expr_stack_t *s;
 	int v1;
 	int tv;
-		
+
 	lwasm_emitop(as, l, instab[opnum].ops[0]);
 	
 	r = toupper(*(*p)++);
--- a/src/insn_logicmem.c	Sat Jan 10 07:09:14 2009 +0000
+++ b/src/insn_logicmem.c	Sat Jan 10 07:18:59 2009 +0000
@@ -31,6 +31,7 @@
 extern void insn_gen_aux(asmstate_t *as, lwasm_line_t *l, char **optr, int opnum, int extra);
 
 // for aim, oim, eim, tim
+// the immediate operand must be constant on pass 2
 OPFUNC(insn_logicmem)
 {
 	int rval, v1;
@@ -40,20 +41,14 @@
 	if (**p == '#')
 		(*p)++;
 	
-	s = lwasm_evaluate_expr(as, l, *p, &p2);
-	*p = (char *)p2;
+	rval = lwasm_expr_result2(as, l, p, 0, &v1, 1);
+	if (rval != 0)
+		v1 = 0;
+	if (rval == 1 && as -> passnum == 2)
+		register_error(as, l, 2, "Illegal external or intersegment reference");
 
-	if (!s)
-	{
-		register_error(as, l, 1, "Bad expression");
-		return;
-	}
-	
 	if (v1 < -128 || v1 > 255)
-	{
 		register_error(as, l, 2, "Byte overflow");
-		v1 &= 0xff;
-	}
 	
 	if (**p != ',' && **p != ';')
 	{