EasyManua.ls Logo

Atari ST series - Page 108

Atari ST series
420 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
CHAPTER 5
add.l
add. 1
bsslen(a5),dO
#stk+bp,dO
* -i- length of uninitialized storage segment
* + (size of base page + stack/heap)
*** Calculate the address of your stack
*** and move it to the stack pointer (a7)
move.1
add.l
and. 1
dO,dl
a5,dl
#-2,dl
move.l dl,a7
new stack address =
size of program memory
+ program's base address,
pick off odd bit to make sure that the
stack starts on a word boundary (it must)
set stack pointer to your stack
which is stk bytes above end of BSS
*** Use the GEMDOS MshrinkQ call to reserve the area of memory
* * * actually used for the program and stack, and release the
*** rest back to the free memory pool.
move.l dO,-(sp) * push the size of program memory
* * (first MshrinkQ parameter) on the stack,
move.l a5,-(sp) * push the beginning address of the
* * program memory area (2nd Mshrink() parameter)
clr.w ~(sp) * clear a dummy place-holder word
move #$4a,-(sp) * finally, push the GEMDOS command number
* * for the Mshrink() function
trap #1 * call GEMDOS
add.l #1 2 ,sp * and clear your arguments off the stack.
Process Control
One of the Disk Operating System's major functions is to
load a program (also known as a process) and start it. After
the program finishes, GEMDOS also has the responsibility
for terminating the process, reclaiming its memory, and re
turning to the GEM Desktop (or whatever other application
happens to be operating as a command shell). GEMDOS in
cludes four process control functions, one for loading and ex
ecuting a process, and three for terminating one.
The function used to load a program file and execute it
is called Pexec(). The syntax for this function is
*char file, command, env;
int mode;
long status;
status = Pexec(mode, file, command, env);
The meaning of the function parameters varies according to
the value of mode. There are four different modes of opera
tion for the Pexec() function. These are:
Table 5-1. Four Modes for Pexec() Function
Mode
Number Function File Command Env
0 Load and Pointer to Pointer to Pointer to
execute filename command string environment
string string
100

Related product manuals