[fpc-pascal] Constants

Carsten Bager carsten at beas.dk
Tue Jan 10 08:17:23 CET 2006

> Carsten Bager wrote:
> > Hi
> > I am programming to an embedded ARM platform and my question 
> > is, is it possible to force constants to stay in the code segment 
> > (constant strings etc.) In C you can do this using "static".
> > It looks as all string constants are placed in the data segment, and all 
> > variables are placed in the bss segment. Is that always the case? 
> Yes. What's the exact reason you need them in text segment?

The Arm I use has 512KB flash and 32KB Ram, therefore I would 
like if I could define text constants that where placed in the flash 
segment (text). A way around this is:
1. To define string constants in an assembler file. 
2. To tell the linker that the data segment are placed in flash (at the 
right location). Then change the start up code so it dos not initialize 
the data segment and change the system files so all predefined 
variables are changed to normal variables which are initialized.
I have not tried (2), but I assume it is possible.

The very best would be if things was like this

St: array[0..4] of char ='12345'; {Placed in text segment}

St: array[0..4] of char ='12345'; {Placed in data segment}

Or something that worked the same way.


More information about the fpc-pascal mailing list