[z88dk-dev] sccz80 and absolute placement of variables

Bridge to the z88dk-developers mailing list
Post Reply
alvin
Well known member
Posts: 1872
Joined: Mon Jul 16, 2007 7:39 pm

[z88dk-dev] sccz80 and absolute placement of variables

Post by alvin »

I've got this bit of code here that works fine:

Code: Select all

#define NIRVANAP_TOTAL_ROWS 19

static unsigned char NIRVANAP_isr[3] @ (56698+328*NIRVANAP_TOTAL_ROWS);

void main(void)
{
NIRVANAP_isr[0] = 205;
}
except for the fact that "NIRVANAP_isr" is made public in the translated asm:

Code: Select all

; --- Start of Scope Defns ---

PUBLIC        _NIRVANAP_isr
defc        _NIRVANAP_isr        =        62930
PUBLIC        _main
This is a problem because it means I can't put the declaration of NIRVANAP_isr[] into a header file. Each source file that includes it will export the symbol as public and the linker will complain that there are multiple instances of the same name.

The equivalent in sdcc is working with the static keyword there but sccz80 is ignoring static for placement syntax. The relevant code is line 388 in sccz80::main.c. There should be some way to know if the symbol is static and if so, the PUBLIC part should not be output. However once that's done, there's another problem: sccz80 emits these symbols at the end of the translation so z80asm will be left with a lone defc at the end and will complain about symbol not found when it is used above in the source code (the 'PUBLIC' causes z80asm to resolve the symbol and without it defc is undefined prior to its occurrence). So sccz80 would also have to be modified to output either all symbols before the translation or just these static defcs.

Are you up for another problem? :) I can start poking around but it's better if it's done by someone who knows what's going on.



------------------------------------------------------------------------------
User avatar
dom
Well known member
Posts: 2076
Joined: Sun Jul 15, 2007 10:01 pm

Post by dom »

The equivalent in sdcc is working with the static keyword there but sccz80 is ignoring static for placement syntax.
The storage is marked as EXTERNP which trumps static, so we'll need to introduce a new storage type for that one, not a massive issue, there'll be somewhere in declvar.c that needs a tweak.
there's another problem: sccz80 emits these symbols at the end of the translation so z80asm will be left with a lone defc at the end and will complain about symbol not found when it is used above in the source code
I don't understand this bit, compiling to assembler, editing to remove the PUBLIC, and then assembling doesn't report an error.



------------------------------------------------------------------------------
alvin
Well known member
Posts: 1872
Joined: Mon Jul 16, 2007 7:39 pm

Post by alvin »

I don't understand this bit, compiling to assembler, editing to remove the PUBLIC, and then assembling doesn't report an error.
You're right -- the assembler must have changed. The new storage class is all that's needed then.



------------------------------------------------------------------------------
Post Reply