EasyManua.ls Logo

Atari ST series - Page 246

Atari ST series
420 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
APPENDIX C
The following program fragment demonstrates how you
would print the character A on the console screen using
GEMDOS command 2:
move.w #'A ', — (sp) * push the character value on stack
move.w # 2, — (sp) * push GEMDOS command number on
* stack
trap #1 * call GEMDOS handler
addq.l #4,sp * pop parameters (4 bytes) off stack
Calling the GEMDOS routines from C is much simpler.
Most C compilers come with a library routine called gem-
dos(), 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) gemdos(0x2,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