
48 Assembly Language Programming for the 68000 Family
terminal. Normally, some degree of hardware independence is provided
by the operating system being used. But here again we will not all be
using the same operating system. Some readers may be using an Apple
Macintosh and others may be using an Atari ST or one of many other
operating systems that operate with 68000-based systems.
In order to start to write programs without worrying about the system-
dependent details, we will use a set of input/output subroutines whose
inner workings will be different for different operating systems. These
subroutines will assume a standard ASCII terminal or display. Since the
interface is through your operating system, the details of your particular
hardware are automatically taken care of. It doesn’t matter if you have a
video display or a printing terminal. Appendix B gives the actual source
statements for these subroutines written for the Atari ST, Commodore
Amiga, and Apple Macintosh operating systems. (While this does not
cover every operating system in use, the majority of readers will probably
be accommodated.)
It is possible to write many programs that involve inputting one
or more decimal numbers from the keyboard and outputting one or
more decimal numbers to the screen. It is also necessary to be able to
input and output ASCII characters. We will start by introducing some
useful subroutines to perform these tasks. A procedure, or subroutine,
is a portion of a program that can be referenced, or called, from many
different places within the program without the necessity of repeating
the instructions for this procedure each time it is used. Here are the
procedures; read their descriptions carefully so that you will understand
their use.
1. INDEC—Input an unsigned decimal number from the keyboard.
The number is entered as one or more decimal digits terminated
by a character other than 0-9. This terminating character may be
a carriage return (RETURN key on most keyboards). The number
must be representable by four bytes and must therefore be between
0 and 4,294,967,295. The number is placed in the DO register.
2. OUTDEC—Output an unsigned decimal number to the screen. The
number is taken from the longword in register DO. It is output
without a terminating carriage return and line feed (doesn’t advance
to the next line). The range of the output value is the same as for
INDEC.
3. NEWLINE—Terminate the present output line and output the car
riage return and line feed characters to advance to the start of the *
next line.
4. GETC—Input a single character from the keyboard. The ASCII
value of the character is returned in the lower eight bits of the register
DO. The high-order bits are cleared.
Kommentare zu diesen Handbüchern