Translates BBC BASIC to Acorn ANSI C.

HTML Manual Edition 2.1 for !BBC_C Version 8.36

May, 2002

Martin Carradus

Copyright © 2002 Leaf Mindcraft and Melotech

2. Additional Notes For Acorn C Compiler Version 5.

1. For the Acorn C Compiler Version 5 onwards you will also need the non-standard header files 'bbc.h' and 'os.h' in your project 'h' directory and to reference the library 'RISC_OSlib', (Needed during the Link phase) under 'Libraries' option off the main panel. This is in addition to 'LeafLib'

2. The Translator now only seems to object to the operator '=' if it is a test for equality. If you mean it to be this enclose it in brackets (e.g. A=(B=C) instead of A=B=C ). Similarly '=' used in FNs to return values must be separated from any preceding expression. Logical expressions after IF, WHILE and UNTIL are taken to be C logical expressions (with '&&', '||', '^^' and '!' for AND, OR, EOR and NOT respectively. If any logical sub-expression is bracketed then it is taken in a bitwise manner with '&','|','^' and '~'. In all other contexts logical expressions are taken to be bitwise.

3. FNs returning character strings are sometimes taken as returning a numerical value and the Translator grammar objects. You can force such FNs to be character string type by giving them a name postfixed with '$'(e.g. strcat$ ) to indicate that the return value is a character string. Generally the Translator determines the return value of a FN by the context in which it finds the FN.

4. For the reasons above, a logic expression starting with an FN will be taken to be numeric to start with. If the FN is in fact returning a character string and this is being compared with a string literal e.g FNmess > "Hello" then reversing the expression i.e. "Hello" < FNmess will make !BBC_C take the FN as returning a character string. !BBC_C then does not produce an error message. Also !BBC_C 'remembers' the return value of a FN from above.

5. Another advantage of translation to C should be that C is a portable language and compilers for it exist on other brands of computer. In simple cases of program it is possible to get the translated BBC BASIC program to eventually do the same thing on another computer. However, BBC BASIC in more complicated programs makes use of facilities that only exist on Acorn computers and which are handled differently on other machines.

Two examples are the use of raw Acorn assembler (translates directly into the machine code of Acorn computers) and SWIs (SoftWare Interrupts). SWIs are pre-written routines that enable the handling of various Acorn constructs and do not exist on other machines. There are also literally hundreds of SWIs that are available.

Lastly BBC BASIC programs sometimes make calls to the operating system of the Acorn computer and the commands are different on other computers.

This document was generated on 20th May 2002 for !BBC_C distributed by Melotech for Martin Carradus.