See
http://www.retrosoftware.co.uk/wiki/index.php/BeebAsm (open source, cross-platform)
This assembler has a number of features inherited from BBC BASIC's built-in assembler, and also has local labels and macros. By using the BASIC-like features you can use loops and conditionals in your source. Output can be to plain binary or can write into a disk image suitable for a Beeb. The FOR loop syntax is a bit odd.
Example:
Code:
.multiply
\\ multiplies A*X, puts result in product/product+1
CPX #0:BEQ zero
DEX:STX product+1
LSR A:STA product:LDA #0
FOR n, 0, 7
BCC skip:ADC product+1:.skip \\ would break BBC BASIC!
ROR A:ROR product
NEXT
STA product+1:RTS
.zero
STX product:STX product+1:RTS
Features:
Quote:
Uses standard 6502 syntax
Supports 65C02 instruction set
Denote hex literals with '&' or '$'
Denote binary literals with '%'
Multiple statement lines, statements separated by colons
Define labels with .label, like BBC BASIC
Assign variables with addr=&70, like BBC BASIC
Add bytes, words and strings with EQUB, EQUW, EQUD and EQUS - as an extension to BBC BASIC, these can take a comma-separated list
FOR...NEXT
IF...ELIF...ELSE...ENDIF
Supports all of the BBC BASIC functions and operators in expressions, e.g. SIN, COS, SQR, DIV, MOD, etc etc
Save object code to a disc image or to a standalone file
INCLUDE "file" to include another source file
Ability to set a guard on a memory address so it will warn you if it is assembled over
Use braces { } to enclose blocks of code so that all labels and variables defined within will be local to that block.
INCBIN command to include a binary file in the object code.
SKIPTO <addr> to move the address pointer to the specified address, generating an error if we are already beyond this address.
MAPCHAR command to allow strings to be assembled using non-ASCII codes (this is maybe more useful than it sounds; there's an example in the documentation).
Warns if there is no SAVE command in the source code.