# HG changeset patch # User William Astle # Date 1436842742 21600 # Node ID d791d47afc48572f522ceed308dbf3bd5154b9ef # Parent b0ec15f955638dd4e3e8dc0a44874bc688309c5b Add m80ext pragma for Macro-80C compatibility and ignore END in includes For compatibility with Macro-80C source, add pragma for it. Also implement ignoring END in include files rather than treating it as the total end of assembly. Thanks to Erik G for the patch. diff -r b0ec15f95563 -r d791d47afc48 lwasm/input.c --- a/lwasm/input.c Mon Jul 13 20:56:48 2015 -0600 +++ b/lwasm/input.c Mon Jul 13 20:59:02 2015 -0600 @@ -82,6 +82,11 @@ struct ifl *ifl_head = NULL; +int input_isinclude(asmstate_t *as) +{ + return IS->type == input_type_include; +} + static int input_isabsolute(const char *s) { #if defined(WIN32) || defined(WIN64) diff -r b0ec15f95563 -r d791d47afc48 lwasm/input.h --- a/lwasm/input.h Mon Jul 13 20:56:48 2015 -0600 +++ b/lwasm/input.h Mon Jul 13 20:59:02 2015 -0600 @@ -38,6 +38,7 @@ char *input_readline(asmstate_t *as); char *input_curspec(asmstate_t *as); FILE *input_open_standalone(asmstate_t *as, char *s, char **rfn); +int input_isinclude(asmstate_t *as); struct ifl { diff -r b0ec15f95563 -r d791d47afc48 lwasm/lwasm.h --- a/lwasm/lwasm.h Mon Jul 13 20:56:48 2015 -0600 +++ b/lwasm/lwasm.h Mon Jul 13 20:59:02 2015 -0600 @@ -98,7 +98,8 @@ PRAGMA_CD = 1 << 17, // enable detailed cycle count PRAGMA_CT = 1 << 18, // enable cycle count running total PRAGMA_CC = 1 << 19, // clear cycle count running total - PRAGMA_QRTS = 1 << 20 // enable BRA ?RTS support + PRAGMA_QRTS = 1 << 20, // enable BRA ?RTS support + PRAGMA_M80EXT = 1 << 21 // enable Macro-80C assembler extensions }; enum diff -r b0ec15f95563 -r d791d47afc48 lwasm/pragma.c --- a/lwasm/pragma.c Mon Jul 13 20:56:48 2015 -0600 +++ b/lwasm/pragma.c Mon Jul 13 20:59:02 2015 -0600 @@ -69,6 +69,7 @@ { "cd", "nocd", PRAGMA_CD }, { "ct", "noct", PRAGMA_CT }, { "qrts", "noqrts", PRAGMA_QRTS }, + { "m80ext", "nom80ext", PRAGMA_M80EXT }, { 0, 0, 0 } }; diff -r b0ec15f95563 -r d791d47afc48 lwasm/pseudo.c --- a/lwasm/pseudo.c Mon Jul 13 20:56:48 2015 -0600 +++ b/lwasm/pseudo.c Mon Jul 13 20:59:02 2015 -0600 @@ -95,9 +95,13 @@ { lw_expr_t addr; - as -> endseen = 1; l -> len = 0; - + + if (CURPRAGMA(l, PRAGMA_M80EXT) && input_isinclude(as)) + return; /* ignore END inside includes */ + + as->endseen = 1; + if (as -> output_format != OUTPUT_DECB) { skip_operand(p); @@ -123,7 +127,10 @@ EMITFUNC(pseudo_emit_end) { lw_expr_t addr; - + + if (CURPRAGMA(l, PRAGMA_M80EXT) && input_isinclude(as)) + return; /* ignore END inside includes */ + addr = lwasm_fetch_expr(l, 0); if (addr)