APPLICATIONSPROGRAMMATION ★ Basically, machine code is a doddle! ★

April Fool: Basic Compiler (Computing with the Amstrad)Applications Programmation
★ Ce texte vous est présenté dans sa version originale ★ 
 ★ This text is presented to you in its original version ★ 
 ★ Este texto se presenta en su versión original ★ 
 ★ Dieser Text wird in seiner Originalfassung präsentiert ★ 

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.
When the routine gains control it looks to see whether Basic has finished converting the current line. If it hasn't it does nothing but if it has it copies the code and stores it starting at &8100 and working up in memory.

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,128

To compile a Basic program first load it as normal. Move HIMEM down with:

MEMORY &7FFF

then load and run the compiler with:

LOAD"Compiler",&8000
CALL &8000

The program will be converted to machine code and stored starting at &8100. To run it:

CALL &8100

Of course it's always advisable to save a machine code program before running just in case there are errors. The compiler will tell you how long the code is so:

SAVE"Code",B,&8100,length

where length is the length.

There isn't any copyright on the compiled code so you can go ahead and market your compiled megagame. However, we'd prefer it if you offered it to us first!

CWTA

★ PUBLISHER: Computing With The Amstrad
★ YEAR: 1987
★ CONFIG: 64K + AMSDOS
★ LANGUAGE:
★ LiCENCE: LISTING
★ COLLECTION: COMPUTING WITH THE AMSTRAD 1987
★ AUTHOR: Roland Waddilove
 

★ AMSTRAD CPC ★ DOWNLOAD ★

Type-in/Listing:
» Basic  Compiler    (Computing  with  the  Amstrad)    ENGLISHDATE: 2020-09-12
DL: 203
TYPE: ZIP
SiZE: 4Ko
NOTE: 40 Cyls
.HFE: Χ

★ AMSTRAD CPC ★ A voir aussi sur CPCrulez , les sujets suivants pourront vous intéresser...

Lien(s):
» Applications » Microsoft Basic Compiler
» Applications » CPC Basic Compiler
» Applications » Hisoft - C for Amstrad
» Applications » MIX C Compiler**Advantage C
» Applications » Basic Compiler (Sizin Amstrad)
» Applications » Basic Compiler (Joachim Günster Computertechnik)
Je participe au site:
» Vous avez des infos personnel ?
» Vous avez remarqué une erreur dans ce texte ?
» Aidez-nous à améliorer cette page : en nous contactant via le forum ou par email.

CPCrulez[Content Management System] v8.7-desktop/c
Page créée en 060 millisecondes et consultée 1082 fois

L'Amstrad CPC est une machine 8 bits à base d'un Z80 à 4MHz. Le premier de la gamme fut le CPC 464 en 1984, équipé d'un lecteur de cassettes intégré il se plaçait en concurrent  du Commodore C64 beaucoup plus compliqué à utiliser et plus cher. Ce fut un réel succès et sorti cette même années le CPC 664 équipé d'un lecteur de disquettes trois pouces intégré. Sa vie fut de courte durée puisqu'en 1985 il fut remplacé par le CPC 6128 qui était plus compact, plus soigné et surtout qui avait 128Ko de RAM au lieu de 64Ko.