 NAM CPDRVR
*
 ENT OPENI
 ENT OPENO
 ENT CLOSI
 ENT CLOSO
 ENT REWIND
 ENT GETB
 ENT OUTB
 ENT INITIO
 ENT MONTOR
 ENT TABLES
 ENT INEEE
 ENT OUTEEE
 ENT OUTLPT
*
* FILE CONTROL BLOCKS FOR IN-FILE
INFCB RMB 2
 FCC 'DSK'
 FDB $0000
 FDB INBUF
 RMB 33
INBUF RMB 256
OUTFCB RMB 2
 FCC 'DSK'
 FDB $0080
 FDB OUTBUF
 RMB 33
OUTBUF  RMB 256
* FILE CONTROL BLOCK FOR LINEPRINTER
LPTFCB RMB 2
 FCC 'LPT'
 FDB $0080
 FDB LPTBUF
 RMB 33
LPTBUF RMB 132
* FILE CONTROL BLOCKS CONSOLE I/O
CNFCBI RMB 2
 FCC 'CON'
 FDB $0000
 FDB CNBUF1
 RMB 33
CNBUF1 RMB 132
CNFCBO RMB 2
 FCC 'CON'
 FDB $0080
 FDB CNBUF2
 RMB 33
CNBUF2 RMB 132
*
DESCRA EQU $20
CUCHAR EQU $23
RC EQU $25
CLASS EQU $26
FCBSTA EQU $5
FCBDBA EQU 7
FCBNAM EQU 16
FCBTYP EQU 29
FCBACS EQU 30
FCBIND EQU 39
FCBSCF EQU 41
*
MONTOR SWI CALL CP/68
 FCB 31
*
INITIO SWI CALL CP/68
 FCB 51
 LDX #CNFCBO
 CLR FCBSTA,X
 LDAA FCBDBA,X
 LDAB FCBDBA+1,X
 STAA FCBIND,X
 STAB FCBIND+1,X
 LDX #LPTFCB
 CLR FCBSTA,X
 LDX FCBDBA,X
 LDAA #$C
 STAA 0,X
 INX
 SWI CALL CP/68
 FCB 2
 LDX #LPTFCB
 STAA FCBIND,X
 STAB FCBIND+1,X
 LDX #CNFCBI
 CLR FCBSTA,X
 CLR FCBIND,X
OUTRET RTS
*
OUTLPT CMPA #4
 BEQ OUTRET
 CMPA #$A
 BEQ OUTRET
 SWI CALL CP/68
 FCB 0
 LDX #LPTFCB
 LDX FCBIND,X
  STAA 0,X
 INX
 PSHA
 SWI CALL CP/68
 FCB 2
 LDX #LPTFCB
OUTL1 STAA FCBIND,X
 STAB FCBIND+1,X
 PULA
 CMPA #$D
 BEQ OUTL2
 SWI CALL CP/68
 FCB 1
 RTS
OUTL2 SWI CALL CP/68
 FCB 19
 LDAA FCBDBA,X
 LDAB FCBDBA+1,X
 STAA FCBIND,X
 STAB FCBIND+1,X
 CLR FCBSTA,X
 SWI CALL CP/68
 FCB 1
 RTS
*
OUTEEE SWI CALL CP/68
 FCB 0
 LDX #CNFCBO
 LDX FCBIND,X
 STAA 0,X
 INX
 PSHA
 SWI CALL CP/68
 FCB 2
 LDX #CNFCBO
 STAA FCBIND,X
 STAB FCBIND+1,X
 PULA
 CMPA #$D
 BEQ OUTL2
 CMPA #4
 BEQ OUTL2
 SWI CALL CP/68
 FCB 1
 RTS
*
INEEE PSHB
 SWI CALL CP/68
 FCB 5
 LDX #CNFCBI
 TST FCBIND,X
 BNE IN2
IN1 SWI CALL CP/68
 FCB 19
 LDAA FCBDBA,X
 LDAB FCBDBA+1,X
 STAA FCBIND,X
 STAB FCBIND+1,X
 CLR FCBSTA,X
