Atari ST series Technical Reference Manual page 107

Hide thumbs Also See for ST series:
Table of Contents

Advertisement

GEMDOS Device I/O and Process Control
the beginning of the TPA is a 256-byte segment known as
the basepage. As shown in Figure 5-1, the basepage contains
information about the size and address of each program seg­
ment, as well as the command line that is passed to the pro­
gram (these are the extra characters you type in when you
run a TOS Takes Parameters program whose name ends in
.TTP).
The actual program code comes after the basepage , fol­
lowed by the data area, and the BSS (block storage segment)
which is used to store uninitialized data. To determine the
total size of the program area, look in the basepage to find
the size of the code and add to that the size of the data and
BSS segments, along with the size of the basepage itself.
Since you need a stack and heap area for the program, it
makes sense to add the sizes of these segments to the end of
the program and reserve the combined program, heap and
stack area together. Once you calculate the size of this area,
set the stack pointer to the top of program memory and
make the Mshrink() call. Once that's done, continue with
your program.
Program 5-2, a program fragment, shows how to start an
application program that needs to give back some of the TPA
memory, either because it uses GEM calls or uses Pexec() to
run another program.
Program 5-2. MSHRINK.S Program Fragment
MSHRINK.S
Shows how to begin a program by
shrinking the memory used for TPA.
*** Program equates
bpadr
=
4
codelen
=
12
datalen
-
20
bsslen
=
28
stk
- $4000
$100
bp
=
* * *
Program starts here.
.text
move.l
a7,a5
move.l
bpadr(a5),a5
*** Calculate the total amount of memory used by
*** your program (including stack space) in
*
move.l
codelen(aS),d
add.l
datalen(a5),d
* Stack offset to base page address
* Base page offset to Code segment length
* Base page offset to Data segment length
* Base page offset to BSS
* size of our stack and heap area (16K)
* size of base page
Get base page address in a5
*
dupe a7 so you can get the base
* a5 now = basepage address
* total memory used =
0
*
length of code segment
0
* + length of data segment
segment length
page address
do
99

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents