[fpc-devel] Linux assembler start-up: rtl/linux/*/*.as

Edmund Grimley Evans edmund.grimley.evans at gmail.com
Thu May 28 00:57:05 CEST 2015

Is there a good reason why the Linux start-up is implemented with so
much assembler code?

There are lots of inexplicable differences between the corresponding
files for different architectures, and there are also inexplicable
differences between cprt0.as and gprt0.as on some architectures, or
between prt0.as and dllprt0.as. When implementing aarch64-linux I
spent a lot of time wondering which architecture I should take as a

As far as I can tell very little in those files has to be implemented
in assembler: perhaps just the initial argument marshalling and
initialising the frame pointer. The rest could be done in Pascal,
presumably, with the code shared between architectures. It would be a
lot easier to maintain that way.

Some questions to answer if one were going to rewrite that stuff in

- In which source file would the Pascal code go?

- Would there be four separate Pascal entry points, one for each
  assembler file? (Each could take arguments: fini, argc, argv, envp.)

- How to do the equivalent of C longjmp in Pascal, used in
  x86_64/gprt0.as, for example?


More information about the fpc-devel mailing list