EXDIS -ON EPROM- EXTENDED DISASSEMBLER FOR THE BBC MICRO MODEL A OR B By ANDREW LORD Copyright (c) 1984 ANDREW LORD INTRODUCTION EXDIS is a sophisticated machine code disassember written especially for the BBC micro. It provides a wide range of facilities including the following: (i) Full disassembler allowing disassembly of paged ROMs and files on disc. (ii) Full labeling capacity, including markers. (iii) Hex/ASCII dumps and memory editing. (iv) Line assembler with labels allowed. (v) Full expression analysis including variable/label names. (vi) Full sideways ROM support. (vii) Allows use of all Operating System commands within EXDIS. EXDIS is useful for debugging machine code programs especially when used with a machine code monitor such as EXMON, or for discovering how someone elses machine code program operates. The function keys con be used to enter frequently used commands. For example *KEY 0 L 8000 807F|M (RETURN) will cause EXDIS to list memory from &8000 to &807f whenever function key f0 is pressed. NOTE: To take full advantage of all the features of EXDIS your machine should be fitted with Acorn's Basic ROM, version I or II. STARTING INSTRUCTIONS (i) Calling EXDIS Once the EPROM containing EXDIS has been installed, EXDIS con be entered by the command *DIS (RETURN), where (RETURN) means press the Return key. This can be abbreviated to *D (RETURN) for quick access (NOTE that there is no full stop after *D ). So that full use of EXDIS can be made, this command should be entered from Basic or a machine code monitor and not, for example, from a wordprocessor EPROM. Pressing break at any time during the running of EXDIS will re-enter EXDIS. If any labels were defined then you will be presented with the option of saving them. To quit EXDIS type Q (or use CRTL/Break). Type OLD (RETURN) to recover any resident Basic (or assembler) program. NOTE: defining any labels will have the effect of overwriting you Basic program and so it is advisable to save your program before entering EXDIS should you want to use labels. An address may also be specified (in hex) after the command *DIS, e.g. *DIS 1900. Disassembly will automatically start from this address on entry. It is possible once in EXDIS to switch into a monitor such as EXMON ,e.g., for single stepping and then return to EXDIS (with *D) for disassembly. Note: answer 'Y' to prompt to keep labels on your return to EXDIS. Should you accidently leave EXDIS by option Q or CTRL/Break then it is possible to retrieve labels defined by entering *D as normal and replying 'Y' to the prompt. The labels will still be intact - except possibly the first 2 bytes of the first label will be overwritten by &0D &FF by Basic. This will give the label an address of &FF0D. You can use the command 0 FF0D to find out the name of this variable. (ii) EXDIS version Typing *HELP followed by Return will give the normal Help message. This should now include EXDIS will its version number. GENERAL OVERVIEW (i) Commands Commands are entered by means of one or two characters to identify the command, followed by a number of parameters. The command summary at the end of this manual gives a detailed description of the precise syntax and default values. There is also a HELP facility within EXDIS which will give a brief on-screen summary of the commands, this is activated by typing '?'. Throughout this manual the following will be used to describe the parameters:
a 2 byte address e.g. 81E5 a range in memory specified by a 2 byte start address and a 2 byte end address, e.g. 8100 82E4. a single byte hex value, e.g. 5D. (ii) Numbers The numbers used by the commandscan be entered in several ways: (a) as a simple hex number. Terminate with (RETURN) only if there are less than the maximum number of digits, e.g. when entering a single digit rather than 2 for or when entering less than 4 characters for
etc. Note: do not prefix with &, hex is assumed. (b) by default i.e. (RETURN) alone is pressed. This has different effects depending on the command. In general a single address or the start address of a range will default to the current address in the memory, and the second address of a range will default to 'infinity' (i.e. the command will continue indefinitely). Note that the second address can be entered relative to the first, using the '+' operator. eg M 9000 +FF is eqivalent to M 9000 90FF. (c) as an expression, using the '#' option (see below). This allows decimal values to be input. (iii) Expression Evaluation (a) The 'C' command causes evaluation of an arithmetic expression, displaying the result as a 4 byte hex integer and decimal equivalent. Negative results are printed in 16 bit complememt form (ie the result -10 is printed as 65526 etc). The expression may contain +,-,*,/,^,brackets to any level, and Basic variable names. In particular this includes labels used in the source code (provided they are still defined). NOTE: The expression evaluator makes use of routines in the Basic interpreter, and so reverts to the Basic convention of assuming decmal. You must therfore prefix hex numbers by &. If the Basic ROM is not installed, attempting to call the expression evaluator will result in an error message to this effect. EXDIS is compatible with versions 1 and 2 of BBC Basic in this respect. (b) The '#' option. This allows fully general expressions to be entered for any of the parametes for any command, if '#' is entered as the first character after the command letter, e.g. entering D #START #START+22 will disassemble 23 bytes from the memory location given by 'START' (which may be a source code variable). However before the expression is passed to Basic for evaluation EXDIS checks to see if you have entered a label name. If so then the address corresponding to that label will be taken. e.g. L #for #next will list memory between labels 'for' and 'next' assuming the have been defined with the command '#'. (iv) Operating System Commands All normal calls to the operating system (commands prefixed by *) are accepted by EXDIS, so that it is possible to set user keys, make *FX calls, perform *LOADs, etc. all from within EXDIS. In particular *KEY can be used from within EXDIS to set up often used command sequences. (v) Zero-page Memory EXDIS uses location &40-&6F as workspace and so does not conflict with Basic or EXMON. (vi) Input correction will cancel the current entry, except on expression or label entry. (escape> will escape from any command. 1. MEMORY COMMANDS L=LIST Syntax: L Lists memory within given range in both hex and ASCII. The second address can be omitted and the listing will continue indefinitely - press Escape to stop. Page mode is engaged so page through with Shift as usual. Control codes are replaced by a full stop in the ASCII column. M=ASCII LIST Syntax: M As L ,above, only the memory is displayed in ASCII only. D=DISASSEMBLE Syntax: D Disassembles the given range of memory listing standard 6502 mnemonics, hex and ASCII with labels replaceing the appropriate address. '???' signifies an unrecognised opcode. Colour is used to highlight branches, unknown opcodes and jumps. This option can be toggled on/off with the command Z. The disassembler also 'homes in' on labels - see the command I for more details. Page mode is engaged. K=DISASSEMBLE & SAVE Syntax: K Disassembles the range of memory, spooling to the specified file. The first record of the file will contain the Basic command "AUTO", so that when the file is *EXEC'd from Basic, a Basic program will be created. This can be edited and run to reassemble the original section. Notes: i) Branch instructions are disassembled with relative addressing e.g. BEQ P%+7 ii) Unknown opcodes are replaced with OPT FNequb(&XX) on BASIC I and EQUB &XX on BASIC II to allow correct reassembly. N=ASSEMBLE Syntax: N
Enters the line assembler at the specified address. Input 6502 mnemonics (only one per line) and these will be assembled at the address displayed. Labels may be used as in Basic. moves forward 1 byte. moves back 1 byte. terminates assembly. Note: This calls the assembler in the Basic ROM. E=EDIT Syntax: E
Enters the memory editor at the specified address. Editor commands: a byte value entered is stored at the current location, and you move to the next byte. move to the next byte without changing. move back one byte. finish editing. "=INPUT STRING Syntax: "
Stores ASCII characters input from the keyboard starting at the specified address. Control characters can be entered. (a full stop will be displayed) Terminate entry by pressing Escape ( the Return key enters the Return character &0D and is not therefore used to terminate this command). FS=FIND STRING Syntax: FS Searches for an ASCII string in the given memory range. Any occurances will be listed, giving the address of the start of the string. Note: Do not be confused by unexpected finds, such as the buffer where EXDIS stores the search string or in the screen memory ! FB=FIND BYTE Syntax: FB As for FB, but a string of bytes is entered. Note: the lower 8 bits of the entered byte are taken if you use # . B=BASIC LIST Syntax: B Lists the program at the given page in Basic format. The default value is the current PAGE setting. Note: this command does not decode GOTO or GOSUB linenumbers correctly. 2. LABELING EXDIS allows the user to define up to about 3100 labels. These are stored in memory above the default setting of PAGE (normally &E00 on tape machines). Labels can be up to 7 characters in length. They come into their own during disassembly when any referance to a labeled location is replaced by the appropriate label. e.g. 8100 LDA &FF A9 FF .. 8102 BMI escape 30 04 .. 8104 JMP noesc 4C AB 81 ... escape 8107 BRK 00 . .. .. .. . Notice that disassembly takes place in five columns : label, address, opcode, hex and ASCII. This is the normal layout used by assemblers and so leads to a very readable code. Note that all major operating system calls are already labeled, but do not take up any RAM. They cannot be redefined or deleted. Markers may also be set. Markers are like labels only they don't show up in the disassembly - they just mark an address. They can be used to mark the end of data areas in a program so that the disassembler can 'home in' on them for a better disassembly without giving the address a label (see the command I). Details of where the labels are stored in memory is given at the top of the screen. The start and end addresses are given. #=SET LABEL Syntax: #