Fortran Compiler for Sinclair ZX Spectrum rediscovered after 40 years

Via a Mastodon toot about it. It was rediscovered in April 2019.

It turns out that everything worked perfectly. On loading it into a Spectrum emulator, Barry could enter and compile Fortran on this platform for the first time in decades!

4 Likes

What a find! It produces standalone executables (5k minimum size) but not very compact (50 bytes for a line of Fortran) and not especially fast (twice as fast as Basic in a benchmark - but then again “Integer arithmetic proved to be fast — between 30 and 100 times quicker than BASIC and similar in speed to Mcoder and Softek’s IS integer BASIC compilers.”). Some quotes from this linked 1987 review:

Mira Fortran is based on Fortran 77S, a small version of the current standard. Mira Fortran can also compile many programs written using older standards such as Fortran 66 and Fortran IV.

15 quid buys you a 16-page dot-matrix-printed instruction manual, and a cassette containing two copies of the compiler and three demonstration programs.

The Mira Fortran editor loads from tape in about 90 seconds, and works much like the ZX BASIC editor. You type in lines character by character at the bottom of the 32-column screen; earlier entries are displayed at the top. Long lines wrap around at the edge of the display. You can move left and right on the usual way to correct mistakes in the line you’re working on.

Mira Fortran recognises most of Fortran 77; the biggest restriction is probably the absence of COMPLEX and DOUBLE data types. Decimal values use the Spectrum’s default precision of about nine digits, and integers are limited to the range -32768 to +32767. Logical (true or false) values are packed into single bits to save space.

When your program is complete the X key starts the compiler. Before it generates machine code, Mira Fortran scans the whole program at a rate of about 16 lines a second, looking for mistakes that could not be spotted on a line-by-line basis, such as missing ENDs or mistyped names. If a mistake is found one of 15 rather general error messages appears: for instance, an absent END produces the unhelpful message ‘Wrong statement order’.

The next step is to load the second part of the system, which actually performs the machine-code translation. The translator takes a minute to load, and then it scans through the program at about 30 lines a second, generating machine code. When it has finished it displays a list of numbers: the code address, length, place to CLEAR before running and, for no apparent reason, the address of the program’s COMMON storage area.

As soon as you press a key — by accident or deliberately — the information vanishes and the machine resets, leaving the code at the top of memory.

2 Likes

I don’t know why, but I’m always a bit enthusiastic, when I hear of a FORTRAN compiler for a micro. I’m not even a FORTRAN programmer, myself.

1 Like

Now there’s a surprise … the “Timex” Sinclair was my first computer, and Fortran was my first computer language (for my BSc. in Maths degree … done on cards with card punch machines, waiting in the basement of the CS building to get a printout that let me know that where I had hit , I should have hit . instead).

I did very little with the Timex Sinclair, and don’t believe I ever did any Fortran programming since I passed Fortran class … so having both together would be a case of (almost never used)^2.

2 Likes