SNASM

A SNES 65816 Cross Assembler for the IBM PC

Introduction

SNASM is a fast 2 pass assembler, supporting source and binary include files, generation of listing files and labels files, generation of executable or object files and support for all 65816 instructions and addressing modes.

Command Line Options

The assembler is executed with the following command:

SNASM <filename> {<options>}

<filename> is the filename of the source code that you want to assemble.

The following options are available:

LIST This generates a ".lis" listing file which interleaves the code generated with the source code.

LABELS This generates a ".lab" file which contains all the public labels in alphabetic order.

OBJECT If this option is not specified, the assembler will generate an executable ".smc" file. The executable file will have a 512 byte Super Magicom header and will be padded to a bank boundary. If this option is specified, the assembler will generate an object ".obj" file. This will not have a SMC header and will not be padded to a bank boundary.

Pseudo Op Codes

ORG <absolute location>

This is used to set the start location for the assembly and must be specified before any instructions. Note that the start location must reside within valid code space (ie. lower 16-bits in $8000 to $FFFF).

Eg. ORG $8000 ; start assembly at location $8000

PAD

This will cause padding with 0's to the next bank boundary. Note that if already at a bank boundary, then this will have no effect.

PAD <absolute location>

This will cause padding with 0's to the specified location. Note that the location must reside within valid code space.

Values and Labels

Values may be specified in either decimal, hex (when preceded by a $) or binary (when preceded by a %).

Labels can be up to 32 characters long and must start with an alphabetic character or an underscore. Labels may only contain alphanumeric and underscore characters. Note that labels are case sensitive but instructions and pseudo op codes are not case sensitive. A maximum of 8000 labels may be defined.

Eg.

start ... is a valid label
START ... is also a valid label, but different from above
7up ... is not a valid label (it's a soft drink)
_7up ... is a valid label

Size Specifiers

Some assembly instructions may have 1, 2 or 3 byte operands. In order to indicate to the assembler the mode required, ".B", ".W" and ".L" size specifiers are available.

The mnemonics are taken from the article in BYTE August 1984 entitled "The 65816 Microprocessor, Part 1: Software". The only differences are that the BRK and COP instructions take an immediate byte operand and MVP and MVN take an immediate word operand.

Defining The Run Address

The run offset for a program is defined at location $FFFC. So to set the run/reset offset you should PAD to $FFFC then declare it.