F9DASM - 6800 / 6809 / 6309 Disassembler
Copyright (c) 2000 Arto Salmi
Parts Copyright (c) 2001-2010 Hermann Seib
Based on Arto Salmi's C core that can be found somewhere on the 'net
(last address known to me was
http://koti.mbnet.fi/~atjs/mc6809/Disassembler/dasm09.TGZ),
I built a complete 6800/6809/6309 disassembler that can handle input files
in a variety of formats (Intel Hex / Motorola S09 / Flex9 Binary / Binary).
Since disassembly without guidance produces measly results, it can load
information files with quite a lot of directives, too.
I taylored the original to my taste by working through the source code; since
F9DASM has reached a level of complexity that doesn't really lend itself to following the "Use
the Source, Luke!" principle if you just want to disassemble a little 6809
program, I've added this documentation. Have fun!
Hermann Seib, 2010
Syntax
f9dasm [-option]* [filename]
Command Line Options
- -offset address
- When disassembling a binary file, the default load address
is 0, since the binary file does not contain any clues; using this
option forces F9DASM to load the file at the specified address.
- -begin address
- start disassembly address (address has to be given in hex format)
Default is the first rferenced address in the file.
- -end address
- end disassembly address (address has to be given in hex format)
Normally, this is defined either through the file size or its contents,
if it has an embedded END addres. This option allows to override the implicit
end address.
- -out filename
- normally, f9dasm streams to standard output;
this option forces it to write to the specified file instead.
- -noaddr
- suppresses the address field output (for clean assembler source files)
- -[no]hex
- disables or enables hex dump output (default is enabled).
While analyzing a file, the hex dump can be quite helpful; if you want to generate a
clean assembler source file, you can disable it.
- -x
- -6309
- puts disassembler in 6309 mode (default is 6809).
- -6800
- puts disassembler in 6800 mode (default is 6809).
- -os9
- using this flag, the disassembler tries to convert swi2 to the
corresponding OS/9 calls.
- -info filename
- filename gives an information file which contains additional
hints for the disassembler. See the Info File section below.
- -cchar char
- char is the character to be used as comment delimiter.
Default is *, but not all assemblers can use this.
-cchar ; would switch the comment delimiter to ;, for example.
- -[no]flex
- using this flag, the disassembler uses the standardized FLEX labels for a defined
range of addresses.
- -[no]conv
- using this flag, the disassembler outputs various "convenience" mnemonics
(like, for example, CLRD instead of CLRA followed by CLRB).
Default is on, but not all assemblers support this, so f9dasm can be forced
to stick to the base set of mnemonics.
f9dasm's companion, A09, can of course handle them :-)
- -[no]dec
- can be used to output values in decimal notation (by default it's hexadecimal).
- -[no]comment
- can be used to enable or disable the output of comments (which can be provided
in an info file, see below).
Normally, comments are enabled.
- -help
- outputs an abbreviated version of this documentation.
Info File
Using the -info filename option, you can give f9dasm additional
information about the layout of the processed file.
Normally, f9dasm will try to interpret everything as code;
it doesn't try to find out which areas contain code and which areas contain data,
or the format of the data. Using an info file, you can give it detailed instructions
how to process the file, add comments, insert additional stuff, and so on.
The info file is a simple text file, which contains one instruction per line.
The instructions are case-insensitive.
Addresses need to be given in hexadecimal notation.
Anything following an asterisk (*) is interpreted as a comment.
The info file can contain the following instructions:
- file filename [baseaddr]
- This instructs f9dasm to load the given file at the given address.
Can be used instead of the command line parameter for the file name;
this can, for example, be useful if you want to generate a listing for a
bunch of small EPROMs that cover a continuous memory area.
- option option [value]
- option is one of the options listed above, just without the leading
hyphen (-).
- code addr[-addr]
- defines the given address (range) as containing code.
- data addr[-addr]
- defines the given address (range) as containing data instead of code.
f9dasm will try to decipher ASCII strings in the area and display them
in the best possible format.
- bin[ary] addr[-addr]
- char addr[-addr]
- dec[imal] addr[-addr]
- hex[adecimal] addr[-addr]
- defines the output format used for the given data range.
This can also be used for constants in the code area; if, for example,
f9dasm outputs the following line of code:
LDA #$D6 *C115: 86 D6
and you know pretty well that this is a binary bit mask, you can force it to
display the data in a nicer format by giving the instruction
bin c116 (note that the address of the constant byte is given,
not the address of the instruction!).
This results in the modified output
LDA #%11010110 *C115: 86 D6
which may be easier to read (depending on your mental approach to assembler
programming :-).
Note that char and bin can not be used for word areas (see below).
- word addr[-addr]
- defines that the area consists of words (i.e., 2-byte entities,
high byte first) instead of single bytes.
- const addr[-addr]
- defines the data in the given range as constants.
Normally, if f9dasm can interpret the data as addresses, it will;
and if there's a label defined for this address, it will display
the label instead of the original value.
- unused addr[-addr]
- defines the given address range as unused.
This can be useful if an area in the loaded file is known to be empty;
there's no need to put it into the generated assembler source.
- rmb addr[-addr]
- defines the given address range as reserved, but not initialized to
defined values.
- label addr name
- sets a label at the given address.
Note that f9dasm doesn't restrict the length of the label, nor does it enforce
a given range of characters (except for * and zero bytes - these terminate
the name). This may conflict with the assembler of your choice, so choose
the labels withg caution.
- used[label] addr
- forces the given address used.
Normally, f9dasm would only emit a label definition in the form of an
EQU statement if the label is really used in the code.
- unlabel addr[-addr]
- removes defined labels in the given address range.
This is mainly useful if you use a set of info files (see the
include instruction below) and want to remove label definitions
from an earlier info file.
- insert addr[-addr] text
- This instruction adds the given text to the text lines which
are displayed before a given (range of) address(es).
In contrast to a comment, there's no comment character written before
the text, which allows to insert any assembler statement or pseudo-op.
- comment addr[-addr] text
- appends a comment to the lines displayed before a given address (range).
- lcomment addr[-addr] text
- appends a line comment to the lines displayed before a given address
(range).
A line comment is displayed as a comment to the right of the instruction.
If more than one line comment is given, they are displayed on separate lines,
but all to the right of the instruction.
- prepend addr[-addr] text
- This instruction prepends the given text to the text lines which
are displayed before a given (range of) address(es).
This is mainly useful if you use a set of info files (see the
include instruction below) and want to add additional text from
a later info file before text lines from an earlier info file.
- prepcomm addr[-addr] text
- Same as prepend (see above), but it prepends a comment
instead of a normal text line.
- preplcom[ment] addr[-addr] text
- prepends a line comment to the lines displayed before a given address
(range).
- uncomment addr[-addr]
- removes insert and comment lines from the given address range.
This is mainly useful if you use a set of info files (see the
include instruction below) and want to remove comments
from an earlier info file so that you can replace them.
- unlcomment addr[-addr]
- removes line comments from the given address range.
This is mainly useful if you use a set of info files (see the
include instruction below) and want to remove line
comments from an earlier info file.
- include filename
- includes the given info file.
- setdp dp-content
- uses the specified direct page (if the specified processor can
do that - 6800 implicitly uses Direct Page 0).
Only the last setdp statement is used. While it would be theoretically
possible to use multiple SETDP statements in a single assembler source,
f9dasm doesn't provide this capability.
- rel[ative] addr[-addr] baseaddr
- This can be used to make instructions with indexed addressing easier
to read.
- unrel[ative] addr[-addr]
- cancels the effect of relative instructions.
- remap addr[-addr] offset
- This is a tricky instruction that only makes sense in very special
situations; imagine, for example, that you already have an elaborate
info file for a specific EPROM - and then you get another EPROM that
contains nearly the same stuff, just with one or two instructions
added or missing.
You could, of course, adapt all instructions in your info file to the new
address layout.
Would you? I wouldn't.
In this case, it's easier to prepend a remap instruction that tells
f9dasm to "shift" the following addresses in the info file some bytes.
- end
- Terminates processing of this info file at once.