Greg816v2 wrote:
Hoping for the following:
- Support for 65C02 and 65816
- Runs on/can be compiled on Linux
- Uses as standard syntax as possible
- Preprocessor directives like #include, #define, #ifdef, etc
- Anonymous labels (i.e. +/-). After using this in ACME I don't think I can do without it.
- The option to generate an output binary that includes a block of address space assembled to. I.e. for an EEPROM, I have code at $8000 and vectors at $FFFA..$FFFF and the output is a 32K binary.
ca65 is a good choice, but I'll put in a good word for
64tass (which you likely can just ask your Linux package manager for, and it's super easy to compile on systems that don't have a package). It doesn't require a configuration file like you might need to create for ca65. I haven't used it with a 65816 but 64tass lists it as supported. Here's some snippets of code (from a Forth implementation) that show several of the things you are looking for:
Anonymous labels:
Code:
inc tmp1
bne +
inc tmp1+1
+
There are also "local" labels - use a label that starts with an underscore and it only exists between the surrounding non-underscored labels and the same name can be reused. Here is an example that uses _done: (used 79 times in this file):
Code:
abort_quote_runtime:
; """Runtime aspect of ABORT_QUOTE"""
; We arrive here with ( f addr u )
lda 4,x
ora 5,x
beq _done ; if FALSE, we're done
; We're true, so print string and ABORT. We follow Gforth
; in going to a new line after the string
jsr xt_type
jsr xt_cr
jmp xt_abort ; not JSR, so never come back
_done:
; Drop three entries from the Data Stack
txa
clc
adc #6
tax
rts
; ## ABS ( n -- u ) "Return absolute value of a number"
; ## "abs" auto ANS core
; """https://forth-standard.org/standard/core/ABS
; Return the absolute value of a number.
; """
xt_abs:
jsr underflow_1
lda 1,x
bpl _done ; positive number, easy money!
; negative: calculate 0 - n
sec
lda #0
sbc 0,x ; LSB
sta 0,x
lda #0 ; MSB
sbc 1,x
sta 1,x
_done:
z_abs: rts
This assembler doesn't quite have #ifdef, but it does have .if and named lists which is what I use for configuring optional assembly.
Code:
.if "wordlist" in TALI_OPTIONAL_WORDS
; ## PREVIOUS ( -- ) "Remove the first wordlist in the search order"
; ## "previous" auto ANS search ext
; """http://forth-standard.org/standard/search/PREVIOUS"""
xt_previous:
jsr xt_get_order
jsr xt_nip
jsr xt_one_minus
jsr xt_set_order
z_previous: rts
.endif
By default the output is a .prg file (has two byte address at the beginning that say where to load it in memory), so I use the --nostart command line option to make binary ROM images.