CODINGROM ★ A Guide to EPROMs on the CPC with Ian Neill - Part. 3 ★

A Guide to EPROMs on the CPC (3/4)
★ 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 ★ 

In this article I will be discussing what at goes into an EPROM, and how the CPC accesses it via software. I will also be describing the different types of EPROM programs, but will concentrate mostly on background types, including how the CPC initialises then at power-up or reset, and how to program then.

EPROM STRUCTURE

We know that an expansion EPROM can be up to 16Kb long, and is memory napped from &C000 onwards. Generally they can contain anything you like -there is no standard that lust be followed. This is true for all but the first few locations in the EPROM which must have the following form:

AddressContents
&C000ROM type (note 1)
&C001ROM mark number
&C002ROM version number
&C003ROM modification number
&C001-&C003 are information only and can be any value required.
&C004Comnand Mane Table Address (Low Byte)
&C005Command Name Table Address (High Byte)
&C006/7/8Jump to INIT_ROM routine
&C009/A/BJump to 1st command program
&C00C/D/EJump to 2nd connand program ......

.... More commands, etc

End of commands - Command Name Table

Start (notes 2 and 3)

End of Name Table - Commands Start

Note 1: The ROM type can be one of the following values:

a. External Foreground &00

b. Background &01

c. Extension Foreground &02

d. Internal (i.e. BASIC) &80

The Extension Foreground type is useful for linking up to 4 foreground ROMs, allowing them to be treated as a single very large ROM. The Firnware allows easy access between then via the Extended Instruction "SIDECALL" (RST 2). Fig. 4 is an example program that can scan every ROM from slot 0 to 15 and display its type.

Note 2: The command name table is a list of command names. Each name can be up to 16 characters long, but cannot contain spaces or punctuation narks, etc. Each name must have the top bit (bit 7) of the last letter set - this "marks" the last letter for the CPC.

Note 3: The end of the command name table is signified by a zero.

This months "DOSCOPY" example shows an example of this structure. (Fig 6)

EPROM INITIALISATION

When the CPC is switched on or reset the firmware (the lower ROM) is entered at address &0000. All sorts of things are set up, including system variables and the firmware jumpblock. The message "Amstrad 128K Microcomputer (v3)' (or whatever) is also displayed. An attempt is then made to jump into an External ROM at position 0 (entry address = &C006). If that fails, the internal ROM (BASIC) is entered at address &C006. BASIC, or whatever foreground ROM at position 0, is now in complete control and Bust attempt to initialise whatever background ROMs are attached.

BASIC initialises background ROMs (using the Firmware command KL ROM WALK) in reverse order starting at position 15 (7 for the 464), and working down towards position 1. Gaps and foreground ROMs are ignored. Note that when BASIC is searching for a taker for an RSX (|whatever) it searches in the order 0 , 1 , 2..... , etc.

BASIC's part in initialising background ROMs is simply entering them at address &C006 - the first entry in the ROM's jumpblock. Note that this routine often has a space in its name, making it impossible for it to be called by a user. From this point on it is the ROM itself that does the initialising.

ROM initialising routines generally perform the following tasks:

  1. Reserve some RAM. When a ROM's initialisation routine is entered, DE contains the address of the lowest byte of available RAM, and HL contains the address of the highest byte of available RAM. To reserve some RAM the ROM's initialisation routine modifies the appropriate register before returning. The returned address in HL+1 is stored by the Firmware, and passed to the ROM in IY whenever the ROM is called.
  2. Print some sort of log-on message. It is normal to start this message with a space, and end it with a CR + LF.
  3. Set the Carry Flag if the initialisation is successful. This flag is ignored by the CPC464 Firmware.
  4. RETurn. A background ROM ALWAYS returns control after initialisation. Note that if you were to put an ordinary background ROM at position 0 the CPC would never boot up because every time the background ROM RETurned the CPC would reset and re-enter it. Its background ROM would once again RETurn and the CPC would reset and re-enter it. And so on forever.....

Figure 6, the ROM based "DOSCOPY" figure shows an example of an initialisation routine.

SOFTWARE TO ACCESS EPROMS

There are two steps required to access EPROMs: 1. Select the ROM. This required ROM position must be written out to I/O address &DF00.

This can be written directly like:

LD A,5 ;ROM position 5
LD BC,&DF00 ;ROM select latch I/O address
OUT (C),A ;Output "A" to I/O ; address "BC"

Or it can be written using the Firmware like:

LD C,5 ;ROM position 5
CALL &B90F ;KL ROM SELECT

NB. This Firmware command also Enables the ROM, so skip step 2.

2. Enable the selected ROM. This will cause all subsequent "reads" in the region &C000 to &FFFF to return the contents of the ROM.

This is done using the Firmware like:

CALL &B900 ;KL U ROM ENABLE

Once you are finished with the ROM you can Disable it using the Firmware call like:

