Using alternative libraries
Given that the new libraries have been written, how are they built into the program? This is done by the linker. The program and assembler routines are compiled and assembled into object modules. The object modules are then linked to-gether by the linker to create the final executable program. The new libraries are incorporated using one of two techniques. The actual details vary from linker to linker and will require checking in the documentation.
Linking additional libraries
This is straightforward. The new libraries are simply included on the command line with all the other modules or added to the list of libraries to search.
Linking replacement libraries
The trick here is to use the search order so that the replacement libraries are used first instead of the standard ones. Some linkers allow you to state the search order on the command line or through a command file. Others may need several link passes, where the first pass disables the automatic search and uses the replacement library and the second pass uses the automatic search and standard library to resolve all the other calls.
The example assembler routines simply use the predefined stack mechanisms to transfer data to and from PASCAL. At no point does the routine actually know that the data is coming from a high level language as opposed to an assembler routine — let alone differentiate between C and PASCAL. If a group of high level languages have common transfer mechanisms, it should be possible to share libraries and modules between them, without having to modify them or know how they were generated. Unfortunately, this utopia has not quite been realised, although some standards have been put forward to implement it.