Technophobia: Compile your BASIC
We've all done it. Whether as a serious effort to break into the software industry, an attempt to learn something or just a bit of fun; most Spectrum owners have, at some stage, tried to write a computer game. Unfortunately, the consequences are usually pretty awful. The problem is that your average Spectrum owner knows as much about programming as most Manchester United supporters know about football - not a lot. Knowing a little bit of BASIC is usually the limit. As we all well know, Sinclair BASIC isn't very fast. The only other option is to write your program in machine code, and that can be very difficult indeed. How much easier it would be to write a program in BASIC, then have it converted into M/C automatically. Well, believe it or not, you can. All you need is a BASIC compiler.
Compilers are very clever programs that convert a program written in one language, into another. Machine code runs much faster - speed increases vary considerably depending on the compiler used and the application being compiled, but usually run between 5 and 100 times faster than the original BASIC program. So what's the catch? Well, no compiler will compile every program as not all keywords and functions are recognised. Many of them won't allow you to have arrays or string variables, and some limit you to single letter variable names. What's more, most won't let you run your compiled program unless the compiler is present in memory at the same time. This means that in order to distribute your compiled program the compiler must be copied too, almost certainly infringing copyright. Another point worth mentioning is that any graphics data or M/C routines stored inside REM statements will be lost - this is how SC stores all the graphics used in each issue, so you won't be able to compile the best tapezine around!
If you fancy having a go with a compiler, you'll find one at the end of the fanzine. It's not particularly sophisticated, but at least the code it produces doesn't need the compiler in memory at the same time for it to run. Try it - maybe you could be the next Pete Cooke... (Jonathan Cauldwell)
Send your programming problems to Technophobia, c/o 2 Belvoir Rd, Nottingham NG2 5DL and our JC will strive to make your world a better place to live. You better had anyway as he costs us 75 per hour just to keep him in lager and peanuts. The two program files following this fanzine are: TUTOR and TURBO.
Share your thoughts about the article