IMPORTANT NOTICE

For historical reasons, or for people who prefer the old Perl code, the old versions are available below.

The P65 Assembler

The P65 assemblers are assemblers for the 6502
microprocessor (such as is used in the Commodore 64, Apple II,
and Nintendo Entertainment System). They are designed to be
able to support a wide variety of output formats, both to
support multiple target platforms and to produce code for
emulators.

The eventual goal of P65 is to be as expressive as the more
powerful assemblers of the late 80s, such as DASM. It's not
there yet, but it's getting there.

If you are here because you have a ".p65" file and you don't
know how to deal with it, you're probably dealing with a
PageMaker file.

P65-Perl is no longer being supported, in favor of the "Ophis" Python-based releases. See
news.

Features of P65

Highly portable - All versions of P65 are written
in portable scripting languages. The original releases were
done in Perl. While P65-Perl 1.1 is stable and reasonably
powerful, it lacks some major features, such as modules and
macros. P65-Ophis, the Python port, will run on slightly
fewer architectures, but will still run on all current major
systems.

Flexible output format - P65 allows for very
flexible control over data and assemble points. Output file
formats are completely independent of the final memory
maps.

Multiple file support - libraries may be kept as
seperate files and included seperately, facilitating code
reuse.

Temporary label support - source may contain
"anonymous labels" that help decrease namespace pollution.
P65-Ophis also supports named temporary labels that only exist
within a well-defined scope.

Assemble-time expressions - P65-Ophis supports
High-byte/low-byte computations along with bitmasking and
traditional arithmetic operations in code and data
statements. Access to the current PC is also supported.
P65-Perl's expressions are more limited but are generally
sufficient.

Symbol table management - Allows for creating
labels and data constants outside of the code, and for
allocating RAM symbolically. This includes full support for
segments.

Optimal instruction selection - Compresses as many
instructions as possible into zero page format. If this
compression permits other instructions to become zero
page instructions, it will compress those as well.

News

17 Jul 2003: Double Oops. The parser was not properly handling indexed LSR instructions. 0.7.2 is has just been uploaded to fix this.

10 Jul 2003: Oops. A bug in 0.7 caused it to fail to accept macros with no arguments. I had a patch for this once upon a time, but it wasn't available from this website. Version 0.7.1 of Ophis has been uploaded to deal with this.

1 Jan 2003: Version 0.7 of Ophis is complete. The tutorial is currently only in text file format, but it is included with the distribution. I'll HTMLize it and put it online at a later date. A new command reference is ready.

31 Dec 2002: Version 0.7 of Ophis is being readied. The code is done; only documentation remains. Version 0.7 adds macros and a new "require" directive to prevent multiple inclusion. Look for a release, complete with an extensive, completely rewritten tutorial, in January 2003.

28 Nov 2002: Version 0.2 of Ophis has been released, adding big-endian data support and named temporary variables. Only repetition and macros remain before the late-beta 0.9 release.

15 Aug 2002: Version 0.1 of Ophis has been released.
Not all features in the draft have been supported yet.
Ophis.Main is the "main program."

8 Aug 2002: Read the draft for the new command reference
for P65-Ophis.

26 Jul 2002: P65 has been quite an experience, but
most of the feedback I've gotten on it has involved powerful
features that are going to be very difficult to implement in
Perl. P65 is thus moving away from Perl and being reimplemented
in Python. A vast number of new abilities will come with this,
including ease of extension (write your own optimization
passes!), macros, a lexical scoping system, full expressions,
and all of the old features of P65. I'm not going to guarantee
backwards compatibility, but only minor changes should be
needed. The goal is to produce a portable cross-assembler
that's open, free, and at least as powerful as TASM and
DASM.

9 Apr 2002: Fixed up the P65 tutorial to cover
segments. We are back in business.

21 Mar 2002: The HKN server suffered a massive crash
a few weeks back which destroyed a lot of the documentation.
Thanks to WebArchive (and a timely email from a reader, for
which I am most grateful), I recovered the 1.0a era pages. The
tutorial is now out of date compared to the command reference
and implementation notes, but at least it's a start. Version
1.1 got released in the news interregnum, as well.

3 Jan 2002: Made some bug repairs, and tightened
error checking. Newest version is now 1.0a. Incidentally, P65
is being tracked on freshmeat
which will let you automatically be informed of updates and
such.

14 Dec 2001: P65 1.0 has finally been fully released.
The site has been redesigned a good bit too, as I migrate
non-P65 material off onto its own page elsewhere.

9 Dec 2001: P65 1.0 is complete, but not documented.
I'm making it available for download now, and updating the
documentation once I get time to do that (soon).

5 Dec 2001: I'm going to be working on enhancing 0.3
still further over Christmas break - this will tentatively be
the 1.0 release. It will have a much stricter grammar as well
as support for more pragmas. It will also have anonymous label
capability, and the ability to do computations based on the
current program counter (allowing for re-linkable data).

3 Dec 2001: Version 0.3 is released! This uses a
greatly enhanced lexer/parser that can catch many more errors
and cleans up the resulting code considerably. String support
is also greatly enhanced. The new design also permits more
expansions; I'm already workout out the next release, which
will not be source compatible with 0.3 or 0.1. Pragmas
will be more tightly integrated with the rest of the program
code, and opcode validity will be checked more carefully - this
will break the traditional uses of a number of rather important
pragmas (like .include). The changes to the source
will be fairly trivial, though.

Documentation

P65-Ophis reference
- tables of the various types, memory modes, and assembler
directives. Also indicates which parts haven't actually been
implemented yet.

P65 tutorial - a guide to the
features of P65. Currently only valid for P65-Perl. An Ophis
tutorial is included with 0.7.

Downloads

P65 releases

Ophis version 0.2 -
adds the .wordbe and .dwordbe
directives for big-endian data structures, and the
.scope and .scend statements for
temporary named label support. Labels that begin with an
underscore are only accessible within the innermost enclosing
scope.

Ophis version 0.1 -
initial Python release, August 15, 2002. Mostly compatible
with P65-Perl, but doesn't support redundant directives by
default, and has slightly different precedence between the
highbyte-lowbyte operators and addition and subtraction.

Version 1.1 - released March 15,
2002. Adds undocumented opcode support for the 6510, more
flexible verbosity in output, memory segmentation simulation,
and the ability to make assertions about how much memory
you're using up.

Version 1.0a - released January
3rd, 2002. Fixed a bug with instruction selection on
zero-page y-indexed instructions, and tightened error
checking so that certain kinds of bugs in P65 code do not
crash P65.

Version 1.0 - released December
9th, 2001. Optimal instruction selection, strong error
checking, more widely available expressions, temporary
labels, the ability to do math with the current program
counter, and enhanced capabilities for statically organizing
the heap at assemble time. Not source compatible with earlier
releases.

Version 0.3 - released December
3rd, 2001. Almost completely recoded, striking down pretty
much all the known bugs in 0.1. All code written for 0.1
should assemble on 0.3 unless that code hinged on 0.1's bugs.
Added the .org pragma.