Electron User
1st February 1987
Author: Stuart Low
Publisher: Slogger
Machine: Acorn Electron
Published in Electron User 4.05
Stuart Low tries out a powerful disassembler which impresses despite the odd bug
One of the most powerful disassemblers currently available for the Electron is Startrek, enabling you to explore the innermost confines of your micro's memory. As the program is supplied on ROM, you'll need some form of Sideways ROM expansion board or cartridge to use it.
Typing *HELP TREK prints a help screen displaying all the commands understood by the ROM and is shown in Figure 1.
*TREK the Complete Disassembler 1.06 (C) Tornado Software 1986
Type *TREK for the Disassembler *MEMORY <adr> - BASIC location use *OSBYTE <adr> - OSBYTE call info *OSWORD <adr> - OSWORD call info *OSFIND <adr> - OSFIND call info *OSFILE <adr> - OSFILE call info Syntax: *MEMORY ddddd (*MEMORY &hhhh) where d=decimal, h=hex digit
During Disassembly: ^B Printer on ^C Printer off ^A ASCII on ^S ASCII off ^L Text on ^K Text off ^N Page mode on ^O Page mode off ^V Screen mode (follow with 0-7) L Enter Labels T Enter Tables * Enter system command ^I Re-enter start & end addresses SPACE Fast/Slow Disassembly |
Figure 1: The Startrek Help Screen |
The disassembler is entered on power up if there are no other language ROMs of higher priority or by typing *TREK. Initially eighty column Mode 3 is selected and you are presented with a list containing the name, number and status of all ROMs present.
The status information tells you which processor type each ROM is intended for - normally on the Electron this is the 6502. It will also tell you whether it will work across the Tube, for those lucky enough to have a second processor, and whether they are either language or service ROMs.
Below this display you are prompted for the start and finishing addresses of the area of memory to be disassembled. An offset address can be given enabling programs meant for Sideways ROMs which start at &8000 to be placed in a lower area of memory before being disassembled.
If the start address lies between &8000 and &BFFF, the area of memory reserved for Paged ROMs, *TREK will ask for the ROM you wish to disassemble.
You may select any Mode but if any other than 80 column Modes 0 or 3 is selected, both ASCII and text outputs are disabled. However, these can be re-enabled at any time using the control keys, which I'll come to later.
Before the disassembly *TREK asks if you want to send the output to a printer. It is quite intelligent and if you answer yes it checks to see if a printer is connected and on line before proceeding.
The printer can be turned on or off, as can paged mode during disassembly using the normal BASIC control keys - B, C, N and O respectively.
ASCII output can be turned on and off with CTRL and S and A - not A and S as stated in the manual.
During disassembly the TAB key, according to the manual, allows you to input a new start and finish address. Unfortunately the Electron doesn't have a TAB key. However, the BBC Micro does and it produces the ASCII code 9. CTRL and I on the Electron produces the same code and, fortunately, has the same effect.
This is a far from standard disassembler. What makes it unique is its impressive ability to comment on the code as it disassembles. Take a look at Figure 2 to see what I mean.
The Operating System commands, such as OSBYTE, OSWORD, OSFIND and OSFILE are all identified and decoded. Each is followed by a brief note stating its function, and the function of each memory location accessed is also given. These interpretations may not be strictly accurate, however, since it is possible to write in quite obscure ways disguising the true function of the code.
When disassembling the BASIC ROM the entry point for BASIC keywords like INKEY$, RND, SOUND and so on are flagged.
The bytes following a BRK instruction are treated as ASCII text characters and are printed out until another BRK is encountered. This is how BASIC stores its error messages.
The contents of an address are displayed if used by an indirect jump. This is useful when following Operating System calls through jump vectors. However, some ROMs alter these during use and therefore their contents may not be accurate.
In addition to commenting on code, Startrek allows you to add labels - up to six characters long - to the output. These can be used to identify program statements, loops, branches or subroutine entry points.
They can be loaded from or saved to a file enabling you to build up a complete annotated disassembly listing of a machine code program.
Areas of memory used for data or text storage can be output as a hex/ASCII dump. The start and end points of these areas or tables can be saved along with the labels.
You can ask Startrek to comment without entering the disassembler, using star commands from BASIC.
*MEMORY will tell you what a particular memory location is used for and OSBYTE, OSWORD, OSFIND and OSFILE will provide information on these Operating System calls.
Unfortunately, Startrek does contain a few irritating bugs - for instance CTRL-K (intended to disable text output) and certain star commands crashed it.
Bugs aside, this package does seem to have a lot going for it. It is easy to use, thoroughly comprehensive and even "intelligent". Startrek is an extremely useful and versatile tool and a virtual necessity for the machine code programmer.