A short program allowing you to copy your CPC464 's ROM to tape -written by Peter Paton
Many Amstrad users have come up with routines for Peeking the Rom's in the CPC464. This short program takes the idea one step further, in that it also saves a memory image of the ROM on cassette.
It is not possible to Peek the Rom's directly from Basic for reasons which are beyond the scope of this short article; suffice it to say that we must resort to a small machine code routine which enables the ROM to be Peeked, and creates a memory image in lower Ram where it can be accessed easily.
On first running the program you will be presented with an option to copy either the upper or lower ROM. Selection is made by pressing either 'U' or 'L' in either upper or lower case. The memory image of the ROM takes only a second or so to produce, and a suitable message is displayed to tell you that this has been completed.
You will then be instructed to insert a blank cassette and press the Play & Rec keys on the cassette unit, and then any key to make the tape copy. This saves eight blocks of code which are named Upper ROM or Lower ROM depending on which you are copying.
The machine code routine employs one of the many advanced features of the Z80 CPU, the Ldir instruction, and works as follows (see Listing One).
Ldir takes the contents of the address held in the HL registers and places the byte in the address held in the DE registers. Both HL and DE are then incremented, and the value held in the BC registers is then decremented. This sequence continues until the value of the BC registers becomes zero.
This is one of the best ways of demonstrating the speed with which machine code is able to copy an entire 16k block of code, and the economy of code as it all takes just 18 bytes .
As for the rest of the program goes (Listing Two), I have tried to make use of some of the easier features of Amstrad Basic, particularly those which help to make screen layout neat and tidy, especially the Locate command and the control characters 18 and 20. Chr$(18) clears the current screen line from the cursor position to the right hand edge of the window, and Chr$(20) clears from the cursor position to the end of the window. These can be used to good effect for removing screen messages and prompts which are no longer needed. I have also used Chi$(24) which prints a message in reverse field for highlighting.
In Line 140 I have used the INSTR function, another powerful Basic command which enables the detection of a sub-string within a longer string. In this case it detects the position of either U or L in answer to the first prompt, and directs the program to the proper Data statement in order to select the right machine code routine.
One of the more convenient features of Amstrad Basic is the ability to convert lower case letters to upper case with the Upper$ function (sadly missing in many machines.) As used in Line 90 it will accept both upper and lower case in answer to the prompt.
For those who are not familiar with the method of saving a block of memory to cassette see Line 260:
Save "!"+ t$,b,5000,16384.
This will save a block of code with the filename held in t$ starting at address 5000 decimal, and 16384 (16K) bytes long. The exclamation mark after the Save turns off the regular Amstrad cassette messages, and so allows me to use my own messages in Lines 190-200. If you use this in your own programs you must remember that it does not wait for a key to be pressed either, consequently if you don't start the cassette in time you may miss saving the first pan of the file, (however, line 210 takes care of this problem).
Once the Rom's have been copied to the cassette by this programme you will be able to examine them under a disassembler. Remember though when you are looking at the code, that it is not in its rightful place, so an instruction to jump to a specific address should actually be given an offset according to which ROM image you are looking at, and the address at which the code was loaded into the disassembler. For example, if you are examining an image of the lower Rom, and you have loaded the code at address #5000, then when you look at address #5000 you are actually looking at address #0000.
30-120 Select the ROM to be copied (Upper or Lower)
140 Select the appropriate machine code routine
150-160 Print message to confirm that a ROM has been copied
170-270 Save ROM image to cassette (Fast speed used)
290-320 Option to re-run and copy other ROM
340-370 Poke machine code into Ram and CALL it
380 Return to main program after copying ROM
390-440 DATA containing the machine code routine
The CALL &BB18 instruction in Line 210 halts program execution until any key has been pressed.
In order to load the machine code into Ram it is necessary to lower the top of useable RAM, this is however reset to its usual value when you select the option to quit the program.
This is one ol those rare programs which, at least in theory, get used only once. However, knowing the peculiarities of the Amstrad cassette unit, I would not advise you to throw it away. You never know when the dreaded Read Exxoz will strike again!
CALL #B900 ; ; Enable the UPPER ROM to be accessed.
LD BC,#4000 ;; Load the BC register pair with the block ength
LD HL,#C000 ;; Load the HL register pair with the start address
LD DE,#1383 ;; Load the DE register pair with the destination
CALL #3903 ; ; Disable the UPPER ROM
Popular Computing Weekly 85-01-31
|★ AMSTRAD CPC ★ DOWNLOAD ★|
|★ AMSTRAD CPC ★ A voir aussi sur CPCrulez , les sujets suivants pourront vous intéresser...|
|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 898 millisecondes et consultée 1678 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.