changeset 235:aa0056ca7319

Added a padding value for the ALIGN directive
author lost
date Fri, 12 Jun 2009 05:25:41 +0000
parents 4e25aa2af73c
children a58f49a77441
files ChangeLog doc/manual.docbook.sgml lwasm/pseudo.c
diffstat 3 files changed, 41 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Fri Jun 12 04:55:16 2009 +0000
+++ b/ChangeLog	Fri Jun 12 05:25:41 2009 +0000
@@ -25,6 +25,8 @@
 [+] Added --6809/-9 switch to cause 6309 instructions to be rejected; also
     included --6309/-3 switch to force default allow of 6309 instructions
     [LWASM]
+[+] ALIGN now takes an optional padding value (ALIGN align,pad) to specify
+    the byte value that will be used for padding if needed [LWASM]
 [ ] Fixed a few cosmetic issues with error reporting
 
 Version 2.4
--- a/doc/manual.docbook.sgml	Fri Jun 12 04:55:16 2009 +0000
+++ b/doc/manual.docbook.sgml	Fri Jun 12 05:25:41 2009 +0000
@@ -649,15 +649,24 @@
 </varlistentry>
 
 <varlistentry>
-<term>ALIGN <parameter>expr</parameter></term>
+<term>ALIGN <parameter>expr</parameter>[,<parameter>value</parameter>]</term>
 <listitem>
-<para>Force the current assembly address to be a multiple of <parameter>expr</parameter>.
-A series of NUL bytes is output to force the alignment, if required. The
-alignment value must be fully resolved on the first pass because it affects
-the addresses of subsquent instructions.</para>
-<para>This directive is not suitable for inclusion in the middle of actual
-code. It is intended to appear where the bytes output will not be executed.
-</para>
+
+<para>Force the current assembly address to be a multiple of
+<parameter>expr</parameter>.  If <parameter>value</parameter> is not
+specified, a series of NUL bytes is output to force the alignment, if
+required.  Otherwise, the low order 8 bits of <parameter>value</parameter>
+will be used as the fill.  The alignment value must be fully resolved on the
+first pass because it affects the addresses of subsquent instructions. 
+However, <parameter>value</parameter> may include forward references; as
+long as it resolves to a constant for the second pass, the value will be
+accepted.</para>
+
+<para>Unless <parameter>value</parameter> is specified as something like $12,
+this directive is not suitable for inclusion in the middle of actual code. 
+The default padding value is $00 which is intended to be used within data
+blocks.  </para>
+
 </listitem>
 </varlistentry>
 
--- a/lwasm/pseudo.c	Fri Jun 12 04:55:16 2009 +0000
+++ b/lwasm/pseudo.c	Fri Jun 12 05:25:41 2009 +0000
@@ -326,14 +326,15 @@
 {
 	int cn;
 	int r, v;
-	
-	if (as -> passnum == 2)
-	{
-		skip_operand(p);
-		while (as -> addr < l -> symaddr)
-			lwasm_emit(as, l, 0);
-		return;
-	}
+	int pad = 0;
+// we have to parse this on pass 2 so that we get the pad value	
+//	if (as -> passnum == 2)
+//	{
+//		skip_operand(p);
+//		while (as -> addr < l -> symaddr)
+//			lwasm_emit(as, l, 0);
+//		return;
+//	}
 	
 	r = lwasm_expr_result2(as, l, p, EXPR_SECTCONST | EXPR_PASS1CONST, &v, 0);
 	if (r != 0)
@@ -352,9 +353,21 @@
 	if (cn)
 		cn = v - cn; 
 
+	if (**p == ',')
+	{
+		// we have a padding value specified
+		(*p)++;
+		r = lwasm_expr_result2(as, l, p, EXPR_SECTCONST, &pad, 1);
+		if (r != 0 && as -> passnum == 2)
+		{
+			register_error(as, l, 2, "Illegal padding value - must be constant on pass 2");
+			return;
+		}
+	}
+
 	while (cn--)
 	{
-		lwasm_emit(as, l, 0);
+		lwasm_emit(as, l, pad);
 	}
 	l -> symaddr = as -> addr;
 }