# HG changeset patch # User lost # Date 1244784341 0 # Node ID aa0056ca7319567f963d95f8810ed18bb9ed15e8 # Parent 4e25aa2af73c9de8ad5bfabaf519675c9e6a2488 Added a padding value for the ALIGN directive diff -r 4e25aa2af73c -r aa0056ca7319 ChangeLog --- 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 diff -r 4e25aa2af73c -r aa0056ca7319 doc/manual.docbook.sgml --- 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 @@ -ALIGN expr +ALIGN expr[,value] -Force the current assembly address to be a multiple of expr. -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. -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. - + +Force the current assembly address to be a multiple of +expr. If value is not +specified, a series of NUL bytes is output to force the alignment, if +required. Otherwise, the low order 8 bits of value +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, value may include forward references; as +long as it resolves to a constant for the second pass, the value will be +accepted. + +Unless value 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. + diff -r 4e25aa2af73c -r aa0056ca7319 lwasm/pseudo.c --- 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; }