Constants

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Constants

Carsten Bager
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?

Regards Carsten


_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Constants

Florian Klaempfl
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?
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Constants

Martin Schreiber
On Sunday 08 January 2006 13.03, Florian Klaempfl wrote:
> 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?

In embedded work *all* should be possible. Every job is a special job and
needs special solutions.

Da kommt noch einiges auf euch zu!  ;-)

Martin
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Constants

Carsten Bager
In reply to this post by Florian Klaempfl
> 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

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

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

Or something that worked the same way.

Regards
Carsten

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Constants

Martin Schreiber
On Tuesday 10 January 2006 08.17, Carsten Bager wrote:
> The very best would be if things was like this
>
> Static
> St: array[0..4] of char ='12345'; {Placed in text segment}
>
> Var
> St: array[0..4] of char ='12345'; {Placed in data segment}
>

Or to have any count of named segments which can be selected at var or const
definition.

Var in text         <- use the appropriate notation
 St: array[0..4] of char ='12345'; {Placed in text segment}

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

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


Martin
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal