Variables Declared with __at Not Initialized

Todd Brown
2008-09-23
2013-03-12
  • Todd Brown

    Todd Brown - 2008-09-23

    I have an array I need to load into a specific location in memory, but it doesn't get initialized.  I can see the problem in the generated .asm file.  So:

    __code unsigned char good[] = { 0, 1, 2, 3 };
    __code __at (0x2800) unsigned char bad[] = { 0, 1, 2, 3 };

    Will generate the following in the .asm file:

    _good:
        .db #0x00
        .db #0x01
        .db #0x02
        .db #0x03
    _bad    =   0x2800

    Note there are no .db calls for _bad...which is...bad!

    Can someone explain this behavior and tell me how to get around it?

    Best,
      Todd

     
    • Todd Brown

      Todd Brown - 2008-09-23

      In section 3.5 of the SDCC manual (Absolute Addressing), it explicitly states that if an initializer is provided, the memory will be reserved, but it doesn't say anything about being initialized....

       
    • Maarten Brock

      Maarten Brock - 2008-10-05

      Todd,

      Which compiler version are you using? And for which target are you compiling?

      Maarten

       
    • Todd Brown

      Todd Brown - 2008-10-05

      SDCC 2.6.0 #4309 (Nov 10 2006)

      I am targeting MCS51 (8051); the processor in question is an NXP P89v664.

      Sorry, I suppose I should have thought to include this critical information the first time!

      Best,
        T

       
    • Maarten Brock

      Maarten Brock - 2008-10-08

      Todd,

      Please try again with a more current version of SDCC. It is at 2.8.0 or even 2.8.4 if you use the snapshots.

      Maarten

       
    • Todd Brown

      Todd Brown - 2008-10-09

      Maarten,

      Upgrading to 2.8.0 solved the problem.  FYI, I'm using an Ubuntu system, and I acquired SDCC by using apt-get to install the SCC package.  I did an update in hopes that I would get 2.8.0, but no luck -- it's still stuck at 2.6.0, so I had to download and install it manually.

      Maybe you care and maybe you don't, but if you do, you may want to speak to the maintainer of the Ubuntu package about updating that package.

      Thanks again!

      Todd

       

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks