# HG changeset patch # User lost # Date 1237738100 0 # Node ID 563adfccb645922915f8b01f3c84839946062656 # Parent 1936ea52b83ea570ee538bf07fbb49219c62b681 Added 'sym=expr' opcode handling diff -r 1936ea52b83e -r 563adfccb645 ChangeLog --- a/ChangeLog Sun Mar 22 06:52:06 2009 +0000 +++ b/ChangeLog Sun Mar 22 16:08:20 2009 +0000 @@ -20,6 +20,8 @@ [+] added LWEX0 (LWOS simple binary) target to LWLINK [+] added ability to extract files in LWAR [+] added ability to "replace" members in LWAR +[+] added support for "sym=expr" in the opcode field; this will define a + global symbol (non-section) if it resolves to a constant [b] arranged for output files for lwasm/lwlink to be removed if the assembly or linking fails [ ] DECB output of LWLINK now collapses contiguous output blocks into single diff -r 1936ea52b83e -r 563adfccb645 lwasm/lwasm.h --- a/lwasm/lwasm.h Sun Mar 22 06:52:06 2009 +0000 +++ b/lwasm/lwasm.h Sun Mar 22 16:08:20 2009 +0000 @@ -108,6 +108,7 @@ int symaddr; // set if this instruction sets a symbol addr with EQU or the like int badop; // bad operation - ignore it int context; // the symbol context for this line + int forceglobal; // force a "global" symbol definition if constant // the following are used for obj format - for external references, inter-section // references, and intrasection relocations @@ -125,6 +126,7 @@ #define SYMBOL_FORCE 4 // force resetting the symbol value if it already exists on pass 2 #define SYMBOL_NORM 0 // no flags #define SYMBOL_EXTERN 8 // the symbol is an external reference +#define SYMBOL_GLOBAL 16 // force global if non-complex symbol typedef struct lwasm_symbol_ent_s lwasm_symbol_ent_t; struct lwasm_symbol_ent_s { diff -r 1936ea52b83e -r 563adfccb645 lwasm/parse.c --- a/lwasm/parse.c Sun Mar 22 06:52:06 2009 +0000 +++ b/lwasm/parse.c Sun Mar 22 16:08:20 2009 +0000 @@ -111,6 +111,25 @@ memcpy(opc, p, p2 - p); opc[p2 - p] = '\0'; + l -> forceglobal = 0; + // if the opcode contains an =, treat it as "symbol = expr" + if (!sym && strchr(opc, '=')) + { + for (p2 = opc; *p2 && *p2 != '='; p2++) + /* do nothing */ ; + sym = lwasm_alloc((p2 - opc) + 1); + memcpy(sym, opc, p2 - opc); + sym[p2 - opc] = '\0'; + l -> sym = sym; + + p2 = p + (p2 - opc) + 1; +// p2++; + opc[0] = '='; + opc[1] = '\0'; + debug_message(2, "Found opcode = with symbol %s and operand %s", sym, p2); + l -> forceglobal = 1; + } + debug_message(2, "Found operation code: '%s'", opc); // skip intervening whitespace if present diff -r 1936ea52b83e -r 563adfccb645 lwasm/pseudo.c --- a/lwasm/pseudo.c Sun Mar 22 06:52:06 2009 +0000 +++ b/lwasm/pseudo.c Sun Mar 22 16:08:20 2009 +0000 @@ -294,7 +294,7 @@ // note: we need to do this because the symbol might have resolved // to a constant! - lwasm_register_symbol(as, l, l -> sym, v, (r > 0 ? SYMBOL_COMPLEX: SYMBOL_NORM) | SYMBOL_FORCE); + lwasm_register_symbol(as, l, l -> sym, v, (r > 0 ? SYMBOL_COMPLEX: SYMBOL_NORM) | SYMBOL_FORCE | (l -> forceglobal ? SYMBOL_GLOBAL : SYMBOL_NORM)); } OPFUNC(pseudo_set) diff -r 1936ea52b83e -r 563adfccb645 lwasm/symbol.c --- a/lwasm/symbol.c Sun Mar 22 06:52:06 2009 +0000 +++ b/lwasm/symbol.c Sun Mar 22 16:08:20 2009 +0000 @@ -139,7 +139,7 @@ se -> sym = lwasm_strdup(sym); se -> context = scontext; - if (!(flags & SYMBOL_EXTERN)) + if (!(flags & SYMBOL_EXTERN) && ((flags & SYMBOL_COMPLEX) || !(flags & SYMBOL_GLOBAL))) se -> sect = as -> csect; else se -> sect = NULL;