Oppolzer - Informatik / Stanford Pascal Compiler


Home       Lebenslauf       Schwerpunkte       Kenntnisse       Seminare       Kunden       Projekte       Produkte       Blog       Stanford Pascal       Kontakt

The Stanford Pascal Compiler / Evolution Steps

Back to Compiler main page

Calling external procedures and functions written in ASSEMBLER

Compiler version: 12.2017

In the beginning, the support for external procedures and functions in Stanford Pascal was very limited. Only one external module was possible, due to name conflicts. This single external module was a Pascal program with the main program omitted. I changed this in 2016 and introduced MODULEs, look here:

Pascal library

With modules, it was possible to add an arbitrary number of external modules, containing one to many entries (external procedures and functions) and local procedures, which appear at lower levels or which have the LOCAL attribute (a new keyword). Further extensions included STATIC variables, which are global to the module, but not visible outside the module. There are also STATIC variables, which are local to procedures and functions. Find details here:

Static definitions

So external procedure and functions in Pascal are no problem any more, but some people asked for subroutines written in ASSEMBLER. Of course, it would be best, if these ASSEMBLER subprograms could be coded using the normal OS linkage conventions. Unfortunately, Pascal itself uses somehow different linkage conventions.

The compiler already supported FORTRAN subprograms, using the normal OS linkage. But FORTRAN has some restrictions on parameters; all parameters must be passed by reference. For by-value parameters, Pascal creates so-called dummy arguments (copies of the real parameters) and passes their addresses; this way, changes to the parameters done by the FORTRAN routines (if there are any) would get lost.

I decided not to do this for ASSEMBLER subprograms; instead all the by-value parameters are passed in the parameter list (register 1 based) in the same way as the C compiler does it. Consequently, the end of the parameter list cannot be marked (because it is not an address list any more).

Find much more technical details and some example programs here:

External Procedures in Stanford Pascal - written in Pascal, FORTRAN or Assembler (2017)

Back to Compiler main page