changeset 418:4b137a8cf32a

Implemented "branch points"
author lost@l-w.ca
date Tue, 10 Aug 2010 23:08:30 -0600
parents f792faf877bb
children 7c0598f69cf3
files lwasm/lwasm.c lwasm/lwasm.h lwasm/pass1.c
diffstat 3 files changed, 25 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/lwasm/lwasm.c	Tue Aug 10 23:08:07 2010 -0600
+++ b/lwasm/lwasm.c	Tue Aug 10 23:08:30 2010 -0600
@@ -137,11 +137,31 @@
 	
 	case lwasm_expr_nextbp:
 		{
+			line_t *cl = ptr;
+			for (cl = cl -> next; cl; cl = cl -> next)
+			{
+				if (cl -> isbrpt)
+					break;
+			}
+			if (cl)
+			{
+				return lw_expr_copy(cl -> addr);
+			}
 			return NULL;
 		}
 	
 	case lwasm_expr_prevbp:
 		{
+			line_t *cl = ptr;
+			for (cl = cl -> prev; cl; cl = cl -> prev)
+			{
+				if (cl -> isbrpt)
+					break;
+			}
+			if (cl)
+			{
+				return lw_expr_copy(cl -> addr);
+			}
 			return NULL;
 		}
 	}
--- a/lwasm/lwasm.h	Tue Aug 10 23:08:07 2010 -0600
+++ b/lwasm/lwasm.h	Tue Aug 10 23:08:30 2010 -0600
@@ -170,6 +170,7 @@
 	int soff;							// struct offset (for listings)
 	int dshow;							// data value to show (for listings)
 	int dsize;							// set to 1 for 8 bit dshow value
+	int isbrpt;							// set to 1 if this line is a branch point
 	struct symtabe *dptr;				// symbol value to display
 };
 
--- a/lwasm/pass1.c	Tue Aug 10 23:08:07 2010 -0600
+++ b/lwasm/pass1.c	Tue Aug 10 23:08:30 2010 -0600
@@ -98,6 +98,7 @@
 		cl -> dshow = -1;
 		cl -> dsize = 0;
 		cl -> dptr = NULL;
+		cl -> isbrpt = 0;
 		as -> cl = cl;
 		if (!as -> line_tail)
 		{
@@ -209,7 +210,9 @@
 					/* do nothing */ ;
 			}
 		}
-		if (sym)
+		if (sym && strcmp(sym, "!") == 0)
+			cl -> isbrpt = 1;
+		else if (sym)
 			cl -> sym = lw_strdup(sym);
 		cl -> symset = 0;