Turbo Pascal Compiler

October 16, 2013

My friend Fredrik Fatemi and I spent the summer after high school (1989) writing graphics programs in Turbo Pascal on his 286 PC (with EGA!) in his basement while watching The Princess Bride again and again on his VCR. He recently found some 3½" diskettes with our programs on it. I couldn’t find a good way to run them on my Mac, so naturally I wrote a Turbo Pascal compiler. It’s web based and you can try it here.

A few notes:

  1. It implements the subset of the language and standard library that I needed to run these five programs. That’s most of the language and a useful subset of the graphics module.
  2. It’s about 6,000 lines of JavaScript code and uses a hand-coded recursive-descent parser.
  3. It compiles to p-code that’s binary compatible with the 1978 UCSD Pascal Compiler. (The real Turbo Pascal compiled directly to machine language.)
  4. For kicks I also implemented a web version of the Turbo Pascal 3.0 menu. Only the Dir, Edit, Work File, and Run commands work. The language and libraries are closer to the later versions, though.

The ROSE.PAS program is our crowning achievement. It’s an animated canvas of a centipede moving slowly toward a golf ball under a rose. It’s really a dumping ground for a bunch of visual experiments, including a fractal mountain. It’s the program I most wanted to see run again.

The SPIDER.PAS program was inspired by a demo on the SGI Iris graphics workstation. That summer Fredrik was an intern at the Naval Research Lab (and still works there today). They had an Iris and he had me drive all the way over there to see this demo, which was written by Thant Tessman and was called “insect” because it only had six legs. I will never forget the shell shock of seeing my first real-time graphics program.

The code is on GitHub: Turbo Pascal.

Back to projects