ZeroPage Pro

Page content

ZeroPage Pro - Ultimate Guided W65C02S Disassembler


About

Projekt 0333/0010 Copyright Carsten Meyer / chesslab.de

ZeroPage Pro is a full featured closed source command line disassembler for 6502 / 65c02 binary code files. ZeroPage Pro will be free for non commercial use.

Version

  • ZeroPage Pro V0.56d
  • Manual V0.21a

Requirements

Features

  • disassembly of all 65c02 instructions
  • codeFlow analysis to differentiate between code and data
  • generates call graphs
  • generates reference listings to all external addresses and I / O ports
  • generates different output formats
  • static memory access analyzing
  • Jumptable support
  • static reference counting
  • Statistics
    • Code / Data generation
    • number of opcodes
      • 6502 opcodes
      • 65c02 only opcodes
      • WDC 65c02 only opcodes
    • number of code bytes (related to bin file size / related to address space)
    • number of data bytes (related to bin file size / related to address space)
    • generated code bytes per address call
    • Labels
    • All
    • Manual
    • Jump
    • Read / Write
    • Types
    • All indirect jumps
    • Constants
  • Data CharSet Extentions: ASCII, LED4DIG7, LCD24DIG7, PETSCII, LCD216DIG40
  • falseCodeDetection() for automated data to code detection
  • Auto LoadAdress Calculation (moves short files to AddressSpace End)
  • StartAddressList sorting (optional)
  • BRK and STP Treatment - END instead of NEXT in CodeFlow analysis (optional)
  • IRQ StartAddress Treatment (optional)
  • Constant Name Definition (Address and Value based) (optional)
  • 64tass compatible assembly file generation (optional)
  • 64tass macro support
  • Guide file support
    • Comments (top / line)
    • Start addresses
    • Jump tables
    • Hi / Lo tables
    • Address constants
    • Value constants
    • Macros
    • Manual labels
    • Byte encoding

To do / To improve

  • handles references to addresses not aligned with instruction (eg: self -modifying code)
  • manual Startaddresslist Optimizer
  • HTML output

Concept

By default the output of ZeroPage Pro includes as many usefull information as possible. The output can be reduced by setting some options to hide the information not needed. A special case is using the option “/tassOutput”, which restricts the output to be ready for a direct assembly process with 64tass assembler.

The output is basically organized in 5 columns which can be deaktivated individually (if needed).

ADDRESS BYTES ASCII LABEL MNEMONICS COMMENT

The output file contains all the content from all guide files and the info file. Main goal is to get an output with all information available, needed and used to generate the output file from the bin file. The content of the guide files and the info file can be manually restored from the output file if neccessary. So finally it is only needed to keep an eye on the output file.

Installation

Just copy ZeroPagePro.exe into your working directory and you are done or place it somewhere else an add the path to the path environment variable.

Usage

ZeroPagePro [options] /f <infile> [/o <outfile>]

Options

/help

/h or /help or /?

Shows the help / usage page. If ZeroPage Pro is called without arguments this page is also shown.

/hideDefaultDescriptions

/hideDefaultDescriptions [CODE|DATA]

If set the default descriptions in the comment column are not used. This can be selectivly set for code and data sections.

/hideLabelInfos

/hideLabelInfos [TOPLINE|REFCOUNT|TYPE]

/hideColumn

/hideColumn [ADDRESS|BYTES|CHARS|LABEL|MNEMONIC|COMMENT]

By default all columns are shown. This setting switches off the specified columns.

/hideStatistics

/hideStatistics [OPCODES|SPACE|CODEPERADDRESS|MANUALSETLABELS|LABELSWITHINFOS|JUMPLABLES|READWRITELABELS|IMMEDIATECONSTANTS|LABELTYPES|STARTADDRESSES|INDIRECTJUMPS]

/disableGuideFiles

