IIGS Stack

4 replies [Last post]
Offline
Joined: Aug 12 2015
Posts: 150

According to the tech manual, you are allowed to
have the stack anywhere you like and upto 64K.

Does anyone know if you can have multiple stacks?
If so, how is this done?

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
mmphosis's picture
Offline
Joined: Aug 18 2005
Posts: 314
Re: IIGS Stack

According to which tech manual? Apple IIGS GS OS Internals describes it's interaction with the stack. There are memory locations to manage the stack and calls.

The 65816 has one 16-bit stack limited to bank 0. You could create smaller stacks within the overall 64K of stack space. You could even copy bank 0 to and from other banks if you needed to free up stack space or switch context, albeit slowly.

There are many ways to do this.

Offline
Joined: Aug 12 2015
Posts: 150
Re: IIGS Stack

Apple IIGS/OS Reference Manual

Page 516-517

I forgot about this section

Each program running on the Apple IlGS reserves a portion of bank $00 as a combined
direct-page/stack space. Because more than one application can be loaded in memory at
one time on the Apple IIGS, more than one stack and one direct page could be in bank $00
at a given time. Furthermore, some applications may place some of their code in bank
$00. A given program should therefore probably not use more than about 4 KB for its
direct-page/stack space.

mmphosis

You say you can have have smaller stacks that add up to 64K. Are you saying
just to write your program in smaller sections?

mmphosis's picture
Offline
Joined: Aug 18 2005
Posts: 314
Re: IIGS Stack

Okay, now I am reading the same manual as you. from page 38...

Quote:

Note: There is no provision for extending or moving the direct-page/stack space after
its initial allocation. Because bank $00 is so heavily used, any additional space you
later request may be unavailable—the memory adjoining your stack is likely to be
occupied by a locked memory block. Make sure that the amount of space you specify
at link time fills all your program's needs.

It sounds like GSOS has some limitations, but nothing that probably could not be worked around if you need to. How large of stack does your program need? I was thinking in terms of programming the 65816 with GSOS out of the way, but I can think of some ways to get around this. It means managing your stack (or stacks) yourself -- like checking for overflow, swapping stack memory as needed and returning everything back to the way GSOS expects it on return.

Offline
Joined: Aug 12 2015
Posts: 150
Re: IIGS Stack

I will say that I will go for the maximum (64K) and tailor it from there.