diff lwasm/insn_indexed.c @ 371:9c24d9d485b9

Much bugfixing
author lost@starbug
date Wed, 21 Apr 2010 23:29:18 -0600
parents 7d91ab7ac7d6
children 8f9d72cfb897
line wrap: on
line diff
--- a/lwasm/insn_indexed.c	Tue Apr 20 21:59:58 2010 -0600
+++ b/lwasm/insn_indexed.c	Wed Apr 21 23:29:18 2010 -0600
@@ -263,13 +263,14 @@
 		// relative addressing modes
 		// on pass 1, adjust the expression for a subtraction of the
 		// current address
+		// e - (addr + linelen) => e - addr - linelen
 		
-		e1 = lw_expr_build(lw_expr_type_special, lwasm_expr_linelen, l);
-		e2 = lw_expr_build(lw_expr_type_oper, lw_expr_oper_plus, l -> addr, e1);
+		e2 = lw_expr_build(lw_expr_type_special, lwasm_expr_linelen, l);
+		e1 = lw_expr_build(lw_expr_type_oper, lw_expr_oper_minus, e, e2);
+		lw_expr_destroy(e2);
+		e2 = lw_expr_build(lw_expr_type_oper, lw_expr_oper_minus, e1, l -> addr);
 		lw_expr_destroy(e1);
-		e1 = lw_expr_build(lw_expr_type_oper, lw_expr_oper_minus, e, l -> addr);
-		lwasm_save_expr(l, 0, e1);
-		lw_expr_destroy(e2);
+		lwasm_save_expr(l, 0, e2);
 	}
 
 	l -> pb = (indir * 0x80) | rn | (f0 * 0x40);