Atari ST series Technical Reference Manual page 14

Hide thumbs Also See for ST series:
Table of Contents

Advertisement

Since all of the GEM code is included in the ROMs, it
will be considered as part of TOS. For purposes of this book,
however, TOS will be considered to be everything in the
ROMs except GEM.
Calling TOS from Machine Language
The various TOS routines are called via the exception vec­
tors. When programming in machine language, the general
procedure is to push the function number and other function
parameters on the stack, issue a TRAP instruction, and then
remove the parameters from the stack. The specific TRAP in­
struction depends on the type of TOS routine you're calling.
The BIOS routines are called with a TRAP #13 instruction,
the XBIOS with a TRAP #14, and the GEMDOS routines
with TRAP #1 . A call to the BIOS routine Bconstat() would
look like this:
move.w
# 2 , — (sp)
move.w
# 1 , — (sp)
trap
# 1 3
addq.l
#4 ,sp
Note that if you plan to use GEM calls in your machine
language application, you'll need to do some preparatory
work at the beginning of the program. When GEMDOS
starts an application program (but not a desk accessory), it
allocates all of the system memory to that program. There­
fore, if a program uses the system memory-management
calls, or any of the GEM AES calls that themselves allocate
memory, or runs another program using the Pexec() func­
tion, at startup time it must deallocate all of the memory it
isn't actually using. This is done using the GEMDOS
Mshrink() function. Complete details and some sample code
can be found in Chapter 5 in the section dealing with
6
CHAPTER 1
computer is first turned on, or the re­
set button is pushed. It checks for
ROM cartridges, configures the I/O
ports and the screen, tests memory
size, sets the exception handler vec­
tors, executes the programs in the
AUTO folder, and jumps to the GEM
Desktop program.
* push device number for console device
* push function number for Bconstat
* call BIOS
* pull the parameters off the stack

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents