Free SNES assembler

0. Contents

This is the documentation of snescom-1.3.2.
   1. Purpose
   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. Branch labels
      2.9. Preprocessor
      2.10. Object file format
      2.11. Automatic jump size detection
   3. Examples and more documentation
   4. Changelog
   5. Known bugs
   6. Copying
   7. Downloading

1. Purpose

This program reads symbolic 65816 or 65c816 machine code and compiles (assembles) it into a relocatable object file.

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

2. Supported syntax

2.1. Mnemonics

The following mnemonics are supported:

adc, and, asl, bcc, bcs, beq, bit, bmi, bne, bpl, bra, brk, brl, bvc, bvs, clc, cld, cli, clv, cmp, cop, cpx, cpy, db , dec, dex, dey, eor, inc, inx, iny, jml, jmp, jsl, jsr, lda, ldx, ldy, lsr, mvn, mvp, nop, ora, pea, pei, per, pha, phb, phd, phk, php, phx, phy, pla, plb, pld, plp, plx, ply, rep, rol, ror, rti, rtl, rts, sbc, sec, sed, sei, sep, sta, stp, stx, sty, stz, tax, tay, tcd, tcs, tdc, trb, tsb, tsc, tsx, txa, txs, txy, tya, tyx, wai, xba, xce

2.2. Addressing modes

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

2.3. Operand size control

The pseudo ops .as, .al, .xs & .xl are used to decide what size accumulator and index mode for the assembler to use. .as and .xs are for 8bit operands, and .al and .xl are for 16 bit operands.

I've found it handy to define these macroes:

#define SET_8_BIT_A()   sep #$20 : .as
#define SET_16_BIT_A()  rep #$20 : .al
#define SET_8_BIT_X()   sep #$10 : .xs
#define SET_16_BIT_X()  rep #$10 : .xl

#define SET_8_BIT_AX()  sep #$30 : .xs : .as
#define SET_16_BIT_AX() rep #$30 : .xl : .al
In addition to these modes, 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.

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. Branch labels

The label - can be defined for branches backward and + for branches forward.
Example:
        ; Space-fill the buffer to end
        phx
         cpx #$0010
         bcs +     ;jumps to the next "+"
         SET_8_BIT_A()
         lda #$FF
-        sta $94A0,x
         sta $94B0,x
         inx
         cpx #$0010
         bcc -     ;jumps to the previous "-"
         SET_16_BIT_A()
+        lda W_VRAMADDR
         sta @$002116
        pla

2.9. Preprocessor

snescom uses GCC as a preprocessor.
You can use #ifdef, #ifndef, #define, #if, #endif and #include like in any C program.

2.10. Object file format

Currently snescom only produces relocatable object files.
The file format has been documented by André Fachat for the XA65 project.

2.11. Automatic jump size detection

If --jumps option is enabled, all short jumps are automatically turned into near jumps when needed.

3. Examples and more documentation

In the source distribution there are some C++ modules that can be used to handle the o65 files.
There are also some example assembler files (copied from Chronotools).

4. Changelog

Sep 23 2003; 0.0.0 started working with the project.
Sep 28 2003; 1.0.0 initial release. All features working.
Sep 29 2003; 1.1.0 added feature: branch labels.
Sep 29 2003; 1.2.0 bugfix: didn't resolve correctly when different scopes had a label with the same name; added warning options
Oct 3 2003; 1.3.0 added feature: jump optimization.
Oct 8 2003; 1.3.1 bugfix: jump optimization only supports two passes. Requiring more now produces an error.
Oct 13 2003; 1.3.2 bugfix: accidentally had broke MVN/MVP some time ago

5. Known bugs

6. Copying

snescom 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.

7. Downloading

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

Generated from progdesc.php (last updated: Mon, 13 Oct 2003 17:08:05 +0300)
with docmaker.php (last updated: Thu, 13 Feb 2003 15:11:29 +0200)
at Mon, 13 Oct 2003 17:08:17 +0300