changeset 383:848d3cca8078

Fixed imm8 to actually use expression and also fixed gen mode to respect > and <
author lost@starbug
date Sat, 15 May 2010 20:01:58 -0600
parents eacdae8a1575
children 38b50ce6967a
files lwasm/Makefile.am lwasm/insn_gen.c lwasm/lwasm.h lwasm/main.c lwasm/pass1.c
diffstat 5 files changed, 22 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/lwasm/Makefile.am	Sat May 15 13:39:21 2010 -0600
+++ b/lwasm/Makefile.am	Sat May 15 20:01:58 2010 -0600
@@ -4,6 +4,6 @@
 	instab.c symbol.c macro.c pass2.c pass3.c pass4.c pass5.c pass6.c \
 	insn_inh.c insn_rtor.c insn_tfm.c insn_rlist.c insn_rel.c \
 	insn_bitbit.c insn_indexed.c insn_gen.c insn_logicmem.c \
-	pseudo.c section.c os9.c pass7.c debug.c output.c
+	pseudo.c section.c os9.c pass7.c debug.c output.c list.c
 lwasm_LDADD = -L$(top_builddir)/lib -L$(top_srcdir)/lib -L$(top_builddir)/lwlib -L$(top_srcdir)/lwlib -lgnu -llw
 EXTRA_DIST =  lwasm.h input.h instab.h
--- a/lwasm/insn_gen.c	Sat May 15 13:39:21 2010 -0600
+++ b/lwasm/insn_gen.c	Sat May 15 20:01:58 2010 -0600
@@ -94,6 +94,9 @@
 		goto out;
 	}
 
+	if (l -> lint2 != -1)
+		goto out;
+
 	// if we have a constant now, figure out dp vs nondp
 	if (lw_expr_istype(s, lw_expr_type_int))
 	{
@@ -435,5 +438,6 @@
 	lw_expr_t e;
 	
 	lwasm_emitop(l, instab[l -> insn].ops[0]);
+	e = lwasm_fetch_expr(l, 0);
 	lwasm_emitexpr(l, e, 1);
 }
--- a/lwasm/lwasm.h	Sat May 15 13:39:21 2010 -0600
+++ b/lwasm/lwasm.h	Sat May 15 20:01:58 2010 -0600
@@ -164,6 +164,8 @@
 	int pragmas;						// pragmas in effect for the line
 	int context;						// the symbol context number
 	char *ltext;						// line number
+	char *linespec;						// line spec
+	int lineno;							// line number
 };
 
 enum
--- a/lwasm/main.c	Sat May 15 13:39:21 2010 -0600
+++ b/lwasm/main.c	Sat May 15 20:01:58 2010 -0600
@@ -175,6 +175,7 @@
 extern void do_pass6(asmstate_t *as);
 extern void do_pass7(asmstate_t *as);
 extern void do_output(asmstate_t *as);
+extern void do_list(asmstate_t *as);
 extern lw_expr_t lwasm_evaluate_special(int t, void *ptr, void *priv);
 extern lw_expr_t lwasm_evaluate_var(char *var, void *priv);
 extern lw_expr_t lwasm_parse_term(char **p, void *priv);
@@ -240,4 +241,6 @@
 	do_output(&asmstate);
 	
 	debug_message(&asmstate, 50, "Done assembly");
+	
+	do_list(&asmstate);
 }
--- a/lwasm/pass1.c	Sat May 15 13:39:21 2010 -0600
+++ b/lwasm/pass1.c	Sat May 15 20:01:58 2010 -0600
@@ -53,7 +53,7 @@
 	int stspace;
 	char *tok, *sym;
 	int opnum;
-	
+	int lc = 1;
 	for (;;)
 	{
 		sym = NULL;
@@ -74,6 +74,7 @@
 				as -> context = strtol(p1, NULL, 10);
 			}
 			lw_free(line);
+			lc = 1;
 			continue;
 		}
 		debug_message(as, 75, "Read line: %s", line);
@@ -81,6 +82,7 @@
 		cl = lw_alloc(sizeof(line_t));
 		memset(cl, 0, sizeof(line_t));
 		cl -> outputl = -1;
+		cl -> linespec = lw_strdup(input_curspec(as));
 		cl -> prev = as -> line_tail;
 		cl -> insn = -1;
 		cl -> as = as;
@@ -98,6 +100,7 @@
 		{
 			lw_expr_t te;
 
+			cl -> lineno = as -> line_tail -> lineno + 1;
 			as -> line_tail -> next = cl;
 
 			// set the line address
@@ -108,6 +111,14 @@
 
 			// carry DP value forward
 			cl -> dpval = cl -> prev -> dpval;
+			
+		}
+		if (!lc && strcmp(cl -> linespec, cl -> prev -> linespec))
+			lc = 1;
+		if (lc)
+		{
+			cl -> lineno = 1;
+			lc = 0;
 		}
 		as -> line_tail = cl;
 		as -> cl = cl;