|
> legOS 0.2.3 or 0.2.4 will load .strings and .rodata sections just like the
> .text section. With this you can achive persistent data by storing your
> variables into the .strings section. There are some nice features in gcc
> to help with this.
>
> Just insert __persistent between the variable name and equal sign followed
> by a value. You need an initializer for the data, else it will not be put
> into .strings, but into .bss
>
> The sample code implements a persistent counter counting the runs of the
> program starting with 0.
>
> -- cut here --
> #include <unistd.h>
> #include <conio.h>
>
> /*
> * This is the real definition of __persistent, it could move
> * into some header file...
> */
> #define __persistent __attribute__ ((__section__ (".strings")))
>
> /*
> * This is how you declare the persistent data:
> */
> static unsigned int counter __persistent = 0;
>
> int
> main(int argc, char **argv)
> {
> lcd_number(counter++, unsign, e0);
> return 0;
> }
> -- cut here --
>
> Hope this helps,
> Eddie C. Dost
> ecd@skynet.be
Hi again!
I have found that this works with scalar variables. However, I need to
make an array persistent. More specifically, I have a 100x100 matrix
containing a population for use with genetic programming and I need to be
able to keep this in memory while the RCX is turned off. Is this possible?
Tobias
|
|
Message has 1 Reply:
Message is in Reply To:
| | Re: Persistent globals
|
| (...) legOS 0.2.3 or 0.2.4 will load .strings and .rodata sections just like the .text section. With this you can achive persistent data by storing your variables into the .strings section. There are some nice features in gcc to help with this. Just (...) (24 years ago, 16-Jul-00, to lugnet.robotics.rcx.legos)
|
12 Messages in This Thread:
- Entire Thread on One Page:
- Nested:
All | Brief | Compact | Dots
Linear:
All | Brief | Compact
This Message and its Replies on One Page:
- Nested:
All | Brief | Compact | Dots
Linear:
All | Brief | Compact
|
|
|
|