What is itIt is a compiler that can be used for many computers and processors.
HistoryPreferring Pascal above C, I decided to write a Pascal compiler for my C64. Yes, there are various compilers available like Oxford Pascal and the Data-Becker version but I wanted one with the capabilities Borland's Turbo Pascal and written using Borland's Turbo Pascal 7.0 (TP7).
The first idea was to write one in ML but then the idea changed into writing it in Pascal with the idea that, in the end, it should be capable of compiling itself. The main idea was that it should generate a binary in the end and should be able to do it for the various Commodores: C64, PET, CBM, Plus/4 etc., etc. I even had some Z80 machines in mind. This meant that I had to reserve program lines for every type of machine for every component and that was a bit too much.
Then I got the great idea of not generating binaries but macros only! Macros can be completely independent of the used machine and/or processor. The only thing I had to do was to tell the assembler what file to use when translating the macros into ML. From this rose the idea that I also wanted it to run on a PC.
At this moment I'm writing the macro files for the 8088. I started with writing them for the C64 but testing the resulting executable was much simpler for the PC version. Still lot of work to do.....
The program itselfI didn't start completely from scratch. I collected various compilers and looked how they worked. Most worked the same: first a list with key words was created and when the parser ran into a word that belonged to that list, then the procedure that handled that keyword was started. So I did roughly the same.
Writing and testing the compilerI developed the program while testing it in the same time. The simplest program IMHO will look like this:
begin end.My compiler knows what first keywords it can expect and "begin" is one of then. So it runs the procedure connected to "begin" and runs it. Here the compiler is told what keywords it can expect now and how to handle them. At the end of the procdure it expects to run into the keyword "end" and nothing else. And in this case it expects this "end" to be followed by a dot, not a semicolon.
So I started with a very simple compiler that was able to handle this very simple program. Then I started to add valid lines, looked where it went wrong, and added the needed code so my compiler could handle them.
You can email me here.