Commodore Amiga · Dev tool

TAsm

A cross-assembler for writing Super Nintendo programs on an Amiga, sending them to a Super WildCard copier sitting on top of the SNES.

Download TAsm 17 KB
The Super WildCard on a Super Famicom

SNES development on an Amiga

TAsm makes programs for the SNES (Super Famicom) using an Amiga and a copier dev kit: the file it makes is normally sent to a Super WildCard that sits on top of the console. It's also semi source-compatible with Fasm by Mr. Madness.

What it runs on

Kickstart/Workbench 2.04 or later and a 68020 or better, which normally rules out the A500 and A2000; an A3000, A1200 or A4000 is fine. It's been tested on an A4000/030; it should work on a 68040, but that's untested. There will never be a version for the older machines.

The cable

For an Amiga to Super WildCard cable, get a ready-made RS-232 DB25 male-to-male cable and swap the wires from pin 1 to 13 at one end. The modified end goes to the Amiga, the other to the Super WildCard.

Using it

TASM ?General help
TASM S sourcenameAssemble a source file; the object is sourcename.SMC unless you add O objectname
TASM C objectnameAssemble the source loaded in CygnusEd (a great editor), straight from its memory rather than from disk

An n-pass assembler

TAsm takes as many passes as it needs to resolve an assembly, up to about 20. It assembles in one or two passes when it can, like a conventional assembler, but it will also assemble code that a normal assembler would throw out:

Label1  EQU  Label2+1   ; a one-pass assembler fails here
Label2  EQU  Label3+1   ; a two-pass assembler fails here
Label3  EQU  Label4+1
Label4  EQU  Label5+1
Label5  EQU  10         ; no problem for TAsm

Unused ROM space is filled with $ff, just like a real cartridge.

Keywords

Keywords go before any code, and the last one of each kind wins: they're dealt with before assembly begins. Defaults are in brackets.

KeywordTakesSets
BESTDoes CASE ON, SNES ON, S700 ON, SMC ON and NES ON
SIZEnumberSize of the object in 32K banks (1); the actual size is 512 bytes larger
EMULnumberEmulation number for the header (0)
CASEON/OFFCase sensitivity (off)
SNESON/OFFSNES constants (off)
S700ON/OFFS700 constants (off)
SMCON/OFFSMC constants (off)
NESON/OFFNES constants (off)
LABELSnumberNumber of labels (20000)
TITLEtextTitle of the program (blank)
MODEnumberCartridge mode ($20)
TYPEnumberCartridge type (0)
ROMSIZEnumberSize of the ROM: N is 8 × 2N (from SIZE)
RAMSIZEnumberSize of the RAM: N is 8 × 2N (0)
COUNTRYnumberDestination country (0)
MAKERnumberProduct maker (0)
VERSIONnumberCurrent version of the program (0)
VECTORSnumbers (6)The jump vector table from $fff4 on: COP, BRK, ABORT, NMI, RESET and IRQ

Directives

Directives can go anywhere in the code. They aren't 65816 or S700 instructions: they control the assembly, or put data into the code.

DirectiveAlso writtenDoes
label EQU numberlabel = numberSets the label to the number
RSRESETResets the RS counter
RSSET numberSets the RS counter to a value
label RS.B sizelabel RB sizeSets the label to RS, then adds 1 × size
label RS.W sizelabel RW sizeSets the label to RS, then adds 2 × size
label RS.T sizelabel RT sizeSets the label to RS, then adds 3 × size
label RS.L sizelabel RL sizeSets the label to RS, then adds 4 × size
ORG numberPC= number, *= numberSets the PC
DS.B sizeDSB sizeAdds 1 × size to the PC; the data is -1
DS.W sizeDSW sizeAdds 2 × size to the PC; the data is -1
DS.T sizeDST sizeAdds 3 × size to the PC; the data is -1
DS.L sizeDSL sizeAdds 4 × size to the PC; the data is -1
DCB.B size,numberBLK.B size,numberAdds 1 × size to the PC; the data is the number
DCB.W size,numberBLK.W size,numberAdds 2 × size to the PC; the data is the number
DCB.T size,numberBLK.T size,numberAdds 3 × size to the PC; the data is the number
DCB.L size,numberBLK.L size,numberAdds 4 × size to the PC; the data is the number
DC.B number(s),...DB numberPuts the data byte(s) into the code
DC.W number(s),...DW numberPuts the data word(s) into the code
DC.T number(s),...DT numberPuts the data tword(s) into the code
DC.L number(s),...DL numberPuts the data long(s) into the code
INCBIN filenameIncludes the file's image in the object code
EMULATEInserts code to put the SNES in emulation mode
NATIVEInserts code to put the SNES in native mode
ACCU 8|16Tells TAsm the accumulator's size
INDEX 8|16Tells TAsm the index registers' size
INITInserts the standard SNES start-up code

Numbers, constants and labels

  • Anything starting with A to Z or ? is a constant, an equate or a label. * is the current PC.
  • Numbers starting 0 to 9 are decimal; $ is hexadecimal; % is binary.
  • @ is a base from 2 to 9, written @base:number: @3:12 is 5 in decimal.
  • " or ' starts ASCII (right-justified, leading bytes zero).
  • Any number, constant or label can be sized with .b, .w (the default), .t or .l.

How they're stored

Bytesas bytes
Wordslo-hi: $8009 is stored $0980
Twordslo-hi-bank: $018009 is stored $098001
Longslo-hi-lo-hi: $12345678 is stored $78563412

Operators

Evaluated in this order: & ! ^ \ / * + -. Brackets aren't allowed, so they can't be confused with the 6502's addressing modes. If you want brackets, write your own assembler.

>shift right7>2 is 1
&and7&2 is 2
!or7!2 is 7
\remainder after a divide7\2 is 1
/integer after a divide7/2 is 3
*multiply7*2 is 14
+add7+2 is 9
-subtract7-2 is 5

Built-in constants

TAsm has all the official SNES constants built in (see SNES ON). It has equates for the S700, the NES and the Magicom too, though as those never had official names, the names are our own. You can replace any built-in equate by equating over it, which keeps TAsm compatible with programs that define the system equates themselves: ROM is normally $8000, but ROM equ 5 makes it 5.

There are far too many to list here: to see them, look at the assembler with an editor. Each constant's value is the long word before the next constant in a hex dump. (If you don't know how to look at the assembler, maybe you shouldn't be using it either.)

The PC

PC and * both mean the current value of the PC, which changes with every line. They can also set it, or set labels:

*=      *+40
ORG     *+80
PC=     PC+90
label   =    *+100
label   EQU  PC*2+100

Local labels

Local labels start with _. TAsm stores each with its parent, so in an emergency you can branch to a local label from outside:

BRA  Routine_Loop