diff src/pseudo.c @ 103:26c058fa0bc1

Fixed up some issues with pseudo ops and object target
author lost
date Fri, 23 Jan 2009 05:48:55 +0000
parents 3dcb12a6f4ff
children 2ba8f9ef1417
line wrap: on
line diff
--- a/src/pseudo.c	Fri Jan 23 04:42:39 2009 +0000
+++ b/src/pseudo.c	Fri Jan 23 05:48:55 2009 +0000
@@ -130,7 +130,7 @@
 		as -> addr += l -> nocodelen;
 		return;
 	}
-	r = lwasm_expr_result2(as, l, p, EXPR_PASS1CONST, &v, -1);
+	r = lwasm_expr_result2(as, l, p, EXPR_SECTCONST | EXPR_PASS1CONST, &v, -1);
 	if (r != 0)
 		return;
 	l -> nocodelen = v;
@@ -146,7 +146,7 @@
 		as -> addr += l -> nocodelen;
 		return;
 	}
-	r = lwasm_expr_result2(as, l, p, EXPR_PASS1CONST, &v, 0);
+	r = lwasm_expr_result2(as, l, p, EXPR_SECTCONST | EXPR_PASS1CONST, &v, 0);
 	if (r != 0)
 		return;
 	v *= 2;
@@ -163,7 +163,7 @@
 		as -> addr += l -> nocodelen;
 		return;
 	}
-	r = lwasm_expr_result2(as, l, p, EXPR_PASS1CONST, &v, 0);
+	r = lwasm_expr_result2(as, l, p, EXPR_SECTCONST | EXPR_PASS1CONST, &v, 0);
 	if (r != 0)
 		return;
 	v *= 4;
@@ -175,7 +175,7 @@
 {
 	int r, v;
 	
-	r = lwasm_expr_result2(as, l, p, EXPR_PASS1CONST, &v, 0);
+	r = lwasm_expr_result2(as, l, p, EXPR_SECTCONST | EXPR_PASS1CONST, &v, 0);
 	if (r != 0)
 		return;
 	while (v--)
@@ -186,7 +186,7 @@
 {
 	int r, v;
 	
-	r = lwasm_expr_result2(as, l, p, EXPR_PASS1CONST, &v, 0);
+	r = lwasm_expr_result2(as, l, p, EXPR_SECTCONST | EXPR_PASS1CONST, &v, 0);
 	if (r != 0)
 		return;
 	v *= 2;
@@ -198,7 +198,7 @@
 {
 	int r, v;
 	
-	r = lwasm_expr_result2(as, l, p, EXPR_PASS1CONST, &v, 0);
+	r = lwasm_expr_result2(as, l, p, EXPR_SECTCONST | EXPR_PASS1CONST, &v, 0);
 	if (r != 0)
 		return;
 	v *= 4;
@@ -246,7 +246,7 @@
 		return;
 	}
 	
-	r = lwasm_expr_result2(as, l, p, EXPR_PASS1CONST, &v, 0);
+	r = lwasm_expr_result2(as, l, p, EXPR_SECTCONST | EXPR_PASS1CONST, &v, 0);
 	if (r != 0)
 	{
 		l -> symaddr = as -> addr;
@@ -280,7 +280,7 @@
 		return;
 	}
 
-	r = lwasm_expr_result2(as, l, p, EXPR_PASS1CONST, &v, 0);
+	r = lwasm_expr_result2(as, l, p, EXPR_SECTCONST | EXPR_PASS1CONST, &v, 0);
 	if (r < 0)
 		v = 0;
 
@@ -304,7 +304,7 @@
 		return;
 	}
 
-	r = lwasm_expr_result2(as, l, p, EXPR_PASS1CONST, &v, 0);
+	r = lwasm_expr_result2(as, l, p, EXPR_SECTCONST | EXPR_PASS1CONST, &v, 0);
 	if (r < 0)
 		v = 0;
 
@@ -325,7 +325,7 @@
 	}
 	
 	// setdp is needed on both passes; must resolve to a constant on pass 1
-	r = lwasm_expr_result2(as, l, p, EXPR_PASS1CONST, &v, 0);
+	r = lwasm_expr_result2(as, l, p, EXPR_SECTCONST | EXPR_PASS1CONST, &v, 0);
 	if (r != 0)
 		return;
 
@@ -439,17 +439,26 @@
 OPFUNC(pseudo_fdb)
 {			
 	int r, v;
+	int extseen = 0;
+	char *p1;
 	
 fdb_again:
+	p1 = *p;
 	r = lwasm_expr_result2(as, l, p, 0, &v, -1);
 	if (r < 0)
 		return;
 
-	if (r > 0)
+	if (r > 0 && extseen == 1)
 	{
-		register_error(as, l, 2, "Illegal external or inter-segment reference");
+		register_error(as, l, 2, "Illegal external or inter-segment reference (only 1 per FDB line)");
 		v = 0;
 	}
+	else if (r > 0)
+	{
+		l -> relocoff = as -> addr - l -> codeaddr;
+		*p = p1;
+		r = lwasm_expr_result2(as, l, p, 0, &v, 0);
+	}
 
 	lwasm_emit(as, l, v >> 8);
 	lwasm_emit(as, l, v & 0xff);
@@ -532,7 +541,7 @@
 		return;
 	}
 
-	rval = lwasm_expr_result2(as, l, p, EXPR_PASS1CONST, &v1, 0);
+	rval = lwasm_expr_result2(as, l, p, EXPR_SECTCONST | EXPR_PASS1CONST, &v1, 0);
 	if (rval != 0)
 		return;
 	if (!v1)
@@ -553,7 +562,7 @@
 		return;
 	}
 
-	rval = lwasm_expr_result2(as, l, p, EXPR_PASS1CONST, &v1, 0);
+	rval = lwasm_expr_result2(as, l, p, EXPR_SECTCONST | EXPR_PASS1CONST, &v1, 0);
 	if (rval != 0)
 		return;
 	if (v1)
@@ -574,7 +583,7 @@
 		return;
 	}
 
-	rval = lwasm_expr_result2(as, l, p, EXPR_PASS1CONST, &v1, 0);
+	rval = lwasm_expr_result2(as, l, p, EXPR_SECTCONST | EXPR_PASS1CONST, &v1, 0);
 	if (rval != 0)
 		return;
 	if (v1 >= 0)
@@ -595,7 +604,7 @@
 		return;
 	}
 
-	rval = lwasm_expr_result2(as, l, p, EXPR_PASS1CONST, &v1, 0);
+	rval = lwasm_expr_result2(as, l, p, EXPR_SECTCONST | EXPR_PASS1CONST, &v1, 0);
 	if (rval != 0)
 		return;
 	if (v1 > 0)
@@ -616,7 +625,7 @@
 		return;
 	}
 
-	rval = lwasm_expr_result2(as, l, p, EXPR_PASS1CONST, &v1, 0);
+	rval = lwasm_expr_result2(as, l, p, EXPR_SECTCONST | EXPR_PASS1CONST, &v1, 0);
 	if (rval != 0)
 		return;
 	if (v1 <= 0)
@@ -637,7 +646,7 @@
 		return;
 	}
 
-	rval = lwasm_expr_result2(as, l, p, EXPR_PASS1CONST, &v1, 0);
+	rval = lwasm_expr_result2(as, l, p, EXPR_SECTCONST | EXPR_PASS1CONST, &v1, 0);
 	if (rval != 0)
 		return;
 	if (v1 < 0)