# HG changeset patch # User lost # Date 1231626269 0 # Node ID 03be43ae19cfee342bab2f6cefe8ced7a32fd543 # Parent b6b1e79cc2778f4c0f6f14d0e69f2b6236abbcfd Added EXTERN directive diff -r b6b1e79cc277 -r 03be43ae19cf src/instab.c --- a/src/instab.c Sat Jan 10 19:05:15 2009 +0000 +++ b/src/instab.c Sat Jan 10 22:24:29 2009 +0000 @@ -75,7 +75,8 @@ extern OPFUNC(pseudo_endsection); extern OPFUNC(pseudo_pragma); extern OPFUNC(pseudo_starpragma); - +extern OPFUNC(pseudo_extern); +\ instab_t instab[] = { { "abx", { 0x3a, -0x1, -0x1, -0x1 }, insn_inh }, @@ -322,6 +323,9 @@ { "equ", { -1, -1, -1, -1 }, pseudo_equ, 0, 0, 1 }, { "=", { -1, -1, -1, -1 }, pseudo_equ, 0, 0, 1 }, + { "extern", { -1, -1, -1, -1 }, pseudo_extern, 0, 0, 1 }, + { "external", { -1, -1, -1, -1 }, pseudo_extern, 0, 0, 1 }, + { "rmb", { -1, -1, -1, -1 }, pseudo_rmb }, { "rmd", { -1, -1, -1, -1 }, pseudo_rmd }, diff -r b6b1e79cc277 -r 03be43ae19cf src/lwasm.h --- a/src/lwasm.h Sat Jan 10 19:05:15 2009 +0000 +++ b/src/lwasm.h Sat Jan 10 22:24:29 2009 +0000 @@ -98,6 +98,7 @@ #define SYMBOL_COMPLEX 2 // register symbol as a complex symbol (from l -> expr) #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 typedef struct lwasm_symbol_ent_s lwasm_symbol_ent_t; struct lwasm_symbol_ent_s { @@ -105,6 +106,7 @@ int context; // the context number of the symbol (-1 for global) int value; // the value of the symbol int flags; // flags for the symbol + char *externalname; // for external references that are aliased locally sectiontab_t *sect; // the section the symbol exists in; NULL for none lwasm_expr_stack_t *expr; // expression for a symbol that is not constant NULL for const lwasm_symbol_ent_t *next; // next symbol in the table diff -r b6b1e79cc277 -r 03be43ae19cf src/pseudo.c --- a/src/pseudo.c Sat Jan 10 19:05:15 2009 +0000 +++ b/src/pseudo.c Sat Jan 10 22:24:29 2009 +0000 @@ -761,3 +761,23 @@ as -> csect = 0; as -> context = lwasm_next_context(as); } + +OPFUNC(pseudo_extern) +{ + if (as -> passnum != 1) + return; + + if (as -> outformat != OUTPUT_OBJ) + { + register_error(as, l, 1, "External references only supported for obj target"); + return; + } + + if (as -> csect) + { + register_error(as, l, 1, "Cannot declare external symbols within a section"); + return; + } + + lwasm_register_symbol(as, l, l -> sym, 0, SYMBOL_EXTERN); +} diff -r b6b1e79cc277 -r 03be43ae19cf src/symbol.c --- a/src/symbol.c Sat Jan 10 19:05:15 2009 +0000 +++ b/src/symbol.c Sat Jan 10 22:24:29 2009 +0000 @@ -141,6 +141,7 @@ se -> sect = as -> csect; se -> expr = NULL; se -> flags = flags; + se -> externalname = NULL; return 0; }