diff src/pseudo.c @ 47:804d7465e0f9

Implemented ORG and fixed problems with constants using $, &, or @ to specify base
author lost
date Sun, 04 Jan 2009 07:25:03 +0000
parents 34568fab6058
children 21ae0fab469b
line wrap: on
line diff
--- a/src/pseudo.c	Sun Jan 04 07:07:00 2009 +0000
+++ b/src/pseudo.c	Sun Jan 04 07:25:03 2009 +0000
@@ -1,6 +1,6 @@
 /*
 pseudo.c
-Copyright © 2008 William Astle
+Copyright © 2009 William Astle
 
 This file is part of LWASM.
 
@@ -21,29 +21,38 @@
 This file implements the various pseudo operations.
 */
 
-#include <ctype.h>
 #include <stdlib.h>
-#include <string.h>
 #include "lwasm.h"
 #include "instab.h"
+#include "expr.h"
 
-#include <stdio.h>
 
-void pseudo_org(asmstate_t *as, sourceline_t *cl, char **optr)
+OPFUNC(pseudo_org)
 {
-	int v1, rval;
+	int rval;
+	lwasm_expr_stack_t *s;
 	
-	if (cl -> hassym)
+	if (l -> sym)
 	{
-		register_error(as, cl, ERR_SYM);
-		cl -> hassym = 0;
+		register_error(as, l, 1, "No symbol allowed with ORG");
 	}
-	rval = eval_expr(as, cl, optr, &v1);
-	cl -> addr = v1;
-	cl -> addrset = 1;
-	as -> addr = v1;
+	s = lwasm_evaluate_expr(as, l, *p, NULL);
+	if (!s)
+	{
+		register_error(as, l, 1, "Bad expression");
+		return;
+	}
+	if (!lwasm_expr_is_constant(s))
+	{
+		register_error(as, l, 1, "Illegal incomplete reference (pass 1)");
+		return;
+	}
+	rval = lwasm_expr_get_value(s);
+	l -> codeaddr = rval;
+	as -> addr = rval;
 }
 
+/*
 void pseudo_include(asmstate_t *as, sourceline_t *cl, char **optr)
 {
 	int v1;
@@ -584,3 +593,4 @@
 	cl -> user_error = strdup(*optr);
 	errorp1(ERR_USER);
 }
+*/