[stella] Macros to manage memory allocation.
R Mundschau
rmundschau at frontiernet.net
Mon Jun 11 22:31:38 CDT 2007
Yes, that code is exactly what I am doing. I should note that you
don't need to put all you ALLOCATE macros together. They can be
scattered throughout your source files as long as INIT_ALLOC appears
before any instance of ALLOCATE at compile time. I want to be able
to build up a library of subroutines in include files, then include
as many as I like in a project and have DASM figure out all the
allocations for me.
Cheers!
Rob
On Jun 11, 2007, at 4:02 PM, Lee Fastenau wrote:
>>> 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
>
>
>
>
>
> _______________________________________________
> Stella mailing list
> Stella at atari2600.org
> http://atari2600.org/mailman/listinfo/stella
>
More information about the Stella
mailing list