Atari ST series Technical Reference Manual page 15

Hide thumbs Also See for ST series:
Table of Contents

Advertisement

The ST Operating System: An Overview
Mshrink(). For now, it is sufficient to know that this step is
necessary for programs using GEM or memory-management
calls, and not for programs that only use TOS function calls.
Calling the TOS Routines from C
It's much simpler to call the TOS routines from C than from
machine language, since most C compilers for the ST include
library routines for the BIOS, XBIOS, and GEMDOS calls.
These library routines make calling TOS routines exactly like
calling any other kind of C routines. For example, the library
call bios() issues the TRAP #13 command after the parame­
ters have been pushed on the stack. To call the BIOS routine
Bconin() to get a character from the console device (device
2), you need only use the statement:
bios(l,2);
Many C compilers include a header file called OS-
BIND.H. This header file contains C macro definitions for the
various BIOS, XBIOS, and GEMDOS commands. For exam­
ple, the macro Bconstat(a) is defined as follows:
#define Bconstat(a) bios(l,a)
Therefore, if you've #included the OSBIND.H file in
your program, you could replace the bios(l,2); statement
with:
Bconstat(2);
Since this is more readable than the bios() call, the ma­
cro format will be used wherever possible. Just remember
that in order for the compiler and linker to understand these
macros, you must use the #include directive to add the OS­
BIND.H file first.
C programmers usually don't have to worry about re­
leasing extra memory with the Mshrink() command, or set­
ting the program stack, since this work is done for them by
the compiler's own startup code. This code is found in the
GEMSTART.O or APPSTART.O module linked in by Alcyon
C programmers, and in the INIT.O module of the SYSLIB li­
brary of Megamax C. You should note, however, that in some
extreme cases, you may have to recompile the startup mod­
ule to give back more or less memory than the default mod­
7

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents