#37 Initialised array at specic address

closed
nobody
None
5
2005-08-16
2005-08-16
a_wombat
No

I am fairly new to SDCC, and find it to be very good.
However, I have run into a problem and do not know how to
resolve it.

My hardware is a P89V51RD2 (Philips), which has 64k of
user flash in the code space. (128 byte flash sectors)

If I define an array to exist in code space, but allowing the
compiler to assign the address, the data is definitely in
the .lst file.

ie: code mydata[] = { 1, 2, 3 , 4 }; // works! compiler
assigned ad-hoc address

If I try to specifically place the data though, ie:
code at 0xc000 mydata[] = { 1, 2, 3, 4 }; // failure

The lst file only contains a few references to the item for the
second case, and only appears to store the pointer to the
data, not the data itself! (or "as well")

Have I missed something here?

i also tried "const code at 0xc000 mydata[] ...", this also
fails! (the const seems somewhat superflous!)
I am certain this question must have been submitted
before, but a (admitedly quick) search of the archives
revealed very little.

Does anyone know how to work around this issue?

Discussion

  • Maarten Brock
    Maarten Brock
    2005-08-16

    Logged In: YES
    user_id=888171

    This is RFE 859412 and it's also documented in the manual
    under Absolute addressing.

     
  • Maarten Brock
    Maarten Brock
    2005-08-16

    • status: open --> closed
     
  • a_wombat
    a_wombat
    2005-08-16

    Logged In: YES
    user_id=1329887

    Thanks Maarten

    I found that in the manual. after I had posted this.

    The compiler
    does not reserve any space for variables declared in this way
    (they are implementedwith an equate in the assembler).

    How do i get RFE 859412?

    I suppose I can always assemble the item and link it in to the
    project?

     
  • Maarten Brock
    Maarten Brock
    2005-08-16

    Logged In: YES
    user_id=888171

    You found "Support" in the menu at the SourceForge SDCC
    site. I'm sure you can find "RFE" there too.

    The manual even says:
    Variables with an absolute address are not initialized.

    You can also put it in a separate file, add #pragma constseg
    MYSEG, and locate this segment with a -Wl-
    bMYSEG=0x2000 linker option. See also Open Discussion
    Forum item "bankswitching".

     
  • a_wombat
    a_wombat
    2005-08-16

    Logged In: YES
    user_id=1329887

    Thanks again Maarten.

    I did indeed find the RFE.

    The #Pragma option seems the easiest way to do this at
    present. My assembler code needs some "kicking" to get the
    AS8051 to compile it.

    This should also help me place my IAP code to utilise the
    P89V51's "inbuilt access procedures" to the flash routines.
    (Philips call this IAP)

    It is because of the Flash block size that I wish to align
    the data at a 0x80 boundary. Preferably well away from where
    the code might eventually grow.

    Anyway, your help is much appreciated!