CALL &B903 ;KL U ROM DISABLE

Note that if you select a ROM position that has no external ROM installed, then the internal BASIC ROM will respond.

Figure 5 is an example program that shows how easy it is to access external EPROms. This program enables each ROM slot, from 0 to 15, in turn. It then checks the ROM type using the Firmware call KL PROBE ROM (&B915). If it finds a ROM slot that is not number 7 (assumed to be AMSDOS), and does not respond as the internal BASIC ROM (type &80), then it enables, copies its contents to RAM, and then saves the "image" in RAM to disc. The images are saved with the following names:

ROM slot 0 - "IMAGEA.ROM"
ROM slot 1 - "IMAGEB.ROM"
ROM slot 2 - "IMAGEC.ROM"
... Etc.

This is a useful program to back-up your expansion EPROMs in case southing happens to them, e.g. a leg falls off due to the ROM being pulled out of a ROM box wrongly! With an image of your ROM you will be able (or at least I will) to program a new EPROM.

EXAMPLE BACKGROUND EPROM SOFTWARE

Figure 6 is the assembler code I wrote to transform successfully the PD disc program into a ROM program, accessed via the bar commands "|DC" or "|DOSCOPY".

One thing to remember is this program (and others like it) is "transformed" and NOT converted. I did not change a single byte of the original DOSCOPY program. What I did was to write a routine that copied it from ROM to RAH and then "call" it. Essentially this is a "ROM loader" as opposed to a "disc loader". It is important to remember that many RAM destined programs reference changeable variable locations within themselves. Obviously this type of program cannot be transferred, without modification, to ROM (ignoring any absolute addressing problems) because these "embedded" variables would reference a ROM or screen location and could not be used. The technique (what I call "transformation") I used for "DOSCOPY" avoids this problem by putting the RAM based program back into RAM and running it from there.

One final complication of the "DOSCOPY" ROM loader arises from the fact that "DOSCOPY" expects only the AMSDOS external ROM to be initialised. Any other ROMs, including "DOSCOPY", cause "DOSCOPY" problems. Thus I had to vrite a routine that made sure that, after "DOSCOPY" was copied from ROM to RAM, only AMSDOS was enabled, before "DOSCOPY was called. Obviously this routine had to be copied to RAM first, otherwise it would kill itself!

The "DOSCOPY" background ROM is a good exaiple of the EPROM structure and initialisation that I have already talked about.

FIRMWARE HELP The Firiware contains a lot of useful functions for both initialising and accessing external ROMs. The following is only a brief list of some of then, see "The Firmware Guide" for a coiplete list and a fuller description.

  1. SIDE CALL (RST 2 &0010) - Calls a routine in ROM, in a group of up to 4 foreground ROMs.
  2. FAR CALL (RST 3 &0018) - Calls a routine anywhere in RAM or ROM.
  3. KL FAR CALL (&0023) - Calls a routine anywhere in RAM or ROM.
  4. KL U ROM ENABLE (&B900) - Enables the current upper ROM.
  5. KL U ROM DISABLE (&B903) - Disables the upper ROM.
  6. KL ROM SELECT (&B90F) - Selects an upper ROM and also Enables it.
  7. KL ROM DESELECT (&B918) - Selects the previous upper ROM and sets it's state.
  8. KL ROM WALK (&BCCB) - Finds and initialises all background ROMs.
  9. KL INIT BACK (&BCCE) - Finds and initialises a specific background ROM.

As usual, if you want to contact lie, my address is: Ian Neill

Warwickshire CV33 9SE

My telephone No is: (01926) 33

*

WHAT'S NEXT?

Next issue I will show you how to put a BASIC progran into an EPROM. This is a simple technique, but it does have a few traps that must be thought about. However, once the technique is mastered, it can be used with virtually any BASIC program that will fit into an EPROM.

WACCI

★ AUTHOR: Ian Neill

Page précédente : A Guide to EPROMs on the CPC (2/4)
★ AMSTRAD CPC ★ DOWNLOAD ★

Type-in/Listing:
» WACCI102-A  Guide  to  EPROMs  on  the  CPC    LISTINGDATE: 2021-02-02
DL: 51 fois
TYPE: PDF
SIZE: 289Ko
NOTE: 4 pages/PDFlib v1.6

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

Lien(s):
» Coding » AMSLIVE n°12 - Rom Pour les Matelots
» Coding » Clefs2 08 - Logiciel Interne Adr Rom Disk
» Coding Src's » RP11 Diagnostic ROM Cartridge source
» Coding » Wacci CRTC (2/2)
» Coding » Clefs1 55 - Annexes - Adresses Principales De La Rom Superieure du CPC664
» Coding » CAT-Syndrom
Je participe au site:
» Pour ce titre nous ne disposons de fichier executable sur CPC, 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 783 millisecondes et consultée 512 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.