Menu

Waste of RAM

2018-03-18
2018-03-19
  • Bertrand BAROTH

    Bertrand BAROTH - 2018-03-18

    Hello everybody ...
    I am presently writing a control program for a model railroad layout, the program has not yet been tested and debugged because neither the layout nor the (power) electronics are finished, I wanted only to test the capacities of the ATMega8 together with GCB to do the task.
    Now I took a glance to the ASM code ; there is a byte-array, dimensioned to 4 ; according to what I understood, the compiler should reserve 5 bytes for it ; but in fact, it reserves 16 ! The array begins at 96 and the next variable is located at 112 (the "aliases" use only adresses 97 to 100, so what is with 101 to 111 ? ). In my case it's not critical, because I use much less memory than available (it sounds stupid, but the Mega8 was the "smallest" easily available with at least 19 or perhaps 20 I/O for a planned modification). But this could cause problems to users who need more resources ...
    If You want, I can send the source to You (but don't try to understand its function ... or You wil be subject to headache ! )

     
  • Anobium

    Anobium - 2018-03-19

    Please post the source.

     
  • Bertrand BAROTH

    Bertrand BAROTH - 2018-03-19

    Here are both the source and the ASM ; the array is "Pile" and the next variable is "Position".
    Sorry, all variable names and comments are in french ...
    PS : I could use the ATMega-48, but the price is almost the same ; the "Tiny's" have only maximum 18 I/O, and I need once 8 bits, once 5 bits and once 5 (or perhaps 6) bits. I tested compiling for the Mega-48, and the result is the same : Pile at 256 and Position at 272 ...

     

    Last edit: Bertrand BAROTH 2018-03-19
  • Anobium

    Anobium - 2018-03-19

    The array pointer and the handler use the extra bytes. This is so the array handler can accept more than 256 bytes in an array. I guess we could optimise the handler but this would be low priority change.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.