Home BMDS: Disassembler
Post
Cancel
Preview Image

BMDS: Disassembler

The disassembler assumes some program code exists in memory. The address range for disassembly is entered, in this case $FC00 to $FFFF for the Tanbug ROM code.

Running a simple disassemble gives the type of result shown above, where the address, machine code and disassembled instruction are produced. Without any data sections added, looking down the listing would give “FE4B 33 = Invalid opcode $33” giving an indication that this is perhaps a data section rather than program code. There is a knack to looking through the following bytes to see where “real” code starts again. In the case above the data sections at $FE4B-$FE72 and $FFEC-$FFFF have been added and the whole address range disassembles satisfactorily, with the data sections being output as defined byte constants.

Having found the data section successfully, a fuller disassembly can be run with labelling and gives an output like that above. In this case the disassembler runs two passes; the first notes all references to memory locations, the second producing the actual disassembly with labels wherever a memory address has been referenced, and replacing the address operand with the label reference. In most instances the labels will be of the form “Lbl_XXXX” where XXXX is the memory address referenced. Each machine can have an address definitions file which lists the standard labels associated with its memory map, and this is used to replace these default labels with those specific to the machine. In the image above, PSWBCK and KBREAD are such machine specific predefined labels. A labelled disassembly can be fed back into the assembler. I have done this a few times when I have taken a program, disassembled it, made some amendments (usually key allocations), then re-assembled it for use.

An optional description can be entered which will be added to the listing header, and the whole listing copied to the clipboard for use elsewhere.

The disassembly settings (address range, data sections and description) can be saved to a file, and reloaded for future work.

This post is licensed under CC BY 4.0 by the author.
Recently Updated
Trending Tags
Trending Tags