	.TITLE	RBCDIO
/
/COPYRIGHT (C) 1975
/DIGITAL EQUIPMENT CORPORATION, MAYNARD, MASS.
/
/THIS SOFTWARE IS FURNISHED UNDER A LICENSE FOR USE ONLY
/ON A SINGLE COMPUTER SYSTEM AND MAY BE COPIED ONLY WITH
/THE INCLUSION OF THE ABOVE COPYRIGHT NOTICE.  THIS
/SOFTWARE, OR ANY OTHER COPIES THEREOF, MAY NOT BE PRO-
/VIDED OR OTHERWISE MADE AVAILABLE TO ANY OTHER PERSON
/EXCEPT FOR USE ON SUCH SYSTEM AND TO ONE WHO AGREES TO
/THESE LICENSE TERMS.  TITLE TO AND OWNERSHIP OF THE
/SOFTWARE SHALL AT ALL TIMES REMAIN IN DEC.
/
/THE INFORMATION IN THIS DOCUMENT IS SUBJECT TO CHANGE
/WITHOUT NOTICE AND SHOULD NOT BE CONSTRUED AS A COM-
/MITMENT BY DIGITAL EQUIPMENT CORPORATION.
/
/DEC ASSUMES NO RESPONSIBILITY FOR THE USE OR RELIABILITY
/OF ITS SOFTWARE ON EQUIPMENT WHICH IS NOT SUPPLIED BY DEC.
	.EJECT
/COPYRIGHT 1971, DIGITAL EQUIPMENT CORP., MAYNARD, MASS.
/
/EDIT #007  1-28-72   **REF**WAD
/EDIT #008  5-MAY-75	R. K. BLACKETT  FIX RBCDIO TO SET BCDIO'S
/				  MASS STORAGE SWITCH ON OUTPUT TO INDICATE
/				  A MASS STORAGE DEVICE.
/ EDIT #009	20-AUG-75	M. HEBENSTREIT	DISCLAIMER
/
/ASSEMBLY PARAMETERS:
/
/DEFINE RSX FOR RSX SYSTEMS.
/DEFINE MSCC TO FORCE THE FIRST CHARACTER OF EACH RECORD ON MASS STORAGE
/ DEVICES TO BE TRANSLATED FOR CARRIAGE CONTROL USE.  SEE ALSO BCDIO.
/ DEFAULT DOS AND RSX SHOULD NOT DEFINE THIS PARAMETER.  DEFINING MSCC
/ EMULATES THE OTS OPERATION IN V3B SYSTEMS AND EARLIER.  THIS OLDER
/ MODE OF OPERATION IS NOT SUPPORTED BY DIGITAL.
/
/NO PARAMETERS FOR DOS15 SYSTEMS.
/
/RANDOM ACCESS BCD I/O OBJECT-TIME PACKAGE
/    CONTAINS ROUTINES TO INITIALIZE A DEVICE FOR
/    RANDOM ACCESS BCD I/O AND TO DO
/    I/O CLEANUP.
/    THE BCDIO ROUTINES .RE AND .RA ARE USED
/    FOR RANDOM ACCESS DATA ELEMENT AND ARRAY
/    I/O, RESPECTIVELY.
/
/ROY FOLK
/
/INTERNAL GLOBALS--
	.GLOBL	.RR		/INT. DEVICE FOR R.A. BCD READ
	.GLOBL	.RW		/INIT. DEVICE FOR R.A. BCD WRITE
	.GLOBL	.RF		/R.A. BCD I/O CLEANUP
	.GLOBL	RBCDIO
RBCDIO=.
/
/ EXTERNAL GLOBLS--
/
	.IFUND	MSCC	/(RKB-008) ALLOW USER TO SUPPRESS USING M.S SWITCH
	.GLOBL	.MSDEV	/(RKB-008)  IF HE SO DESIRES.  .MSDEV IS DEFINED IN BCDIO
	.ENDC		/(RKB-008)
	.GLOBL	.FH		/R/W FLG. (FIOPS)
	.GLOBL	.ER		/ERROR ROUTINE (OTSER)
	.GLOBL	.RN		/R.A. FLG. (FIOPS)
	.GLOBL	.FF		/SEQ. ACCESS BCD I/O CLEANUP (BCDIO)
	.GLOBL	.RAENT		/R.A. ENTRY PT. IN EOR (BCDIO)
	.GLOBL	.BFLOC		/HOLDS .FN (S.A.) OR FNPTR (R.A.) (BCDIO)
	.GLOBL	.STEOR		/HOLDS EOR (S.A.) OR REOR (R.A.) (BCDIO)
	.GLOBL	.HILIM		/HIGH LIMIT ON BUFFER ADDRESS (BCDIO)
	.GLOBL	.INIFD		/INIT. FORMAT DECODER (BCDIO)
	.GLOBL	.INILB		/INIT. LINE BUFFER (BCDIO)
	.GLOBL	.RCDNM		/RCD. NUM. (RANCOM)
	.GLOBL	.FM		/WDS. PER RECORD (FIOPS)
	.GLOBL	.RIO		/RANDOM I/O (RANCOM)
	.GLOBL	.FNPTR		/PNTR. TO FIRST WD. OF RCD. (RANCOM)
	.GLOBL	.LRFLG		/LAST REC. FLG. (RANCOM)
	.GLOBL	.INRRW		/INIT. RANDOM RD./WR. (RANCOM)
	.GLOBL	.ADAVR		/ADDR. OF ASSOC. VAR. (RANCOM)
	.GLOBL	.MDSW		/MODE SW. =0 (BIN) =2 (ASCII) (RANCOM)
	.GLOBL	.ER4		/RE-INIT .ER (OTSER)
