[stella] Macros to manage memory allocation.
Lee Fastenau
stella at leefastenau.com
Mon Jun 11 15:02:10 CDT 2007
> > For a solution to the problem of avoiding clumsy hard-coded label EQU
> > address statements, I've picked up the habit of using the segment and org
> > pseudo-ops and then using ds statements to define the vars.
>
> So have I. This morning I was trying to think of an advantage to using the
> macors instead but I haven't thought of one. Can someone enlighten me?
I think most people use ds statements for allocating RAM, but the macros allow you to assign labels for local variables with a bit more context. It's not perfect, but I think it's a nice start. Instead of doing something like "myLocalVar equ myGlobalVar" or defining locals up in the global var definition space.
So your code can look like:
; Setup globals
INIT_ALLOC
ALLOCATE "globalVarA",1
ALLOCATE "globalVarB",1
ALLOCATE "globalSet",10
...
; Some subroutine
someSub subroutine
NEWLOCAL
LOCAL "someCounter",1
LOCAL "somePointer",2
ENDLOCAL
...
; Other subroutine
otherSub subroutine
NEWLOCAL
LOCAL "otherSet",5
LOCAL "otherCounter",1
ENDLOCAL
...
-Lee
More information about the Stella
mailing list