Copyright © 2002 Leaf Mindcraft and Melotech
These HTML notes describe what the application !BBC_C does and the various options that !BBC_C presents to the user.
!BBC_C translates from Acorn BBC BASIC held in its associated file into Acorn ANSI C in a text file suitable for an Acorn C compiler.
In order to understand the advantage of translation you will need to know something about the difference between compilers and interpreters.
All computer languages need to be translated into the fundamental instructions of the particular computer (machine code). A compiler is presented with the complete program and translates the whole thing into machine code. The machine code is then run on the computer in a separate stage. An interpreter, however, translates the program and obeys it as it goes along. The advantage is that you do not need a preceding stage before you run the program. The disadvantage is that, since the whole program has not been seen, the final code is usually less efficient and runs more slowly than compiled code. The compiled C that !BBC_C produces seems to run about three times faster than the same interpreted BBC BASIC.
In order for an interpreter to obey the program efficiently, it is usually coded so that it makes it easier to work out parts of the program. The main 'trick' is to code the keywords (words like GOTO, or IF or PRINT) into only a couple of characters (bytes), known as a token. This means that they can be easily recognised every time the interpreter runs across them in the program. There are over 160 different tokens used in BBC BASIC files.
At the beginning of each line of the program, the interpreter will need to know the line number of that line and where the next line is. Both are coded for greater efficiency.
All types of BASIC use an interpreter.
Due to the nature of BASIC, it can do things 'on the fly' that a compiled language cannot. Also BBC BASIC was designed without any formal structure (the grammar of the language) in mind, whereas the C language has a formal grammar. In particular, the C language and its compiler are very particular about the mixture of different data types (i.e. storage locations (variables) designated as integer, floating point or character string) whereas BBC BASIC uses these locations interchangeably. For these reasons, you should know something about the C language before using !BBC_C in order to understand any compiler error messages.
This document was generated on 20th May 2002 for !BBC_C distributed by Melotech for Martin Carradus.