Shop OBEX P1 Docs P2 Docs Learn Events
location of a long aray in memory — Parallax Forums

location of a long aray in memory

mike goettlingmike goettling Posts: 31
edited 2007-06-21 05:28 in Propeller 1
i have a long array···· long·· array[noparse][[/noparse]tiles/2]·

can i specify were in memory it is. i want the array to be at the end of program and·variable ·space.

the way my program is laid out now it has variables after it. i want the array it be the last varable do to issues with the way the user writes to it.

mike

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2007-06-21 05:16
    There's no reliable way to do this. The compiler does allocate variables of the same size in order within the same object, but I'm not sure what the order is for allocating objects although it's probably in compile order (each object as it's completed has its storage allocated).

    You could allocate it in the stack during the program's initialization and pass its address around.

    In the Propeller OS, I allocate a lot of tables and work areas at the end of memory, starting at $8000 and working "downwards" towards the program's stack. This occurs during the OS's initialization and the pointers to the various tables are stored in global variables at fixed locations in the high end of memory.
  • CardboardGuruCardboardGuru Posts: 443
    edited 2007-06-21 05:28
    Mike Goettling,

    Your problem is that immediately after the end of the code and data in memory comes the stack, which increases in size upwards from there. So even if you arrange the array to be the last thing in the program, it and the stack are going to interfere with each other if you decide to grow the array beyond the declared size. As Mike Green suggests, your best option is probably to arrange it so that your array grows downwards from $8000.
Sign In or Register to comment.