diff lwasm/pseudo.c @ 382:80d615a6642c

Add REORG pseudo op For Macro-80C compatibility, add REORG pseudo op. It has some utility so this one is not protected by a pragma. Thanks to Erik G <erik@6809.org> for the patch.
author William Astle <lost@l-w.ca>
date Mon, 13 Jul 2015 21:18:02 -0600
parents e3f4aaa2a4e8
children 6ee9c67a0f8d
line wrap: on
line diff
--- a/lwasm/pseudo.c	Mon Jul 13 21:11:12 2015 -0600
+++ b/lwasm/pseudo.c	Mon Jul 13 21:18:02 2015 -0600
@@ -965,6 +965,44 @@
 	l -> len = 0;
 }
 
+PARSEFUNC(pseudo_parse_reorg)
+{
+	lw_expr_t e = NULL;
+
+	l -> len = 0;
+
+	line_t *cl = l;
+	for (cl = cl -> prev; cl; cl = cl -> prev)
+	{
+		if (cl -> insn == -1) continue;
+
+		if (!strcmp("org", instab[cl -> insn].opcode))
+		{
+			if (cl -> prev)
+			{
+				e = lw_expr_copy(cl -> prev -> daddr);
+				break;
+			}
+		}
+	}
+
+	if (!e)
+	{
+		lwasm_register_error(as, l, E_ORG_NOT_FOUND);
+		return;
+	}
+
+	lw_expr_destroy(l -> daddr);
+	l -> daddr = e;
+
+	if (l -> inmod == 0)
+	{
+		lw_expr_destroy(l -> addr);
+		l -> addr = e;
+	}
+	l -> len = 0;
+}
+
 PARSEFUNC(pseudo_parse_equ)
 {
 	lw_expr_t e;