My future extensions to the runtime library will be Pascal functions, not ASSEMBLER, so I tried to change the system in a way that it is easier to add new (Pascal) library functions.
At the moment, SNAPSHOT is the only Pascal library function that is added to the compiler generated Pascal code.
SNAPSHOT is an external Pascal function with a dummy Pascal main program, containing the X+ compiler switch. This has three effects:
the external names are derived directly from the Pascal procedure names
the main program is renamed from $MAINBLK to #MAINBLK, so that it is not called from the Pascal monitor program
all names in the program (!) are allowed to start with the $ character
But this is not sufficient at all. When you add another "module" built in this way, you get duplicate names (#MAINBLK) on the linkage editor. And: the internal procedures of deeper nesting levels have the external attribute, too. In the end, I want to be able to add more than one external module (written in Pascal) to the compiler generated main program, and it should be no problem, if there exist procedures with the same name anywhere at deeper levels.
So I changed the Pascal system in the following way:
allowing a program unit to start with the new keyword MODULE instead of PROGRAM, which implies the X+ switch and enforces an empty main program (syntax errors, if not)
with the MODULE keyword, there is no code generated for the empty main program, so there are no name collisions
I wanted only the top level function and procedure names to be external (that is: known to the linker), but that did not work at the moment, because they all are CSECTS - this has to wait until later
When this all worked, I converted SNAPSHOT to the new design (MODULE keyword etc.) and renamed it to $PASSNAP. This all worked without problems.
Then I did further renames to make the names more consistent accross the Pascal system. That is:
$TRACER (which is an entry in the Pascal monitor) is now called $PASTRC
$MAINBLK (the entry to the main program generated by the compiler and called by the Pascal monitor) is now called $PASMAIN
In fact, we now have four kinds of predefined procedures or functions:
simple functions, which are implemented by inline code (some P-code instructions); for example PRED, SUCC, ORD, ROUND, ABS, ...
functions, which refer to a CSP P-Code instruction (they are implemented in $PASCSP, which is part of the Pascal Monitor); for example most I/O procedures
functions, which are implemented by external Pascal library functions (there is not much at the moment, only $PASSNAP; but I will use this to build the new LE storage management functions)
FORTRAN math library functions (SIN, COS, ...)