/  CONSTANTS
S00001	000001
S00002	000002
S00007	000007
W00000	400000
/  WORKING STORAGE
LDREOR	.DSA	REOR
TEMP	0
	.EJECT
/BCD RANDOM READ AND WRITE
/
/  WRITE
/  CALLING SEQUENCE--
/	JMS	.RW
/	.DSA	ADDR. OF SLOT NUM.
/	.DSA	ADDR. OF FORMAT STMNT. OR ARRAY
/	(AC HOLDS INTEGER RECORD NUMBER)
.RW	0
	DAC*	.RCDNM
	LAC	S00001
	DAC*	.FH		/WRITE
	.IFUND	MSCC	/(RKB-008)
	LAC	(NOP)	/(RKB-008) SET THE BCDIO MASS STORAGE
	DAC*	.MSDEV	/(RKB-008) TO INDICATE A MASS STORAGE DEVICE
	.ENDC		/(RKB-008)
	JMP	ARWCOM
/  READ
/  CALLING SEQUENCE--
/	JMS	.RR
/	.DSA	ADDR. OF SLOT SUM.
/	.DSA	ADDR. OF FORMAT STMNT. OR ARRAY
/	(AC HOLDS INTEGER RECORD NUMBER)
.RR	0
	DAC*	.RCDNM
	DZM*	.FH		/READ
	LAC	.RR
	DAC	.RW
ARWCOM	LAC	W00000		/400000
	DAC*	.RN		/SET R.A. FLG.
	LAC	S00002
	DAC*	.MDSW		/ASCII MODE
	LAC*	.RW		/GET ADDR. OF SLOT NUM.
	JMS*	.INRRW		/INIT RANDOM RD./WRITE
	.IFUND RSX
/CHECK FILE HEADERS FOR DOS15 ONLY.
	JMS	CHKAMD		/CHK. ASCII MODE
	.ENDC
/INIT. .FD AND .INILB (IN BCDIO) FOR R.A.
	LAC	LDREOR
	DAC*	.STEOR
	LAC*	.FNPTR
	DAC*	.BFLOC
/
	JMS*	.INILB		/INIT. LINE BUFF.
	ISZ	.RW
	LAC*	.RW		/GET FORMAT ADDRESS
	DAC	TEMP		    /IF TRANS. VECTOR, GO ONE MORE
	SPA			    /  LEVEL OF INDIRECT
	LAC*	TEMP
	JMS*	.INIFD		/INIT. FORMAT DECODER
/SET HIGH LIMIT ON WORD ADDR. IN BUFFER
/USED BY WRITE ONLY
	LAW	-1
	TAD*	.FM		/WDS PER RCD.
	TAD*	.FNPTR
	DAC*	.HILIM
	ISZ	.RW		/INCREM. FOR RTN.
	JMP*	.RW
	.EJECT
/BCD R.A. END-OF-RECORD
/CALLING SEQUENCE--
/	JMS	REOR
REOR	0
	LAC*	.FH
	SZA			/SKP IF READ
	JMS*	.RAENT		/ENTRY PT. IN EOR (IN BCDIO)
	DZM*	.LRFLG		/CLR. LAST RCD. FLG.
	JMS*	.RIO
	LAC*	.FNPTR		/RESET .BFLOC FOR .INILB INITIAL.
	DAC*	.BFLOC
	.IFUND RSX
/CHECK FILE HEADERS FOR DOS15 ONLY.
	JMS	CHKAMD		/CHK. ASCII MODE
	.ENDC
	JMS*	.INILB
	JMP*	REOR
	.EJECT
	.IFUND RSX
/CHECK ASCII MODE
/CALLING SEQUENCE
/	JMS	CHKAMD
CHKAMD	0
	LAC*	.FNPTR		/ADDR. TO AC
	DAC	TEMP
	LAC*	TEMP		/DATA TO AC
	AND	S00007		/MODE BITS
	SAD	S00002
	JMP*	CHKAMD
	JMS*	.ER		/BAD MODE OR EOF ERROR
	11
	.EJECT
	.ENDC
/BCD RANDOM ACCESS I/O CLEANUP
/CALLING SEQUENCE--
/	JMS	.RF
.RF	0
	JMS*	.FF		/SET NCF - JMS .FD (IN BCDIO)
	LAC*	.ADAVR		/ADDR. TO AC
	DAC	TEMP
	ISZ*	TEMP		/INCREMENT ASSOC. VAR.
	ISZ*	.LRFLG		/SET LST. RCD. FLG.
	LAC*	.FH
	SNA			/SKP IF WRITE
	JMP	RF1
	JMS*	.RAENT		/PUT CR AT END OF RCD.
	JMS*	.RIO		/WRITE - .RTRAN OUT LAST RCDS.
RF1	LAC	(NOP
	DAC*	.ER4		/RE-INIT .ER
	JMP*	.RF
	.END
