changeset 83:964d68cde469

Fixed problems with re8 and rel16 addressing
author lost
date Wed, 14 Jan 2009 06:33:13 +0000
parents 03be43ae19cf
children e12edcfbebd5
files src/insn_rel.c
diffstat 1 files changed, 3 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/src/insn_rel.c	Sat Jan 10 22:24:29 2009 +0000
+++ b/src/insn_rel.c	Wed Jan 14 06:33:13 2009 +0000
@@ -38,14 +38,13 @@
 	
 	lwasm_emitop(as, l, instab[opnum].ops[0]);
 
-	if ((r = lwasm_expr_result2(as, l, p, EXPR_PASS2CONST | EXPR_NOINTERSECT, &v, 0)) != 0)
+	if ((r = lwasm_expr_result2(as, l, p, EXPR_PASS2CONST | EXPR_NOINTERSECT, &v, 0)) < 0)
 		v = 0;
 	else
 	{
 		if (as -> passnum == 1)
 		{
 			// need to adjust the expression
-			v -= as -> addr + 1;
 			if (l -> exprs[0])
 			{
 				t = lwasm_expr_term_create_int(as -> addr + 1);
@@ -83,17 +82,16 @@
 	lwasm_emitop(as, l, instab[opnum].ops[0]);
 	
 	r = lwasm_expr_result2(as, l, p, EXPR_PASS2CONST, &v, 0);
-	if (r != 0)
+	if (r < 0)
 		v = 0;
 	else
 	{
 		if (as -> passnum == 1)
 		{
 			// need to adjust the expression
-			v -= as -> addr + 1;
 			if (l -> exprs[0])
 			{
-				t = lwasm_expr_term_create_int(as -> addr + 1);
+				t = lwasm_expr_term_create_int(as -> addr + 2);
 				lwasm_expr_stack_push(l -> exprs[0], t);
 				lwasm_expr_term_free(t);
 				t = lwasm_expr_term_create_oper(LWASM_OPER_MINUS);