[fpc-devel] How are short/ansi strings implemented ?

Skybuck Flying skybuck2000 at hotmail.com
Sat Apr 16 14:06:59 CEST 2011


Hello,

I've been wondering lately a little bit how the basic types are implemented.

Now byte, integer and so forth seem easy, these can be directly translated 
by the assemblers into machine instructions.

However pascal's string types, seem more of a special type, one could 
consider this a "software type" which is not really implemented by the 
instruction set and therefore requires some kind of software routines to 
make it work.

Furthermore it seems obvious to me for the compiler to be able to compile 
itself with string support that it needs some kind of units/source code 
which implements these string types in a self-supporting/self-hosting 
fashion so that it does not depend on the implementation of other compilers.

So my question about this is:

1. What units are responsible for the implementation of "pascal strings".

Second question will probably be automatically answered by 1 but I'll ask it 
just in case anyway:

2. Are these units part of the compiler or the rtl and please explain why.

My guess would be that:

1. these units would probably be part of the compiler, otherwise the 
compiler could not handle strings itself ?

or

2. I can also imagine a situation where the compiler would first be 
"string-less" and then it would first compile the rtl (which would contain 
the string types) and then later on it would do a re-compile of itself to 
introduce the strings for itself... though this last possibility seems a 
little bit more cumbersome... but perhaps it would have certain adventages 
as well or maybe just disadventages.

Such which one is it ? Some more clearification/explanation would be nice ;)

Bye,
  Skybuck.




More information about the fpc-devel mailing list