Atari ST series Technical Reference Manual page 96

Hide thumbs Also See for ST series:
Table of Contents

Advertisement

mode and begins executing the instructions found at the ad­
dress stored in exception vector 33, whose address is 132
($84). This exception vector contains the address of the GEM­
DOS handler which reads the command number on the top
of the stack and directs program execution to the appropriate
function. When the function terminates, the program returns
to user mode, and the results, if any, are returned in register
DO. In most cases, the value is returned as a longword, but
there are exceptions. Some error codes are returned as
words, so it's best to test only the low-order words when
checking for errors. Also be aware that sometimes a GEM-
DOS function will return a BIOS error number (between - 1
and -3 1 ). When a GEMDOS function call is completed, the
calling program is responsible for adjusting the stack to re­
move the command parameters and command number.
The following program fragment demonstrates how to
print the character A on the console screen using GEMDOS
command 2:
move.w
# 'A ', — (sp)
move.w
# 2 , — (sp)
trap
# 1
addq.l
#4,sp
Calling the GEMDOS routines from C is much simpler.
Most C compilers come with a library routine called gem-
d os() that stacks the parameters and executes the TRAP #1
instruction. For example, the sample call illustrated above
could be accomplished in C by the single statement:
gemdos(2, "A');
Since it's easier to remember a command name than a com­
mand number, most C compilers include a header file called
OSBIND.H that defines macros for all of the GEMDOS func­
tions. For example, the macro definition for GEMDOS com­
mand 2 is:
#define Cconout(a)
Therefore, after you #include OSBIND.H in your pro­
gram, you can call your sample function like this:
Cconout('A');
CHAPTER 5
* push the character value on stack
* push GEMDOS command number on
* stack
* call GEMDOS handler
* pop parameters (4 bytes) off stack
gemdos(0x2,a)

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents