CODINGROM ★ Writing a ROM ★

Writing a Rom (Computing With the Amstrad)Menu - Soft - ROM
★ 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 way out of the perpetual space problem — put your utilities on ROM

Machine code utilities are among the most popular features in Computing with Amstrad. They are short, easy to enter and genuinely useful.

However, there is a problem: If all the utilities we've published wore loaded at the same time there wouldn't be any room left for your programs. And this isn't the only problem, as most utilities are designed to run at or around &A000. So, once you've loaded one you can't switch off or reset the micro.

The situation isn't quite as gloomy as it might at first appear and there is a solution. The way round the problom is to put the utilities in ROM.

Even CPC has at least two roms and many of you will have more. The operating system (or) ROM controls all input from the keyboard and cassette, and output to the screen, sound chip and cassette. The Basic ROM interprets your Basic programs and translates them into a form understandable by the Z80 processor.

All roms contain either machine code programs or pure data (for instance the character set in the 08 rom). But the advantage of a ROM is that it doesn't use up much of your micro's memory. So it's quite possible to have seven roms each containing 10 machine code utilities — seventy programs — all taking up very little memory, and all instantly available, like Basic.

Each rom, apart from the os starts at &C000 in memory. In other words they all appear at the same address. Sow, $o that the Amstrad doesn't get double vision and become confused with all these roms it is able to switch each one in and out of the memory map. Effectively, each ROM can be turned on or off by your micro as and when it feels like it. Each ROM is given a unique number, for instance Basic is 0 and the disc ROM is 7. The machine code routines in this are then located from &C000 onwards and can quite easily be called.

After calling a routine the micro switches the disc ROM out and switches in whatever ROM it was using before the interruption.

When the operating system comes across an RSX command it automatically searches through each of the roms one by one for the corresponding machine code routine. So. when we use the |DISC command it switches in ROM 0 (and all th» others out) and looks for the machine code routine. If it can't find it, it will look in ROM 1, then ROM 2, ROM 2 and so on until it finds it in ROM 7, the disc ROM.

So, how can we take advani of this facility? Can we put our utilities in a rom? Yes, we can our RSXs in ROM and it's not a difficult as wo'll see.

The listing accompanying article is our Computing with Amstrad utility ROM. You can semble it with Maxam and be your own ROM using the ROM block reviewed on page 59 of this issue.

Two RSX commands are set — |DOUBLE, a double height routine (use |DOUBLE,@a$ why a$ contains the text), and |HI which prints a list of the command accepted by this ROM. Not tremendously useful you might think, that isn't my intention. They two simple commands that she how to implement RSX command in ROM. We'll see how these are up.

All roms start at &C000 and first few bytes form the ROM pre or header. You can see this at Start of the listing. This essential information is required by the operating system and if it's not there ROM will be ignored or the mi may even crash and you'll have switch off.

The listing shows the layout the ROM header. The first byte is the ROM type — 0 for a foreground ROM such as a language, 1 for a baground ROM (containing utilities), and 2 for an extension ROM containing all the bits that won't fit into a foreground ROM. As roms are 16k long it's unlikely that you'll see an extension rom, this would be a very large chunk of code.

Bytes one, two and three of the header aren't that important. They contain the mark, version and modification level of the ROM and is for your own use. As you modify and improve your ROM you can increase these numbers so that you can tell which is the most recent.

Byte four marks the start of a standard RSX command table. The first two bytes of this — 4 and 5 in the ROM header — point to the list of RSX names and the third byte — 6 in the ROM header — is the start of the jump table.

All the command names appear twice in the command table. The second time each appears it is prefixed with CWTA. This is in case there is a clash of names with any other roms you may have. For instance, Amor's Utopia also has the command |HELP so use the alternative |CWTAHELP.

The first entry in the jump table is rather special and is only called when the Amstrad is reset or powered up. It should also be given a unique name so that it can't be called as an RSX. This can even be an illegal name such as :MY ROM — it's impossible to enter, from the keyboard, an RSX name containing a space.

When this first entry is called by the operating system the lowest and highest memory locations available are passed in the DE and HL registers. If your utilities require some workspace to temporarily store variables you can grab a chink of RAM by increasing DE or decreasing HL. All the currently available roms take RAM from the top of memory by lowering HL so it's probably best to do likewise.

The CWTA ROM subtracts 32 from HL so the os reserves 32 bytes for our own private use. However, we don't know the address of this 32 byte block.

During this call the title string is printed and you'll see the message "Computing with the Amstrad ROM" printed when you reset or switch the micro on.

Having set up the ROM header, command and jump tables and power-up entry, the only remaining task is to write the themselves. The |HELP command is straightforward and merely prints a string of text

The |DOUBLE command is more complex though you've probably seen or written something similar yourself. When writing a ROM RSX the difficulty lies in not knowing where your workspace is. In the case of the CWTA ROM there are 32 bytes somewhere in memory.

Every RSX command in no entered with the IY register pointing to the start of this workspace. You must write your code so that no matter where the workspace is located the routine will work providing the IY register points to it It's a bit of a nuisance but, it can be done.

As you can see form the listing you don't need to write a lot of code to create a ROM. Providing the header is correct you can have a few simple commands and pad out the rest of the ROM with spaces or zeros.

Using the CWTA ROM as an example, why not write your own? Or. using the CWTA ROM header replace the commands with some of the others we've published in the past. They'll need some modification , but not too much and it's easier than starting from scratch.

If you think you've written something special why not send it in? You never know, you might just have a potential top selling ROM like Arnor's Utopia or Maxam!

Computing with the Amstrad — October 1987 p57

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

★ AMSTRAD CPC ★ DOWNLOAD ★

Type-in/Listing:
» Writing  a  ROM    (Computing  with  the  Amstrad)    ENGLISH    LISTINGDATE: 2020-08-04
DL: 224
TYPE: PDF
SiZE: 78Ko
NOTE: 1 page/PDFlib v1.6

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

Lien(s):
» Coding » Adresses principales de la ROM supérieure CPC 6128
» Coding » CAT-Syndrom
» Coding » De port en port : Programmation du contrôleur de disquettes à travers les ports [2/2] - Formatages de Pistes (Micro-Mag)
» Coding » AMSLIVE n°07 - HAPPY DRIVERS : LES RSX AMSDOS
» Coding » Clefs1 28 Adr Lowrom 464
» Coding Src's » Disassembly of AMSDOS ROM CPCplus
Je participe au site:
» Pour ce titre nous ne disposons de fichier executable sur CPC (Saisie du listing) , alors si vous avez ça dans vos cartons ou vous désirez usé vos petit doigts boudinés sur votre clavier faites le nous savoir.
» 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 266 millisecondes et consultée 2386 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.