Re: [cc65] Atari stack pointer?

Date view Thread view Subject view

From: Christian Groessler (chris_at_groessler.org)
Date: 2003-09-17 23:41:56


On Tue, 16 Sep 2003, Shawn Jefferson wrote:

> On Tue, 16 Sep 2003 11:30:18 +0200 (CEST), you wrote:
>
> Ah, ok.  You are doing it this way to support the various memory
> configurations of the Atari computer, and possibly any graphics modes
> in operation or cartridges (that would have changed MEMTOP.)

Yes. The graphics modes (function "graphics()", similar to the BASIC
function) and cartridges eat up memory from the top. I think hardcoding
the top addresses would be too unflexible. You'd have to use different
config files for the graphics modes you intend to use, and the presence of
cartridges is anyway not foreseeable.

> >What do you want to do with the memory? Maybe a malloc() could work too?
>
> I'm wanting to reserve various parts of memory like this:
>
>  * Memory map:
>  *
>  * BFFF +----------
>  *      | pmeditor dlist (78 bytes)
>  * BDB8 +----------
>  *      | options bitmap (336 bytes)
>  * BC68 +----------
>  *      | status bitmap (40 bytes)
>  * BC40 +----------
>  *      | gr.0 dlist
>  * BC20 +----------
>  *      | grid bitmap (2560 bytes)
>  * B220 +----------
>  *      | pmarea (2048 bytes)
>  * AA00 +----------
>  *      | code/data
>  * 2E00 +----------
>
> So I guess what is happening is that the stack is right in the middle
> of my grid bitmap.  Maybe I can move it lower down in memory. (How
> much memory can the stack take up?)

Hmm, I don't think that the stack resides inside your assigned memory
areas.
By default, the runtime assumes the largest possible memory use for
graphics (graphics 9) and adjusts the stack pointer accordingly. So the
stack pointer would initially be around 8k below MEMTOP.

> I wanted to just assign pointers instead of using malloc since malloc
> is expensive.  I thought that changing the config file would make cc65
> only use the amount of RAM that I told it I had and leave the rest
> alone.  That isn't the case.

No, it's not. We could invent some mechanism to reserve memory from the
top, but with the different possible configurations the absolute addresses
which are available aren't guaranteed.

> I guess this problem comes down to whether or not you want the system
> to automatically size to a different graphics mode or memory
> configuration, or let the programmer set all that up via the config
> file.  It would be nice to have some docs for each platform's
> idiosyncracies wouldn't it?

You're absolutely right. I indended to write some Atari documentation for
some time, but didn't do it yet :-(
E.g., you can set the variable "char _graphmode_used = 0" to reclaim the
default memory reserved for graphics, if you don't intend to use another
graphics mode.

regards,
chris

----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo_at_musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.


Date view Thread view Subject view

This archive was generated by hypermail 2.1.3 : 2003-09-17 23:44:39 CEST