Skip to content

Direct Page Stack Segment

ksherlock edited this page Jan 20, 2020 · 1 revision

Direct-Page/Stack Segment

The Apple IIGS stack can be located anywhere in the lower 48 KB of bank $00 and can be any size up to 48 KB. The direct page is the Apple IIGS equivalent of the zero page of 8-bit Apple II computers; the direct page can also be located anywhere in the lower 48 KB of bank $00. Like the zero page, the direct page occupies 256 bytes of memory; on the Apple IIGS, however, a program can move its direct page while it is running. Consequently, a given program can use more than 256 bytes of memory for direct-page functions.

Each program running on the Apple IIGS 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.

When an instruction uses one of the direct-page addressing modes, the effective address is calculated by adding the value of the operand of the instruction to the value in the direct-page register. The stack pointer, on the other hand, is decremented each time a stack-push instruction is executed. The convention used on the Apple IIGS, therefore, is for the direct page to occupy the lower part of the direct-page/stack space, whereas the stack grows downward from the top of the space.

Important GS/OS provides no mechanism for detecting stack overflow or underflow, or collision of the stack with the direct page, Your program must be carefully designed to make sure those conditions cannot occur

If you do not define a direct-page/stack segment in your program, GS/OS assigns 4 KB of direct-page/stack space when the System Loader InitialLoad or Restart call is executed. To specify the size and contents of the direct-page/stack space, follow the procedures outlined in Chapter 2, "GS/OS and Its Environment."

Clone this wiki locally