Beebug


Two C Compilers Reviewed

Author: Ray Hughes
Publisher: Mijas
Machine: BBC B/B+/Master 128

 
Published in Beebug #58

Two C Compilers Reviewed

C is suddenly the 'in' language, and two more C compilers have appeared for the BBC micro. Ray Hughes, who reviewed Acornsoft's C for Beebug, looks at the competition.

This is a second look at some of the recent versions of the C programming language that have been made available for the BBC micro and Master series. In Vol. 6 No. 5 I reviewed the Acornsoft version (with some reference to Beebug's own C Compiler); this month I shall take a look at two more versions and assess their potential.

One of the most surprising things about the four C compilers now available for the Beeb is the fact that for a so-called standard language these packages really are quite different in how they work, what they are capable of, and what systems they can be run on.

Mijas Small C Compiler

This implementation is a combination of three different software packages, the Small C compiler, the 65C02 development package and the debugger. Mijas will supply the software on a number of different disc formats (DFS, ADFS etc) and all the ROM images on the disc can be supplied as proper ROMs if requested. 40 track DFS format drives are not recommended for use with this software.

This suite of programs is very useful for the development of assembly language programs, with the additional benefit of of a C based structure.

Using this software suite, it is possible to automate virtually the whole process of program creation. This is done using the MAKE directive which enables a pre-created ASCII file (MEMFILE) to drive all the individual program stages directly. It is somewhat similar to using a standard BBC EXEC file, but the MAKE version is much more flexible in operation. The linker, debugger and assembler can all be run directly with the MAKE facility. There are also a number of other ways in which this utility really can automate and speed up the generation of your software including code relocation. It allows for the use of labels within the MAKE file which are then replaced by the required file names at execution time.

TCPP $1_C :2.TCPP_I
BASIC CH."TCC"
:2.TCPP_I
$1
:2.ASM_A
*SHELL
ASMB :2.ASM_A :2.ASM_O AX
LINK
CODE 1902 $1
RE :2.ASM_O
SE :2.CRT0_O
SE :2.LIB_O
SE :2.SYS_O
SE :2.CRT1_O
SE :2.OSHDR_O
EN
PU :2.TCPP_I
PU LITFILE
PU :2.ASM_O

In the above example (MEMFILE), the file is run from within the 'shell' environment. The first line then calls the C pre-processor (TCPP) using the given filename (i.e. MAKE SIEVE). During execution of this MAKE file, the $1_C string is converted to SIEVE_C. The pre-processor then writes its output to an intermediate file on drive 2 called TCCP_IL The MAKE file then leaves the shell environment, drops back to Basic and chains to the C Compiler (TCC), supplying as a source file :2.TCPP_I. This file is then assembled to machine code, linked with all the relevant library files etc, and is given a RUN address of &1902. The PU commands at the end are simply removing the intermediate files that were created during the above process.

Another point to note is that most of the software, but not ALL, is Tube compatible. It is also supposed to run under the ADFS, but my experiences proved it was easier to work under DFS with the Tube turned off. This is on my ancient old BBC and may not be the same as on the Master, particularly as PAGE on the Master is always set at &E00 whatever filing system is currently selected.

Brasscourt C

This is the first software I have ever used on the Beeb which has been dongled. That is to say, a small hardware device has to be fitted to the user port to enable the software to run. However, once the package has been used to produce stand alone code, the dongle is no longer required to fun the resulting compiled programs.

The software consists of several machine code files that are simply *RUN to operate. However, program development does not follow the usual path of:

EDIT SOURCE
COMPILE SOURCE
LINK with LIBRARY files
RUN
DEBUG
RE-EDIT etc etc.

With Brasscourt C, one simply creates a source text file. A reasonable editor is supplied for this. After that:

*CC sourcefile TO codefile
*ASM codefile otherfiles TO runfile

No linking is required; the compiler produces a compact form of p-code. The Assembler then converts this, with any other additional programs to a final stand-alone machine code file. Brasscourt C generates compact code which is quite fast in operation. The main fault in the software, as supplied, is the lack of anything like a reasonable collection of library routines, but more of this later.

Finally

The alternative Acornsoft and Beebug versions of C are both very near to the accepted standard, and both offer added enhancements to make fuller use of the Beeb. The Beebug version generally produces more compact code. The speeds of both versions are quite similar, but at the moment only the Beebugsoft version is capable of producing stand alone code (albeit with the addition of an extra program). Both have excellent manuals, and can be heartily recommended.

Brasscourt and Mijas fall into a different camp. While neither of these packages seems to have any real faults, two of the C language's better known plus points are the standardisation of operation and the portability of source code. Brasscourt and Mijas do not attempt to conform to the norm as far as operation goes, nor are they particularly portable. They do both produce stand-alone code and they both have reasonable manuals. In summing up I believe that the Brasscourt version is very easy to use (if the user port is not required for a mouse), though both Brasscourt and Mijas versions are limited by their very simple libraries.

The Mijas version is much more complicated to use, and takes a while to get the best out of it; it is really an Assembler package that allows the use of a limited subset of the C structure. As an assembler development package this is fine, but as a development tool for C programs it is quite poor. The prices of the Brasscourt & Mijas versions are expensive considering what they offer. The Acornsoft and Beebug versions both offer good value for money, and are excellent systems to learn the C language with.

Benchmarks

As a rough comparison of speed and compiled code size the PCW INTMATH benchmark was run using all four versions of the C language for the BBC micro (model B) with the following results.

INTMATH RUNtime (secs) Codesize (bytes)
Acornsoft 13 8876
Beebugsoft 2.5 230
Brasscourt 1.8 1430

Mijas 2.0 4656
Full details of the INTMATH benchmark program used can be obtained from Beebug Vol 5 No 6.

Ray Hughes