
Turbo Assembler Macro

Original written for DOS by the c64 group Taboo, then ported to ansi C by
BigFoot/Breeze, and finally added 65816 support, illegal opcodes,
optimizations, multi pass compile and a lot of features by Soci/Singular.

Compile it with "make", if argp is missing or search.h then try to add
-DWIN32 to CFLAGS. (that workarounds these, but there's a small performance
loss)

Syntax is the same as the well known Turbo Assembler on c64, so you can
port your sources easy by only replacing the CR at the end of each line.

Maintainer: soci@c64.rulez.org

V1.43: Added 8 alias illegal opcodes, and fixed addressing mode of shx and shy.
V1.44: Added experimental CPU64 support, local label bugfix, message cache,
       nop illegal addressing modes, .warn, lot of listing improvements, .enc,
       performance improvement for win32, .binary fix for win32

Options:
--------
  -a, --ascii                Convert ASCII to PETASCII
  -b, --nostart              Strip starting address
  -B, --long-branch          Automatic bxx *+3 jmp $xxxx
  -C, --case-sensitive       Case sensitive labels
  -D <label>=<value>         Define <label> to <value>
  -n, --nonlinear            Generate nonlinear output file
  -o <file>                  Place output into <file>
  -w, --no-warn              Suppress warnings

 Target selection:
  -c, --m65c02               CMOS 65C02
  -i, --m6502                NMOS 65xx
      --m65xx                Standard 65xx (default)
  -x, --m65816               W65C816
  -X, --mcpu64               CPU64

 Source listing:
  -l <file>                  List labels into <file>
  -L <file>                  List into <file>
  -m, --no-monitor           Don't put monitor code into listing
  -s, --no-source            Don't put source code into listing

 Misc:

  -?, --help                 Give this help list
      --usage                Give a short usage message
  -V, --version              Print program version

Expressions:
------------
()	- guess what ;)
<	- lower byte
>	- higher byte
=	- equal? 1=yes 0=no
<	- less?
>	- more?
!=	- non equal?
>=	- more or equal?
<=	- less or equal?
+	- add
-	- substract
*	- multiply
/	- divide
//	- modulo
|	- or
^	- xor
&	- and
<<	- shift left
>>	- shift right
-	- negate
~	- invert
!	- not

Compiler directives:
--------------------
;
	- comment
oeoe
	- label
nop
	- mnemonic
geq
gne
gcc
gcs
gpl
gmi
gvc
gvs
gra
	- same as beq, bne, ..., but compiled as jmp if branch too long
*
	- current address
	*=$1000
.byte
	- same as .text
.text
	- include constants:
	.text "oeU"	- text
	.text 23, $33	- bytes
	.text ^OEU	- the decimal value as string (^23 is $32,$33)
.word
	- include words constants
	.word $2342, $4555
.offs
	- add compile offset to logical address
	.offs 100
.macro
	- macro definition
	name .macro
	lda #\1 ;first parameter
	.endm
	
	#name 23;call macro
.endm
	- end of macro definition
.for
	- compile loop
	.for ue=0,ue<10,ue=ue+1
	.byte ue
	.next
.next
	- end of compile loop
.if
	- conditional compile
	.if oeu=1
	nop
	.else
	lda #1
	.fi
.else
	- the inverse condition
.fi
	- end of conditional compile
.rept
	- repeated compile
	.rept 100
	nop
	.next
.include
	- include source file here
	.include macros.asm
.binary
	- include binary data
.comment
	- comment block
	.comment
	lda #1
	sta $d020
	.endc
.endc
	- end of comment block
.page
	- error on page boundary crossing
	.page
	lda $d012
	bne *-3
	.endp
.endp
	- end of page cross checking
.logical
	- change logical address
	.logical $300
	drivecodestart lda #$80
	sta $00
	jmp drivecodestart
	rts
	.here
.here
	- restore logical address to physical
.as
	- 8 bit accu
.al
	- 16 bit accu
	.al
	lda #$4322
.xs
	- 8 bit index
.xl
	- 16 bit index
	.xl
	ldx #$1000
.error
	- exit with error
	.if *>$1200
	.error "Program too long!"
	.fi
.warn
	- Warning
	.if *>$1200
	.warn "This may not work!"
	.fi
.proc
	- procedure start
	ize	.proc 
		nop
	cucc	nop
		.pend
	
		jsr ize
                jmp ize.cucc

	If "ize" is not referenced then the code won't be compiled at all!
	All labels inside are local.
.pend
	- end of procedure
.databank
	- set databank
.dpage
	- set directpage
.fill
	- repeated bytes
	.fill $4000,0
.global
	- do not use this, buggy!
.enc
	- text encoding, "none" or "screen" (screen code)

Warnings:
---------
Top of memory excedeed
	- compile continues at the bottom
Possibly incorrectly used A
	- do not use "a" as label
Memory bank excedeed
	- compile continues in the next 64K bank
Possible jmp ($xxff) bug
	- yet another 65xx feature...
Long branch used
	- Branch too long, so long branch was used

Errors:
-------
Double defined
	- double use of label/macro
Not defined
	- not defined label
Extra characters on line
	- there's some garbage on the end of line
Constant too large
	- the number was too big
General syntax
	- can't do anything with this
X expected
	- X may be missing
Expression syntax
	- syntax error
Branch too far
	- can't relative branch that far
Missing argument
	- no argument given
Illegal operand
	- can't be used here
Unknown encoding
	- give screen or none as encoding

Fatal errors:
-------------
Can't locate file
	- cannot open file
Out of memory
	- won't happen ;)
Can't write object file:
	- cannot write the result
Line too long
	- input line was too long
Can't write listing file:
	- cannot write the list file
Can't write label file:
	- cannot write the label file
File recursion
	- wrong use of .include

Illegal opcodes:
----------------
ANC
ANE (XAA)
ARR
ASR (ALR)
DCP
ISB (ISC)
JAM
LAE (LAS)
LAX
LXA (LAX #)
RLA
RRA
SAX
SBX (AXS)
SHA (AHX)
SHS (TAS)
SHX
SHY
SLO
SRE
