|
From: Raphael N. <rn...@we...> - 2007-11-08 18:32:16
|
Hi Alan,
Sorry for having ported the wrong version; I just googled for picos and
found that one...
> These functions are defined as extern and prefixed by underscore at
> the header file, but the compiler is not placing they at "extern
> variables in this module" section into generated asm file. I tested
> removing the underscore from header declaration with no success.
Yes, this is a bug... Unused (or ones used only in inline assembly
fragment and thus effectively hidden from the compiler) extern
declarations are discarded; as a consequence, they do not appear in the
.asm file as EXTERN SYMBOL nor EXTERN _SYMBOL and hence cannot be
resolved by the assembler. Sigh...
The really bad workaround is to effectively access the symbols in c:
extern void _kernel(void);
with _kernel being only referenced in _asm ... _endasm; blocks such as
_asm goto _kernel _endasm;
should (for now) be rewritten as
extern kernel; // Note: SDCC mangles this into _kernel
static void *k = &kernel; // WORKAROUND SDCC BUG
As I said, the workaround is really bad: It is both a maintenance
nightmare and even costs memory space at runtime! I really need to look
into a way of emitting even unused externs...
Assembler symbols with no leading underscore need to be rewritten in the
defining .asm (or better .S) file to have a leading underscore if they
are to be accessed from C (which includes all symbols that need the
above workaround):
global tsk_1_stack
tsk_1_stack res 15
global great_function
great_function:
return
becomes
global _tsk_1_stack
_tsk_1_stack res 15
global _great_function
_great_function:
Alternatively one might introduce an option for SDCC not to add a
leading underscore to user-defined symbols, probably risking name
clashes with compiler-defined symbols...
Regards,
Raphael
|