/COPYRIGHT 1970, DIGITAL EQUIPMENT CORP., MAYNARD, MASS.
/	EDIT 5  10-14-70
/	FOR CONDITIONING FOR BF
/	DEFINE BF=0 FOR BACKGROUND/FOREGROUND MONITOR SYSTEM
       .TITLE FIOPS
       .GLOBL .FC,.FQ,.FH,.FM,.FN,.ER,.FP
	.GLOBL FIOPS
FIOPS=.
/INITIALIZE I/O DEVICE (.INIT)
/CALLING SEQUENCE--LAC  ADDRESS OF SLOT NUMBER.
/	         JMS* .FC
/EXIT WITH ACTUAL SLOT NUMBER IN AC.
.FC    CAL    0
       DAC    SLOT	         /TEMP STORE SLOT NUMBER ADDRESS.
	SMA			/ *** DDS MAR69 ***
	JMP	.+3		/ *** DDS MAR69 ***
	LAC*	SLOT		/ *** DDS MAR69 ***
	DAC	SLOT		/ *** DDS MAR69 ***
       LAC*   SLOT	         /GET ACTUAL SLOT NUMBER AND TEST
       SMA!SZA	         /   FOR ZERO OR NEGATIVE.  IF SO,
       JMP    FC0	         /   GO TO ERROR EXIT.  IF OK, GO
FCERR  JMS*   .ER	         /   AHEAD. 
       .DSA   10
FC0    AND    (777)          /STORE 9-BIT SLOT NUMBER.
       DAC    SLOT
       TAD    (STAB-1)       /ADD STATUS TABLE ADDRESS TO
       DAC    STADD          /   GET STATUS WORD ADDRESS.
       LAC    .FH	         /MOVE R/W FLAG TO BIT 0 AND SAVE.
	RCR;	RAR
       DAC    RWFLG
       LAC*   STADD          /TEST STATUS WORD TO SEE IF THIS
       SNA	         /   SLOT HAS BEEN INITIALIZED.
       JMP    FC1	         /   NO--INITIALIZE IT.
/	IF BF MONITOR SYSTEM,FIOPS DOES NOT
/	WANT TO INIT ON CHANGE OF TRANSFER DIRECTION
/	ONLY WANTS TO INIT IF .DAT SLOT HAS NOT BEEN
/	PREVIOUSLY INITIALIZED.
	.IFDEF BF
	AND (777)		/MASK OFF BUFFER SIZE FOR .FM
	JMP FC2
	.ENDC
	.IFUND BF
/	WANT TO INIT ON CHANGE OF TRANSFER DIRECTION IN
/	CASE OF KEYBOARD OR I/O MONITOR SYSTEMS
       XOR    RWFLG          /   YES--CHECK BIT 0.
       RAL	         /IF BIT 0 HAS CHANGED, INITIALIZE
       SNL!RCR	         /   THE SLOT IN ITS NEW MODE.	IF
       JMP    FC2	         /   NOT, RESTORE OLD STATUS WORD.
	.ENDC
FC1    LAC    .FH	         /TEST FOR READ OF WRITE.
       SZA	         /   SLOT.OR.000000 FOR READ.
       LAC    (1000)         /   SLOT.OR.001000 FOR WRITE.
       XOR    SLOT
       DAC    .+1	         /STORE IN .INIT CAL.
       CAL    0	         /.INIT IOPS ROUTINE.
       .DSA   1
       .DSA   FCERR
       .DSA   0
       LAC    .-1	         /GET LINE BUFFER SIZE.
       AND    (776)
FC2    DAC    .FM	         /SAVE BUFFER SIZE FOR I/O ROUTINES.
       XOR    RWFLG          /MERGE IN MODE AND STORE IN I/O
       DAC*   STADD          /   STATUS TABLE.
	AND (777
	CMA
	TAD (1
	DAC FQ3
       LAC    SLOT
       JMP*   .FC	         /EXIT WITH SLOT NUMBER IN AC.
       .EJECT
/TRANSFER LINE BUFFER (.READ, .WRITE, AND .WAIT).
/CALLING SEQUENCE--LAC  SLOT(BITS 9-17) AND MODE(BITS 6-8).
/	         JMS* .FQ
.FQ    CAL    0
       AND    (7777)         /FORM CAL INSTRUCTION FOR .READ OR .WRITE
       DAC    FQ1	         /   AND .WAIT IOPS ROUTINE CALLS.
       AND    (777)
       DAC    FQ4
       LAC    .FH	         /SET UP WORD 2 OF .READ OR .WRITE.
       TAD    (10)	         /   10 FOR .READ.
       DAC    FQ2	         /   11 FOR .WRITE.
FQ1    CAL    0	         /.READ OR .WRITE IOPS CAL.
FQ2    .DSA   0
       .DSA   .FN
FQ3    XX
FQ4    CAL    0	         /.WAIT IOPS CAL.
       .DSA   12
       JMP*   .FQ	         /EXIT.
       .EJECT
/INITIALIZE I/O STATUS TABLE.
/CALLING SEQUENCE--JMS* .FP
.FP    CAL    0	         /STORE ZEROES IN ALL ENTRIES
       LAC    (STAB)         /   IN STATUS TABLE TO INDICATE
       DAC    STADD          /   THAT NO SLOT NUMBERS HAVE
       LAW    -20	         /   BEEN INITIALIZED.  IF
       DAC    CNT	         /   DURING EXECUTION AN I/O
FP1    DZM*   STADD          /   SLOT IS INITIALIZED, THE
       ISZ    STADD          /   BUFFER SIZE IS STORED IN
       ISZ    CNT	         /   THE CORRESPONDING SPOT IN
       JMP    FP1	         /   THE I/O STATUS TABLE AND
       JMP*   .FP	         /   BIT 0 IS SET TO 0 OR 1
STAB   .BLOCK 20	         /   ACCORDING TO WHETHER IT
/		         /   IS FOR INPUT OR OUTPUT.
.FH    .DSA   0	         /READ-WRITE FLAG (0=READ, 1=WRITE).
.FM    .DSA   0	         /LINE BUFFER SIZE
.FN    .BLOCK 376	         /LINE BUFFER.
STADD=.FQ 	         /STATUS WORD ADDRESS.
CNT=.FC		         /COUNTER.
RWFLG=.FP 	         /SHIFTED READ-WRITE FLAG.
SLOT=FQ1		         /SLOT NUMBER.
       .END
