Mira Software
Not Known
Programming: General
ZX Spectrum 48K

Simon Goodwin
Chris Bourne


FORTRAN, one of the world's first computer languages, now runs on the 48K Spectrum, thanks to Mira Software; this small Leicestershire firm has also released a Britisth Standard version of the Pascal language. Fortran and Pascal are widely used in colleges by engineering and computing students and, as a new academic year gets under way it seems a good time to check out these compilers.

Compilers take programs written in a form that humans can understand and translate them into machine code, the simple, fast language of the processor chip inside the computer.

As any hacker knows, the best way to learn about computing is to get lots of hands-on experience, but students often end up queueing for a small ration of time on overworked mainframes.

So even a Spectrum can help a lot if the right software is available. A few years ago I found it worthwhile to do most of my computing degree coursework on my humble Video Genie - a 48K machine with half the processing power of the Spectrum. For too long the mystique of the mainframe has led people to believe that you can't run serious languages on a small micro.

Consider the number of students and programming enthusiasts with Spectrums - Mira Software could be on to a winner if their compilers are up to scratch. After all, Turbo Pascal, for bigger micros, has sold half a million copies. Mira Fortran is unique on the Spectrum, and Hi Soft's ageing Pascal 4T is the only competitor of Mira Pascal.


30 years ago Fortran was a breakthrough, the first programming language that looked anything like English. It was developed to run on an early mainframe - an IBM 704 - and some of the peculiarities of that machine have been enshrined in the language ever since.

Hundreds of better languages followed Fortran, but it built up a following and went through several versions - like the Spectrum 128, but more slowly. Even BASIC was first developed in an attempt to make it easier to teach Fortran. The name stands for FORmula TRANslation.

IBM pitched the language at mathematicians and engineers. Nowadays Fortran is outdated, but it is used in so many standard routines that advanced engineering courses usually include Fortran programming.

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 A5 manual is too short to do justice to the program. It covers the difference between Mira Fortran and Fortran 77 at breakneck pace, throwing in a few useful hints and tips, and you have to read it several times before you're really sure what's going on. It you're new to Fortran you'll need a good tutorial; Roger Kaufman's Fortran Coloring Book, ISBN 0-262-61026-4, is my favourite.


When Fortran was invented, programs were not typed directly into the system but read from cards punched with holes to require a punched-card-reader - indicate the required commands. At least Mira Fortran doesn't but, like all Fortran systems, it still expects you to enter your program as if it were on a card, strictly laid out in columns.

There are three types of line in a Fortran program. Comment lines (like REMs in BASIC) start with a C or a *. Debug lines start with D. They are used during testing and you can tell the compiler to ignore them, for a finished program, or compile them, for a test run. Thus you can keep test routines in your program text, and choose whether or not to include them just before you compile.

Anything else is a normal program line. The first five characters must be spaces or digits. You can put a line number here if you like, as in a BASIC program, but lines don't have to have numbers - and the numbers don't have to be in the correct order, though obviously it helps if they are!

The sixth character on a program line is usually blank, but a + sign indicates that the line is a continuation of the previous line. Mira Fortran is unusually fussy in that anything else gives an error.

Individual Fortran lines have a fixed maximum length of 80 characters, and you can only put one statement on a line. Many Fortran compilers ignore the last eight characters, treating them as a comment, but Mira's program compiles the entire line. Programs must be in capital letters, apart from comments and messages. Spaces are ignored.


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 in the usual way to correct mistakes in the line you're working on.

When you press ENTER the syntax of the line is checked. If all is well Mira Fortran asks for the next line; otherwise you must correct the mistake at the place shown before you can continue.

You stop entering lines by pressing the {down cursor} key. This gives you access to a set of single-letter commands to edit lines or scan up and down the program, line by line or in eight-line steps - much as in BASIC. Fortran text can be loaded, merged and saved on cassette. The H key calls up a list of commands.

You can list the file to stream 3, usually a ZX printer or Centronics interface, but you must print the whole lot. There's a block delete command to get rid of several lines, but no way to copy a block without deleting the original. This editor is rather rudimentary, but few people will prefer a card punch.


Mira Fortran recognises most of Fortran 77; the biggest restriction as 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.

Memory permitting, you an declare arrays of any number of dimensions. Variable space can be shared, using COMMON and EQUIVALENCE. DATA statements let you preset variable values.

Maths functions include logarithms, type conversions, trigonometric and hyperbolic functions, things like MOD (to find the remainder after division) and a job lot of MIN and MAX functions to pick out the biggest or smallest of several values.

All the usual numerical comparisons and logical operators are allowed, but Mira Fortran lacks routines to handle characters - you can't slice strings or stick them together.

Program control facilities are very rudimentary. The DO loop is similar to FOR..NEXT in ZX BASIC, and there are three kinds of IF test, including Fortran 77's multiline IF..THEN..ELSE.

Functions and subroutines can be defined and called with any type of parameter. Built-in subroutines mimic BASICS ARC, BEEP, CIRCLE, DRAW and PLOT commands, but you must write your own POINT function if you need it. The only way to control attributes like INK, PAPER, OVER and so on is to print the appropriate control codes; this isn't mentioned in the manual.

For a long time Fortran led the way in its range of output-formatting facilities, and Mira Fortran reflects this. The syntax is horrible, but that's Fortran; however, the facilities are pretty good, and there's a nonstandard PRINT command which you can use if you don't want to bother with the bells and whistles of Fortran's WRITE. Mira Fortran imposes some minor restrictions on FORMAT statements, but all but the most obscure programs should compile without trouble.

You can't use cassette data tapes, but you can read and write desk and microdrive files from a Fortran program. The trick is to open the files from BASIC, and then use the appropriate stream number from inside the Fortran program. You can read or write tiles from the start, but you cant use random access to move back and forth.

END can be used to check for the end of a file in a READ statement, but the check has an unusual syntax and only works on files which are read a line at a time,


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'.

When an error has been found the appropriate line is marked with a flashing question mark and you are thrown back into the editor. When all the errors have been fixed the computer beeps and the screen shows a mess of dots and lines. This appears because the compiler uses screen memory to hold details of the names in the program. In this way, the size of program you can compile is increased.

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.

This two-step approach allows you to compile programs of several hundred lines on a small machine, but it makes Mira Fortran a drag to use: you must reload the editor and translator every time you compile a program. This is not too bad if you've got a disk or microdrive, especially if you save the program and editor together with a 'magic button' utility, but it is very frustrating on a cassette system.


Compiled Fortran runs without the compiler loaded. You start programs with RAND US 63500. They are always at least 5K long, because they load a library of utility routines at the top of memory. The code is not particularly concise - the programs I tried used about 50 bytes per line.

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. You can only break into compiled Fortran when SCROLL? is displayed.

Floating-point number-crunching was not very fast. One demonstration routine searched for prime numbers, digging them out at a rate of about two a second. The method proved to be very inefficient, but the compiled code was only about twice as fast as equivalent ZX BASIC, or a fifth quicker than BASIC compiled with Mcoder 3.

Mire Fortran can't always detect errors in FORMAT statements. One incorrect program compiled without a squeak, but locked up the machine when I ran it. And it took a while to fix, because there was no hint of the position of the error. In the end I kept loading and recompiling the program with extra PRINT statements till I zeroed in on the fault.


Mira has produced a real Fortran compiler for the Spectrum. Unfortunately Mira Fortran is not particularly friendly. It lacks some of the features you'd expect on a larger system - like a run-time debugger and linker - but it is still a useful package for compiling fairly small, independent Fortran programs.