diff lwasm/output.c @ 12:6b9991fb39b6

Brought forward patch to fix bug with complex external references generating invalid relocations in the object file
author lost@l-w.ca
date Sat, 22 Jan 2011 16:11:15 -0700
parents 7317fbe024af
children d92b9c968731
line wrap: on
line diff
--- a/lwasm/output.c	Sat Jan 22 16:10:42 2011 -0700
+++ b/lwasm/output.c	Sat Jan 22 16:11:15 2011 -0700
@@ -234,6 +234,7 @@
 {
 	int tt;
 	int v;
+	int count = 1;
 	unsigned char buf[16];
 	
 	tt = lw_expr_type(e);
@@ -242,10 +243,12 @@
 	{
 	case lw_expr_type_oper:
 		buf[0] =  0x04;
+		
 		switch (lw_expr_whichop(e))
 		{
 		case lw_expr_oper_plus:
 			buf[1] = 0x01;
+			count = lw_expr_operandcount(e) - 1;
 			break;
 		
 		case lw_expr_oper_minus:
@@ -254,6 +257,7 @@
 		
 		case lw_expr_oper_times:
 			buf[1] = 0x03;
+			count = lw_expr_operandcount(e) - 1;
 			break;
 		
 		case lw_expr_oper_divide:
@@ -299,7 +303,8 @@
 		default:
 			buf[1] = 0xff;
 		}
-		writebytes(buf, 2, 1, of);
+		while (count--)
+			writebytes(buf, 2, 1, of);
 		return 0;
 
 	case lw_expr_type_int: