★ APPLICATIONS ★ PROGRAMMATION ★ DISASSEMBLER ★![]() |
| Z80 Disassembler (Practical Computing) | Applications Programmation |
WRITTEN IN Locomotive Basic for the Amstrad CPC-464, this program by Stephen Devine provides rapid disassembly of machine-code programs in a comprehensive and easily readable format. Output can be directed to the screen or printer and all addresses can be in either hex or decimal as required. The program uses a very efficient algorithm to interpret each instruction. It involves splitting each byte into various segments, and examining the resultant bit patterns to determine the appropriate part of the mnemonic. The individual segments are then reconstructed to form a complete mnemonic, and any special symbols are replaced with their equivalents, which may be absolute addresses or special registers such as IX and IY. The final mnemonic is then printed out, along with its associated bytes in both hex and ASCII, and the next instruction is then processed in exactly the same way. This method results in very fast disassembly, with speeds of up to three lines per second. In order to disassemble the ROM the program includes a short machine-code routine which accesses the Basic ROM to fetch the required bytes, which it then stores in an array for subsequent processing by the Basic program. When the program is run it first fills a string array with the data required during disassembly, and sets up the machine-code program in an integer array. It then prompts for the address from which you wish to begin disassembling, and this can be given in either hex or decimal. A value preceded by a & is interpreted as a hexadecimal address. All addresses produced by the program are given in hex, except for any offsets to index registers, which will always be given in decimal. All addresses below &C000 are taken as being in RAM, while those above refer to the Basic ROM. You are asked to enter an end address for the disassembly, which must be greater than the start address. Pressing Enter alone will set the end address to &FFFF. Enter y to the next prompt if you wish the output to be sent to the printer, or press n or Enter to direct output to the screen. The program cannot determine whether or not you have a printer connected, so use this option with care. If you get stuck, just press Esc twice and start again. Disassembly will now begin. Each line contains: the address, in hex or decimal, of the current instruction; the bytes, in hex, of the code stored there; the instruction itself in standard Zilog mnemonics, and the ASCII equivalent of the bytes themselves. This last feature is useful when disassembling areas of text, but note that control codes and graphics characters are printed as a symbol. Any invalid code is taken to be data and is displayed using the word Data. This also applies to the data bytes which follow some restart instructions. The listing can be halted at any time by pressing the space bar and continued by pressing any key. When the listing is complete you will be prompted for new start and end addresses as before. To break out of the program press Esc twice. Although formatted for 40 columns, the program can also be run in mode 2 by changing the value in line 10. The display colours can also be changed to suit the user by altering the Ink statements in the same line.
|