Trailing-Edge
-
PDP-10 Archives
-
decuslib20-04
-
decus/20-0108/filio.mac
There are 17 other files named filio.mac in the archive. Click here to see a list.
;/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/
;
; F I L I O
;
; PERFORM VARIOUS FILE UTILITY ROUTINES FOR COBEDT
;
; DAVE GORKA
; 18-JUNE-76
;
;/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/
TITLE FILIO
SUBTTL VARIOUS SUBROUTINES FOR FILE HANDLERS
TWOSEG
.IOIMG==10 ; I/O IMAGE MODE
P=17 ; THE PDL REGISTER
OPDEF CALL [PUSHJ P,]
OPDEF RET [POPJ P,]
OPDEF PJRST [JRST ]
TTY==1 ; CHANNEL FOR TTY I/O
DSK==2 ; CHANNEL FOR DSK INPUT
DS2==3 ; CHANNEL FOR DSK OUTPUT
DS3==4 ; CHANNEL FOR DSK UTILITIES
DS4==5 ; ASCII CHANNEL FOR INPUT
INTERNAL SCAN ; FILE NAME SCANNER
INTERNAL TTYINI,TTYI ; TTY SUBROUTINES
INTERNAL DSKINI,DSKIN ; INPUT FROM DISK
INTERNAL DSKCLS ; CLOSE
INTERNAL DS2INI,DS2OUT ; OUTPUT TO DISK
INTERNAL DS2CLS ; CLOSE
INTERNAL DS3INI,DS3OUT ; 3RD I/O CHANNEL
INTERNAL DS3CLS ; CLOSE
INTERNAL DS4INI,DS4IN,DS4CLS
INTERNAL TTYLST ; LAST CHAR FROM TTY
SUBTTL TTY I/O ROUTINES
;/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/
;
; CALLED VIA:
; PUSHJ 17,TTYINI
; RETURNS:
; +1 CANNOT INIT TTY
; +2 TTY INITED
;
;/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/
RELOC 400000
TTYINI: CLOSE TTY, ; CLOSE THE TTY CHANNEL
RELEASE TTY, ; AND RELEASE
INIT TTY,0 ; INITIALIZE THE CHANNEL WITH 1 BUFFER
SIXBIT .TTY. ; DEVICE TYPE
+ TTIBUF ; STARTING ADDR OF RING BUFFERS
RET ; +1 => BAD INITIALIZATION
INBUF TTY,2 ; SETUP INPUT
AOS 0(P) ; +2 => GOOD RETURN
RET
TTYI: SOSG TTIBUF+2 ; CHARACTERS TO INPUT ?
INPUT TTY, ; NO =- GET SOME
GETSTS TTY,1 ; GET THE STATUS
TRZE 1,762000 ; ANY BAD BITS ?
JRST TTYX ; YES
ILDB 1,TTIBUF+1 ; GET THE CHARACTER
MOVEM 1,TTYLST ; SAVE FOR CHARACTER SCANNERS
JUMPE 1,TTYI ; IGNORE ALL NULLS
RET
TTYX: CALL TTYINI ; TRY AGAIN
JRST 4,.
JRST TTYI ; TRY AGAIN
SUBTTL DISK INPUT ROUTINES
;/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/
; DISK INPUT ROUTINES
;
; CALLED WITH:
; 1/ FILE NAME
; 2/ EXTENSION
; 3/ PPN
;
; RETURNS:
; +1 INIT FAILURE FOR DISK
; +2 LOOKUP FAILURE FOR FILE
; +3 FILE INITIALIZATION OK
;/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/
DSKINI: CALL DSKCLS
OPEN DSK,DSKPKT ; OPEN THE DEVICE FOR INPUT
RET ; +0 => OPEN FAILURE
AOS 0(P) ; INCREMENT RETURN ADDRESS
MOVE 4,3 ; COPY PPN
SETZ 3, ; ZERO
INBUF DSK,2 ; SET UP 2 RING BUFFERS
LOOKUP DSK,1 ; GO GET THE FILE
RET ; OOPS - LOOKUP FAILED
AOS 0(P) ; +2 => OK RETURN
RET ; GIVE THE GOOD RETURN
DSKIN: AOS 0(P) ; SKIP RETURN
SOSG DSKBUF+2 ; ANY CHARACTERS LEFT ?
CALL DSKIN1 ; NO -- GET SOME
ILDB 1,DSKBUF+1 ; GET THE CHARACTER
RET
DSKIN1: MOVEI 1,(POINT 36,0,35)
HRLM 1,DSKBUF+1 ; CORRECT
INPUT DSK, ; READ THE NEXT BUFFER
STATO DSK,762000 ; INPUT DATA ERROR ?
JRST DSKIN3 ; NO - BUILD A SIX BIT BUFFER
GETSTS DSK,1 ; 1 HAS THE TERMINATION DATA
POP P,0(P)
SOS 0(P)
RET ; RETURN TO USER
DSKIN3: MOVEI 1,DSKBUF ; PASS THE BUFFER
PJRST SIXCON ; AS A PARAMETER
DSKCLS: CLOSE DSK,
RELEASE DSK,
RET
SUBTTL OUTPUT FILE ROUTINES
;/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/
; CALLED WITH:
; 1/ FILENAME
; 2/ EXTENSION
; 3/ PPN
; RETURNS:
; +1 INIT FAILURE
; +2 ENTER FAILURE
; +3 ALL OK
;/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/
DS2INI: CALL DS2CLS
OPEN DS2,DS2PKT ; OPEN THE DEVICE FOR INPUT
RET ; +0 => OPEN FAILURE
AOS 0(P) ; INCREMENT RETURN ADDRESS
MOVE 4,3
SETZ 3, ; MOVE PPN TO RIGHT SPOT
OUTBUF DS2,2 ; SET UP 2 RING BUFFERS
ENTER DS2,1 ; GO GET THE OUTPUT FILE
RET ; OOPS - FAILED
AOS 0(P) ; +2 => OK RETURN
RET ; GIVE THE GOOD RETURN
DS2OUT: AOS 0(P) ; GIVE SKIP NOW
SOSG DS2BUF+2 ; CHARACTER LEFT TO OUTPUT ?
CALL DS2OU1 ; NO -- FLUSH BUFFER
IDPB 1,DS2BUF+1 ; DEPOSIT THE CHAR
RET
DS2OU1: PUSH P,1 ; SAVE
MOVEI 1,(POINT 36,0,35)
HRLM 1,DS2BUF+1 ; SET HERE
OUTPUT DS2, ; DO THE WRITE
STATO DS2,762000 ; OUTPUT DATA ERROR ?
JRST DS2OU3 ; NO -- JUST RETURN
GETSTS DS2,1 ; GET THE STATUS OF THE FIL
POP P,0(P)
SOS 0(P) ; DECREMENT FOR NO SKIP
RET ; RETURN TO USER WITH STATUS IN 1
DS2OU3: MOVEI 1,DS2BUF ; PARAM
CALL SIXCON ; CVT TO SIXBIT RING BUFFER
POP P,1 ; RESTORE CHAR
RET ; AND RETURN
DS2CLS: CLOSE DS2,
RELEAS DS2,
RET
SUBTTL MORE OUTPUT ROUTINES
DS3INI: CALL DS3CLS
MOVEM 4,DS3PKT+1 ; SAVE DEVICE TYPE
OPEN DS3,DS3PKT ; OPEN THE FILE
RET ; OOPS -- NO GOOD
AOS 0(P) ; SKIP RETURN FOR THIS PHASE
MOVE 4,3 ; PPN
SETZ 3,
OUTBUF DS3,2 ; SET UP OUTPUT BUFFERS
CAMN 4,['TTY ']
AOSA 0(P) ; DOUBLE SKIP RETURN
ENTER DS3,1 ; ENTER FILE FOR OUTPUT
RET ; NO GO ON ENTER
DS3IN1: AOS 0(P) ; SKIP RETURN
RET ; $E
DS3OUT: AOS 0(P) ; ASSUME A SKIP RETURN
SOSG DS3BUF+2 ; CHAR LEFT TO OUTPUT ?
CALL DS3OU1 ; NO -- FLUSH BUFFER
IDPB 1,DS3BUF+1
CAIE 1,12 ; LF ?
RET ; NO
MOVE 1,DS3PKT+1
CAMN 1,['TTY ']
CALL DS3OU1
MOVEI 1,12 ; AND RESTORE
RET ; RETURN -- ALL OK
DS3OU1: OUTPUT DS3,
STATO DS3,762000
RET ; NO ERRORS
GETSTS DS3,1 ; RETURN STATUS IN 1
POP P,0(P) ; THROW THIS CALL ON GROUND
SOS 0(P) ; ON NON SKIP
RET
DS3CLS: CLOSE DS3,
RELEASE DS3,
RET
; CONVERT RING BUFFERS TO SIXBIT
SIXCON: DMOVEM 2,1(P) ; HOPE PDL HAS ENOUGH
MOVE 2,2(1) ; # WORDS
MOVEI 3,6 ; ASSUME SIXBIT
TRNE 0,2000 ; ** ASCII ** ?
MOVEI 3,5 ; YES -- 5 PER WORD
IMULI 2,0(3) ; 2 = # CHARS
MOVEM 2,2(1) ; AND SAVE
HRRZI 2,(POINT 6,0,35)
TRNE 0,2000 ; ** ASCII ? **
HRRZI 2,(POINT 7,0,35) ; YES
HRLM 2,1(1) ; SET IN RING BYTE PTR
DMOVE 2,1(P) ; GET THEM BACK
RET ; AND RETURN
SUBTTL ASCII INPUT ROUTINE
DS4INI: CALL DS4CLS ; CLOSE UP SHOP
MOVEM 4,DS4PKT+1 ; SET DEVICE
OPEN DS4,DS4PKT ; INIT THE DEVICE
RET ; BAD RETURN
AOS 0(P) ; PHASE 1
MOVE 4,3 ; PPN
SETZ 3,
INBUF DS4,2 ; ONLY NEED ONE
LOOKUP DS4,1 ; FIND THE FILE
RET ; LOOKUP FAILED
AOS 0(P) ; IT SUCEEDED
RET
DS4IN: AOS 0(P) ; GIVE A SKIP RETURN
DS4IN0: SOSGE DS4BUF+2 ; ANY CHARACTERS ?
JRST DS4IN1 ; NO
ILDB 1,DS4BUF+1 ; GET THE CHAR
JUMPE 1,DS4IN0 ; INGNORE ALL NULLS
RET ; AND EXIT
DS4IN1: INPUT DS4, ; READ THE NEXT BLOCK
STATO DS4,762000 ; BAD ?
JRST DS4IN0 ; SEE IF ALL OK
GETSTS DS4,1 ; RETURN THE BAD STATUS
SOS 0(P) ; MAKE SURE WE DO THIS
RET ; ON A NON SKIP
DS4CLS: CLOSE DS4,
RELEAS DS4,
RET
SUBTTL SCAN -- SCAN A INPUT FILE
;/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/
;
; S C A N
;
; CALLED WITH THE ASSUMPTION THAT TTY CHANNEL INITED!
;
; RETURNS:
; 1/ FILE NAME
; 2/ EXTENSION
; 3/ PPN (IF PRESENT)
; 4/ DEVICE (DSK IF NOT PRESENT)
;
; +1 SOMETHING BAD HAPPENED
; +2 ALL OK
;/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/
SCAN: MOVEM P,SAVE+P ; SAVE ALL THE REGISTERS
MOVE P,[0,,SAVE] ; WHAT TO SAVE
BLT P,SAVE+P-1 ; SAVE ALL UP TO
MOVE P,SAVE+P ; USE THE USERS STACK
SETZB 10,11 ; 10=PPN,11=DEV,12=FN,13=EXT
SETZB 12,13
SCNF2: MOVSI 2,(POINT 6,) ; THE BYTE POINTER TO SIXBIT IN A0
SETZB 0,3
SCNF3: CALL TTYI ; GET A CHARACTER
CAIE 1," " ; SPACES AND
CAIN 1,15 ; CR'S ARE IGNORED
JRST SCNF3
CAIN 1,"[" ; START OF PPN ?
JRST SCNPPN ; YES,SCNPPN
CAIE 1,"." ; ASCII PERIOD ?
CAIN 1,":" ; POSSIBLE DEVICE SCANNED
JRST SCNF1 ; YES - SAVE
CAIN 1,12 ; LF ?
JRST SCNF1
CAIL 1,"A"
CAILE 1,"Z"
JRST [CAIL 1,"0"
CAILE 1,"9"
JRST SCNFB
JRST .+1]
TRC 1,40 ; CVT TO SIXBIT
IDPB 1,2 ; SAVE THE SIXBIT AWAY
JRST SCNF3
SCNF1: CAIN 1,":" ; DEVICE ?
MOVEI 3,11 ; YES - SET INDEX
CAIN 1,"." ; A FILENAME ?
MOVEI 3,12 ; YES =- SET THIS INDEX
CAIN 1,12 ; THE LF ?
JRST [JUMPE 12,[JUMPE 0,.+4
MOVEI 3,12
JRST .+1]
MOVEI 3,13 ; ASSUME EXTENSION
JRST .+1]
SKIPE 0(3) ; NONZERO?
JRST [OUTSTR [ASCIZ@?BAD FILE NAME@]
JRST SCNBAD]
MOVEM 0,0(3) ; SAVE THE WHATEVEDR
CAIE 1,12
JRST SCNF2 ; GET THE NEXT
DMOVE 1,12 ; 1=FN,2=EXT
SKIPN 4,11 ; A DEVICE SPECIFIED ?
MOVSI 4,'DSK' ; INSERT A SIXBIT DSK
SKIPN 3,10 ; PPN ?
CALLI 3,24 ; GET THE PPN
MOVE P,[SAVE+5,,5] ; GET ALL
BLT P,P-1 ; AND RESTORE
MOVE P,SAVE+P
AOS 0(P) ; GIVE A GOOD SKIP
MOVE 0,SAVE
RET ; THEN RETURN
SCNFB: OUTSTR [ASCIZ@?ILLEGAL CHARACTER@]
JRST SCNBAD
SCNPPN: JUMPN 10,BADPPN
JUMPE 0,SCNP0 ; ANYTHING COLLECTED ?
JUMPN 11,.+3
MOVE 11,0
JRST SCNP0
JUMPN 12,.+3
MOVE 12,0
JRST SCNP0
MOVE 13,0 ; LOAD THE EXTENSION
SCNP0: SETZ 2, ; 2 = NUMBER
SCNP1: CALL TTYI ; GET A CHAR FROM THE TTY
CAIE 1,"]"
CAIN 1,"," ; END OF PROJECT ?
JRST SCNP2 ; YES
IMULI 2,8 ; SHOULD BE A SHIFT
ADDI 2,-"0"(1)
JRST SCNP1
SCNP2: JUMPN 10,.+3 ; FIRST TIME HERE ?
HRLZI 10,0(2) ; LOAD PROJECT UP THEN
JRST SCNP0 ; AND $E
HRRI 10,0(2) ; LOAD PROGRAMMER
JRST SCNF2
BADPPN: OUTSTR [ASCIZ/?CANNOT HAVE 2 PPN'S/]
SCNBAD: OUTSTR [BYTE (7)15,12]
RET ; RETURN UNFAVORABLY
SUBTTL DATA AREA
RELOC 0
DSKPKT: + .IOIMG ; IMAGE MODE
'DSK ' ; DEVICE DISK
+ DSKBUF ; OUTPUT RING BUFFER
DS2PKT: + .IOIMG ; IO IMAGE MODE
'DSK ' ; DEVICE DSK:
+ DS2BUF,,0 ; THE RING BUFFER START
DS3PKT: + 1B0
'DSK '
+ DS3BUF,,0
DS4PKT: 1B0
'DSK '
+ DS4BUF
DSKBUF: BLOCK 3 ; DSK RING BUFFER HEADER
DS1BUF: BLOCK 3 ; FOR INPUT
DS2BUF: BLOCK 3 ; FOR OUTPUT
DS3BUF: BLOCK 3
TTIBUF::BLOCK 3 ; TTY INPUT BUFFER
DS4BUF: BLOCK 3 ; ASCII INPUT BUFFER
SAVE: BLOCK 17+1 ; SAVE 0-17 IN SCAN
TTYLST: Z ; LAST CHAR READ FROM TTY
END