Kevin Probert with a more subtle way of disassembling than the picture shows.
This disassembler occupies less than 2K oncc loaded and can be located anywhere in memory. It can be called from within Basic as an external command and (a) correctly disassembles all Z80 op codes using standard mnemonics including the RST instructions as implemented in the 464 Operating System (OS); (b) disassembles routines in ROM or Ram; (c) sends output in hex or decimal to either screen or printer.
Those who have tried to Peck the ROM to get a glimpse of the O.S. will appreciate option (b) since Peek always returns the contents of RAM. The program can be altered to a certain degree to suit user requirements.
The program has been implemented as an RSX — Resident System Extension — and once loaded sits above Himem. However, since Hiinem can vary dependent on space reserved for expansion Roms, for example, disc ROM or user machine-code routines then an RSX needs to be relocatable. This is achieved by an additional routine which is called before the program is "logged on" with the OS and makes use of the fact that a Call from within Basic enters the routine with the DE register pair containing the argument of the Call instruction. For those interested in using the RSX facility, the following illustrates how "logging on" is achieved:
LD BC,NNNN ;Address of Command Table Pointer
LD HL,NNNN ;Address of 4 bytes for OS to use as workspace
JP BCD1 ;Log on external command(s) with OS COM TAB
POINTER ; 2 bytes holding start address of keyword table
JP NNNN ; FLASH routine
JP NNNN ; INVERSE routine
FLASH + 80h Last letter in each keyword has bit 7 set
INVERSE + 80h etc 0 End of keywords marker
Once logged on an external command server is recognised by preceding the keyword with shifted @
Parameters can also be passed to the external command server routine in the following fashion:
On entry to the routine the A register holds the number of parameters being passed, the index register IX. points to an area in memory where the parameters are stored in two-byte integer form in the reverse order to that in which they were entered, that is, from the above example:
IX + 0 = 23
IX + 1 =0
IX + 2- 144
IX + 3 = 1 (1*256+144 = 400)
Strings can also be passed to the external command server routine: in this case IX points to ail address which in turn points to a three-byte string describer where byte 0 holds the length of the string, bytes 1 and 2 hold the address where the string is stored.
I have selected a method of entering the program often seen in this magazine, because I have found this method to produce the least number of errors. The program should be entered with all expansion Roms disconnected. This can be checked by:
PRINT HIMEM which should return the value 43903. Enter the hex loader program in listing 1 and when complete type Run 100. Input as prompted the code in listing 2, code and Checksum being separated by a comma. The code can be Saved at any stage of its development by Escaping from the loader program and typing Run 20. It can then be reLoaded at a later date by
Once all code has been entered, delete the loader program and enter the Basic Load/Save program in listing 4. Save the completed program to tape by typing Run 4. Enter as a direct command
CALL 41987 and if the ready prompt appears go on to use the program as described later in this article. If the system crashes, reset the system then enter:
MEMORY 41766: LOAD"DISASSEMBLER":LOAD"!CODE,",41767
Once Loaded, check the code by entering listing 3 and Run 300. Compare the results to listing 2 and, after all errors have been corrected, reSave as above.
Once the program has been Saved in its final form it can be recalled by
if no other program is in memory or by
CHAIN MERGE "DISASSEMBLER"
if a program in memory is to be retained. To use the disassembler the following syntax is required:
|disassembler, . ,
The start and finish addresses arc mandatory , the output state optional defaulting to zero if omitted. All parameters can be cither numeric or variable expressions.
For example, if it is required to send output to the printer, LRom on, URom off, as code in decimal, then the output state value is as follows:
(1*1) + (1*2) + (0*4) + (0*64) + (1*128) =131
When output to the screen is selected, the disassembler uses stream 7 and sets a window size on this stream 40 characters wide and 25 high. The disassembler must be used in Mode 1 or 2 or it will not operate.
As it stands, the disassembler produces mnemonics using upper case. For those who prefer mnemonics in lower case the program in listing 5 should be entered and run before saving the disassembler in its final form.
| ||SET (1)||RESET (0)|
|Bit 0 (1) |
Bit 1 (2)
Bit 2 (4)
Bit 3 (8)
Bit 4 (16)
Bit 5 (32)
Bit 6 (64)
Bit 7 (128)
|Output to printer|
Output as DATA
Output in decimal
|Output to screen|
Output as code
Output in hex
- Bit 0. Self-explanatory.
- Bit 1. Selects what will be disassembled (LRom or Ram) when addressing memory between 0000h and 3FFFh.
- Bit 2. Selects what will be disassembled (URom or Ram) when addressing memory between C000h and FFFFh.
- Bit 3. When Bit 2 is Reset, this Bit is ignored. When Bit 2 is Set, this Bit selects the URom which will be addressed.
- Bit 6. When Reset memory between the start and finish addresses is disassembled; when Set this memory area is output as Data.
- Bit 7. Self-explanatory.
For those who intend to use a printer with the disassembler, various options are available. If using cut sheet paper then the number of lines per sheet can be set by Poking the value to 42210 — A4E2h. The disassembler will then wait at the end of the sheet for "C" to be pressed giving time to change the sheet.
If using continuous paper this value should be set to 255 — FFh. The area from 43893 (AB75h) to 43903 (AB7Fh) has been set aside for up to 10 control codes which the user can enter and arc sent before printing starts. The control codes must be terminated by a marker byte 255 - FFh.
The only non-standard results produced by the disassembler are those of the RST 08h, 10h, 18h and 28h instructions. The 464 OS implements these op codes as "extensions" to the instruction set. When executed, the following two bytes arc taken as an inline address; the RST 08h uses bits 14 and 15 to select the ROM state, the RST 10h uses these bits for ROM select.
The RST 18h instruction takes a third byte for ROM state/select but is thus able to jump to any location in memory in any ROM. Typical examples of the output produced by the disassembler for each of these RST instructions are given below plus their interpretation.
Upper ROM disabled,
Lower ROM enabled
|CALL DFCC Side|
CALL to an expansion ROM
Upper ROM enabled,
Lower ROM disabled
|Lower ROM disabled|
Select ROM 199
Lower ROM enabled
41767 (A327h) Data for relocating routine.
41987 (A403h) Relocating routine.
42019 (A423h) Log on disassembler with OS.
42028 (A42Ch) Data for log-on.
42033 (A431h) Print syntax error.
42056 (A448h) Entry to disassembler: check syntax.
42074 (A45Ah) Set up output state, finish and start address.
42101 (A475h) Set up stream and window size.
42124 (A48Ch) Check if printer connected: send control codes.
42143 (A49Fh) Set up required ROM state.
42174 (A4BEh) Call disassember start.
42177 (A4Clh) Restore previous ROM state and stream: return.
42198 (A4D6h) Check if start = current address.
42209 (A4E1h) Disassembler start: set up No. of lines for screen/printer.
42236 (A4FCh) Set up print position in print buffer.
42244 (A504h) Call build up mnemonic in print buffer.
42253 (A50Dh) Print address, op code and operand to print buffer.
42327 (A557h) Wait for key press.
42354 (A572h) Copy print buffer to current screen line/printer: return.
42393 (A599h) Data for syntax error.
42407 (A5A7h) Data for log-on assembler.
42420 (A5B4h) Mnemonic keyword list/control codes.
42892 (A78Ch) Data for valid IX/IY op codes.
42924 (A7ACh) Data for valid ed op codes.
42932 (A7B4h) Workspace for OS.
42936 (A7B8h) Start, current and finish addresses.
42942 (A7BEh) Print position in print buffer.
42944 (A7COh) RST flags.
42946 (A7C2h) Disassembler flag.
42947 (A7C3h) Conversion routines.
42958 (A7CEh) Check for valid IX/IY and ed op codes routine.
42980 (A7E4h) RST 18/28 handler.
43009 (A801h) Data handler.
43028 (A814h) Entry to build up mnemonic in print buffer.
43035 (A81Bh) RST 08/10 handler.
43114 (A86Ah) CB op code handler.
43175 (A8A7h) IX/IY op code handler.
43195 (A8BBh) Ed op code handler.
43253 (A8F5h) Check for CB,ED and IX/IY op codes.
43295 (A91Fh) Op codes <64.
43332 (A944h) Data for op codes >=192.
43419 (A99Bh) Data for ed op codes.
43488 (A9E0h) Data for op codes <64.
43575 (AA37h) Various print routines.
43660 (AA8Ch) Find mnemonic keyword and print to print buffer.
43713 (AAC1h) Print decimal/hex number to print buffer.
43850 (AB4Ah) Print buffer.
43890 (AB72h) Carriage return: line feed.
43892 (AB74h) Control codes.
43903 (AB7Fh) End.
|★ 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 127 millisecondes et consultée 703 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.