/disableGuideFiles [ADDRESSCONSTANTS|MANUALLABELS|VALUECONSTANTS|STARTADDRESSES|JUMPTABLES|HILOTABLES|BYTEENCODING|MACRODEFINITIONS|TOPCOMMENTS|LINECOMMENTS|HWVECTOR

/setDefaultCharset

/setDefaultCharset [ASCII|LED4DIG7|PETSCII|LCD24DIG7|LCD216DIG40]

The default charset is used if no specific charset is used for a specific data section using the .gbe guide file. If not set ASCII is used.

/dataBytesPerLine

/dataBytesPerLine [numberOfBytes]

The default is 8 bytes per line. This options sets a new default value. The default value will be overwritten by .gbe guidefile settings.

/sortStartAdresses

Given start addresses are processed in unsorted order. This option sorts (ascending) all given start addresses. This can lead to different results in code detection through the flow based disassembling process.

/optimizeManualStartAdresses (WIP)

xxx

/disableAccuDisplay

Disables explicit adding the letter “a” after mnemonic with addessing mode “accumulator”

asl <-> asl a
inc <-> inc a
rol <-> rol a
dec <-> dec a
lsr <-> lsr a
ror <-> ror a

/treatBRKasIllegal

This switch affects FlowControl analysis. If set BRK will be treated as illegal instruction. Assuming that code sections normally do not contain illegal instructions the analyzed byte block will be marked as data.

/treatSTPasIllegal

This switch affects FlowControl analysis. If set STP will be treated as illegal instruction. Assuming that code sections normally do not contain illegal instructions the analyzed byte block will be marked as data.

/disableLoadAddressAsStart

This switches off the load address (given or calculated) as possible start address.

/disableIrqBrkVectorAsStart

This switches off the IRQ / BRK Vector as possible start address. If a load address is given and the highest bin file address does not reach the Vector space the vector is by default not used as start address.

/disableNmiVectorAsStart

This switches off the NMI Vector as possible start address. If a load address is given and the highest bin file address does not reach the Vector space the vector is by default not used as start address.

/disableResetVectorAsStart

This switches off the RESET Vector as possible start address. If a load address is given and the highest bin file address does not reach the Vector space the vector is by default not used as start address.

/enableSpeculativeCodeAnalysis (WIP)

/tassOutput

This will overwrite some settings (mainly regarding display) to produce a ready-to-use assembly file which can directly be assembled with the 64tass assembler.

Usefull batch files

@echo off
del mephisto4.bi2
del mephisto4.as2
ZeropagePro.exe /sortStartAdresses /treatLoadAddressAsStart /useExtension LED4DIG7 /f mephisto4.bin /o mephisto4.asm
ZeropagePro.exe /tassOutput /sortStartAdresses /treatLoadAddressAsStart /useExtension LED4DIG7 /f mephisto4.bin /o mephisto4.as2
64tass -a -b -o mephisto4.bi2 -Wall mephisto4.as2
echo.
fc /B mephisto4.bi2 mephisto4.bin

Info file

If an info file exists .ifo it will be included into the output file header section. The content is not interpreted and can contain information about the project or binfile. It is just a way to include whatever needed in an automated way into the output file.

Guide files

Guide files are the heart of ZeroPage Pro. They are the main philosophy of how to use this disassembler and the right way to squeeze the last out of it.

Guide files can be shared and worked on collaboratively to describe the contents of a bin file as good as possible. ZeroPage Pro uses all these information to generate the best disassembly listing possible.

There are several different guide files, each one for its own suppose. You do not have to use guide files but you should.

  • All input files have to be in ANSI format.
  • The filename has to be the same as the input file but with a guide file specific filename extention.
  • Format: inputfilename.guidefileextention

Guide file contents will get included in the output file header section.

.gac - guide address constants

; Immediate Address Name
8001 WP
8103 BP

.gml - guide manual labels

; address label
8000 Start

.gvc - guide value constants

; value name
0 Zero
1 WP
2 WK
3 WB
4 WR
5 WQ
6 WK

.gsa - guide start addresses

; address
8000

.gjt - guide jump tables

; addressLoByteTable addressHiByteTable offset size name
a000 a0010 01 0f Name

.ghl - guide Hi Lo (WIP)

; addressHi addressLo name

.gbe - guide byte encoding

  • a set bytesPerLine value is valid till the next non zero value
  • bytesPerLine at addressEnd + 1 is set to the default value
  • bytesPerLine takes only affect inside data sections
  • values of bytesPerLine = 0 are ignored. The value vaild before that address is continued than
  • a lineWrap is caused if values changed from byte to byte
  • Column with will set according to the bytesPerLine value

    ; addressStart addressEnd bytesPerLine encoding
    0d00 0dff 10 ASCII
    0e00 0eff 4 LED4DIG7
    

.gmc - guide macro definition

; addressStart addressEnd macroName addressParam1 typeParam1 [addressParamN typeParamN]
e000 e020 something e004 MACRO_ADDRESS e008 MACRO_BYTE e012 MACRO_ADDRESS e020 MACRO_ADDRESS_LO e021 MACRO_ADDRESS_HI

.gtc - guide top comments

Top Comments are shown directly above the given address embedded between two dash lines. The top comment can include spaces.

; address topcomment
eb60 Example Top Comment 

.glc - guide line comments

Line Comments are shown in the comment column of the line. In code sections, line comments are only displayed if the address points to the opcode byte (first). In data sections the existance of a line comments leads to a line split. The line comment can include spaces.

; address linecomment
eb60 Example Line Comment

.ghv - guide hardware vector (WIP)

This guide file allows for customize the names and comments used for the hardware vectors.

; address vectorlabel vectorcomment targetlabel
fffa HW_VECTOR1 "NMI Vector" NMI
fffc HW_VECTOR2 "Reset Vector" Main_Reset
fffe HW_VECTOR3 "IRQ / BRK Vector" IRQ_BRK

CharSet Extentions

Sometimes data bytes are set to technically represent a char on a special kind of display (7 segments etc.). Use and try one of the following settings to turn these data bytes into readable text.

ASCII (default)

Standard ASCII decoding.

LED4DIG7

Special decoding for 7 segment displays (like 4 char LED displays in Mephisto Chesscomputers)

LCD24DIG7

Special decoding for 7 segment displays (like 2 x 4 char LCD displays in Mephisto Chesscomputers)

LCD216DIG40

Special decoding for 40 dot matrix displays (like 2 x 16 char LCD displays in Mephisto Chesscomputes)

PETSCII

Special decoding for Commodore text data (C64)

Label Types

A good help for analyzing foreign bin files is the feature of ZeroPage Pro to group labels into types and have reference counters for them.

  • “J” - JUMP - address is a jump target
  • “R” - DATA_READ - data is read from this address
  • “W” - DATA_WRITE - data is written to this address
  • “V” - VECTOR - address (an the following) is accessed as vector address
  • “M” - MANUAL - address label was manually given
  • “T” - TABLEJUMP - address is a jump target from a jump table

Example: Labelname_Jx_V_Rx_Wx_M_T

Example

Code

todo

Full output

todo

64tass output

todo