[stella] Macros to manage memory allocation.

David Galloway david.c.galloway at gmail.com
Mon Jun 11 13:33:09 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.

For example ---

 SEG.U vars_bank0
 ORG $0080

;---- Kernel
Counter ds 1

PlayerX ds 1
PlayerY ds 1

OpponentX ds 5
OpponentY ds 5

On 6/10/07, R Mundschau <rmundschau at frontiernet.net> wrote:
>
> Hello,
>
> I thought I would share a set of macros that I have been using lately
> to help simplify allocating memory.  The macros as attached allow you
> to allocate RAM for global variables, and RAM for sets of local
> variables.  All the sets of local variables are overlayed in memory.
> It is up to the programmer to handle the issues of sharing RAM
> between variables.    A general protocol, like local variables are
> not valid outside of the routine where they are used is usually
> sufficient.
>
> The macros could be expanded to support multiple overlays of local
> variables, like layers of scope in a structured language such as C.
> Or, include expanded RAM like the SARA chip or the Supercharger, but
> right now only the one layer of locals and the original 128 bytes of
> RAM are supported.  There is no accounting for stack usage, RAM is
> simply allocated starting from $80 and growing towards $FF.
>
> The main advantage of these macros is to eliminate clumsy hard-coded
> "label EQU address" like statements.  DASM is not too happy about how
> the macros work right now because it takes many passes for the
> variable addresses to all settle down, but I find the macros very
> useful in saving time and reducing errors.  Does anyone have ideas
> for improving on this technique?
>
> Cheers!
> Robert M
>
>
> _______________________________________________
> Stella mailing list
> Stella at atari2600.org
> http://atari2600.org/mailman/listinfo/stella
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.atariage.com/pipermail/stella/attachments/20070611/4efac2dc/attachment.html 


More information about the Stella mailing list