Free NES assembler

0. Contents

This is the documentation of nescom-1.0.0.
   1. Purpose
      1.1. History
   2. Supported syntax
      2.1. Mnemonics
      2.2. Addressing modes
      2.3. Operand size control
      2.4. Expression evaluation
      2.5. Segments
      2.6. Comments
      2.7. Command separation
      2.8. Code pointer relocation
      2.9. Branch labels
      2.10. Preprocessor
      2.11. Object file format
      2.12. IPS output support
      2.13. Linkage selection
   3. Changelog
   4. Known bugs
   5. Copying
   6. Downloading

1. Purpose

This program reads symbolic 6502/RP2A03/RP2A07 machine code and compiles (assembles) it into a relocatable object file or into an IPS patch.

The produced object file is binary-compatible with those made with XA65.

1.1. History

This program was born when Bisqwit needed to have something for NES that is already accomplished for SNES by snescom.

2. Supported syntax

2.1. Mnemonics

The following mnemonics are supported:

adc, and, asl, bcc, bcs, beq, bit, bmi, bne, bpl, brk, bvc, bvs, clc, cld, cli, clv, cmp, cpx, cpy, dec, dex, dey, eor, inc, inx, iny, jmp, jsr, lda, ldx, ldy, lsr, nop, ora, pha, php, pla, plp, rol, ror, rti, rts, sbc, sec, sed, sei, sta, stx, sty, tax, tay, tsx, txa, txs, tya

2.2. Addressing modes

All the standard addressing modes of the 6502 cpu are supported.

To be detailed later.

2.3. Operand size control

There are several operand prefixes that can be used to force a certain operand size/type.

2.4. Expression evaluation

Expressions are supported. These are valid code:

2.5. Segments

Code, labels and data can be generated to four segments: text, data, zero and bss.
Use .text, .data, .zero and .bss respectively to select the segment.
However, only the contents of text and data segments are saved into the o65 file. Labels are saved in all segments.

2.6. Comments

Comments begin with a semicolon (;) and end with a newline.
A colon is allowed to appear in comment.

2.7. Command separation

Commands are separated by newlines and colons (:).

2.8. Code pointer relocation

You can use a command like *= $F200 to change where the code goes by default.
With IPS this is especially useful.
You can change the code pointer as many times as you wish, but unless you're generating an IPS file, all code must be a continuous block.

2.9. Branch labels

The label - can be defined for local branches backward and + for branches forward.

2.10. Preprocessor

nescom uses GCC as a preprocessor.
You can use #ifdef, #ifndef, #define, #if, #endif and #include like in any C program. (See bugs)

2.11. Object file format

Currently nescom only produces relocatable object files (O65) or non-relocatable patch files (IPS).
The O65 file format has been documented by André Fachat for the XA65 project.

2.12. IPS output support

This version of nescom allows you to create IPS files.
This IPS format has been extended to allow you to specify global symbols and externs to be patched later.
In the generated format:

2.13. Linkage selection

By default, O65 objects are linked to any free location in the ROM.
IPS files are linked to predefined locations.

With the .link statement, you can change that.

.link page $3F declares that this object should be placed into page $3F.

.link group 1 declares that this object should be placed to the same page together with all other objects that want to be linked in group 1. This is useful when you want to ensure that certain tables or routines go to the same page, even if they are not in the same compilation unit.
The actual page is determined during link time, and you can get the page by using 24-bit (@) or segment reference (^) to a symbol from those modules.

This is not completely ready for NES yet.

3. Changelog

Nov 20 2005; 0.0.0 import from snescom-1.5.0.1.
Nov 29 2005; 0.1.0 bugfixes, now it's functional.
Dec 16 2005; 0.2.0 support for deeper "++" and "--" labels. Also support for .nop statement.
Jun 20 2006; 1.0.0 raw output file format support in snescom. Also using boost::smart_ptr.

4. Known bugs

5. Copying

nescom has been written by Joel Yliluoma, a.k.a. Bisqwit,
and is distributed under the terms of the General Public License (GPL).

If you happen to see this program useful for you, I'd appreciate if you tell me :) Perhaps it would motivate me to enhance the program.

6. Downloading

The official home page of nescom is at http://iki.fi/bisqwit/source/nescom.html.
Check there for new versions.

Generated from progdesc.php (last updated: Tue, 20 Jun 2006 11:49:59 +0300)
with docmaker.php (last updated: Sun, 12 Jun 2005 06:08:02 +0300)
at Tue, 20 Jun 2006 11:50:23 +0300