Commodore 2001-8 User Manual page 81

Table of Contents

Advertisement

20 FOR K
~
1
to
50
30 PRINT#5,K
40 NEXT K
50 CLOSE 5
Record the series of 50 numbers on tape.
Close logical file #5.
In the above cassette example, the data would be accumulated in a 192 character buffer one character at
a time. When the capacity of the buffer is exceeded, then data entry is suspended, the tape started, and
the buffer contents written to tape. The buffer is initialized to accept up to 192 characters and then the
program is allowed to proceed.
Note: Not all tape units currently operate with the same
START/STOP characteristic as defined tor the
original tape operating system. In order to obtain reliable operation of the tape recorders, the 192
characters of the buffer should be monitored by the program. Prior to transferring 192 characters, the
programmer should turn on the appropriate cassette motor and then wait for at least .1 second
before transferring the last character.
There are several ways to accomplish this. The simplest is to just POKE 59411,53 for cassette #1 and
POKE 59456,207 for cassette #2 after every PRINT statement, this keeps the motor on all of the time and
eliminates the problem.
On the other hand, if your programs have time consuming functions like human input, sorting, or other
long program run times, you should not run the motor alf the time, but obtain the delay either putting a
delay loop before each print, or turning the motor oft with a POKE 59411,61 for cassette #1 or a
POKE 59456,223 for cassette #2 before the long function and turning it back on after it.
IEEE·488 BUS OUTPUT
The PRINT# command causes BASIC to call an output subroutine which initializes an IEEE·488device for
output. The first step in the command is that the PET reassigns its normal output from the screen device
to the physical device that was chosen forthe logical file in the open routine. A listen command is sent on
the IEEE bus to the physical device and a secondary addressd specified for that logical file in the OPEN.
BASIC then hands one character at a time to another subroutine which proceeds to transfer that
character over the bus with the PET acting as a talker and all addressed devices responding listeners.
When BASIC has finished the PRINT#, another subroutine in the operating system is called and the PET
sends an "unlisten" command to the entire bus and restores the primary address to the screen. This frees
the Whole bus for the next operation.
This unlisten sequence also sends an EOI signal on the bus, along with the last character sent from
BASIC. To accomplish this, each character is stored in a buffer priorto transmission by the IEEE routines
and the previous character is sent.
CMD COMMAND
Normally, each print command deals only with one logical device and at the end of the command entire
bus is unlistened. In some instances, itis advisable to have more than one device on the bus; in order to
facilitate this, the special command CMD is provided. CMD is virtually identical to PRINT#, except that at
the end of the data transfer, the unlisten routine is not called, thereby leaving the device on the bus as
a listener.
The operating system continues to treat the last device to be commanded by the CMD as the primary
output device for BASIC. PRINT or LIST commands are then directed to this primary device, rather than to
the video screen. More specifically, the CMD of the printer device, followed by LIST, results in hard copy
78

Advertisement

Table of Contents
loading

This manual is also suitable for:

Pet 2001-8

Table of Contents