The functions
(GEM Disk Operating System) form the highest level of TOS.
These functions are also sometimes referred to as the BDOS
(using the old CP/M and MS-DOS operating system terminol
ogy). They include a wide variety of character device func
tions, several process control and memory management func
tions, and a large number of functions used to control file I/O
and the filing system. The character device and system
routines will be covered in this chapter, while the next chap
ter will be devoted to the filing system routines. In many
cases, GEMDOS functions are modeled after similar com
mands available under the MS-DOS operating system used
on the IBM PC. In fact, most of them share the same func
tion numbers as their DOS counterparts. That's why GEM
DOS functions are often referred to by a hexadecimal func
tion number, just like MS-DOS functions.
Like the BIOS and XBIOS functions, GEMDOS routines
can be called from user mode. As with those functions,
GEMDOS uses registers A0-A2 and D0-D2 as scratch regis
ters; assume that it changes their contents. If you are pro
gramming in machine language and your program uses these
registers, save their contents before making a GEMDOS call
and restore them after the call terminates. Each of the GEM
DOS routines is associated with a command number, and
some use command parameters that specify more precisely
what they should do. For example, the GEMDOS function to
write a character to the console screen has a command num
ber of 2. It requires a single command parameter that tells
the function which character to print.
To call a GEMDOS function from machine language,
push the command parameters onto the stack, followed by
the command number, and execute a TRAP #1 statement.
The TRAP #1 instruction puts the program into supervisor
that make up the GEMDOS
87