This status
information
from the printer can
be
tested
by
the
TRS-80
CPU if we connect it to
one of
the four inputs
available on
the
RS-232-C Interface
(CTS. DSR, DC
RI). A jumper
wire
from
pin
6
of
the printer connector (assuming
the standard
DB-25
is
used
on the printer) to the
"status output" of
the
printer
should be
the only
modification needed.
The printer should now be ready
to
print if we can
provide the
proper
software
to
interface
with it.
Before we can actually
output
data,
the printer and the
RS-232-C Interface must be properly
initialized
as to
the baud rate, word
length,
parity
convention and
stop bits required by the printer. This is one of the tasks
which
must be taken care of by the
driver
software.
The assembly language
listing on pages 27 and 28
provides Software to
drive a
DECWRITER.
Lines
1
80 through 440
of
the listing comprise
the initialization
section of the driver routine. This section of code tests a flag in
memory to see if the Interface has been
initialized, and,
if
so,
branches around
the
rest
of the initialization section and goes
directly to
the
actual output section of the code (lines 500 through
620).
The initialization occurs the first time
the driver program is
called
by
BASIC and a flag is set
indicating this
fact. This section
of code is bypassed
on successive calls to the
driver routine.
Assembly Language
DECWRITER Driver
Program
88E8
88E9
80EB
7F88
7F80
E5
7F81 C5
7F82 F5
7F83 3A487F
7F86
FE81
7F88 2828
7F8A 3E81
7F8C
32487F
7F8F D3E8
7F11 DBE9
7F13 E6F8
7F15 F684
7F17
32477F
7Fifl D3EA
7F1C DBE9
7F1E E687
7F28 213F7F
7F23 8668
88180 RESURT EQU
8E8H
; AN OUT TO THIS L0C
RESETS THE UART, AN IN RERDS
THE RS232
CONTROL
BITS
88118 SWITCH EQU 8E9H ; RN OUT
TO
THIS L0C
LORDS THE BRUD
RATE GENERATOR, RN IN RERDS
THE SENSE SWITCHES
88128
CNTREG EQU 8ERH
; RN OUT TO THIS LOC LORDS THE
URRT CONTROL
REGISTER,
RN IN RERDS
THE URRT STATUS REG.
88138
DTAREG
EQU 8EBH
;
RN
OUT
TO
THIS LX
LORDS TH URRT
XMIT HOLDING REG.
,
RN IN READS THE
RECEIVED
DATA
88148 ORG 7F88H ; 32512D ORG FOR DRIVER
88158 ; RS232C OUTPUT DRIVER TO BE USED WITH
THE LPR1NT
COMMAND IN LEVEL
II BRSIC.
88168 , THE DRIVER IS POKED INTO HIGH MEMORY (16K MACHINE)
AND THE
DEVICE
CONTROL BLOCK
88178 ; CHANGED TO VECTOR THE LPR1NT COMMAND TO
THE RS232C
DRIVER
WITH A SHORT BASIC
PROGRAM.
88188 IN1T PUSH HL
;
SAVE
REG. USED
88198
88208
88218
80228
80238
80248
80258
88268
00278
08280
08298
88380
88310
00328
88330
88340 BRUDST
00358
08368
08378
PUSH BC
PUSH RF
THIS SECTION OF CODE
IS USED TO
INITIALIZE
THE RS232C
INTERFACE
TO
CORRESPOND TO
THE OPTIONS SPECIFIED
BV THE SENSE
SWITCHES IN THE
INTERFACE
(BAUD
RATE, STOP BITS,
BITS/CHAR.
ETC.
)
LD A, (FLAG)
CP 01H
JR 2, RESTOR
LD
A,
01H
LD (FLAG),
A
OUT (RESURT),
A
IN A, (SWITCH)
RND
8F8H
OR 84H
LD
(SWT1MG),R
OUT
(CNTREG), R
IN R,
(SWITCH)
RND 87H
LD H,BDTRBL
LD
B,88H
CHECK FLAG
TO SEE IF
URRT AND
BRG HRVE BEEN
INIT.
RESTORE REG. AND
OUTPUT CHRR IF SO
SET FLAG TO
INICRTE INIT.
RERD 37DCH TO RESET
URRT
READ
SENSE SWITHES
LOP OFF
LOWER
3
BITS
RESETS
RTS, RESETS
DTR,SETS BRK IN
HANDSHAKE LATCH
LOAD SWTIMG
W/1MAGE OF LATCH
BITS
LORD URRT
W/SWITCH
IMRGE
SET BAUD
RATE ACCORDING TO
SWITCH
SELECTION
LOP
OFF UPPER 5
BITS
POINT TO
FIRST LOC
IN BRUD TBL
ZERO B REG
27