@(#)startup.txt, SozobonX library docs Mar 29 1995

Startup Modules
     The startup modules perform a variety of functions;  they create
global variables used by library functions, they call the _crtinit()
function, _acc_crtinit() for accessories, set the size of the stack, and
(for some startup modules) call the library function _initargs(). In
accessories the environment pointer (_envp) maybe not initialized!  Make
sure you include some special environment function 'getenv()' for
accesories (see 'hints.txt' for this).

     If there is not enough memory left for the stack, all startup modules
will terminate and return ENSMEM, except those dealing with accessories
only, where this situation cannot arise.

         standard    no args     & no stdio   special ones
no ACC   crt0.o      min_s.o     minimum.o             pcrt0.o
only ACC             acc_s.o     accmin.o     accx_s.o
both     accappcr.o  accapp_s.o  accappmi.o


crt0.o
     crt0.o     standard: no accessory, arguments, stdio access

     This is the normal startup module for .TTP, .TOS, .APP, .GTP,
and .PRG programs.  The global variable _app is always TRUE.

accappcr.o
     accappcr.o     standard: acc & app, arguments, stdio access

     This startup module can be used for programs which can be run as
accessories, too.  The command line is initialized with argc = 0 and argv
pointing to NULL if run as accessory.  The _STKSIZ variable (for
accessories) is set to 4K. The global variable _app is set to 1 if the
binary is executed as a program, and 0 when it is run as an accessory.
This startup module contains the teststack() function.

min_s.o
     min_s.o     no accessory, no arguments, stdio access

     This startup module may be used for programs that do not support
command line parameters, but do use standard input/output functions.
The global variable _app is always TRUE. The 'argv' parameter passed to
main() is empty, and 'argc' is set to 0. The environment is normal.  The
Pexec() command line can be accessed (_base+0x80), even without the
_initargs() function.  See minimum.h for an example doing this.

     SEE: minimum.o

acc_s.o
     acc_s.o     only accessory, no arguments, stdio access

     This startup module is only for accessories!  The _STKSIZ variable
is set to 4K, if you need more stack see 'accx_s.o'.  The global
variable _app is set to 0.  If the accessory is started as a program,
it will terminate with a message and -1 as the error code.

accapp_s.o
     accapp_s.o     acc & app, no arguments, stdio access

     This startup module can be used for programs which can be run as
accessories, too.  The command line is initialized with argc = 0 and
argv pointing to NULL. The _STKSIZ variable (for accessories) is set to
4K.
     The global variable _app is set to 1 if the binary is executed as a
program, and 0 when it is run as an accessory.  This startup module
contains the teststack() function.

minimum.o
     minimum.o     no accessory, no arguments, no stdio access

     This startup module is for programs that do not support command line
arguments and do not use any standard input/output function from the
library.  The global variable _app is always TRUE. The 'argv' parameter
passed to main() is empty, and 'argc' is set to 0. The Pexec() command
line can be accessed (_base+0x80), even without the _initargs() function.
See minimum.h for an example doing this.

     SEE: min_s.o

accmin.o
     accmin.o     only accessory, no arguments, no stdio access

     This startup module is only for accessories that do not use standard
input/output functions from the library.  The _STKSIZ variable is set to
4K. The global variable _app is set to 0. If the accessory is started as a
program, the startup module will terminate with -1 as the error code.

accappmi.o
     accappmi.o     acc & app, no arguments, no stdio access

     This startup module can be used for programs which can be run as
accessories, too.  The command line is initialized with argc = 0 and
argv pointing to NULL. It is only for programs or accessories that do
not use standard input/output functions from the library.  The _STKSIZ
variable (for accessories) is set to 4K.
     The global variable _app is set to 1 if the binary is executed as a
program, and 0 when it is run as an accessory.  This startup module
contains the teststack() function.

accx_s.o
     accx_s.o     only accessory, no arguments, stdio access

     This startup module is only for accessories!

     You will need an extra module containing the stack used by the
accessory linked with this startupcode. This should be made of
a file like:
----- begin of file accstack.s ------
    .globl __stackbottom
    .globl initstack
    .globl __STKSIZ
        .even
__stackbottom:
        .ds.b   4096                    ; Set up a stack (4K here)
initstack:
        .ds.l   1                       ; and a top for it
__STKSIZ
        .dc.l   4096                    ; just for information, the
                                          ;   stacksize in bytes
----- end of file accstack.s ------

    The global variable _app is set to 0. If the accessory is started as
a program, it will terminate with a message and -1 as the error code.


pcrt0.o
     pcrt0.o      standard: no accessory, arguments, stdio access

     This startup module is for programs that use profiling.  It is
exactly like 'crt0.o' in all other respects.  The profiling information
is written to a file when the program exits via the exit() function or
returns from the main() function.  This startup module can only be used
with SOZOBON C 2.00X and upper.

-eof
