Instructions for: Genie Disassembler (128) ------------------------------------------- Introduction. ------------- GENIE is a Z80 programming aid exclusively for the use with the Multiface 128. It loads into the 8K of RAM within the unit, leaving all Spectrum memory free for running other software. GENIE allows you to freeze programs and examine their operation in minute detail. Whether writing your own programs or modifying the work of others, GENIE offers instant access to: * Z80 Disassembler - including undocumented op-codes. * Find - Search text, op-codes etc. * "Front panel" display of Z80 CPU - Registers, Program counter & interrupt status. * View memory as numbers or ASCII characters. * Hex or decimal output to screen or printer. Although some knowledge of Z80 machine code is needed to get the best from GENIE, the power to examine any program at the touch of a button is an invaluable learning aid. Loading ------- Select the appropriate Z80 file and load it ! Press 'I' to install this enhanced version of GENIE 128 and then press 'Symbol Shift & A' to reset the computer and install GENIE 128. Whenever you press F5 from now on you will access GENIE. The Menu Options ---------------- The menu option is selected by pressing its initial letter. There are also further commands available in all or some models: Key Summary: D(isassemble) T(ext) N(umeric) F(ind) Z(80 registers, interrupt mode display etc.) R(eturn control to program being viewed) G(o back - GENIE 1 only) M(emory select - GENIE 128 only) A(lter mode - memory or registers) P(rinter output) C(opy top 8 lines to printer) S(croll; any key to stop) Cursor Left/Right - step up/down one addressl; GENIE 128 only) SPACE to abort DIS --- DIS: Full Z80 disassembler using standard Zilog mnemonics A number of valid Z80 op-codes were omitted from the official instruction set and can't be guaranteed to work on every Z80 but are used nontheless. GENIE disassembles the extra op-codes, adding suffix 'H' or 'L' as appropriate: DD84 ADD,IXH or CB37 SLL A Display shows: Address Op-Codes Mnemonics --------------------------------------- 00000 F3 DI The data byte followin RST 8 (Spectrum Error RST) is decoded: RST 8 DB 1 The 128 Edit ROM uses RST 40 (28h) to access routines in the 48K BASIC ROM Two bytes follow the RST 40 instruction, giving the address to call in the 48K ROM. GENIE decodes these bytes (RST 28 DW 0016) only if the 128 ROM is selected via ROM=0. D, T & N keys switch between Disassemble, Text & Numeric Modes TEXT ---- TEXT: View memory contents as ASCII characters. Bytes <32 or >143 are shown as '.' NUM --- NUM: View memory contents as decimal or hex number. FIND ---- FIND: Search RAM (16384-65535) for occurrences of a sequence of numbers. Input up to 24 bytes in hex or decimal, one after the other. Press ENTER by itself to start searching. If the string is found the address of each match is displayed. Press 'H' to toggle Hex/Dec. Press 'P' to print the address. SPACE to abort or any other key to look for the next occurrence. The numbers you input can represent many things - Z80 op-codes and address or text. To search for a string of text, input the ASCII code of each character (See Spectrum Manual). For example, to find the machine code instruction LD (5C3D), SP - input in hex, ED 73 3D 5C ENTER. Z80 --- Z80: View contents of Z80 registers in decimal or hex. FLAGS are shown by letter, upper case if set (ie = 1). The status of Maskable Interrupts (Disabled/Enabled) is shown as 'DI' or 'EI' to the left of the value in the (I)nterrupt register. Press 'A' to alter register contents. Select the item to alter using (shifted) cursor keys or Space to exit Alter mode. 'MI' stands for Maskable Interrupt. Only Bits 0 and 2 have any meaning. Bit 0: 0 = IM 1 (or IM 0) 1 = IM 2 Bit 2: 0 = DI (Disabled) 1 = EI (Enabled) So to set IM 1 and Disable Interrupts, one would input the value of 0 while 5 would set the IM 2 and Enable interrupts. 'Mb' stands for Memory Bank; the value here is only relevant to 128K Spectrums and controls selection of ROM, RAM and screen. The layout is exactly the same as the 128K Basic System Variable BANKM at 23388. Bits 0-2: Select 16K page (0 to 7) at C000h Bit 3: 0 = Screen at 4000h 1 = screen at C000h Bit 4: 0 = 128K Edit ROM 1 = 48K BASIC ROM Bit 5: 0 = paging enabled 1 = locked 48K mode Bits 6-7: Unused Do not confuse this option with menu option 'M' which only selects pages of ROM/RAM for viewing. The combination of ROM/RAM and screen held in 'Mb' is 'live'. Ie. the 128K will be put into this state when you quit GENIE 'PC' (Program Counter) is a Z80 register which, normally cannot be directly accessed. However, when menu option 'R' is used to restart program execution, the address shown against PC will be put on top of the machine stack, causing the Z80 to resume execution at this new location. This gives a way for to force the Spectrum back to BASIC from ANY program, but losing anything stored below RAMTOP. First set RAMTOP to, say, 25000 using Alter mode to POKE 23730,168 and 23731,97. Then put address 4535 (11B7h - NEW routine in ZX ROM) onto PC. Now, instead of returning to the program, menu option R will NEW the Spectrum leaving memory above 25000 intact. H - This key can be used at any time to toggle the display between Hex and Decimal. The border colour changes to show which base is in use; blue for decimal and cyan for hex. Decimal numbers are shown with 3 or 5 digits, and hex with 2 or 4 digits. A - Alter mode, lets you POKE values into any of the Spectrums 49152 RAM addresses. Printable ASCII characters (including ZX KEYWORDS) are shown to the right. In Z80 mode, 'A' lets you alter contents of registers instead of RAM. P - Output to printer as well as screen. Input either an address to print from, or ENTER to begin at the currently shown one. The default END address is 65535. SPACE aborts printing. Printing errors or pressing BREAK will return you to the menu. S - Scroll continously. Press any key to STOP. C - Copies the top eight lines to the printer. SPACE - returns to the menu or exit from an input prompt. G - Go back. The display jumps back 12, 24 or 48 addresses, according to the mode (D/N/T). This is a quick way to take another look at an area of memory you have scrolled past. On GENIE 128, left & right cursor keys are used instead. Please note that stepping back may restart a disassembly at an address part way through an instruction, in which case ignore the the first few mnemonics. Inputting numbers: Pressing ENTER alone at a prompt for a start address gives a default value. When GENIE is first summoned, the default is the value in the Program Counter (PC). Thereafter, it is the address most recently viewed. Hex digits can only be input in hex mode (cyan border). Press H to change the base at an input prompt. M - GENIE 128 Only ! Select 128K memory configuration - only appears on 128K machines is paging is enabled. The first digit (1 or 0) indicates which of the 128's two ROMS was paged in when the button was pressed. The second number (0 - 7) shows which RAM bank was paged in. Since only one of these ROMs and 48K of RAM may be addressed by the Z80 at one time, you must select a bank before examining it. Press M and then: ROM: 0 - press key 0 or 1 to select ROM RAM: 7 - press key 0 to 7 to select RAM Press SPACE or ENTER to move from one prompt to the next, and again to exit this prompt. RET: Return to the program being examined. The program's screen will be restored and execution continued from when F5 was pressed (but see notes on altering the PC register). 128K Memory Map --------------- The 128 has two 16K ROMs (either of which can be mapped onto the Z80 address space 0 - 16383) and eight 16K banks of RAM, any one of which may be mapped from 49152 to 65535 (C000h - FFFFh). In addition, RAM bank 5 is always mapped from 16384 - 32767 and RAM bank 2 always from 32768 - 49151. So these two banks can appear in two different areas of memory at one time ! FIND searches the banks in both positions; you must decide which is relevant. Some points to note ------------------- Although GENIE uses no Spectrum RAM, Multiface paging inevitably places two addresses onto the Z80 machine stack. Bear this in mind if you need to examine the stack. In rare cases, where stack space is small, Multiface stack usage could cause a 'crash' on return from GENIE. If so, try pressing the button at another stage. e.g. in PAUSE mode or at a menu. It is, of course, possible for users to crash software by haphazard alteration of RAM or Registers. To summon Multiface instead of GENIE, hold down CAPS & SPACE as you press F5. This corrupts GENIE and it will need to be re-installed for subsequent use. However, after returning to Multiface operation, pressing the button without holding CAPS & SPACE will still attempt to run GENIE, causing a crash. Prevent this by using Toolkit to POKE address 8915 (decimal) with 0 to cancel the Direct Jump vector (see Multiface manual). Since GENIE loads into Shadow RAM, typing NEW or RANDOMIZE USR 0 will not affect it. Neither will the ZX Reset Button (or F10 - X - R) unless this is pressed when GENIE is in use. A note from the typer of these documents ----------------------------------------- I have not included various sections that were not valid when using this software with the Z80 Emulator. Such sections included altering the IN & OUT value for each version of the Mulitface, plus how to customize it for Microdrive etc. Where possible, I have tried to expand on this somewhat confusing documentation !!