Most of the tass example programs start with a header like this, which places BASIC code at the beginning of the file that has an appropriate SYS
instruction to run the rest of the application:
* = $0801
.word (+), 2005 ;pointer, line number
.null $9e, format("%d", start);will be sys 4096
+ .word 0 ;basic line end
* = $1000
start rts
I would like to reproduce this in ca65 compatible syntax, and the one line that is given me trouble is:
.null $9e, format("%d", start)
There is a .sprintf
function in ca65, but it appears to only work with constant values. That is, if I have:
.ORG $0801
.word :+, 10 ; pointer, line number
.byte $9e, (.sprintf("%d", start))
; this is `start` as a decimal string
.byte 0 ; string terminator
:
.word 0
start: rts
I get:
example.s(8): Error: Constant expression expected
example.s(8): Error: Syntax error
While obviously one could simply hardcode the start address, is there any way to create a string value containing the decimal version of a memory address?
.word start
give you? – the busybee Jan 27 '20 at 7:53start
a constant, since you know it's going to be 4096? – JeremyP Jan 27 '20 at 8:54