changeset 381:e3f4aaa2a4e8

Allow FCB-like syntax after constant in FCC under m80ext This is an abomination (say what you really mean!) but for compatibilty with Macro-80C, allow handling of FCB style syntax after a string constant specified for FCC. Mostly, there are better ways to do this in new code so it is only accepted under the m80ext pragma. Thanks to Erik G <erik@6809.org> for the patch.
author William Astle <lost@l-w.ca>
date Mon, 13 Jul 2015 21:11:12 -0600
parents 17fcd0c3ee45
children 80d615a6642c
files lwasm/lwasm.h lwasm/pseudo.c
diffstat 2 files changed, 23 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/lwasm/lwasm.h	Mon Jul 13 21:04:39 2015 -0600
+++ b/lwasm/lwasm.h	Mon Jul 13 21:11:12 2015 -0600
@@ -263,6 +263,7 @@
 	int cycle_adj;						// cycle adjustment
 	int	cycle_flags;					// cycle flags
 	int genmode;						// generation mode (insn_parse_gen0/8/16)
+	int fcc_extras;						// fcc extra bytes
 	lwasm_error_t *err;					// list of errors
 	lwasm_error_t *warn;				// list of errors
 	lwasm_errorcode_t err_testmode;		// error code in testmode
--- a/lwasm/pseudo.c	Mon Jul 13 21:04:39 2015 -0600
+++ b/lwasm/pseudo.c	Mon Jul 13 21:11:12 2015 -0600
@@ -436,7 +436,6 @@
 	delim = **p;
 	(*p)++;
 	
-	
 	i = cstringlen(as, l, p, delim);
 	
 	if (**p != delim)
@@ -446,14 +445,34 @@
 	}
 	(*p)++;	
 	l -> len = i;
+
+	/* handle additional expressions, like FCC "Hello",13,0 */
+	if (CURPRAGMA(l, PRAGMA_M80EXT))
+	{
+		if (**p == ',')
+		{
+			(*p)++;
+			pseudo_parse_fcb(as, l, p);
+			l -> fcc_extras = l -> len;
+			l -> len = i + l -> fcc_extras;
+		}
+	}
 }
 
 EMITFUNC(pseudo_emit_fcc)
 {
 	int i;
-	
-	for (i = 0; i < l -> len; i++)
+	lw_expr_t e;
+
+	for (i = 0; i < l -> len - l -> fcc_extras; i++)
 		lwasm_emit(l, l -> lstr[i]);
+
+	/* PRAGMA_M80EXT */
+	for (i = 0; i < l -> fcc_extras; i++)
+	{
+		e = lwasm_fetch_expr(l, i);
+		lwasm_emitexpr(l, e, 1);
+	}
 }
 
 PARSEFUNC(pseudo_parse_fcs)