Open
Description
I'm working on a local variable allocator that counts how many HRAM variables a subroutine uses so that its callers know how many HRAM variables to skip when placing their own locals. I had planned to build it as a macro pack where macros would do this:
- Import the address of the end of local variables for each callee
- Calculate their maximum, giving the address of the start of local variables for the present subroutine
- Add the size of local variables for the present subroutine, giving the address of the end of local variables for the present subroutine
- Export this address for use by the present subroutine's callers
I wrote an example of steps 1, 3, and 4 in ca65 (locals-sample-ca65.s.txt), which assembled successfully. The right side of the symbol definition isn't constexpr, and honey badger don't give a bleep because honey badger can put it in a patch and make the linker fix it up.
However, a line-by-line translation of this code to RGBASM syntax (locals-sample-rgbasm.s.txt) produces an error at the DEF ... EQU
.
error: locals-sample-rgbasm.s.txt(3):
Expected constant expression: 'calleeFunc_hLocalsEnd' is not constant at assembly time
error: Assembly aborted (1 error)!
suggested labels: enhancement, ca65 parity