Next Previous Contents

3. Detailed workings

3.1 Supported CPUs

The default (no CPU given on the command line or in the GLOBAL section of the info file) is the 6502 CPU. The disassembler knows all "official" opcodes for this CPU. Invalid opcodes are translated into .byte commands.

With the command line option --cpu, the disassembler may be told to recognize either the 65SC02 or 65C02 CPUs. The latter understands the same opcodes as the former, plus 16 additional bit manipulation and bit test-and-branch commands.

While there is some code for the 65816 in the sources, it is currently unsupported.

3.2 Attribute map

The disassembler works by creating an attribute map for the whole address space ($0000 - $FFFF). Initially, all attributes are cleared. Then, an external info file (if given) is read. Disassembly is done in several passes. In all passes with the exception of the last one, information about the disassembled code is gathered and added to the symbol and attribute maps. The last pass generates output using the information from the maps.

3.3 Labels

Some instructions may generate labels in the first pass, while most other instructions do not generate labels, but use them if they are available. Among others, the branch and jump instructions will generate labels for the target of the branch in the first pass. External labels (taken from the info file) have precedence over internally generated ones, They must be valid identifiers as specified for the ca65 assembler. Internal labels (generated by the disassembler) have the form Labcd, where abcd is the hexadecimal address of the label in upper case letters. You should probably avoid using such label names for external labels.

3.4 Info File

The info file is used to pass additional information about the input code to the disassembler. This includes label names, data areas or tables, and global options like input and output file names. See the next section for more information.


Next Previous Contents