DEFINE looks useful, though it's not obvious from the readme that it sets global variables. It could be renamed to GLOBAL to emphasise the point?
I'm probably teaching you to suck eggs, but a common way to define variables is to use labels, for example:
Code: Select all
ORG &70
.ptr
EQUW 0
.bvar1
EQUB 0
.bvar2
EQUB 0
This avoids having to explicitly set the location of every variable but it does separate the definitions from their use. On the other hand, when memory is tight it can be useful to get an overview of memory usage.
Anyway, by design, it has never been possible to change the value of a symbol in beebasm. Doing so has some unexpected consequences. For example, this prints 2 twice:
So I'm not keen on ASSIGN. This feature has been requested before and allocating memory is nearly always the motivation. Another option is to add an explicit allocation feature. Perhaps some way of defining named regions and allocating from them. This would integrate with the existing code that checks that code blocks don't inadvertently overlap. Maybe something like:
Code: Select all
REGION zp, &70, &90
REGION code, &1900 \ End address is optional
ORG zp \ Allocate a variable in zero page
.var
EQUB 0
ORG code \ Assemble some code
.start
LDA var
RTS
ORG zp \ Allocate another variable
.another
EQUW 0
This is quite simple and seems like it might be useful.