Development Systems and Created Code (reentrant, ROMable, ...)
Posted: Tue Jul 07, 2020 4:40 pm
NOTE: This thread started originally on the first 4 pages in the thread (discussion) "EJC (C-Compiler) experiments". But as it is offtopic in this thread, I have created this one.
Peter said in the above thread: "PDQC can create ROMable code".
Well that is correct and (I'm afraid) also wrong. The C-Compiler of PDQC (Lattice as in EJC and Metacomco C Development Kit [MCDK]) can create reentrant and even ROMable code. Therefore you must use the compiler option "-b" in phase 1.
But the PDQC Development System does (I'm afraid) not create reentrant code, not even position independent code. The reason is, that the libraries (at least qlib_l) are NOT compiled with the -b option. There is a (short) manual for PDQC on Dilwyns eBooks page, and it states in the description for option -b:
"It may be possible to link with modules not compiled with this option if they do not use any register pointer variables but the practice is not recommended. Also the supplied QL library qlib_l has not been compiled with this option, as it would require a special linker to use programs with over 64K of data. This option is still useable if you only wish to link to similarly compiled object files or to your own, carefully designed assembly language objectfiles."
This is the same as with the original MCDK. EJC Libraries are compiled with the -b option and so programs created with EJC are reentrant and ROMable (but static data limited to 64 KBytes) AND functions must be arranged in a way, that jumps (branches) to them are never > +- 32KByte. If you have a look in the attached screenshot in my message for the example program simplecalc (in thread EJC (C-Compiler) experiments page 4), you will see the command for phase 1 of the Lattice compiler. The cc (or my changed ecc) compiler driver inserts the -b switch as default.
It would be of interest, if EJC can be used with the Lattice C from PDQC, as it seems to support some newer constructs like const. But it's an Atari ST program which requires the TOS emulator. I don't know what file is the TOS emulator and how it must be started. But it should be possible, albeit the cc compiler driver most probably must be adapted.
Conclusion: It's not sufficient to have a compiler, which can create reentrant code. More important is, that all library functions are reentrant. Of course you can use Lattice C to compile modules (with the -b option) and then call it's functions from reentrant assembler code.
BTW: AFAIK Prospero Fortran and Pascal also create reentrant code (code which can be HOT_CHP'ed without the I(gitit) option). AND, albeit not capable of Multitasking in the beginning (because the Cursor was not enabled, can be cured with a few lines of SuperBASIC), the PSION programs are reentrant.
Peter said in the above thread: "PDQC can create ROMable code".
Well that is correct and (I'm afraid) also wrong. The C-Compiler of PDQC (Lattice as in EJC and Metacomco C Development Kit [MCDK]) can create reentrant and even ROMable code. Therefore you must use the compiler option "-b" in phase 1.
But the PDQC Development System does (I'm afraid) not create reentrant code, not even position independent code. The reason is, that the libraries (at least qlib_l) are NOT compiled with the -b option. There is a (short) manual for PDQC on Dilwyns eBooks page, and it states in the description for option -b:
"It may be possible to link with modules not compiled with this option if they do not use any register pointer variables but the practice is not recommended. Also the supplied QL library qlib_l has not been compiled with this option, as it would require a special linker to use programs with over 64K of data. This option is still useable if you only wish to link to similarly compiled object files or to your own, carefully designed assembly language objectfiles."
This is the same as with the original MCDK. EJC Libraries are compiled with the -b option and so programs created with EJC are reentrant and ROMable (but static data limited to 64 KBytes) AND functions must be arranged in a way, that jumps (branches) to them are never > +- 32KByte. If you have a look in the attached screenshot in my message for the example program simplecalc (in thread EJC (C-Compiler) experiments page 4), you will see the command for phase 1 of the Lattice compiler. The cc (or my changed ecc) compiler driver inserts the -b switch as default.
It would be of interest, if EJC can be used with the Lattice C from PDQC, as it seems to support some newer constructs like const. But it's an Atari ST program which requires the TOS emulator. I don't know what file is the TOS emulator and how it must be started. But it should be possible, albeit the cc compiler driver most probably must be adapted.
Conclusion: It's not sufficient to have a compiler, which can create reentrant code. More important is, that all library functions are reentrant. Of course you can use Lattice C to compile modules (with the -b option) and then call it's functions from reentrant assembler code.
BTW: AFAIK Prospero Fortran and Pascal also create reentrant code (code which can be HOT_CHP'ed without the I(gitit) option). AND, albeit not capable of Multitasking in the beginning (because the Cursor was not enabled, can be cured with a few lines of SuperBASIC), the PSION programs are reentrant.