Atari ST series Technical Reference Manual page 246

Hide thumbs Also See for ST series:
Table of Contents

Advertisement

The following program fragment demonstrates how you
would 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(), which 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
command number, most C compilers include a header file
called OSBIND.H that defines macros for all of the GEMDOS
functions. For example, the macro definition for GEMDOS
command 2 is
#define Cconout(a)
Therefore, after you #include OSBIND.H in your pro­
gram, you can call the sample function like this:
Cconout('A');
Since this format is the most readable, most reference
books and sample programs use the C macro notation. Re­
member, however, that in order to use GEMDOS functions
in your C programs, you must link your program with the
compiler library that contains the gemdos() function, and
you must #include OSBIND.H if you use the macros.
238
APPENDIX C
* 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