ast@cs.vu.nl (Andrew S. Tanenbaum) (10/14/87)
At long last, here is the announcement of the Pascal compiler for MINIX. It is available from the following two companies: UniPress Software Transmediair Utrecht BV 2025 Lincoln Highway Melkweg 3 Edison, NJ 08817 3721 RG Bilthoven USA Holland Tel: (201) 985-8000 Tel: +31 (30) 78 18 20 Source code is available. Contact them for pricing and more information. As this compiler belongs to the Vrije Universiteit, and the royalties the sales generate are used to allow graduate students to travel to conferences, I ask people not to copy or further distribute the software from UniPress and Transmediair. These ground rules are different than for MINIX itself. I will be off-line for several weeks starting tomorrow. If there are TECHNICAL questions (as opposed to marketing questions), they can be directed to Ceriel Jacobs at ceriel@cs.vu.nl. Andy Tanenbaum (ast@cs.vu.nl) =========================================================================== .ce 5 THE MINIX PASCAL COMPILER Andrew S. Tanenbaum Johan Stevenson Ceriel Jacobs .PP The MINIX Pascal compiler is derived from the Amsterdam Compiler Kit (see Communications of the ACM, Sept 1983, pp. 654-660). The MINIX Pascal compiler and MINIX C compiler are built up of several modules, most of which are common to both compilers. Schematically, the two compilers look like this: .nf cpp preprocessor (handles #include, #define, etc) / \ pem cem pem = Pascal front end; cem = C front end (parser) \ / opt optimizer (reads EM code, produces optimized EM) | cg code generator (reads optimized EM, produces .s) | asld assembler-loader (assembles .s files to a.out) .fi In addition, there are driver programs that call the compiler passes. The C driver is called cc; the Pascal driver is called pc. Pascal also has a program em_pc that does error reporting and other things. The two compilers are almost the same. The only real difference is the front end, which converts the input program to EM code, an intermediate code used throughout the ACK system. Once the front end has converted the input program to EM code, the optimization, code generation and assembly is identical. .PP The directories contain the sources of the MINIX Pascal compiler. Binaries for MINIX are also included. The front-end is written in Pascal, the rest is written in C. The compiler uses UNIX system calls for I/O, but none of these are very elaborate, mostly just reads and writes, so the compiler should be easy to port to various computers. The biggest problem is probably, that the front-end is written in Pascal, so you need a Pascal compiler (preferably the Amsterdam Compiler Kit Pascal compiler) to compile it. It has been tested on the folowing systems: .nf - IBM PC running the PC-IX operating system (PC-IX = IBM's UNIX for the PC) - VAX 11/750 running 4.1 BSD - IBM PC running MINIX - SUN 3 workstation .fi Moving it to other systems is up to the user. .PP The compiler is distributed as 7 directories. The files in each directory are to be compiled and linked into a separate binary, so that when you are done you will have 7 binaries. These correspond to the main program, an error reporter, and the 5 passes of the compiler. The table below describes the programs (named for their directories), the input files and the output files, and a brief description of what the programs do. See Appendix C of "Operating Systems: Design and Implementation" by Andrew S. Tanenbaum (Prentice-Hall, 1987) for additional information. .nf Prog Input Output Function pc --- --- Main program; calls the various passes em_pc --- --- Driver and error reporter for Pascal compiler cpp file.p file.i Preprocessor (handles #include, #define, #ifdef) pem file.i file.k Parsing and semantic analysis opt file.k file.m Optimization cg file.m file.s Code generation asld file.s a.out Assembly and linking of libraries .fi .PP The directories "cpp", "opt", "cg", and "asld", are the same ones as those of the MINIX C compiler. Only the front-ends and the driver programs are different, although the "pc" program is perfectly capable of driving the C compiler. In fact, if you make a link "cc" to "pc", then this "cc" behaves much like the MINIX "cc". The (older) cc program cannot drive Pascal. The versions of opt and cg provided with Pascal are the same ones as are supplied with the MINIX 1.2 C compiler. Be careful about mixing pieces of the MINIX 1.1 and 1.2 C compilers however; they are not interchangeable. You need all of 1.1 or all of 1.2, not mixtures. .PP Each directory, except for the front-end, contains a makefile. Each makefile contains two options, for making a compiler to run on MINIX and for making a compiler to run on a VAX running UNIX. To generate a compiler to run on MINIX, make sure that the variable 'l' gives the directory in which the MINIX library is contained, and the CFLAGS variable contains a -I flag for the standard include files, such as <stdio.h>. Then type 'make minix'. Similarly, for making a cross compiler to run on a VAX that produces code to run on MINIX, type 'make unix'. .PP There are two minor things to watch out for. First, the program 'pc' must know where to find the various passes of the compiler. These are defined by the strings PP, PC, PEM, OPT, CG, and ASLD in the files 'pc/pcpaths.h', 'pc/paths512k.h', and 'pc/paths640k.h'. The variables LIBC and LIBP tell pc where to find the libraries. .PP As described in the book, the compiler produces .s files, rather than .o files (even when you say 'pc -c file.p'), and the assembler-linker expects these. The libraries are also in .s format, except that they are in compact format. The programs libpack and libupack in the commands directory can be used to go back and forth between compact and ASCII format. .PP The other thing to watch out for is in cg. The file 'wr.c' contains a procedure 'write' that does the compaction of the ASCII output fed to it. However, when it finally wants to generate output, it calls 'realwrite', which calls 'callm1'. In the MINIX version, 'callm1' is a library procedure that sends a message to the file system to achieve output. In the UNIX version, it calls an assembly language version of the UNIX write(2) system call, only renamed, because 'write' is being used to filter output from ASCII to compact code. .PP Other than these two minor issues, and of course the fact that the Pascal front-end is written in Pascal, there is nothing tricky about the compiler and it should work without much trouble.