Atari ST series Technical Reference Manual page 181

Hide thumbs Also See for ST series:
Table of Contents

Advertisement

The ST BIOS
mode, and are reentrant to three levels. They use registers
A0-A2 and D0-D2 as scratch registers, which means that if
you're programming in assembly language, and you're using
these registers to store important information, you must save
their contents before making a BIOS call, and restore them
after the BIOS call. Each of the BIOS routines is associated
with a command number (called an opcode), and, optionally,
command parameters that specify more precisely what it
should do. For example, the BIOS function to output a char­
acter to a device is command number 3. It requires two com­
mand parameters: One tells the function which character to
print and the other specifies the output device to use.
To call a BIOS function from machine language, you
must push the command parameters onto the stack, followed
by the command number, and execute a TRAP #13 state­
ment. The TRAP #13 instruction puts the program into su­
pervisor mode, and begins executing the instructions found
at the address stored in exception vector 45, whose address
is 180 ($B4). This exception vector contains the address of the
BIOS handler, which reads the command number on the top
of the stack, and directs program execution to the appropri­
ate function. When the function terminates, the program re­
turns to user mode, and the results, if any, are returned in
register DO. When a BIOS function call is completed, it's the
responsibility of the calling program to adjust the stack in or­
der to remove the command parameters and command num­
ber. You should note that the BIOS changes the command
number and return address on the stack.
The following program fragment demonstrates sending
the character X out to the console device using BIOS com­
mand number 3:
routines can be called from user
173

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents