★ APPLICATIONS ★ PROGRAMMATION ★ Basically, machine code is a doddle! ★ |
April Fool: Basic Compiler (Computing with the Amstrad) | Applications Programmation |
Roland Waddilove offers a utility that will give your programs that professional touch — or will it? HAVE you ever wanted to write superb games like those produced by software houses such as Ocean, Mastertronic and Elite? I would guess that the main stumbling block for most people is probably machine code. As you know the Z80 microprocessor at the heart of your Amstrad only understands Z80 machine language, which is very difficult to comprehend at the best of times. Even experienced programmers would agree that machine code is very difficult, especially when it comes to floating point arithmetic using sin, cos, log and so on. Fortunately we don't have to understand machine code to use our micro, as Locomotive has provided an interpreter - Basic. Basic is a high level language which is much easier to understand and use than machine code. A simple Basic command such as PRINT corresponds to many machine code instructions. The Basic rom contains a powerful interpreter that converts what we type in to a form - machine code - that the Z80 can understand. When a program is run, Basic has to interpret each command and turn it into machine code before it can be executed. This is a very time consuming process and is the main reason why Basic is unsuitable for arcade games which must be written in pure machine code for speed. Using the utility presented here you can write in Basic with all the advantages of a high level language, convert the program into Z80 code and run it with the great speed advantage of machine language. As you can see the listing is extremely short and that's because it uses a very sly trick to compile the program. Locomotive Basic doesn't simply interpret each Basic command, it interprets a whole line at a time, converting it all to machine code. This is stored in a 256 byte buffer starting at &BE20 - part of Basic's reserved workspace at the top of memory. When the current line has been converted it is executed and Basic then moves on to the next line. What the compiler does is to set up an event routine using the fast ticker interrupt every 300th of a second. Then the Basic program is run. As you can see the compiler has very little to do since all the hard work is carried out by Basic. Enter and save the listing. Run it and save the machine code with: SAVE"Compiler",B,&8000,128To compile a Basic program first load it as normal. Move HIMEM down with: MEMORY &7FFFthen load and run the compiler with: LOAD"Compiler",&8000 |
|
|