APPLICATIONSDIVERS ★ The procedure to follow is ... ★

Rsx - Procedures|Computing With the Amstrad)Applications Divers
★ 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 ★ 

Robin Nixon shows how to take a more structured approach to your CPC programming

Having previously been a BBC Micro user 1 was pleasantly surprised on my first encounter with the Amstrad, which has 40k available for Basic programs, a true 16 colour mode and a choice of 27 colours.

The 16 colour mode on the BBC Micro has eight normal and eight flashing colours selectable from eight and only leaves you 10k free for Basic.

Other Amstrad features I was impressed with were the comprehensive jump block, the ease with which you can add resident system extensions (RSXs), and the logical way the screen is laid out, facilitating simple development of machine code sprites.

But, and there's always a but when you compare two micros, there were one or two features I was used to on the BBC Micro which I missed when I started programming the CPC.

The first was the in-built assembler, but this has been overcome by a number of assemblers that are now available commercially.

Second came the use of procedures. The closest the Amstrad gets to procedures is the GOSUB statement which is fine for working on small programs but can make development trickier the longer a program gets. As you add more and more subroutines, remembering where a particular one is located becomes quite a headache.

The problem is avoided on the BBC Micro because procedures can replace GOSUBS and are not line dependent. If you 1ook at Program I, which is written in BBC Basic, you'll see that line 40 is actually the equivalent to GOSUB 1000. However, the subroutine at line 1000 is identified by "name" and when working on a program you never need know where PROCname is in order to call it.

10 REM Program I
20 REM An example of using procedures
30 CLS
40 PROCname
50 REM Rest of program ...
...

...
900 END
1000 DEFPROCname
1010 PRINT Amstrad"
1080 ENDFROC
Program I

Without a GOSUB in sight I think you'll agree that this lends itself to structured programming as well as making your listings more legible to other people.

Program II is a routine that will give you procedures on the CPC. Save it before you run it. It sets up the RSXs |PROC, |DEFPROC, |EXDPROC and |SART, |PROC works in exactly the same way as in Program I except that the syntax is slightly changed. In place of typing:

PROCname

you enter:

|PROC,name

The same goes for DEFPROC.

You also have to enter |START as one of the first lines before you use any |PROCS or |DEFPROCS. This is because you are allowed to nest procedures up to 10 deep, which is achieved by storing the return address each time a procedure is called.

|START restores the pointer to the return addresses to 0 so you start on the first level of nesting each time you run the program.

If you leave |STARTS out and press Escape, or the program stops in the middle of a few layers of nesting due to an error, the pointer won't be restored when you re-run the program. The next |ENDPROC encountered will take you back to the procedure that was executing before you pressed Escape or the error occurred.

If you try to nest procedures more than 10 deep "Too many PROCs" will bo reported and you will be returned to Basic with a syntax error. A true Basic error occurs and the program doesn't attempt to continue execution.

Another way this error could occur is if you forget to enter the correct I ENDPROC for each procedure, or put it in the wrong place.

CWTA

★ PUBLISHER: Computing With The Amstrad
★ YEAR: 1987
★ CONFIG: 64K + AMSDOS
★ AUTHOR: Robin Nixon

★ AMSTRAD CPC ★ DOWNLOAD ★

File:
» Procedures-Robin  NixonDATE: 2013-09-03
DL: 63 fois
TYPE: ZIP
SIZE: 20Ko
NOTE: 40 Cyls
.HFE: OUI

Je participe au site:
» Newfile(s) upload/Envoye de fichier(s)

QUE DIT LA LOI FRANÇAISE:

L'alinéa 8 de l'article L122-5 du Code de la propriété intellectuelle explique que « Lorsque l'œuvre a été divulguée, l'auteur ne peut interdire la reproduction d'une œuvre et sa représentation effectuées à des fins de conservation ou destinées à préserver les conditions de sa consultation à des fins de recherche ou détudes privées par des particuliers, dans les locaux de l'établissement et sur des terminaux dédiés par des bibliothèques accessibles au public, par des musées ou par des services d'archives, sous réserve que ceux-ci ne recherchent aucun avantage économique ou commercial ». Pas de problème donc pour nous!

CPCrulez[Content Management System] v8.7-desktop/cache
Page créée en 129 millisecondes et consultée 651 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.