IN2 LDX FCBIND,X
 LDAA 0,X
 INX
 PSHA
 SWI CALL CP/68
 FCB 2
 LDX #CNFCBI
 STAA FCBIND,
 STAB FCBIND+1,X
 PULA
 CMPA #$D
 BEQ IN3
 SWI CALL CP/68
 FCB 6
 PULB
 RTS
IN3 CLR FCBIND,X
 SWI CALL CP/68
 FCB 6
 PULB
 RTS
INMSG FCC 'INPUT FILE'
 FCB 4
OUTMSG FCC 'OUTPUT FILE'
 FCB 4
ADERR FCC 'READ ERROR'
 FCB $D
WRTERR FCC 'WRITE ERROR'
 FCB $D
*
OPENI LDX #INFCB
 CLR FCBNAM,X
 LDX #INMSG
 SWI CALL CP/68
 FCB 49
 SWI CALL CP/68
 FCB 48
 LDAB RC
 CMPB #$D
 BNE OPNI2
 CLV
 SEC
 RTS
OPNI2 LDX DESCRA
 STX CUCHAR
 LDX #INFCB
OPEN3 CLR FCBSTA,X
 CLR FCBIND,X
  CLR FCBACS,X
 LDAA #$FF
 STAA FCBSCF,X
 LDAA #3
 STAA FCBTYP,X
 SWI CALL CP/68
 FCB 44
 TST FCBSTA,X
 BNE FILERR
 SWI CALL CP/68
 FCB 20
 TST FCBSTA,X
 BNE FILERR
 CLC
 CLV
 RTS
FILERR SWI CALL CP/68
 FCB 30
 CLC
 SEV
 RTS
*
OPENO LDX #OUTFCB
 CLR FCBNAM,X
 LDX #OUTMSG
 SWI CALL CP/68
 FCB 49
 SWI CALL CP/68
 FCB 48
 LDAB RC
 CMPB #$D
 BNE OPNO2
 CLV
 SEC
 RTS
OPNO2 LDX DESCRA
 STX CUCHAR
 LDX #OUTFCB
 BRA OPEN3
CLOSI LDX #INFCB
CLOSE1 CLR FCBSTA,X
 TST FCBNAM,X
 BNE CLOSI2
 CLV
 SEC
 RTS
CLOSI2 SWI CALL CP/68
 FCB 21
 TST FCBSTA,X
 BNE FILERR
 CLC
 CLV
 RTS
*
CLOSO LDX #OUTFCB
 BRA CLOSE1
*
REWIND LDX #INFCB
 CLR FCBSTA,X
 SWI CALL CP/68
 FCB 21
 TST FCBSTA,X
 BNE FILERR
 SWI CALL CP/68
 FCB 20
 TST FCBSTA,X
 BNE FILERR
 CLC
 CLV
 RTS
*
GETB PSHB
 SWI CALL CP/68
 FCB 5
 LDX #INFCB
 TST FCBNAM,X
 BNE GETB0
 LDAB #8
 STAB FCBSTA,X
 BRA GETEOF
GETB0 SWI CALL CP/68
 FCB 24
 LDAB FCBSTA,X
 BEQ GETB1
 CMPB #8
 BNE GETB2
GETEOF SWI CALL CP/68
 FCB 6
 PULB
 CLV
 SEC
 RTS
GETB1 SWI CALL CP/68
 FCB 6
 PULB
 CLC
 CLV
 RTS
GETB2 JSR FILERR
 LDX #ADERR
 SWI CALL CP/68
 FCB 30
 SWI CALL CP/68
 FCB 31
*
OUTB PSHB
 SWI CALL CP/68
 FCB 5
 LDX #OUTFCB
 SWI CALL CP/68
 FCB 25
 TST FCBSTA,X
 BEQ OUTB1
 JSR FILERR
 LDX #WRTERR
 SWI CALL CP/68
 FCB 30
 SWI CALL CP/68
 FCB 31
OUTB1 SWI CALL CP/68
 FCB 6
 PULB
 CLC
 CLV
 RTS
*
TABLES FDB *+2
*
 END
