	.TITLE DOS DISK HANDLERS RF15, RP15, RB09, RK15

/

/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

/ 

/ 

/ 

/ 

/

/THIS SOURCE SUPPORTS THE A,B,C,AND L VERSIONS.

/

/EAE IS REQUIRED TO EXECUTE THIS HANDLER.

/

/DEFINING %RK05 AND %RP02 PRODUCES THE RK15 (PDP-11 CONTROLLED) VERSION

/    NOTE, UNDER THIS VERSION %DEBUG GIVES A VERSION THAT HALTS

/   PRIOR TO WRITING A BLOCK OF ALL ZEROES

/DEFINING %RB09=1 PRODUCES THE RB09 VERSION

/DEFINING %RP02 PRODUCES THE DISK PACK VERSION.

/DEFINING RSX PRODUCES A DEFUNCT RSX VERSION, IGNORE.

/IF %RB09 AND %RP02 ARE NOT DEFINED THE RF15  IS PRODUCED.

/

/EDIT  #131  7/2/73

/	132	SK	13-NOV-73	UPDATE FOR SPR BUG FIXES

/				AT P. 76,161

/  #128 TWO PROBLEMS: CHANGE UC15 LEVEL TO API0;

/    AND CLEAN UP ERROR HANDLING FOR RK05

/EDIT #133 SCR 11/73 1.FIX TCBABOVE 50000 PROBLEM FOR RK05

/			 2. FIX ERROR HANDLING FOR WRITE RE-TRY

/EDIT #134 SCR 11/73  #133 MISSED. ALSO TRY FIX FOR SPR 703+678

/			CHANGED LINES HAVE !!134!!. EDITOR L SEARCH .

/			FIX BY DE MARI+BALLADELLI. THANK YOU!

/EDIT #135 SCR 12/73 API OPERATION DESTROYS PI STATE, FIX.

/			ALSO NOTE, API OPERATION HANGS SYSTEM

/			FOR UNDULY LONG PERIODS OF TIME AT API

/			LEVEL OF DISK. NOT PRESENTLY FIXED; FIX

/			IS VERY TROUBLESOME.

/EDIT #136 SCR 12/73 WHEN RUN OUT OF BLOCKS, AND BITS IN MAP NOT

/			EQUAL TO COUNT AT TOP OF MAP,

/			LOOPS INSTEAD OF IOPS75. FIX IT.

/	137	SK	6-FEB-74	RKL.  INTERRUPT ADDRESS "INT"

/					BANK BIT INITIALIZATION BUG FIX

/					AT ONCELY + REMOVE CODE TO CHECK

/					WRITING OF ZEROED BLOCK.

/	138	SCR	5/6/74		TAKE OUT 3 PDP-15 INST.'S TO

/					ALLOW PDP-9 TO RUN. AT

/					NOSEEK+13,GONNER+7,GONNER+16

/

/EDIT #139	J. K. 6/24/74

/		FIX TIMING PROBLEMS CAUSED BY INTERRUPT ROUTINE RETURNING

/		FROM DRIVER AT PRIORITY LEVEL ONE.  INT NOW ISSUES SOFTWARE

/		INTERRUPT REQUESTOR LEVEL 4 AND RETURNS.  INT4 NOW RETURNS FROM

/		DRIVER.  ALSO, THE RSX VERSION OF THE A DRIVERS IS NT

/		SUPPORTED HERE SINCE RSX HAS ITS OWN VERSION NOW.

/

/EDIT #140	J.K. 7/8/74

/		FIXED PRIORITY STRUCTURE

/EDIT #141	SCR	11/2/74	MAKE SECOND AC HOLDER 'ACLOW' FOR CAL EXIT

/EDIT #142	SCR	12/16/74 FIX TO DP ERROR HANDLING; READ THERE

/	143	SK	17-DEC-74	SPR:15-992 FIX. RENAMING TRUNCATED FILES

/	146	SCR	26-DEC-74	ADD .INH-.ENB TO FIX 2 DISK CONTENTION

/	147	SCR	26-DEC-74	SMALL ADJUST TO DP ERROR HANDLING

/	148	BLR	28-APR-75	ELIMINATE Q AREA AND EXTEND

/					RK TRANSFERS TO 128K

/	149	BLR	04-JUN-75	TRAP VARIOUS XVM ERRORS

/	150	EAG	8-JUL-75	CHANGE WAIT LOOP (USED	/EAG:150

/					BY .DELETE, .FSTAT,	/EAG:150

/					ETC.) TO RUN AT API	/EAG:150

/					LEVEL 4 INSTEAD OF AT	/EAG:150

/					MAINSTREAM.		/EAG:150

/	151	SCR	9-15-75		RK ERROR IOPS4 FIX

/	152	SCR	9-17-75		COPYRIGHT

/	153	SCR	9-29-75		BLOCK LIMITS; ALL DISKS

/	154	SCR	10-2-75		RK:IOPS12 FIX ONCE ONLY
/	155	SCR	10-7-75		154 MISSED A CONDITIONAL
/	156	RCHM	10-08-75	155 %LVERS OF DP IS 4 WORDS TOO BIG.
/	157	SCR	10-9-75		RK:MULTI-ONCE ONLY ON IOPS12
/	158	SCR	10-14-75	BOSS IOPS0 ON INIT PROBLEM
/	159	SCR	10-21-75	158 MISSED A CONDITIONAL
/
/
/THIS PROGRAM RUNS IN RELOCATABLE MODE AND IS LOADED BY THE LINKING 

/OR SYSTEM LOADER.  THE RESIDENT MONITOR'S CAL HANDLER KNOWS WHERE

/THIS PROGRAM IS BY REFERENCING THE DEVICE ADDRESS TABLE (.DAT).

/WHEN A CAL IS EXECUTED BY A CALLING PROGRAM IT TRAPS TO LOCATION.

/20(8), WHERE CONTROL IS THEN TRANSFERRED TO THE RESIDENT MONITOR'S

/CAL HANDLER.  THERE THE CAL IS DECODED TO MAKE SURE IT REFER-

/ENCES A LEGAL DATSLOT AND THAT THE CAL ARGUMENT FUNCTION

/(I.E. .INIT, .READ) IS A LEGAL ONE.  THEN CONTROL IS GIVEN TO

/THIS HANDLER WITH THE 15-BIT ADDRESS OF THE USER'S CAL

/IN THE AC.  THIS ADDRESS IS IMMEDIATELY SAVED AT 'CALPTR'

/AND IS USED AS THE BASE FOR DECODING THE CAL.

/

/

/THE FOLLOWING  FUNCTIONS ARE HONORED BY THIS HANDLER.

/	1	.INIT

/	2	.OPER--SUBFUNCTIONS

/			1  .DLETE

/			2  .RENAM

/			3  .FSTAT

/			4  .RAND

/			5  .RTRAN

/	3	.SEEK

/	4	.ENTER

/	5	.CLEAR

/	6	.CLOSE

/	7	.MTAPE

/			REWIND

/			BACKSPACE

/	10	.READ

/	11	.WRITE

/	12	.WAIT,.WAITR

/	13	.TRAN

/

/*****

	.IFDEF %CODE	/DON'T PRINT BEGINNING COMMENTS.

	.NOLST

	.ENDC

	.EJECT

/IF %NOFUNC IS DEFINED ONLY THE CODE FOLLING THE I/O

/FUNCTIONS IS LISTED.

	.IFDEF %NOFUN

	.NOLST

	.ENDC

	.TITLE DIRECTORY STRUCTURE 

/

/ A HIERARCHY OF DIRECTORIES IS USED BY THIS HANDLER. A

/MASTER FILE DIRECTORY(MFD) POINTS TO NAMED USER FILE

/DIRECTORIES(UFD'S). THE UFD NAME IS DETERMINED BY THE 

/ARGUMENT DAT SLOT AND ITS CORRESPONDING USER FILE DIR-

/ECTORY TABLE ENTRY IN LOW CORE.

/

/		MFD

/		---

/WORD	0	777777		DUMMY UFD (.BAT INDICATOR)

/	1	777777		BAT BLOCK # OR -1 IF NONE.

/	2	777777		SYSBLK PTR OR -1

/	3	4+SUBMAP1	MFD ENTRY SIZE+1ST SUBMAP#

/WORD	4	ABC		UFD NAME

/	5	N		BLOCK NUMBER

/	6	PCODE+M		UFD ENTRY SIZE(BIT 0=PROTECTION CODE)

/	7	SPARE		UNUSED AT WRITING.

/	.

/WORD	376	PTR TO LAST MFD BLOCK

/WORD   377 	PTR TO NEXT MFD BLOCK OR -1.

/

/		UFD

/		---

/WORD	0	NAME AND

/	1	EXTEN-

/	2	SION

/	3	FIRST BLOCK #	IF BIT0 =1, TRUNCATED FILE

/	4	# OF DATA BLOCKS

/	5	RIB PTR

/	6	WORD IN RIB(FILE PROTECT=BITS 0-2)

/	7	CREATION DATE  	MM.DD.YY(YY = MODULO 70 DECIMAL)

/	.

/WORD	376	LAST UFD PTR.

/WORD	377	NEXT UFD PTR.

/

/IF BIT0 OF WORD3 OF MFD ENTRIES IS 1 THE UFD IS PROTECTED.

/

/THERE IS A USER FILE DIRECTORY TABLE(UFDT) ENTRY FOR

/ EVERY DAT SLOT  THE NAME IN THE

/UFDT IS USED FOR SEARCHING THROUGH THE MFD BLOCKS

/

/**TRUNCATED FILE DEFINITION**

/

/WHEN A .ENTER IS EXECUTED THE NAMED FILE IS IMMEDIATELY PUT

/INTO THE UFD WITH BIT 0 SET TO 1 OF WORD 3 (IN THE BLOCK#

/ENTRY). THIS INDICATES THAT THIS FILE HAS NEVER BEEN CLOSED

/AND THAT THE DIRECTORY ENTRY IS INCOMPLETE. THIS FILE CAN STILL

/BE PROCESSED BUT THERE IS NO EOF LINE ATTACHED TO IT.

/A TRUNCATED FILE USUALLY RESULTS WHEN A FILE HAS BEEN ENTERED

/BEFORE CNTRL C WAS TYPED.

	.TITLE	SUBMAPS, RIBS, AND DATA BLOCKS

/

/***SUBMAPS***

/

/THE DOS-15 SYSTEM USES A STORAGE ALLOCATION

/TABLE TO REPRESENT DISK BLOCK BEING BUSY OR NOT BUSY.

/IF MORE THAN ONE DISK BLOCK IS REQUIRED THE INDIVIDUAL

/BLOCKS ARE CALLED SUBMAPS.

/

/SUBMAPS ARE COMPLETELY NON-RESIDENT.  WHEN OUTPUT

/BLOCKS ARE REQUIRED THE SUBMAP IS READ IN, UPDATED, AND

/WRITTEN OUT AGAIN.  AT .CLOSE TIME ANY BLOCKS THAT WERE

/TAKEN FROM THE MAP, BUT NOT USED, ARE GIVEN BACK.

/

/STORAGE ALLOCATION SUBMAP FORMAT:

/

/WORD 0		TOTAL BLOCKS IN SYSTEM (7637 IF RB09)..

/WORD 1		# BLKS DESCR BY THIS MAP.

/WORD 2		# BLKS OCCUPIED IN THIS MAP.

/WORD 3		1ST WORD DESC 1ST 18 BLOCKS.

/  .

/  .

/WORD 376	PTR TO PREV SUBMAP (OR -1).

/WORD 377	PTR TO NEXT SUBMAP (OR -1).

/

/

/***RIBS***

/

/WORD 0		NO. OF BLOCKS DESCR. BY THIS RIB.

/WORD 1		1ST DATA BLOCK PTR

/WORD 2		2ND DATA BLOCK PTR

/   .

/   .

/WORD 376	PTR TO PREV RIB.

/WORD 377	PTR TO NEXT RIB.

/

/

/***DATA BLOCKS***

/

/WORD 0		DATA

/   .

/   .

/WORD 376	PTR TO LAST DATA BLOCK.

/WORD 377	PTR TO NEXT DATA BLOCK.

	.TITLE CONDITIONALIZED RESULTS.

	.IFDEF	RSX

%AVERSION=1	/AVERSION IS THE ONLY ONE SUPPORTED BY RSX

%RP02=1		/DISK PACK RSX HANDLER

	.ENDC

/

	.IFUND	RSX

	.IFDEF	%RK05

%RP02=1

	.ENDC

	.ENDC

/

	.IFUND %RP02	/WAS DISK PACK REQUESTED?

	.IFUND %RB09	/WAS THE PDP9 RB DISK REQ?

%RF15=1			/NO ASSUME RF DISK (DEFAULT CASE).

	.ENDC

	.ENDC

/

/IF NO VERSION PARAMETERS ARE DEFINED (E.G %LVERS) THE 

/A-VERSION OF THE DISK HANDLER IS PRODUCED.

/	

/	DEFINING: %LVERS PRODUCES THE L-VERSION

/	DEFINING: %BVERS PRODUCES THE B-VERSION

/	DEFINING: %CVERS PRODUCES THE C-VERSION

/

	.IFUND	RSX

	.IFUND %LVERSION

	.IFUND %BVERSION

	.IFUND %CVERSION

%AVERSION=1		/DEFAULT VERSION.

	.ENDC

	.ENDC

	.ENDC

	.ENDC

/

/***L-VERSION***

/

	.IFDEF %LVERSION

%NOOUT=1		/NO OUTPUT FOR L VERSION

	.IFUND %LVLOC	/IF USER WANTS TO CHANGE START ADDR.

%LVLOC=13500

	.ENDC

	.ABS

	.LOC %LVLOC

	.IFDEF	%RK05

	.DEFIN	TYPE

	.SIXBT	+RKL+

	.ENDM

	.ENDC

	.IFUND	%RK05

	.IFDEF %RP02

	.DEFIN TYPE

	.SIXBT +DPL+

	.ENDM

	.ENDC

	.IFUND %RP02

	.DEFIN TYPE

	.SIXBT +DKL+

	.ENDM

	.ENDC

	.ENDC

	.ENDC

	.TITLE MACRO FOR A,B,C,L VERSIONS

	.DEFIN VERSION,DUMMY1,DUMMY2,DUMMY3

	.IFUND %RP02

	.DEFIN %GLOBE

DUMMY1@.=.

	.GLOBL DUMMY1@.

	.ENDM

	.DEFIN TYPE

	.SIXBT +DUMMY1

	.ENDM

	.ENDC

	.IFUND	%RK05

	.IFDEF %RP02

	.DEFIN %GLOBE

DUMMY2@.=.

	.GLOBL DUMMY2@.

	.ENDM

	.DEFIN TYPE

	.SIXBT +DUMMY2

	.ENDM

	.ENDC

	.ENDC

	.IFDEF	%RK05

	.DEFIN	%GLOBE

DUMMY3@.=.

	.GLOBL	DUMMY3@.

	.ENDM

	.DEFIN	TYPE

	.SIXBT	+DUMMY3

	.ENDM

	.ENDC

	.ENDM

	.IFUND	RSX

	.IFDEF %AVERSION

	VERSION DKA,DPA,RKA

	.ENDC

	.ENDC

	.IFDEF %BVERSION

	VERSION,DKB,DPB,RKB

%NOTRN=1

	.ENDC

	.IFDEF %CVERSION

	VERSION DKC,DPC,RKC

%NOTRN=1

%NOOUT=1

	.ENDC

	.TITLE MACRO DEFINITIONS.

/

/

/

/***DIVIDE AC AND PUT QUOTIENT IN AC***

/

	.DEFIN DIVIDE,QUOT

	LMQ		/DIVIDEND ALREADY IN AC.

	CLA!CLL

	DIV

	QUOT		/DIVISOR.

	LACQ		/PUT QUOTIENT IN AC.

	.ENDM

/

/*** RETURN FROM DRIVER SUBR CALL ***

/

	.DEFIN DREXIT

MIN400	LAW -400	/RESET NUMWDS FOR NEXT CALL.

	DAC NUMWDS

MINUSM	LAW -MAXBUF	/RESET WDSLFT TO MAXIMUM

	DAC WDSLFT	/NO OF WORDS AVAIL IN BLOCK.

	JMP* DRIVER	/AT INT LEVEL (API LEVEL 1).

	.ENDM

	.EJECT

/

/*** MULT THE AC BY 22(18 DECIMAL).

/

	.DEFIN MULT22,ARG

	RCL

	RTL

	TAD ARG

	RCL

	.ENDM

/

/***ERROR,GO TO MONITOR***

/

	.IFUND	RSX

	.DEFIN ERR,A

	LAW A

	JMP FATAL

	.ENDM

	.ENDC

	.IFDEF	RSX

	.DEFIN	ERR,A

	LAW	-A

	JMP	FATAL

	.ENDM

	.ENDC

	.EJECT

/

/***INPUT PARITY ERROR OR WRITE CHECK ERROR***

/

	.DEFIN I.OERR,A

	LAC BLOCK	/ARGUMENT BLOCK NUMBER.

/			/##133##USED TO BE XOR L45ZS!!EXPERIMENTAL

	DAC* (BADBLK

	LAW A

	JMS E.PRNT

	LAW -5		/ARG TO SUBR 'E.PRNT'.

	JMP MIN400	/ACCEPT THE DATA ANYWAY.

	.ENDM

/

/*** BLOCK 0 CANNOT BE GIVEN BACK OR USED IN A SEQ FILE ***

/

	.DEFIN TSTB00

	SNA		/IF NOT ZER CONTINUE.

	JMS IOPS74	/FILE STRUCTURED CLOBBERED.

	.ENDM

/

/*** DIVIDE AC AND STORE REMAINDER  ***

/

	.DEFIN DIVREM,DIVISR,REMAIN

	LMQ		/PUT DIVIDEND IN MQ.

	CLA!CLL

	DIV

	DIVISR

	DAC REMAIN	/SAVE REMAINDER.

	LACQ		/PUT QUOTIENT IN AC.

	.ENDM

/

/*** RESTORE MQ,SC, AND AC ***

/

/LOCATION 'RES.SC' IS A NORMALIZE INSTRUCTION BUILT BY

/SUBROUTINE SAVEAE. ITS LOW ORDER SIX BITS REPRESENT

/THE 2'S COMPLEMENT OF THE STEP COUNTER AT ENTRY FROM 

/THE CAL HANDLER OR FROM AN INTERRUPT. THE NORMALIZE

/INSTRUCTION WILL RESTORE IT. THE AC IS 400000 SO THAT

/THE STEP COUNTER IS NOT CHANGED BY EXECUTING THE NORM.

/

	.DEFINE RESTORE

	JMS	RESEAE	/MQ AND STEP COUNTER

	LAC EXITAD		/ VERIFY THAT RETURN ADDRESS	/EAG:150

	SNA			/ HAS BEEN SET UP.		/EAG:150

	JMP .			/ IF IT HASN'T, LOOP		/EAG:150

	LAC	AC	/AC

	DBR

	JMP*	EXITAD

	.ENDM

	.EJECT

/

/*** HARDWARE FAILURE ***

/

	.IFUND	RSX

	.DEFIN HRDFAL

EROR20=.

	.IFDEF	%RP02

	.IFUND	%RK05

	ISZ PARITY	/RETRY 10 TIMES.

	SKP		/TRY RECALIBRATING 10 TIMES.

	JMP NOGOOD	/ALL DONE ITS A HARD ERROR.

	DPCS		/CLEAR FLAG AND LET OTHER I/O CONT.

	ION		/PI ON ; LOOP AT LEVEL 1.

	LAC UNITNO	/OFFENSIVE UNIT NUMBER.

	XOR (RECAL	/RECALIBRATE FUNC, API PI DISABLED.

	DPLF

	IOT		/* DELAY *

	IOT		/* DELAY *

ATTENT	DPSA		/WAIT FOR RECAL.

	JMP ATTENT

	JMP RETRY

	.ENDC

	.ENDC

NOGOOD	LAW -12

	DAC PARITY

	LAC STATUS	/HARDWARE STATUS REG.

	DAC LOC.0	/ERROR ROUTINE PRINTS THIS.

	LAC BLOCK	/ALLOW USER TO USE DEVICE AFTER

	DAC* (BADBLK	/DOING 'UPDATE' WITH PIP.

	JMP IOPS20

	.ENDM

	.ENDC

	.IFDEF	RSX

	.DEFIN	HRDFAL

EROR20=.

	.IFUND	%RK05

	ISZ	PARITY	/RETRY 10 TIMES.

	SKP

	JMP	IOPS20

	LAC	UNITNO	/DO A RECAL TO RECOVER THE

	TAD	(036000)	

	DZM	STATUS	/HEAD POSITION ON THE DISK

	DPLF		/START THE DISK

	CAL	WFSTAT	/WAIT FOR EVENT VARIABLE

	.ENDC

	JMP	RETRY	/GO RETRY UNCONDITIONALLY

	.ENDM

	.ENDC

	.EJECT

/

/*** DIVIDE A VARIABLE. ***

/

	.DEFIN DIVAR,DIVDND,DIVSOR,REMANE,STOREQ,SHIFT

	LAC DIVDND	/DIVIDEND

	LMQ		/PUT IT IN MQ.

	CLA!CLL		/HIGH ORDER DIVIDEND.

	DIV		/LOGICAL(UNSIGNED) DIVIDE.

	DIVSOR		/DIVISOR

	DAC REMANE	/SAVE REMAINDER

	LACQ		/PUT QUOTIENT IN AC.

	ALS SHIFT

	DAC STOREQ	/SAVE QUOTIENT.

	.ENDM

/

/*** SAVE THE MQ AND STEP COUNTER ***

/

	.DEFIN SAVER,SAVEQ,RES.SC

	LACQ		/PUT MQ IN AC.

	DAC SAVEQ	/SAVE THE MQ.

	LACS		/GET THE STEP COUNTER.

	TCA		/GET ITS 2'S COMPLEMENT.

	AND (77		/KEEP LOW ORDER 6-BITS.

	XOR (640400	/BUILD A NORMALIZE INSTR.

	DAC RES.SC	/EXECUTE IT AT EXIT FROM HANDLER.

	.ENDM

	.EJECT

/

/*** RESTORE TH MQ AND STEP COUNTER ***.

/

	.DEFIN REST

	LAC SAVEQ	/GET THE SAVED MQ.

	LMQ		/PUT IT IN MQ REG.

	LAC L45ZS	/(400000) FOR THE STEP

RES.SC	000		/TO BE UNCHANGED BY NORM INSTR.

	.ENDM

/

/***TURN ON BANK BITS***

/

	.DEFIN BITS56,A

	LAC A

	AND L17777	/(17777

	XOR DRIVER 

	DAC A

	.ENDM

/

/*** SET API LEVEL AND EXEC IOT'S ***

/

	.IFUND	RSX

	.DEFIN SETAPI

	JMS RESEAE	/RESTORE MQ AND SC.

/			/!!135!! MODIFIED ON EDIT 135

	.INH			/// AVOID REENTRANT INTERRUPT	/EAG:150

	.IFUND	%RK05		///

	LAC	IOFUNC		///GET IOFUNCTION.

	.IFDEF %RP02		///

	XOR	UNITNO		///ONLY FOR RP02 DO WE NEED UNIT #

	.ENDC			///

	EXECIO			///

	.ENDC			///

	.IFDEF	%RK05		///

	LAC	ITCB		///POINTER TO TCB IN MONITOR

	SIOA			///MAKE SURE 11 CAN ANSWER REQUEST

	JMP	.-1		///

	LIOR			///

	.ENDC			///

	LAC EXITAD		/// IF EXITAD IS NON-ZERO, THEN	/EAG:150

	SNA			/// RETURN TO USER.		/EAG:150

	JMP DROP.0		/// ELSE GO LOOP UNTIL INT.	/EAG:150

	LAC	AC		///

	.ENB			/// ALLOW INTRRPTS AFTER RETURN	/EAG:150

	DBR			///

	JMP* EXITAD		///

	.ENDM

	.ENDC

	.IFDEF	RSX

	.DEFIN	SETAPI

	.IFUND	%RK05

	LAC	UNITNO

	XOR	IOFUNC

	EXECIO

	.ENDC

	.IFDEF	%RK05

	LAC	(TCB	/CALL PDP-11 WITH REQUEST

	SIOA		/MAKE SURE 11 CAN ANSWER REQUEST

	JMP	.-1

	LIOR

	.ENDC

	.ENDM

	.ENDC

/

/*** SET THE .RTRAN DIRECTION ***

/

	.DEFIN RDIREC

	LAC* LOC.2	/BIT 0=0 IF INPUT.

	RCL		/SAVE IN LINK

	LAC (FRD	/ASSUME READ.

	SZL		/IS IT A WRITE?

	LAC (FWR	/YES..WRITE FUNCTION.

	DAC SAVDIR	/EXECUTED BY DRIVER ROUTINE.

	.ENDM

/

/*** CHANGE THE DELTA VALUE. ***

/

	.DEFIN CDELTA,A

	.IFUND DELTA

DELTA=A

	.ENDC

	.ENDM

/

/*** DON'T ALLOW SPURIOUS INTERRUPTS ***

/

	.DEFIN FATAL3

	LAC UNDWAY	/IF A DISK ACCESS WAS

	SNA		/NOT REQUESTED THIS IS 

	JMP IOPS3	/A FATAL INTERRUPT.

	DZM UNDWAY	/GOODBY!

	.ENDM

	.TITLE INTERRUPT PROCESSING MACROS (ALL DEVICES).

/

/*** PIC AND API INTERRUPTS ***

/

	.IFUND	RSX

	.DEFIN INTERRUPT

								/EAG:150

INTAC	0			/ PLACE TO SAVE INTERRUPT AC	/EAG:150

								/EAG:150

INTADR	0			/ PLACE TO SAVE INTERRUPT RETRN	/EAG:150

								/EAG:150

PIC	DAC INTAC		/SAVE AC AT INT.		/EAG:150

	.IFDEF	%RK05

	CAPI0		/CLEAR API LEVEL 0 REQUEST FLAG

	.ENDC

	LAC* (0		/SAVE PC LINK ETC.

	JMP COMMON		/ JOIN COMMON CODE		/EAG:150

/

/API INTERRUPT.

/

INT	JMP PIC		/CLOBBERED BY API.

	DAC INTAC		/ SAVE AC			/EAG:150

	.IFDEF	%RK05

	CAPI0

	.ENDC

	LAC INT

COMMON	DAC INTADR		/ SAVE INTERRUPT ADDRESS	/EAG:150

	LAC (JMP PIC)		/ RESTORE INT IN CASE CLOBBERED	/EAG:150

	DAC INT			/ BY API			/EAG:150

	.ENDM

								/EAG:150

								/EAG:150

								/EAG:150

/ DROP BACK TO HANDLER LEVEL (API LEVEL 4) FROM INTERRUPT	/EAG:150

								/EAG:150

	.DEFIN DROP						/EAG:150

	LAC EXITAD		/ CHECK IF HANDLER IS LOOPING	/EAG:150

	SZA			/ SKIP IF IT IS			/EAG:150

	JMP DROP.2		/ IT ISN'T -- GO HANDLE IT	/EAG:150

	LAC (JMP DROP.9)	/ CHANGE LOOP SO IT WON'T LOOP	/EAG:150

	DAC DROP.1		/ NO MORE			/EAG:150

	LAC INTAC		/ AND RETURN FROM INTERRUPT	/EAG:150

	ION							/EAG:150

	DBR							/EAG:150

	JMP* INTADR						/EAG:150

								/EAG:150

								/EAG:150

DROP.0	LAC (JMP DROP.1)	/// COME HERE (FROM JMP IN	/EAG:150

	DAC DROP.1		/// SETAPI) TO START UP THE	/EAG:150

	.ENB			/// INFAMOUS LOOPER.  MUST	/EAG:150

DROP.1	XX			/ ALLOW INTERRUPTS OF COURSE.	/EAG:150

								/EAG:150

								/EAG:150

/ COME HERE WHEN LOOPER IS NOT RUNNING.  CHECK FOR API AND	/EAG:150

/ DO APPROPRIATE THING						/EAG:150

								/EAG:150

DROP.2	.INH			/// DON'T LET ANYONE DISTURB US	/EAG:150

	RPL			/// USING API?			/EAG:150

	SMA			/// SKIP IF YES			/EAG:150

	JMP DROP.7		/// GO HANDLE NON-API CASE	/EAG:150

/ LOOPER NOT RUNNING AND API EXISTS.  REQUEST LEVEL 4 INTERRUPT	/EAG:150

/ AND WHEN IT COMES WE ARE AT HANDLER LEVEL			/EAG:150

	AND (404000)		/// SAVE OLD REQUEST STATUS	/EAG:150

	DAC DROP.3		/// STATUS REGISTER REQUEST BIT	/EAG:150

	LAC* (SC.LV4)		/// AND TRANSFER VECTOR IN	/EAG:150

	DAC DROP.4		/// .SCOM			/EAG:150

	LAC (404000)		/// ISSUE NEW REQUEST		/EAG:150

	ISA			///				/EAG:150

	LAC DROP.5		/// TO GO TO DROP.6		/EAG:150

	.ENB							/EAG:150

	DAC* (SC.LV4)		/// ALLOW INTERRUPTS AFTER THIS	/EAG:150

	LAC INTAC		/ RETURN FROM DISK INTERRUPT	/EAG:150

	DBR			/ AND WAIT FOR LEVEL 4		/EAG:150

	JMP* INTADR						/EAG:150

								/EAG:150

DROP.3	0			/ TEMPORARY IN WHICH TO SAVE	/EAG:150

				/ API LEVEL 4 REQUEST BIT	/EAG:150

								/EAG:150

DROP.4	0			/ TEMPORARY IN WHICH TO SAVE	/EAG:150

				/ API LEVEL 4 TRANSFER VECTOR	/EAG:150

								/EAG:150

DROP.5	DROP.6			/ USED INSTEAD OF CONSTANT SO	/EAG:150

				/ BANK BITS CAN BE SET UP FOR	/EAG:150

				/ L VERSION			/EAG:150

								/EAG:150

DROP.6	0			/ LEVEL 4 INTERRUPT ENTRY	/EAG:150

	.INH			/// CAN'T LET ANYONE GET IN	/EAG:150

	DAC AC			/// UNTIL AFTER WE RESTORE	/EAG:150

	LAC DROP.3		/// THE OLD API STATUS.		/EAG:150

	ISA			///				/EAG:150

	LAC DROP.4		///				/EAG:150

	.ENB			///				/EAG:150

	DAC* (SC.LV4)		///				/EAG:150

	LAC DROP.6		/ SET UP EXIT ADDRESS		/EAG:150

	DAC EXITAD						/EAG:150

	JMP DROP.8		/ GO SAVE EAE REGISTERS		/EAG:150

								/EAG:150

								/EAG:150

/ COME HERE IF LOOPER ISN'T RUNNING AND API DISABLED		/EAG:150

								/EAG:150

DROP.7	LAC INTAC		/// COPY INTERRUPT LEVEL STATUS	/EAG:150

	DAC AC			/// TO HANDLER LEVEL STATUS	/EAG:150

	LAC INTADR		///				/EAG:150

	DAC EXITAD		///				/EAG:150

	.ENB			/// AND ALLOW INTERRUPTS	/EAG:150

	ION			///				/EAG:150

DROP.8	JMS SAVEAE		/ SAVE EAE REGISTERS		/EAG:150

DROP.9=.			/ AND NOW WE'RE THERE		/EAG:150

	.ENDM							/EAG:150

	.ENDC

	.EJECT

/

/*** GET THE UIC FROM UFDT ***

/

	.IFUND	RSX

	.DEFIN GETUIC

	XOR (400	/TURN BIT 9 ON OR OFF

	TAD MIN400	/IF TCA SLOT EXTEND TO 18 BITS.

	TAD* (.UFDT	/GET THE UIC POINTER.

	DAC TEMP1	/ONE MORE LEVEL OF INDIRECT.

	LAC* TEMP1

	DAC UIC		/TEST FOR LEGAL UIC.

	SNA		/000000 IS ILLEGAL.

	JMP IOPS51

	SAD MINUS1	/777777 IS ILLEGAL.

	JMP IOPS51

	.ENDM

	.ENDC

	.IFDEF	RSX

	.DEFIN	GETUIC

	.ENDM

	.ENDC

/

/*** TEST FIRST BLOCK FOR TRUNCATED FILES ***

/

	.DEFIN TFILES

	LAC* U.FBLK	/MAX BLK IS 16 BITS LONG.

	AND (600000	/RSX USES HIGH BITS ALSO.

	SAD L45ZS	/TRUNCATED FILE?

	.ENDM

	.TITLE COMMON DIRECT ASSIGNMENTS.

/

INC=ISZ		/INCREMENT A COUNTER.

IDX=ISZ		/INDEX A POINTER THAT CAN'T OVERFLOW.

SET=ISZ		/SET A SWITCH,NON0=ON,0=OFF.

.INH=705522		/ IOT TO INHIBIT INTERRUPTS		/EAG:150

.ENB=705521		/ IOT TO REENABLE INTERRUPTS		/EAG:150

	.IFUND	RSX

.SCOM=100

BUSYTB=.SCOM+62	/POINTER TO BUSY TABLE.

BUSYSZ=.SCOM+63	/SIZE OF BUSY TABLE ENTRIES.

BUSYNO=.SCOM+36	/NO OF POSSIBLE ENTRIES IN BSYTAB.

.MED=3

.UFDT=.SCOM+25	/USER FILE DIRECTORY TABLE POINTER.

NUMBUF=.SCOM+26	/ARGUMENT OF BUFFS COMMAND.

BSIZE=.SCOM+27	/# OF WORDS PER BUFFER.

BFPOOL=.SCOM+30

BADBLK=.SCOM+32	/BAD BLOCK NO ON IOPS 12.

DUMBLK=.SCOM+35	/BIT0=1=PARITY ERROR 1-17=BLOCK# (DUMP,.TRAN)

WAITER=.SCOM+36	/MONITOR WILL WAIT FOR IT TO BE 0.

EXERRS=.SCOM+37	/ENTRY POINT FOR EXPANDED ERRORS.

LOGGED=.SCOM+41	/CURRENT (LOGGED IN) UIC.

LOGMIC=.SCOM+42	/BIT0=1=MIC LOGGED(KEY TO ALL OF DISK).

DATE=.SCOM+47	/CREATION DATE MM.DD.YY

DFAULT=.SCOM+54	/BITS 15-17=DEFAULT FILE PROT. CODE.

SC.LV4=.SCOM+12		/ API LEVEL 4 INTERRUPT TRANSFER VECTOR	/EAG:150

	.ENDC

MPREBK=1	/MPREBK+WRD0 OF MFD ENTRY=1ST UFD BK.

UPREBK=3	/UPREBK+WRD0 OF UFD ENTRY=1ST DATA BLK.

MAXBUF=376	/MAX BUFFER SIZE (FOR .INIT).

MAXRIB=375

RIBSIZ=375

MAPDES=3

LOWEST=4

SIZUFD=10

MFDPRO=SIZUFD	/USED AT AUTO ENTRY INTO MFD(UNPROTECTED).

MFDSIZ=4

	.TITLE DEVICE DEPENDENT DIRECT ASSIGNMENTS.

/

	.IFDEF %RF15

MFDBLK=1777	/1ST MFD BLOCK(LAST BLOCK ON DISK 0).

FWR=5		/WRITE FUNCTION

FRD=3		/READ FUNCTION.

FWC=7		/WRITE CHECK FUNCTION

DEVTYP=200000	/PASSED BY FSTAT TO USER.

APIAD=63

BITMAX=10000

MAPNO=2

MAX4=10000	/2000 BLOCKS * 4

	CDELTA 2

EXECIO=DSCF!DSFX!DSCN

	.ENDC

/

	.IFDEF %RB09

BITMAX=7640	/4000(10)BLOCKS DESCRIBED BY MAP.

MFDBLK=1777	/1ST MFD BLOCK.

FWR=007000	/WRITE FUNCTION

FRD=006000	/READ FUNCTION.

MAXBLK=7640	/NO OF BLOCKS( 0-7637) OR 4000 DECIMAL.

APIAD=47

MAPNO=1

DEVTYP=200000	/PASSED BY FSAT TO USER.

	CDELTA 2

EXECIO=DSCS!DSLS

	.ENDC

/

	.IFDEF %RP02

	.IFUND	%RK05

APIAD=64	/API INTERRUPT ADDRESS.

MFDBLK=47040	/CYL 100(10),HEAD 0,SECTOR 0(MIDDLE).

PAKSIZ=117230	/40,600(10) BLOCKS PER PACK.

	.ENDC

	.IFDEF	%RK05

APIAD=47	/API INTERRUPT ADDRESS

MFDBLK=1777	/1ST MFD BLOCK

PAKSIZ=11410	/4872(10) BLOCKS PER CARTRIDGE

MAXBLK=11410	/MAXIMUM NUMBER OF BLOCKS PER CARTRIDGE

	.ENDC

RESERV=0	/0(10) BLOCKS RESERVED FOR CNTRL Q AREA. (BR-148)

TOTALB=PAKSIZ-RESERV	/# OF BLOCKS AVAIL TO USER.

	.IFUND	%RK05

FRD=015000	/READ FUNCTION(BITS 3,4,5 =FUNCTION).

FWR=025000	/WRITE FUNC.(BIT 6 = ONLY 2 INTS

FWC=075000	/JOB DONE,ERROR, ENABLED).

DEVTYP=300000	/DEVICE TYPE PASSED BY .FSTAT

	.ENDC

	.IFDEF	%RK05

FRD=000004	/READ FUNCTION

FWR=000002	/WRITE FUNCTION

FWC=000006	/WRITE-CHECK FUNCTION

DEVTYP=500000	/DEVICE TYPE PASSED BY .FSTAT

	.ENDC

RECAL=031000	/RECALIBRATE API,PI DISABLED.

	CDELTA 3

	.IFUND	%RK05

EXECIO=DPLF

	.ENDC

	.ENDC

/

/*****

/

	.IFDEF %CODE

	.LST

	.ENDC

	.TITLE *** DOS CODE STARTS HERE ***

/

	.IFUND	RSX

	.IFUND %LVERSION

	%GLOBE

	.ENDC

/

	DAC CALPTR	/(LOC) CAL POINTER

	DAC ARGPTR

	LAC* CALPTR	/BITS 9-17 FROM LOC

	AND (777	/KEEP ONLY 9 BITS

	DAC ASLOT	/ARGUMENT DAT SLOT

	LAC* CALPTR	/SAVE BITS 6-8 OF ARG. CAL.

	AND (17000	/KEEP 4 BITS.

	DAC B.5678	/BITS 6,7,8.

	IDX ARGPTR	/LOC+1 POINT TO FUNCTION

/

/THE NEXT INSTRUCTION IS A JMP ONLY ONCE PER CORE LOAD.

/AFTER EXECUTING THE ONCE ONLY CODE FOR API SETUP

/AND SKIP CHAIN SETUP THIS JMP BECOMES A NOP.

/

F1ONCE	JMP ONCELY	/DO ONCE ONLY CODE OR(NOP).

/

/THE ,.WAIT, AND .TRAN SYSTEM MACROS DO NOT

/REQUIRE DATA BUFFERS.  DECODE THE CAL FUNCTION AND

/GO TO THE FUNCTION DISPATCHER . 

/.CLOSE DOES NOT REQUIRE A BUFFER IF ONE WAS'NT ALLOCATED.

/THIS HAPPENS BY (.INIT,.TRAN,.CLOSE). THIS IS A SPECIAL

/CASE AND IS EXPLICITLY TESTED FOR.

/

NOTONCE	LAC* ARGPTR	/PTR TO LOC+1

	DZM TRANSW	/.TRAN SWITCH

	AND (77		/RIGHTMOST 6-BITS ONLY.

	IDX ARGPTR	/POINT TO LOC+2

	SAD (12		/.WAIT, .WAITR?

	JMP WAITS	/YES, WELL WAIT THEN!

	DAC TEMP	/SAVE THE FUNCTION

	JMS TSTIOU	/ANY I/O UNDERWAY?

	.TITLE NO I/O UNDERWAY,SETUP DESCRIPTORS.

/
IO.OFF	LAC CALPTR	/SAVE CAL POINTER FOR

	DAC LOC.0	/SETUP CAL ARG PTRS

	IAC

	DAC LOC.1	/LOC+1

	IAC	

	DAC LOC.2	/LOC+2

	IAC	

	DAC LOC.3	/LOC+3

	IAC	

	DAC LOC.4	/LOC+4

	IAC	

	DAC LOC.5

	DZM EXITAD	/ DEFAULT EXITAD TO LOOPER		/EAG:150

	JMS SAVEAE	/SAVE STEP COUNTER AND MQ.

	.IFDEF %RP02	/IF DISK PACK SAVE UNITNO

	LAC* LOC.1	/USER CAL +1

	AND (700000

	DAC UNITNO
	RCR		/MOVE IT TO BITS 3-5

	RTR		/FOR POSSIBLE AUTOINITING.

	DAC SHUNIT	/SHIFTED UNIT NO.

	.IFDEF	%RK05

	RTR

	RTR

	DAC	RKUNIT	/RK UNIT NUMBER IN LEFT BYTE

/			/(SCR-154)REMOVE FOUR LINES OF (149)

	.ENDC

	.ENDC

/PUT THE SUBFUNCTION CODE FROM BIT 5,6,7 1ND 8 INTO

/BITS 14-17 OF SUBFUN AND SET THE CLOSE OR TRAN SWITCH

/IF THIS CAL IS EITHER.

/

	LAC B.5678
	SWHA			/(RCHM-156) PIK UP ONE WORD WITH SWHA.

	DAC SUBFUN

	LAC TEMP

	DAC FUNCTN

	SAD (13

	SET TRANSW

	TAD JMPDIS	

	DAC DISPCH	/BUILD DISPATCHER

	.IFDEF %AVERSION

	LAC TRANSW	/IF THIS IS A TRAN SAVE THE

	SZA		/CURRENT SET EVEN IF THE SLOTS

	JMP SAVETR	/MATCH(READ,TRAN, IS LEGAL).

	.ENDC

	.ENDC

	.TITLE CURRENT SET AND DATA BUFFER SETUP.

/

/A DATA BUFFER MAY BE REQUIRED FOR THIS DAT SLOT.

/SETUP THE POINTERS AND COUNTERS FOR THE CURRENT DAT SLOT.

/THE 'ARGUMENT' DAT SLOT GOES THROUGH THIS CODE AND THEN

/BECOMES THE 'CURRENT' DAT SLOT.  THE POINTERS AND COUNTERS

/SUCH AS 'EOF',  ETC ARE ALWAYS SET UP TO BE

/DESCRIBING THE DAT SLOT CURRENTLY BEING PROCESSED.  IF

/A DIFFERENT DAT SLOT CALL COMES IN, THESE DESCRIPTORS

/ARE SAVED AS PART OF THE DATA BUFFER.

/

FFILES	LAC CSLOT	/IF THE ARGUMENT DAT SLOT = THE

	SAD ASLOT	/CURRENT DAT SLOT, NO DESCRIPTOR SETUP

JMPDIS	JMP DISPCH	/IS REQ GO TO  DISPACHER.

/

/TAKE ALL THE DESCRIPTORS FOR THE 'CURRENT' DAT SLOT AND

/PUT THEM AWAY UNTIL THIS SLOT IS CALLED AGAIN.  IF THE

/CURRENT SLOT IS 0 ITS BECAUSE THIS IS A NEW CORE IMAGE

/OR  THE PREVIOUS CAL WAS A 'CLOSE' OR A 'TRAN'.

/IN EITHER CASE NOTHING HAS TO BE SAVED BEFORE THE

/ARGUMENT DAT SLOT DESCRIPTORS BECOME CURRENT.

/

	.IFDEF %LVERSION

	SZA

	JMP IOPS10

	LAC ASLOT

	DAC CSLOT

	.ENDC

	.IFUND %LVERSION

SAVETR	LAC CSLOT	/IS THE CURRENT SLOT BUSY?

	DZM CSLOT

	SZA!STL		/LINK IS ARG TO CSAVE

	JMS CSAVE	/SAVE CURRENT STUFF

/

/EVERYTHING HAS BEEN SAVED.  GO THROUGH (BSYTAB)

/TO FIND THE DESCRIPTORS FOR THIS FILE.  IF NOT

/INDICATED AS BEING BUSY USE THE FIRST 0 ENTRY OF THE

/BUSY TABLE AND ASK THE MONITOR FOR A BUFFER.

/

	LAC ASLOT

	DAC CSLOT

	JMS FINDBY

YES.IN	NOP		/FOUND IN TABLE.

	.IFUND	RSX

	LAC* BSYWD0	/WAS THIS FILE .INITED FOR

	AND (4000	/BIT 5 FROM .INIT=WRITE CHK.

	DAC WRCHEK	/SAVED AT BIT 6 OF BSYWD0.

	.ENDC

	.IFDEF %AVERSION

	.IFUND RSX

	LAC TRANSW	/IF THIS IS A TRAN DON'T EXPECT

	SZA		/OR TEST FOR A BUFFER.

	JMP TRAN

	.ENDC

	.ENDC

	LAC* BSYWD1	/GET PTR TO BUFFER

	DAC BEGBUF	/POINTS TO WORD0.

	SZA		/NO BUFFER IF PTR IS 0.

	JMP SETBUF	/SET UP OTHER PTRS BEFORE DISPCH

	.IFUND	RSX

	LAC TEMP	/THERE IS NO BUFFER FOR THIS CAL.

	SAD (6		/IF THIS IS A .CLOSE DON'T ASK

	JMP DISPCH	/THE MONITOR FOR A NEW BUFFER.

	SAD L1		/IF IT'S A .INIT DON'T ASK FOR

	JMP DISPCH	/A BUFFER EITHER.

	.ENDC

	.IFDEF	RSX

	LAC	5,X	/PICK UP THE REQUEST

	AND	(777)	/MASK OFF THE FUNCTION

	SAD	(34)	/IS IT A CLOSE?

	JMP	CLOSE

	SAD	(30)	/IS IT A GET?

	JMP	TRAN	/YES TRAN

	SAD	(31)	/NO -- PUT?

	JMP	TRAN	/YES - TRAN OUT

	.ENDC

/

/THE CAL IS NOT A .TRAN OR A .CLOSE. A BUFFER IS 

/REQUIRED. BEFORE ASKING FOR IT MAKE SURE ITS BIG

/ENOUGH TO HANDLE THE CURRENT SET AND THE DATA BUFFER

/PLUS 'LOWEST' (THE LOWEST # OF BLOCKS TO GET AT LSTFIL).

/

	.IFUND	RSX

	LAC BUF.OK	/SET BY ONCE ONLY CODE.

	SMA!SZA		/IF ITS BIG ENOUGH AC=TCA 

	JMP IOPS70	/OR 0.

FREESL	.GTBUF		/ASK FOR A BUFFER.

	SNA!SPA		/IS ONE AVAILABLE?

	JMP IOPS55	/NO TOO MANY FILES.

	.ENDC

	.IFDEF	RSX

/	GET A BUFFER

	LAW	-NUMFIL	/SET UP TO FIND A BUFFER FOR THIS REQUEST

	DAC	TEMP17	/MAXIMUM NUMBER OF BUFFERS

	LAC	(BUFFPT) /POINTER TO BUFFER TABLE

	DAC	TEMP18	/SAVE POINTER

BUFLP	LAC*	TEMP18	/PICK UP THE FIRST BUFFER POINTER

	SZA	/IS IT FREE?

	JMP	BUFFND	/YES -- USE IT

	ISZ	TEMP18	/NO -- LOOK AT THE NEXT BUFFER

	ISZ	TEMP17	/END OF BUFFERS?

	JMP	BUFLP	/NO -- TRY AGAIN

	JMP	IOPS17	/YES -- EXIT ERR -17

BUFFND=.

/

	.ENDC

	DAC BEGBUF	/YES SAVE IT.

	.IFDEF	RSX

	DZM*	TEMP18	/CLEAR THE BUFFER EMPTY SWPOINTER

	.ENDC

	DAC* BSYWD1	/COMPLETE BUSY TABLE.

	JMS ZERO	/WIPE OUT ENTIRE BUFFER.

	LAC BUFSIZ	/ARG TO ZERO.

	.IFUND	RSX

SETBUF	LAC* BSYWD2	/GET USER I.D. CODE.

	DAC UIC

	CLL

	.ENDC

	.IFDEF	RSX

SETBUF	CLL		/UIC ALWAYS RSX

	.ENDC

	JMS CSAVE	/BRING IN CURRENT SET

	JMS SETPNT	/SET THE DIR ENTRY POINTERS.

	LAC BEGBUF	/COMPUTE OTHER POINTERS.

	TAD (NODESC	/CURRENT SET SIZE.

	DAC BKPTRS	/POINTER TO BLOCK LIST.

	TAD LSTSIZ	/BLOCK LIST SIZE.

	DAC DATABK	/WORD0 OF 400 BLOCK.

	IAC	

	DAC WORD1	/WORD1 OF DATA BUFFER.

	IAC	

	DAC WORD2	/WORD2 OF BUFF.

	IAC	

	DAC WORD3	/WORD3

	TAD (373

	DAC BAKWRD

	IAC	

	DAC DATALK

	.ENDC

	.IFDEF	RSX

	JMP	DISPCH	/DISPATCH THE FUNCTION

/

TEMP17	0	/BUFFER COUNTER

TEMP18	0	/BUFFER TABLE POINTER

	.REPT	NUMFIL,500	/BUFFER TABLE

BUFFPT	BUFTMP

	.ENDC

	.IFUND	RSX

	.TITLE FUNCTION DISPATCHER.

/

/****A-VERSION****

/

	.IFDEF %AVERSION

DISPCH	XX		/JMP TO 1,2,3,4,5,6,7,10,11

	JMP INIT	/1 = .INIT 

	JMP OPER	/2 = .OPER

	JMP SEEK	/3 = .SEEK

	JMP ENTER	/4 = .ENTER

	JMP CLEAR	/5 = .CLEAR

	JMP CLOSE	/6 = .CLOSE

	JMP MTAPE	/7 = .MTAPE 

	JMP READ	/10 = .READ

	JMP WRITE	/11 = .WRITE

TEMP1	XX		/12 = .WAIT(R) (INTERCEPTED ALREADY)

	JMP TRAN	/13 = .TRAN

	.ENDC

/

/****B-VERSION****

/

	.IFDEF %BVERSION

DISPCH	XX

	JMP INIT

	JMP OPER	/2=.OPER

	JMP SEEK	/3=.SEEK

	JMP ENTER	/4=.ENTER

	JMP IOPS6	/5=.CLEAR(NOT SUPPORTED BY 'B'.

	JMP CLOSE	/6=.CLOSE

	JMP IOPS6	/7=.MTAPE

	JMP READ	/10=.READ

	JMP WRITE	/11=.WRITE

TEMP1	XX		/12=.WAIT(R) (INTERCEPTED).

	JMP IOPS6	/13 = .TRAN

	.ENDC

	.EJECT

/

/****C-AND L-VERSIONS****

/

	.IFUND %AVERSION

	.IFUND %BVERSION

DISPCH	XX		/JMP TO 1,2,3,6,10

	JMP INIT	/1=.INIT

	JMP OPER

	JMP SEEK

	JMP IOPS6	/4=.ENTER

	JMP IOPS6	/5=.CLEAR

	JMP CLOSE	/6=.CLOSE

	JMP IOPS6	/7=.MTAPE

	JMP READ	/10=.READ

	JMP IOPS6	/11=.WRITE

TEMP1	XX

	.IFDEF %LVERSION

	JMP TRAN	/13 = .TRAN

	.ENDC

	.IFUND %LVERSION

	JMP IOPS6

	.ENDC

	.ENDC

	.ENDC

	.ENDC

	.IFUND	RSX

	.TITLE (1) -INIT

/

/RETURN THE MAXIMUM BUFFER SIZE LOC+2.  

/

INIT	LAC (MAXBUF	/MAX L.B. SIZE.

	DAC* LOC.3

	.IFUND %NOOUT

INIT.1	LAC WREXSW	/ALREADY PUT IN BUSYTB. IS IT

	SZA		/ALREADY OPENED AS AN OUTPUT FILE?

	JMP YESOUT	/YES WIPE IT OUT FROM DIRECTORY.

	.ENDC

/

/SUBROUTINE 'FINDBY' NOT ONLY FINDS A DAT SLOT IN THE

/BUSY TABLE IT ALSO FINDS AN AVAILABLE SLOT (0'S)

/FOR INSERTING THIS DAT SLOT IN IT.  IF THERE ARE

/NO AVAILABLE SLOTS 'FINDBY' WILL TERMINATE (IOPS17)!

/

INITNO	LAC LOC.4	/RETURN ADDRESS.

	DAC EXITAD

	.IFUND %LVERSION

NOTOUT	JMS GVBACK	/IF IT HAD A BUFFER GIVE IT BACK.

	JMS FINDBY	/USE THIS AGAIN FOR NEW UIC.

	NOP		

	LAC B.5678

	AND (010000	/BIT 5 FROM INIT CAL.

	RCR		/MOVE IT TO BIT6 FOR BSYWD0.

	XOR* BSYWD0

	DAC* BSYWD0

	DZM CSLOT

	JMP NORMXT	/INITIALIZING IS COMPLETE; EXIT

	.ENDC

/

/AN ABORT CONDITION. MORE THAN ONE INIT BEFORE THIS

/FILE IS CLOSED. IF ANY WRITING(.ENTER) HAS BEEN

/DONE, USE WIPOUT TO RETRIEVE THE BLOCKS AND GET

/RID OF THIS FILE NAME FROM THE UFD.

/

	.IFUND %NOOUT

YESOUT	DZM WREXSW	/YES TURN OFF FOR NEXT TIME.

	LAC UFD1	/FILE NAME LIVES IN THIS BLK.

	JMS RDRIVE	/READ IT IN.

	JMS WIPOUT	/GET RID OF ALL TRACES

	LAC LOC.4		/ I/O ALL DONE.  RETURN TO	/EAG:150

	DAC EXITAD		/ USER NEXT TIME INSTEAD OF	/EAG:150

				/ INVOKING LOOPER		/EAG:150

	JMP NOTOUT

	.ENDC

	.EJECT

	.IFDEF %LVERSION

	LAC ASLOT

	GETUIC		/GET FROM UFD TABLE.

	JMP CLRCUR-1	/CLEAR CURRENT SET.

	.ENDC

	.TITLE	(2)- .OPER ( OPERATE FUNCTIONS)

/

/THE 1ST 3 OPERATE FUNCTIONS REQUIRE AN ARGUMENT

/TO BE RETURNED IN THE AC.  FOR THIS REASON .DLETE,

/.RENAM,AND .FSTAT CAUSE A LOOP TO OCCUR.  CONTROL

/CANNOT BE RETURNED TO THE USER UNTIL THE OPERATION

/IS COMPLETE.

/

OPER	LAC SKNTSW	/ANY SEQ OR RAND I/O 

	SZA		/GOING ON?

	JMP IOPS10

	LAC SUBFUN	/SET UP SUBFUNTION DISPATCH

	.IFDEF %AVERSION

	SNA

	JMP IOPS6	/SUBFUNCTION 0 IS ILLEGAL.

	AND (7

	TAD (JMP OPDISP

	DAC OPDISP

	LAW -6

	TAD SUBFUN	/CHECK SUBFUNCTION

	SMA		/1-5 LEGAL ONLY

	JMP IOPS6

OPDISP	XX		/DISPATCH TO SUBFUNCTION

	JMP DELET	/1=.DLETE

	JMP RENAM	/2=.RENAM

	JMP FSTAT	/3=.FSTAT

	JMP RTRAN	/4=.RTRAN

	JMP RAND	/5=.RAND

	.ENDC

	.IFUND %AVERSION

	SAD (3		/FSTA ONLY LEGAL OPER.

	JMP FSTAT

	JMP IOPS6

OPDISP	XX

	.ENDC

/CONTROL COMES TO 'ENDLUP' WHEN PROCESSING IS COMPLETE

/FOR THE .DELET, .RENAM, AND .FSTAT FUNCTIONS.  THE

/LOOPER IS TURNED OFF, THE FIRST BLOCK # OF THE FILE

/IS PUT INTO THE AC, AND CONTROL GOES TO THE USER.

/

ENDLUP	LAC OPDISP	/1ST BLOCK NO.

	DAC	AC		/ RETURN IN AC			/EAG:150

	JMP LOC3XT	/GO TO LOC+3 USER PROG EXIT.

	.ENDC

	.IFDEF %AVERSION

	.TITLE 	DELETE A FILE

/

/THE .DELET SYSTEM MACRO IS EXPANDED AS FOLLOWS:

/LOC	CAL+1000+A	/SUBFUNCTION=1

/LOC+1	2		/OPERATE FUNCTION

/LOC+2	D		/PTR TO 3-WRD NAME TO DELETE

/LOC+3	RETURN HERE IF WRITING TO THIS SLOT IS LEGAL.

/

/IF THE UIC ASSOCIATED WITH THIS DAT SLOT DOES NOT

/EXIST IN THE MFD OR IF THE 3-WORD NAME CANNOT

/BE FOUND IGNORE THE CALL.

/

DELET	JMS RELDEL	/COMMON SUBR FOR SEARCHING.

	JMP AUTOCL	/NO UIC OR FILE(AUTO CLOSE).

	.IFUND	RSX

	JMS CKDIRP	/DIRECTORY PROTECTED?

	.ENDC

	JMS WIPOUT	/ENTRY FOUND DELETE IT.

AUTOCL	DZM CSLOT	/AUTO MATIC CLOSE.

	JMS GVBACK	/RETURN BUFFER.

	.IFUND	RSX

	JMP ENDLUP	/DELET DONE, EXIT

	.ENDC

	.IFDEF	RSX

	JMP	NORMXT

	.ENDC

/

RELDEL	0

	.IFUND	RSX

	DZM OPDISP

	.ENDC

	JMS FINDER	/FIND NAME.

	NOP		/UIC NOT FOUND IN MFD.

	NOP		/UIC EMPTY

	JMP* RELDEL	/NAME NOT FOUND IN UFD.

/

	IDX RELDEL	/PNT TO FOUND EXIT.

	.IFUND	RSX

	LAC* U.FBLK	/FIRST BLOCK NO.

	DAC OPDISP	/SET AT OPER COMPLETION.

	.ENDC

	JMP* RELDEL

	.TITLE 	RENAME A FILE (NEW DATE ALSO).

/

/

/LOC	CAL+2000+A	/SUBFUNCTION=2

/LOC+1	2		/OPERATE FUNCTION.

/LOC+2	D

/LOC+3 RETURN AT COMPLETION

/D=STARTING ADDRESS OF TWO 3-WORD BLOCKS OF STORAGE

/CONTAINING THE FILE NAMES AND EXTENSIONS OF THE

/FILE TO BE RENAMED AND THE NEW NAME, RESPECTIVELY.

/

/THIS FUNCTION MUST FOLLOW THE PROTECTION RULES.

/

RENAM	JMS RELDEL

	JMP AUTOCL	/NAME NOT IN OR UIC MISSING.

	.IFUND	RSX

	LAC OPDISP	/TEST FOR TRUNCATED FILE?

	SPA

	JMP IOPS10	/YES. REPORT IOPS10

	JMS CKDIRP	/DIRECTORY PROTECTED?

	LAC* LOC.2	/D FROM LOC+2=AC

	TAD (3		/POINT TO NEW NAME.

	DAC TEMP1

	LAC UFD2	/OLD NAME PTR IN UFD.

	DAC TEMP2	

	LAW -3

	JMS MOVER

	LAC* (DATE

	DAC* U.DATE	/THE LATEST DATE.

	LAC BLOCK	/LAST BLOCK # READ

	JMS WDRIVE	/WRITE IT OUT.

	JMP AUTOCL	/END THE LOOP AND EXIT

/

	.ENDC

	.IFDEF	RSX

	LAC	BLOCK	/SAVE THE BLOCK NUMBER

	DAC	EOF

	ISZ	RENSW	/SET RENAME IN PROGRESS SWITCH

	JMP	NORMXT	/NORMAL EXIT

/

RENCLO	LAC	DPNODE	/PICK UP THE ADDRESS OF THE FILE NAME FOR

	AAC	7	/RENAME -- RENAME FOLLOWED BY CLOSE REQUEST

	DAC	TEMP1

	LAC	UFD2	/OLD NAME PTR IN UFD.

	DAC	TEMP2

	LAW	-3	/MOVE 3

	JMS	MOVER

	.INH		/INHIBIT ALL INTERRUPTS

	LAC*	(MO)	/PICK UP THE MONTH

	ALSS	6

	XOR*	(DAY)	/XOR IN THE DAY

	ALSS	6

	.ENB		/ENABLE INTERRUPTS

	TAD*	(YR)	/ADD IN THE YEAR

	AAC	-106	/DOS YEAR STARTS AT 1970

	DAC*	U.DATE	/STORE THE NEW DATE

	LAC	EOF	/WRITE IT OUT

	JMS	WDRIVE	/WRITE IT OUT

	JMP	AUTOCL	/END THE LOOP AND EXIT

	.ENDC

	.ENDC

	.IFUND	RSX

	.TITLE 	.FSTAT FIND A FILE.

/

/LOC	CAL+3000+A	/SUBFUNCTION 3

/LOC+1	2		/OPERATE FUNCTION

/LOC+2	D

/LOC+3	RETURN HERE WHEN DONE.

/

/.FSTAT CHECKS THE STATUS OF THE FILE SPECIFIED BY THE

/FILE ENTRY BLOCK AT D. ON RETURN, THE AC WILL

/CONTAIN THE FIRST BLOCK # OF THE FILE IF FOUND.

/THE CONTENT OF THE AC WILL BE ZERO ON RETURN

/(TO LOC+3) IF THE FILE SPECIFIED IS NOT ON THE

/DEVICE. IF THE ARG FILE IS FOUNF REMEMBER IT SO

/SUBSEQUENT SEEKS DON'T CAUSE DISK ACCESSES.

/BITS 0,1,2 AT LOC+2 ARE CHANGED TO INDICATE DEVICE TYPE. 

/

FSTAT	LAC* LOC.2

	AND (77777

	XOR (DEVTYP	/PASS ON DEVICE TYPE.

	DAC* LOC.2

	.IFDEF %AVERSION

/

	JMS RELDEL

	JMP ENDLUP

	DAC FSTSWH	/1ST BLK STILL IN AC.

	JMP ENDLUP

	.ENDC

/

	.IFUND %AVERSION

	DZM OPDISP

	JMS FINDER	/SEARCH FOR UIC AND NAME.

	JMP ENDLUP	/UIC NOT FOUND.

	JMP ENDLUP	/UIC EMPTY.

	JMP ENDLUP	/NAME NOT FOUND.

	LAC* U.FBLK	/FIRST BLOCK#

	AND (177777

	DAC FSTSWH	/SET FILE .FSTAT'ED SWITCH.

	JMP ENDLUP+1

	.ENDC

	.ENDC

	.IFDEF %AVERSION

	.TITLE 	.RAND  OPEN A FILE FOR RANDOM ACCESS.

/

/OPEN A FILE FOR RANDOM ACCESS. IF THIS FILE HAS

/ALREADY BEEN .SEEK'ED OR .ENTER'ED THIS IS A

/FATAL ERROR (IOPS 10).

/FORM: RAND,A,D

/EXPANSION:

/

/LOC	CAL+5000+A

/LOC+1	2

/LOC+2	D	PTR TO 3-WORD NAME.

/LOC+3	0		/WORD OF 0'S GENERATED.

/RAND RETURNS THE FILE SIZE AT LOC+3.

/

/A FILE MUST BE OPEN'ED WITH A .RAND IN ORDER

/TO PROCESS THE BLOCKS IN THE FILE RANDOMLY.

/IT CAUSES THE FIRST RIB TO BE BROUGHT IN

/AND USED FOR RELATIVE ADDRESSING.  IF THE

/UIC OR THE FILE DOES NOT EXIST IT CAUSES

/AN IOPS MESSAGE JUST AS A .SEEK DOES.

/

RAND=.

	.IFUND RSX

	LAC LOC.4	/LOC+4 EXIT ADDRESS

	DAC EXITAD

	.ENDC

	DZM RIBNUM	/THE RIB NO IF MANY RIBS.

	LAC SKNTSW	/WAS THIS FILE .SEEKED

	TAD RANDSW	/OR .RANDED

	SZA!CLC		/OR .ENTERED?

	JMP IOPS10	/YES..FATAL ERROR

	DAC RANDSW	/NO..SET RAND SWITCH

	LAC L1		/PROTECT CODE AS INPUT ARG

	JMS NOSEEK	/TO SEEKER(NO) SUBR.

RANDIN	LAC* U.SIZ

	.IFUND RSX

	DAC* LOC.3	/RETURN TO THE FILE SIZE.

	.ENDC

			/NO RETURN TO RSX

	DAC RANDHI	/HIGHEST RELATIVE BLOCK #

	LAC* U.RBWD

	AND (777	/377 HIGHEST NO.

	DAC RIBWRD	/WORD IN BLK WHERE IT STARTS.

	LAC* U.RIB

	JMS RDRIVE	/READ THE FIRST RIB.

	LAC RIBWRD	/IS IT SHARING A DATA BLOCK?

	SZA		/NO IF 0.

	JMS RIBADJ	/YES.. MOVE IT TO TOP.

	JMP NORMXT	/RAND COMPLETE.

RNDBLK	0

SAVDIR	0		/SAVE I/O DIRECTION FROM LOC+2

SAVBLK	0		/SAVE REQUIRED BLOCK NO.

	.TITLE 	.RTRAN  TRANSFER (IN/OUT) A REL BLOCK.

/

/LOC	CAL+4000+A(9-17)

/LOC+1	2

/LOC+2	D(0)+B(1-17)	/D=DIRECTION(BLK=1,2,3,4...N)

/LOC+3	L		/L=CORE ADDRESS

/LOC+4	WN		/IN BLOCK WORD NUMBER

/LOC+5	WC	2'S COMP

/

/TRANSFER A BLOCK OF DATA (UP TO 254(10) WORDS)

/STARTING AT WORD WN (RF15 ONLY).

/THE BUFFER IS OUTPUT TO OR INPUT

/FROM A PHYSICAL DISK DATA BLOCK WHOSE NUMBER IS

/RELATIVE TO THE BEGINNING OF THE FILE OPENED

/ON SLOT A.

/

RTRAN=.

	.IFDEF RSX

	PAL		/SAVE DIRECTION

	.ENDC

	LAC RANDSW	/WAS A .RAND EXECUTED?

	SNA		/YES..CONTINUE.

	JMP IOPS11	/NO FATAL ERROR.

/

/IF THE RELATIVE BLOCK NO IS GREATER THAN THE 

/HIGHEST BLOCK NUMBER FOR THIS FILE OR 000 

/TERMINATE WITH AN IOPS66 MESSAGE.

/

	.IFUND RSX

HITEST	LAC* LOC.2	/RELATIVE BLOCK NO.

	.ENDC

	.IFDEF RSX

HITEST	LAC 7,X	/REL BLOCK NO.

	.ENDC

	AND (177777

	TAD MINUS1	/SUBR 1 TO MAKE DIV ALGORITM WORK.

	SAD MINUS1	/WAS THE ARG BLOCK 0?

	JMP IOPS66	/FATAL ERROR,BLOCKS START AT 1,2,3,4.

	DAC RNDBLK	/GET THE ARGUMENT BLK NO-1.

	IAC			/RESTORE 'REAL' ARG FOR MAX TEST.

	TCA		/2'S COMP.

	TAD RANDHI	/HIEST NO OF BLOCKS.

	SPA

	JMP IOPS66

	DAC CKSUM	/SAVE FOR LAST BLK TEST.

/ IF THE WORD COUNT IS 0 TREAT THIS AS A NOP.

/

	LAC*	LOC.3	/GET BUFFER START (BR-149)
	AND (700000)		/(RCHM-156) BEYOND 32K?
	SZA			/(RCHM-156) 0 => NO.
	JMP	IOPS67	/ERROR-ABOVE 32K (BR-149)

	.IFUND RSX

MACNOP	LAC* LOC.5	/WORD COUNT.

	.ENDC

	.IFDEF RSX

MACNOP	LAC 11,X	/WORD COUNT

	.ENDC

	SZA		/0=NOP.

	JMP NOTNOP

	.IFUND RSX

	LAC LOC.5	/INDEX TO EXIT ADDRESS.

	IAC	

	DAC EXITAD

	.ENDC

	JMP NORMXT

	.EJECT

/

/ 'RIBNUM' IS THE RIB BLOCK NO CURRENTLY IN CORE.

/ 0=1ST RIB,1=2ND AND SO ON. DIVIDE THE ARGUMENT

/ BLOCK NO BY RIBSIZ(BLOCKS IN RIB) TO GET THE 

/ REQUIRED RIB NUMBER. AFTER THE DIVIDE THE QUOTIENT

/ IS THE REQUIRED RIB AND THE REMAINDER IS THE

/ LOCATION IN THE RIB WHERE THE ARG BLK LIVES.

/

NOTNOP	LAC RNDBLK	/ARGUMENT BLOCK OF .RTRAN-1

	DIVREM RIBSIZ,RNDBLK

	DAC SAVSUM	/SAVE THE QUOTIENT.

	TCA		/COMPUTE ARG RIB NUMBER..

	TAD RIBNUM	/CURRENT RIB NUMBER.

	SNA		/IF 0 THE CORRECT ONE IS IN.

	JMP RIBIN

	DAC WPC		/USE AS COUNTER FOR MORE RIBS.

	SMA		/IF TCA READ FORWARDS.

	JMP RIBBAK	/POS READ BACKWARD LINKS.

RIBFOR	LAC* DATALK	/FORWARD DATA LINK.

	JMS RDRIVE

	INC RIBNUM	/INDEX TO NEW RIB.

	ISZ WPC

	JMP RIBFOR

	JMP RIBIN	/DONE! RIGHT RIB IS IN.

RIBBAK	TCA		/GET 2'S COMP.

	DAC WPC

REDBAK	LAC* BAKWRD	/BACKWARD DATA LINK.

	JMS RDRIVE

	LAW -1

	TAD RIBNUM

	DAC RIBNUM	/DECREMENT TO CORRECT RIB.

	ISZ WPC		/DONE READING?

	JMP REDBAK	/NOT DONE KEEP READING BACK.

/

/THE CORRECT RIB IS NOW IN CORE. THE REMAINDER AT (RNDBLK'

/IS STILL INCOMPLETE BECAUSE OF THE SUBTRACTION. ADD 1 TO

/THE REMAINDER TO GET THE POINTER WIHIN THE RIB WHERE THE 

/ .RTRAN ARGUMENT BLOCK NUMBER LIVES.

/

RIBIN	LAC RNDBLK

	TAD DATABK

	DAC RECEV1	/BACKWARD DATA LINK

	IAC			/GET 'REAL' ARG POINTER.

	DAC SAVSUM	/THIS IS THE ONE WE WANT.

	.IFUND %RF15

	IAC			/GET PTR TO FORWARD LINK.

	DAC RECEV2

	DZM WORD	/ALWAYS START AT WORD 0.

	LAC* SAVSUM	/GET THE REQUIRED BLOCK.

	DAC SAVBLK

	.ENDC

	.IFDEF %RF15

	LAC* LOC.4

	DAC WORD

	.ENDC

	.IFUND RSX

	LAC* LOC.5

	.ENDC

	.IFDEF RSX

	LAC 11,X

	TCA		/GET TCA

	.ENDC

	DAC NUMWDS

	.EJECT

/'WORD' IS POINTING AT THE EXACT WORD IN THE DATA BLOCK

/WHERE THE TRANSFER IS GOING TO START. IF THE NUMBER

/OF WORDS TO TRANFER EXCEEDS THE BACKWARD DATA LINK

/THE USER HAS ASKED FOR TOO MUCH DATA.

/

	TCA

	TAD WORD

	TAD MINUSM

	SMA!SZA

	JMP IOPS67

	.IFUND RSX

	RDIREC		/SET THE DIRECTION SWITCH.

	.IFUND %RF15

	SNL		/LINK IS 0 IF INPUT

	JMP SETRET	/PARAMETERS ALL SET GO AHEAD.

	.ENDC

	.ENDC

	.IFDEF RSX

	LAC (FRD

	DAC SAVDIR

	PLA		/GET DIRECTION

	SAD (42		/IS IT A WRITE?

	SKP

	JMP SETRET	/NO, A READ

	LAC (FWR

	DAC SAVDIR

	.ENDC

/

/THIS IS AN .RTRAN IN THE OUTPUT DIRECTION ON RB OR RP

/DISK. THE WORD COUNT WILL BE 400,WITH THE FORWARD

/AND BACKWARD DATA LINK STORED IN THE USER AREA BY

/THIS HANDLER BEFORE THE TRANSFER TAKES PLACE.

/

	.IFUND %RF15

	LAW -400

	DAC NUMWDS

	.IFUND RSX

	LAC* LOC.3	/USER BUFFER DONATING.

	.ENDC

	.IFDEF RSX

	LAC 10,X

	.ENDC

	TAD (376	/SETUP THE LINK POINTERS.

	DAC DONOR1	/POINTER TO BACK LINK.

	IAC	

	DAC DONOR2	/BACKWARD LINK.

/

/ ONE BLOCK FILES ARE SPECIAL CASES. THE FORWARD AND 

/ BACKWARD LINKS MUST BE SET TO -1.

/

	LAC RANDHI	/# OF BLOCKS IN FILE.

	SAD L1		/IS IT 1?

	SKP!CLC		/YES..VERY LITTLE TIME REQ.

	JMP MORET1	/NO..MORE THAN 1.

	DAC* DONOR1	/BACKWARD LINK=-1

	DAC* DONOR2	/1 BLOCK FILE ARE EASY BUT RARE..

	JMP SETRET

	.EJECT

/ IF THE BACKWARD LINK POINTER IS

/ EQUAL TO 'DATABK' THE BACKWARD LINK IS

/ IN THE PREVIOUS RIB.  IN THIS CASE IMMEDIATELY

/ SAVE THE -FORWARD LINK- AND READ IN THE PREV RIB

/ *** THIS SAME KIND OF THING IS REQUIRED IF THE

/  FORWARD DATA KINK POINTER IS EQ TO 'BAKWRD'.

/ IF SO,IMMEDIATELY SAVE THE BACKWARD LINK AND

/ READ IN THE NEXT RIB TO GET THE FORWARD LINK

/	** THESE OPERATIONS ARE REQUIRED SO **

/	** THAT RP AND RB DATA CAN BE

/	** PROCESSED SEQUENTIALLY "AFTER" **

/	** BEING .RTRAN'ED.

/

MORET1	LAC* RECEV1	/ASSUME THIS IS NOT A

	DAC* DONOR1	/SPECIAL CASE AND ALL

	LAC* RECEV2	/LINKS ARE IN THIS RIB

	DAC* DONOR2

/

/TWO MORE SPECIAL CASES OCCUR IF THE ARGUMENT

/BLOCK# IS 1 OR THE "LAST" BLOCK IN THE

/FILE.  THE BACKWARD LINK FOR THE FORMER MUST

/BE -1 ANF THE FORWRD LINK -1 FOR LATTER

/

BAKSET	LAC RECEV1	/IF RECEV1 DOES NOT EQUAL

	SAD DATABK	/DATABK THERE IS NO SPECIAL

	SKP!CLC		/CASE HERE FOR THE BACKWARD

	JMP FORSET	/LINK.

	DAC* DONOR1	/RIB IS -1 THERE IS NO PREV. RIB

	LAC RIBNUM	/CAN WE GO BACK?

	SNA!CLC		/NO IF 0. THIS MUST BE #1.

	JMP FORSET	/BACKEARD LINK IS -1.

	TAD RIBNUM

	DAC RIBNUM

	LAC* BAKWRD

	JMS RDRIVE	/READ IN THE PREVIOUS RIB

	LAW -1		/THE LAST BLOCK IN THE

	TAD BAKWRD	/RIB IS THE TRUE BACKWARD LINK.

	DAC TEMP2

	LAC* TEMP2

	DAC* DONOR1	/AT LAST! THE BACKWARD LINK IS COMPLETE!

	JMP SETRET	/YOU CAN SEE THE BEQUTY OF WORD ADDRESSABILITY

/

/ AT FORSET THE FORWARD DATA LINK IS CHECKED

/ FOR THE TWO SPECIAL CASES WHERE THE

/ FORWARD LINK IS IN THE NEXT RIB OR THE

/ FORWARD LINK SHOULD BE -1 BECAUSE

/ THIS (THE ARG BLOCK) IS THE LAST BLOCK OF

/ THE FILE.

/

FORSET	LAC CKSUM	/LAST BLOCK IN FILE IF 0.

	SZA!CLC

	JMP NOTLST

	DAC* DONOR2	/YES IT IS, MAKE IT -1.

	JMP SETRET

NOTLST	LAC RECEV2	/CHECK THE LAST CASE WHERE

	SAD BAKWRD	/THE FORWARD LINK IS IN THE

	SKP		/NEXT RIB

	JMP SETRET

	LAC* DATALK	/READ IN NEXT RIB

	JMS RDRIVE

	INC RIBNUM	/ADJUST RESIDENT RIB#

	LAC* WORD1

	DAC* DONOR2	/DONE! FINI!

/

	.ENDC

	.IFUND RSX

SETRET	LAC LOC.5	/LOC+5

	IAC			/SETUP THE RETURN ADDRESS.

	DAC EXITAD

	.ENDC

	.IFDEF RSX

SETRET	JMS	ADJ		/ADJUST PARAMETERS

	.ENDC

	.IFUND %RF15

	LAC SAVBLK	/REQUESTED BLOCK.

	.ENDC

	.IFDEF %RF15

	LAC* SAVSUM

	.ENDC

	JMS DRIVER

	.IFUND RSX

	LAC* LOC.3	/CORE ADDRESS.

	.ENDC

	.IFDEF RSX

	LAC*	(R3	/CORE ADDRESS

	.ENDC

	LAC SAVDIR	/READ OR WRITE.

	JMP NORMXT

	.ENDC

	.TITLE (3)- .SEEK

/

/THE SEEK FUNCTION REQUIRES A MINIMUN OF THREE ACCESSES

/TO THE DISK. FIRST FOR READING THE MFD BLOCK,SECOND

/FOR READING THE UFD, AND LAST FOR THE USER'S

/FIRST DATA BLOCK.

/

/LOC	CAL+A(9-17)	/DAT SLOT

/LOC+1	3		/SEEK FUNCTION.

/LOC+2	D		/POINTER TO 3 WORD NAME.

/LOC+3	NORMAL RETURN IF NAME IS FOUND.  IF NOT FOUND

/PROCESSING TERMINATES WITH IOPS 13 OR IOPS 51.

/

SEEK	JMS TSTRAN	/RANDOM ACCESS BUSY??

	LAC (3		/INPUT ARG TO NOSEEK.

	JMS NOSEEK	/IF .FSTATED DON'T SEEK.

NAMOK	LAC* U.FBLK	/1ST BLOCK # IS ARG TO DRIVER.

	AND (177777

	JMS RDRIVE

	.IFUND	RSX

LOC3XT	LAC LOC.3

	DAC EXITAD		/ RETURN TO USER THIS TIME	/EAG:150

	.ENDC

FRSTIN	JMP NORMXT	/PTR TO WORD0.

/

/

/IF THE FILE HAS ALREADY BEEN OPENED FOR RANDOM

/ACCESS IT A FATAL IOPS 10.

/

TSTRAN	0

	LAC SKNTSW	/IS FILE OPEN FOR SEQ IO?

	SZA!CLC

	JMP IOPS10

	.IFDEF %AVERSION

	LAC RANDSW	/.RAND EXECUTED SWITCH.

	SZA!CLC		/OK

	JMP IOPS10

	.ENDC

	DAC SKNTSW

	JMP* TSTRAN

	.EJECT

/SUBROUTINE NOSEEK CHECKS THE .FSTAT SWITCH TO AVOID

/MORE DISK ACCESSES. IF ITS ON THIS FILE WAS .FSTATED

/AND FOUND. IF OFF NO .FSTAT WAS DONE OR THE FILE WAS

/NOT FOUND BY AN .FSTAT.

/THE PROTECTION CODE IS INPUT AS THE ARGUMENT TO

/THIS SUBR. IF PROTECTION IS ON THE FILE PRO MUST

/MATCH THAT OF THE SUBR CALLER.

/

/'FINDER' IS USED TO BRING IN THE MASTER FILE

/DIRECTORY AND THE USER FILE DIRECTORY.  IN

/THE PROCESS THE DIRECTORIES ARE SEARCHED FOR THE 1-WORD

/UIC AND THE 3-WORD ARGUMENT NAME.

/

NOSEEK	0

	DAC DONOR1

	LAC FSTSWH	/FILE .FSTATED SUCCESSFULLY?

	SZA		/NO IF 0.

	JMP BYPASS	/YES..DON'T SEEK AGAIN.

	JMS FINDER	/FIND THE FILE.

	JMP IOPS51	/UIC NOT IN MFD.

	JMP IOPS71	/UIC IS EMPTY.

	JMP IOPS13	/NAME NOT IN UFD.

/ 

/ THE FOLLOWING CODE TESTS TO SEE IF THE FILE IS AN RSX

/ RANDOM FILE. THIS IS INDICATED IF THE 1ST BIT, I.E. BIT 0,

/ OF THE FILE SIZE IS SET TO A 1. IF IT IS, THERE ARE NOT

/ BLOCK LINKS IN ANY OF THE DATA BLOCKS AND THE RIB DATA 

/ DOES NOT EXIST. THEREFORE, DOS CANNOT READ THE FILE.

/ 

	.IFUND %LVERS

	DAC	RSXT1	/SAVE THE AC

	LAC	UFD2	/GET THE FILE SIZE

	AAC	4	/REPLACE TAD (4 (BR-149)

	DAC	U.SIZ

	LAC*	U.SIZ

	SPA		/IF THIS IS AN RSX RANDOM FILE SIZE IS <0

	JMP	IOPS6	/IT IS, RETURN IOPS6 -- CANNOT SEEK THIS FILE

	LAC	RSXT1	/IT ISN'T -- RESTORE THE AC

	.ENDC

BYPASS	TFILES		/TRUNCATED FILE?

	JMP IOPS10	/YES FATAL ERROR.

	.IFUND	RSX

	JMS DIRPRO	/IS THIS DIR PROTECTED.

	.ENDC

	JMP* NOSEEK	/NO..PROCEED.

	.IFUND	RSX

	.IFUND %LVERS

	LAC FPRO	/NO IF CONTROL COMES BACK.

	SAD DONOR1	/DOES FILE PRO MATCH INPUT ARG?

	JMP IOPS64	/NO FATAL ERROR.

	.ENDC

	JMP* NOSEEK

	.ENDC

	.TITLE (4)- .ENTER

/

	.IFUND %NOOUT

/NORMAL RETURN IF .ENTER IS OK IS LOC+3. IF THE

/NAME CAN'T BE ENTERED IN A DIR, NOT ONLY IS THE

/DIRECTORY BLOCK FULL BUT THE ENTIRE DISK IS 

/FULL.  THE NUMBER OF FILES IS RESTRICTED BY THE SIZE 

/OF THE DEVICE.

/

/VERIFY THAT THE ENTRY IN THE TABLE

/ASSOCIATED WITH THIS DAT SLOT AND THE "LOGGED" IN

/UIC ARE IDENTICAL.  IF YES, CONTINUE AS NORMAL.  IF

/NOT, CHECK FOR THE MIC AND TERMINATE IF NOT EQUAL,

/

ENTER	JMS TSTRAN

	DZM OLDSW	/ASSUME NO OLD FILE.

	.IFUND %RB09

	DZM MAPOFF

	.ENDC

ENTERS	LAC WORD3	/1ST WRD IN SUBMAP TO LOOK AT.

	DAC START

	DZM WREXSW

	DZM RIBWRD

	JMS FINDER	/LOOK FOR THIS FILE.

	JMP NO.MFD	/NO ENTRY IN MFD FOR USER.

	JMP UICEMPTY	/ITS THERE BIT ITS EMPTY.

	JMP NOTOLD	/NO OLD FILE IN.

	JMP YESOLD	/OLD FILE MUST BE DELETED.

/

/

	.IFUND	RSX

UICEMP	JMS CKDIRP	/CHECK PROTECTION.

	JMS ENTSET	/DIRECTORY PROTECTED

	.ENDC

	.IFDEF	RSX

UICEMP	JMS	ENTSET

	.ENDC

	LAC MFD1	/1ST MFD BLOCK.

	JMS RDRIVE

MFDSET	JMS GETNXT	/GET THU UFD BLOCK.

	DAC* DUMSET	/SET BY 'FINDER'

	DAC* BSYWD3

	DAC UFD1

	LAC MFD1	/MFD STILL IN.

	JMS WDRIVE

	LAW -1		/A NEW UFD THE BACK

	DAC* BAKWRD	/LINK MUST BE -1.

	LAC TEMP2

	JMP COMUFD	/COMPLETE THE UFD ENTRY.

	.EJECT

/THERE IS NO ENTRY IN THE MFD BLOCK FOR THIS USER.

/PUT ONE IN FOR HIM AND USE THE ASSUMED DIRECTORY

/PROTECTION AND ENTRY SIZES.

/

NO.MFD	LAC BLOCK	/LAST MFD BLOCK READ.

	DAC MFD2	/SAVE IT HERE.

	JMS NAMSAV	/MOVE NAME TO ERROR ROUTINE.

	JMS ENTSET	/GET SOME BLOCKS.

	LAC MFD2	/BRING LAST MFD BLK AGAIN.

	JMS RDRIVE

	LAC DUMSW	/HAS A PLACE BEEN FOUND FOR ENTRY?

	SZA		/YES IF NON ZERO.

	JMP USEMFD	/YES USE THIS MFD BLOCK.

	JMS GETNXT	/NO..GET NEW MFD BLK#.

	DAC* DATALK	/FORWARD DATA LINK OF OLD MFD.

	DAC MFD1

	LAC BLOCK	/OLD MFD STILL IN CORE.

	JMS WDRIVE	/WRITE AND SET LINKS.

	LAC DATABK	/SET THE ENTRY POINTERS.
MFDINS	DAC MFD2
	IAC	
	DAC DUMSET	/USED AT MFDSET FOR UFD BLK.
	IAC			/POINT TO PROTRCT CODE ,SIZE.

	DAC ENTSET	/USE TEMPORARILY.

	.IFUND	RSX

	LAC UIC

	.ENDC

	.IFDEF	RSX

	LAC	UICRSX	/USE A UIC OF RSX

	.ENDC

	DAC* MFD2	/WORD0 OF EMPTY BUFFER

	LAC (MFDPRO	/UFD SIZE AND PRO.

	DAC* ENTSET	/WORD2 OF ENTRY.

	JMP MFDSET

USEMFD	LAC DUM.BK	/BLOCK# OF AVAILABLE MFD BLK.

	DAC MFD1	/INSERT THE MFD ENTRY HERE.

	SAD BLOCK	/IS IT ALREADY IN CORE?

	SKP		/YES..DON'T READ IT.

	JMS RDRIVE

	LAC DUM.WD	/WORD 0 OF NEW MFD ENTRY.

	JMP MFDINS

	.EJECT

/

/THE OLD NAME HAS BEEN FOUND. SET THE 'OLD-FILE-IN'

/SWITCH AND REMEMBER THE BLOCK# AND THE WORD WITHIN 

/THE BLOCK WHERE THIS ENTRY STARTS.

/

/IF THE FILE WITH THE SAME NAME IS A TRUNCATED

/FILE DELETE IT IMMEDIATELY,THE GO TO THE FINDER

/SUBR TO GET ANOTHER ONE.

/

YESOLD	TFILES		/IS THIS TRUNCATED???

	SKP		/YES DELETE NOW!

	JMP SETOLD	/NO DELETE AT .CLOSE.

	JMS WIPOUT

	JMP ENTERS

SETOLD	SET OLDSW	/SET OLD FILE IN SWITCH.

	LAC UFD1	/BLK# AND FIRST WORD

	DAC OLDBLK	/WHERE THE OLDNAME LIVES

	LAC UFD2	/IN THE UFD.

	DAC OLDFIL

/IF DUMSW .EQ.0 A PLACE HAS NOT YET BEEN FOUND FOR ENTRY.

/

	.IFUND	RSX

NOTOLD	JMS CKDIRP	/DIRECTORY PROTECTED?

	JMS ENTSET	/PROTECTED DORECTORY?

	.ENDC

	.IFDEF	RSX

NOTOLD	JMS	ENTSET

	.ENDC

	LAC DUMSW

	SZA

	JMP DUMNAM

	LAC* BSYWD3	/SET AT FINDER.

EDUMMY	DAC UFD1

	JMS RDRIVE

	STL		/UFD SEARCH

	LAW -SIZUFD	/#OF 0'S TO FIND ENTRY

	JMS SEARCH	/IN MFD BLOCK.

	LAC FAKER	/DUMMY NAME.

	JMP SETDUM	/FOUND GO COMPLETE UFD.

	LAC* DATALK	/AYMORE LEFT?

	SMA

	JMP EDUMMY	/LOOK FOR DUMMY NAME AGAIN.

/

/A NEW UFD BLOCK IS REQ. THE LAST UFD BLOCK IS CURRENTLY

/IN CORE. ITS DATA LINK MUST BE CHANGED FROM -1 TO THE NEW

/UFD BLOCK THE THE NEW BLOCK MUST SET ITS LINK TO -1.

/

ENONAM	JMS GETNXT	/GET A BK FROM LIST.

	DAC* DATALK

	DAC UFD1

	LAC BLOCK

	JMS WDRIVE	/NEW LINK SET BY WDRIVE.

SETDUM	LAC TEMP2

/

/A PLACE TO PUT THIS NEW ENTRY HAS BEEN FOUND.

/REMEMBER THE BLOCK NUMBER AND THE LOCATIONS SO

/ IT CAN BE EASILY RETRIEVED FOR UPDATING

/INFORMATION.

/

COMUFD	DAC UFD2

	JMS SETPNT

	.IFUND	RSX

	LAC* LOC.2	/POINTER TO 3-WORD NAME

	.ENDC

	.IFDEF	RSX

	LAC	DPNODE	/PICK UP THE NODE POINTER

	AAC	7

	.ENDC

	DAC TEMP1

	LAW -3		/TEMP2 ALREADY SETUP.

	JMS MOVER	/MOVE THE NAME IN

E.WD56	JMS GETNXT

	DAC* U.RIB	/WORD5

	DAC RIBBLK

	DAC	FRSTRB	/!!134!!SAVE FIRST RIB IN CURRENT SET, IN CASE

/			/MULTIPLE RIB BLOCK FILE.

	.IFUND	RSX

	LAC SUBFUN	/PROTECTION CODE FRON CAL.

	SNA!CLL		/IF 0 USE DEFAULT CODE.

	LAC* (DFAULT	/DEFAULT SET BY SGEN.

	AND (7

	RTR		/PUT IT IN BITS 0-2.

	RTR

	.ENDC

	.IFDEF	RSX

	LAC	(100000)	/UNPROTECTED UIC

	.ENDC

	DAC* U.RBWD

	DZM RIBWRD

E.WD34	LAC* NXTLST	/FROM TEMP LIST

	XOR L45ZS	/TRUNCATED FILE

	DAC* U.FBLK

	DZM* U.SIZ

	.IFUND	RSX

E.WD07	LAC* (DATE

	.ENDC

	.IFDEF	RSX

E.WD07	.INH	/INHIBIT ALL INTERRUPTS TO PREVENT UPDATING OF DATE

	LAC*	(MO)	/PICK UP THE MONTH

	ALSS	6	/MOVE IT 6 BITS

	XOR*	(DAY)	/PICK UP THE DAY

	ALSS	6	/MOVE IT OVER 6 BITS

	.ENB		/ENABLE INTERRUPTS

	TAD*	(YR)	/PICK UP THE YEAR

	AAC	-106	/DOS DATE STARTS AT 1970

	.ENDC

	DAC* U.DATE

/

/ENTRY COMPLETE WRITE IT OUT

/

E.COMP	LAC UFD1

	JMS WDRIVE

	JMS BLDRIB

	SET WREXSW

	JMS GETNXT	/SAME AS CONTENTS OF

	DAC NXTBLK	/U.FBLK

	JMS ZFILL

	JMP LOC3XT	/EXIT AT LOC+3

DUMNAM	LAC DUM.BK

	DAC UFD1

	JMS RDRIVE

	LAC DUM.WD

	DAC TEMP2

	JMP COMUFD

ENTSET	0		/.ENTER SETUP CODE.

	LAC SBMAP1	/START WITH 1ST MAP.

	DAC CSBMAP

	DZM FILSIZ	/# OF DATA BLOCKS IN FILE.

ENTR1	JMS LSTFIL	/FILL TEMP LIST

	LAW -RIBSIZ

	DAC ROOMRB	/ROOM LEFT IN RIB.

/

/THE WORST CASE .ENTER REQUIRES 'LOWEST' BLKS:

/ 1-THE MFD 2-FOR A NEW UFD BLOCK, 3-THE RIB

/BLOCK, AND 4-THE FIRST DATA BLOCK. 

/

ENTFUL	LAW -LOWEST

	TAD BLKLFT	/SET AT LSTFIL

	SMA		/IF NEH THERE AREN'T ENOUGH

	JMP* ENTSET	/BLOCKS. IF 0 OR POS CONT.

	LAC BLKLFT	/BEFORE TERMINATING GIVE BACK

	SNA		/THE BLOCKS JUST TAKEN FROM MAP.

	JMP IOPS15	/NONE..MAP WAS ALREADY FULL.

	TCA		/USE NUMBER IN LOOP.

	DAC DUM.BK

	DZM CSBMAP	/MAKE SURE 'OFFBIT' WORKS.

DEAD15	JMS GETNXT	/GET A BLOCK.

	JMS OFFBIT	/GIVE IT BACK.

	ISZ DUM.BK	/ARE ALL BLOCKS GIVEN BACK?

	JMP DEAD15	/NO KEEP GOING.

	LAC CSBMAP	/YESS..WRITE OUT THE MAP

	JMS WDRIVE	/THEN TERMINATE.

	JMP IOPS15

	.ENDC

	.IFUND	RSX

	.IFDEF %AVERSION

	.TITLE	(5)-.CLEAR THE ENTIRE DISK

/

/THE CLEAR FUNCTION WIPES OUT THE ENTIRE DISK.

/THE DISK IS CLEARED BY TURNING OFF ALL THE BITS

/IN THE BIT MAPS (BLOCKS 17776 AND 17775),AND

/BY ZEROING THE MFD BLOCK(1777).

/

/THE .CLEAR IS THE MOST PRIVILEGED OF ALL THE DISK FUNCTIONS.

/IT WILL NOT BE HONORED UNLESS THE USER HAS LOGGED IN UNDER

/THE MIC.

/

CLEAR	LAC LOC.2

	DAC EXITAD	/LOC+2 EXIT ADDRESS.

	LAC* (LOGMIC	/SYSTEM OWNER LOGGED IN??

	SMA		/YES IF TCA.

	JMP IOPS63	/RESTRICTED USE OF .CLEAR.

/

/CLEAR AND SET THE MFD BLOCK FIRST.

/

	JMS ZFILL	/FILL DATA BLOCK WITH 0'S.

	LAW -1

	DAC* DATABK	/DUMMY UFD.

	DAC* WORD1	/DUMMY BAT POINTER

	DAC* WORD2	/DUMMY SYSBLK

	LAC (MFDSIZ	/ASSEMBLY PARAMETER.

	CLL

	RTR

	RTR

	TAD SBMAP1	/1ST SUBMAP NO.

	DAC* WORD3

	LAC (MFDBLK

	JMS WDRIVE

	.IFUND %RP02

/

/THE BIT MAPS MUST NOW BE SET.  IF LESS THAN FOUR

/PLATTERS THERE IS ONLY ONE BIT MAP.  

/SWITCHES ARE SET UP DURING ONCE ONLY CODE JUST FOR

/THE .CLEAR FUNCTION.  'MULMAP' IS SKP IF ONLY ONE SUBMAP

/AND NOP OTHERWISE.

/

CLRBAK	LAW -1		/BACKWARD DATA LINK.

	DAC* BAKWRD

	LAC DATABK

	TAD (73

	DAC TEMP1

	LAC (3

	DAC* WORD2	/3 BLKS OCCUPIED

	LAC WORD2	/SETUP THE POINTER TO THE FIRST

	IAC			/18 BIT DATA WORD IN THE FIRST MAP.

	DAC ZFILL

	LAC L45ZS	/BLOCK 0 CANN NEVER BE USED FOR OUTPUT.

	DAC* ZFILL

	LAC HI.BLK

	DAC* DATABK

	DAC* WORD1

	.IFDEF %RF15

	LAW -MAX4	/MAX BLKS IN ONE MAP.

	TAD HI.BLK	/HIGHEST BLOCK#+1

	DAC LOC.3	/LOC.3 NOT USED HERE

	SMA!SZA

	JMP TWOMAP	/2 MAPS REQ.

	.ENDC

	LAC (14		/ONLY BLOCKS 1777 & 1776 ARE BUSY

	DAC* TEMP1	/WORD 73(8) BIT 4 & 5

	LAC SBMAP1

CLRDON	JMS WDRIVE

	JMS GVBACK	/GIVE BACK DATA BUFFER

	JMP NORMXT

	.IFDEF %RF15

/

/MORE THAN 4 PLATTERS IN THIS SYSTEM.

/

TWOMAP	LAC (MAX4	/# BLOCKS IN 4 PLATTERS.

	DAC* WORD1

	INC* WORD2

	LAC (34

	DAC* TEMP1

	LAC SBMAP2

	DAC* DATALK	/FORWARD PTR.

	LAC SBMAP1

	JMS WDRIVE

/

/DO BLOCK 1775 NEXT.

/

	LAC HI.BLK

	DAC* DATABK

	LAC LOC.3	/USED AS TEMP STORAGE	

	DAC* WORD1	/BLOCKS LEFT OVER(MAX4-HI

	DZM* WORD2

	LAC SBMAP2

	JMP CLRDON

	.ENDC

	.ENDC

	.IFDEF	%RK05

	.TITLE	CLEAR THE DISK CARTRIDGE

/

/ THE BIT MAPS MUST NOW BE SET.  SWITCHES ARE SET UP DURING

/ ONCE ONLY CODE JUST FOR THE .CLEAR FUNCTION.

/

CLRBAK	LAW -1		/BACKWARD DATA LINK.

	DAC* BAKWRD

	LAC SBMAP2

	DAC* DATALK

	LAC DATABK

	TAD (73

	DAC TEMP1

	LAC (4

	DAC* WORD2	/4 BLKS OCCUPIED

	LAC WORD2	/SETUP THE POINTER TO THE FIRST 18 BIT

	IAC			/    DATA WORD IN THE FIST MAP.

	DAC ZFILL

	LAC L45ZS	/BLOCK 0 CAN NEVER BE USED FOR OUTPUT

	DAC* ZFILL

	LAC HI.BLK

	DAC* DATABK

	LAC (BITMAX

	DAC* WORD1

	LAC (34		/ONLY BLOCKS 1777, 1776 & 1775 ARE BUSY

	DAC* TEMP1	/WORD 73(8) BIT 4 & 5

	LAC SBMAP1

	JMS WDRIVE

	LAC (LFTOVR	/NOW DO 2ND UFD (BLOCK 1775)

	DAC* WORD1

	LAC HI.BLK

	DAC* DATABK

	DZM* WORD2

	DZM* TEMP1

	LAC SBMAP2	/NOW WRITE OUT 1775

CLRDON	JMS WDRIVE

	JMS GVBACK	/GIVE BACK DATA BUFFER

	JMP NORMXT

	.ENDC

	.IFDEF %RP02

	.IFUND	%RK05

	.TITLE 	CLEAR THE DISK PACK.

/

/THE MFD IS COMPLETE. NOW SET THE BIT MAPS.

/

CLRBAK	LAW -1

	DAC* BAKWRD	/BACKWARD LINK OF 1ST MAP IS -1.

	LAC TST.74	/INHIBIT IOPS74 CHECK.

	DAC UFD1	/SAVE THE INSTRUCTION.

	INC* WORD2	/BLOCK 0 IS ALWAYS BUSY.

	LAC WORD2

	IAC	

	DAC ZFILL	/POINT TO WORD3

	LAC L45ZS	/(400000)

	DAC* ZFILL	/BIT CORRESPONDING TO BIT 0.

	LAC BITFND	/AND INSERT (LAC TEMP1).

	DAC TST.74

	LAW -MAPNO+1	/NO OF MAPS -1.

	DAC UFD2

	LAC MAPTAB

	IAC			/SETUP MAP POINTERS.

	DAC LOC.4

	DAC LOC.5

/

/ALL POINTERS AND COUNTERS ARE SETUP.

/

C.LOOP	IDX LOC.5	/POINT TO NEXT MAP

	LAC (TOTALB	/WORD 0 OF ALL MAPS=TOTALB.

	DAC* DATABK

	LAC (BITMAX	/NO OF BITS PER MAP.

	DAC* WORD1

	INC* WORD2	/WORD2 IS DECREMENTED BY

	INC* WORD2	/SUBROUTINE OFFBIT.

	LAC* LOC.4	/THIS SUBMAP.

	DAC CSBMAP	/NEEDED BY 'OFFBIT'

	JMS OFFBIT

	LAC* LOC.5	/FORWARD LINK.

	DAC CSBMAP	/NEXT SUBMAP.

	DAC* DATALK

	LAC* LOC.4

	IDX LOC.4

WRTMAP	JMS WDRIVE	/WRITE OUT THE COMPLETED MAP.

	ISZ UFD2	/DONE WITH ALL WHOLE MAPS?

	JMP C.LOOP	/NO..KEEP LOOPING.

	.EJECT

/

/ALL THE WHOLE MAPS ARE DONE. DO THE LEFTOVERS.

/

LSTMAP	LAC (TOTALB	/ALL WORD0'S ARE SAME.

	DAC* DATABK	

	LAC (LFTOVR

	DAC* WORD1

	LAC (2

	DAC* WORD2

	LAC* LOC.4	/THIS SUBMAP.

	JMS OFFBIT	/CSBMAP ALREADY SETUP.

	LAC* LOC.4	/LAST SUBMAP.

	JMS WDRIVE.

/

/ALL SUBMAPS ARE COMPLETE EXCEPT THE ONE POINTING TO THE

/1ST MFD BLOCK. THE BIT CORRESPONDING TO THE MFD IS STILL

/OFF. USE OFFBIT TO TURN IT ON THEN RESTORE THE

/IOPS74 CHECK AND EXIT AT LAST!

/

C.MFDB	LAC (MFDBLK	/1ST MFD BLOCK.

	DZM CSBMAP	/NO SUBMAP IS IN.

	JMS OFFBIT

	LAC* WORD2	/DECREMENTED BY 'OFFBIT'

	TAD (2		/IT NEVER DID REFLECT THE

	DAC* WORD2	/TRUE COUNT.

	LAC BLOCK	/LAST BLOCK READ.

	JMS WDRIVE

	LAC UFD1

	DAC TST.74	/RESTORE IOPS74 CHECK.

CLRDON	JMS GVBACK	/GIVE BACK THE BUFFER.

	JMP NORMXT	/DONE AT LAST!!

	.ENDC

	.ENDC

	.ENDC

	.ENDC

	.TITLE (6)- .CLOSE

/

/IF INPUT,GIVE THE BUFFER BACK(IF THERE IS ONE) AND

/REMOVE ALL TRACES OF THIS FILE FROM THE BUSY TABLE.

/IF OUTPUT,WRITE AN END OF FILE LINE,THEN THE LAST

/DATA BLOCK WITH A LINK OF -1.  ANY UNUSED BLOCKS IN THE

/TEMP LIST MUST BE GIVEN BACK TO THE STORAGE ALLOCATION

/TABLE(SUBMAPS). IF THE RIB WILL FIT IN THE LAST BLOCK

/PUT IT IN AND GIVE BACK THE RIB BLOCK ALSO.

/WHEN ALL THE RIB PROCESSING FOR THE NEW FILE IS 

/COMPLETE DELETE THE OLD FILE IF ONE EXISTED.

/

CLOSE=.

	.IFDEF	RSX

	LAC	RENSW	/CHECK FOR RENAME IN PROGRESS

	DZM	RENSW	/CLEAR THE RENAME SWITCH

	SZA		/RENAME?

	JMP	RENCLO	/YES FINISH RENAME

	.ENDC

	.IFUND %LVERSION

	.IFUND %CVERSION

	LAC WREXSW

	SNA

	.IFDEF RSX

	JMP	UNBUSY

	.ENDC

	.IFUNDEF RSX

	JMP UNBUSY		/ NO DISK ACCESS REQUIRED	/EAG:150

	.ENDC

/

/IF EOF IS ON(NON0) THE USER HAS WRITTEN HIS OWN END

/OF FILE LINE. IF NOT THE TWO WORD LINE MUST BE WRITTEN.

/'WDSLFT' REPRESENTS THE # OF WORDS LEFT(2'S COMP)

/IN THE DATA BUFFER, IF 2 MORE WON'T FIT WRITE IT

/OUT AND DO THE EOF CODE.

/

	LAC L1		/AC=1

	TAD WDSLFT

	SMA		/.GT. 1?

	JMS SETWDR	/WON'T FIT WRITE IT.

MOVEOF	LAC EOF1

	DAC* DATAPT

	IDX DATAPT

	LAC EOF2

	DAC* DATAPT

	IDX DATAPT

	LAW -1

	DAC* DATALK

	INC FILSIZ	/COUNT DATA BLOCK ONLY.

	.EJECT

/

/THE EOF LINE HAS BEEN WRITTEN.'WDSLFT REPRESENTS THE NUMBER

/OF WORDS LEFT IN THE DATA BUFFER-2. IF 'FILSIZ'+1 WILL FIT

/MOVE IN THE USED RIB INFO THE WRITE OUT THE LAST DATA

/BLOCK.

/

EOFDON	DZM RIBWRD

FITTER	LAC WDSLFT	/WORD LEFT-2

	TAD (3		/(WDSLFT+2)-(FILSIZ+1)

	TAD FILSIZ

	DAC FITIND

	SZA!SMA		/IF POS IT WON'T FIT.

	JMP RNOFIT

/

/THE RIB INFO WILL FIT IN THE LAST DATA BLOCK.

/DATAPT IS POINTING THE THE FIRST WORD TO RECEIVE

/THE RIB INFO. DATABK-DATAPT=WORD IN LAST DATA

/BLOCK WHERE THE BLOCK LIST WILL LIVE.

/SAVE DATAPT AT TEMP4(CLOBBERED BY 'DRIVER')

/

SAVDPT	LAC DATAPT

	DAC TEMP4

	DZM WORD	/START TRANSFER AT WRD0.

	LAC DATABK

	TCA

	TAD DATAPT

	DAC RIBWRD	/BLOCK LIST WILL LIVE HERE.

GETLST	LAC FILSIZ	/#OF BLOCKS IN LIST.

	IAC			/ONE MORE FOR WORD0.

	TCA

	DAC NUMWDS	/READ IN THIS MANY.

	LAC	FRSTRB	/!!134!!FIRST RIB BLOCK #, IN CASE SECOND

/			/ALLOCATED (PLACED IN RIBBLK) BUT NOT USED.

/			/THIS LOGIC REDUCES XTRA 1  TO 0 BUT NOT

/			/XTRA 2 TO 1, I.E. THE SAVING AT 248 BLOCK

/			/FILE IS NOT GOT AT 248+254

	JMS DRIVER

	LAC DATAPT

	LAC (FRD	/READ FUNCTION.

/

/THE BLOCK LIST HAS BEEN STORED IN THE LAST DATA BLOCK.

/TEMP4 POINTS TO THE TRUE FILSIZ.

/

	LAC FILSIZ

	DAC* TEMP4

RNOFIT	LAC NXTBLK

	JMS WDRIVE

	.EJECT

/

/***COMPLETE ENTRY BY PUTTING IN FILE SIZE ***

/

PUTSIZ	LAC UFD1	/UFD BLOCK #.

	JMS RDRIVE

	LAC FILSIZ

	DAC SAVSIZ

	DAC* U.SIZ	/WORD 4 OF ENTRY.

	LAC* U.FBLK	/WORD 3 OF ENTRY.

	XOR L45ZS

	DAC* U.FBLK

	LAC* U.RIB

	DAC RIBSAV

	LAC NAME3

	DAC* U.EXT

/

/IF THE RIB INFO IS STORED IN THE LAST DATA BLOCK MAKE

/U.RIB CONTAIN THE LAST DATA BLOCK NUMBER.

/

	LAC FITIND

	SMA!SZA

	JMP INFPRO	/NO FIT,INSERT FILE PROTECT.

	LAC NXTBLK	/LAST DATA BLOCK#.

	DAC* U.RIB

INFPRO	LAC* U.RBWD	/PROTECTION ALREADY SET AT .ENTER.

	TAD RIBWRD

	DAC* U.RBWD

/

/THE ENTRY IS COMPLETE. IF THERE WAS AN OLD FILE

/AND IT LIVES IN THE SAME UFD BLOCK DELETE IT

/FROM THIS UFD BEFORE WRITING IT OUT.

/

SAME	LAC OLDSW	/WAS THERE AN OLD FILE?

	SNA		/YES IF NON 0

	JMP WRTUFD	/NO WRITE THE UFD OUT.

	LAC UFD1	/ARE THE BLK#S THE SAME?

	SAD OLDBLK	/OLD UFD BLOCK NO.

	JMP SAMUFD	/YES DON'T WRITE IT YET.

	JMS WDRIVE	/NO WRITE OUT THE NEW UFD.

	LAC OLDBLK

	DAC UFD1

	JMS RDRIVE	/READ IN OLD UFD BLOCK.

SAMUFD	LAC OLDFIL

	DAC UFD2	/WORD 0 OF ENTRY.

	JMS WIPOUT

	JMP UNUSED

WRTUFD	LAC UFD1

	JMS WDRIVE

/

/THE FILE HAS BEEN COMPLETELY CLOSED, THE OLD FILE HAS

/BEEN DELETED. THE ONLY OPERATION LEFT TO DO THAT REQUIRES 

/DISK ACCESSES IS THE BLOCK 'GIVE BACK' STUFF. THE 

/UNUSED BLOCKS IN THE LAST RIB MUST BE GIVEN BACK

/TO THE SAT. THE RIB BLOCK MAY BE GIVEN BACK ALSO IF

/THE BLOCK LIST INFO WAS STORED IN THE LAST DATA BLOCK.

/

UNUSED	LAC RIBSAV	/FIRST RIB BLOCK.

TRNRIB	DAC RIBBLK

	JMS RDRIVE	/READ IT IN.

	LAC* DATALK

	DAC RECEV1	/USED AT 'LSTMOV' IN 'WIPOUT'

	LAC* DATABK	/#OF BLOCKS DESC BY THIS RIB.

	TCA

	TAD SAVSIZ	/TRUE FILE SIZE.

	SNA

	JMP NO.UNU	/NO UNUSED BLOCKS!

	SPA		/THERE ARE MORE RIBS.

	JMP THISRB	/THIS IS THE RIB TO USE.

	DAC SAVSIZ

	LAC* DATALK	/NEXT RIB

	JMP TRNRIB

/

/THE COUNT IN THE AC REPRESENTS THE # OF BLOCKS

/TO GIVE BACK TO THE SAT.

/

THISRB	DAC TEMP9

	LAC SAVSIZ	/#OF GOOD BLOCKS TO KEEP.

	DAC* DATABK

	LAW -1		/THE FORWRD DATA LINK MUST BE

	DAC* DATALK	/SET TO -1 SO .DELET WORKS.

	LAC RIBBLK

	JMS OUTPUT

	LAC SAVSIZ

	TAD DATABK

	DAC DONOR1	/PT TO 1ST BLK TO GIVE

	LAC FITIND	/-1. USE THE -1 POSITION FOR

	SZA!SMA!CLA	/THE RIBBLK # (IF IN LAST DATA BLK)

	JMP KEPRIB	/DON'T RETURN RIB BLOCK #.

	LAC RIBSAV

	DAC* DONOR1

	SKP!CLC		/SUBR 1 FROM TEMP9.

KEPRIB	IDX DONOR1	/1ST BLOCK#

	TAD TEMP9	/AC WAS 0 OR -1.

	DAC FILSIZ	/SETUP THE WIPOUT ROUTINE.

	LAC (UNBUSY

	DAC WIPOUT

USEWIP	JMP LSTMOV

/

/THERE WERE NO UNUSED BLOCKS IN THE RIB. HOWEVER,

/THE RIB MAY HAVE TO BE GIVEN BACK.

/

NO.UNU	LAC FITIND

	SMA!SZA		/YES GIVE IT BACK

	JMP UNBUSY

	DZM CSBMAP	/SETUP THE OFFBIT ROUTINE.

	LAC RIBSAV	/RIB BLOCK #

	JMS OFFBIT

	LAC BLOCK	/SAT IS IN.

	JMS WDRIVE

/

	.ENDC

UNBUSY	JMS GVBACK

	.ENDC		/FROM L-VERSION

	.IFUND RSX

	LAC LOC.2

	DAC EXITAD

	.ENDC

	.IFDEF %LVERSION

	LAC UIC		/SAVE THE UIC FOR OLDTEST.

	DAC OLDUIC	/TO AVOID MFD ACCESS.

	.ENDC

	DZM CSLOT

CLRCUR	LAC CDESC	/CLEAR THE CURRENT SET.

	JMS ZERO

	LAW -NODESC

	JMP NORMXT

	.IFUND	RSX

	.TITLE (7)-.MTAPE

/

	.IFDEF %AVERSION

/MAGTAPE OPERATIONS:  .MTAPE A,XX

/		XX=00 REWIND TO LOAD POINT.

/		02 BACKSPACE RECORD.

/EXPANSION:

/LOC:  CAL+XX(5-8)+A(9-17)

/LOC+1:  7

/

/.MTAPE IS USED TO PERFORM FUNCTIONS UNIQUE TO NON-FILE-

/ORIENTED BULK STORAGE DEVICES.  IN GENERAL, THESE

/FUNCTIONS ARE INTENDED FOR MAGNETIC TAPE; TWO OF

/THE FUNCTIONS ARE IMPLEMENTED HERE THROUGH.

/REWIND:  INPUT AND OUTPUT MODES -- .CLOSE

/

/BACKSPACE:  INPUT MODE - MOVE POINTER BACK ONE ASCII LINE

/	     OUTPUT MODE - IOPS 7

/NOCHECKING IS PERFORMED FOR DUMP MODE FILES.

/

MTAPE	LAC SUBFUN	/IS IT A LEGAL COMMAND?

	SNA		/00=REWIND (.CLOSE)

	JMP CLOSE		/

	SAD (2		/IF IT'S NOT 02 IT'S ILLEGAL.

	SKP		/BACKSPACE: IT'S OK

	JMP IOPS6	/ILLEGAL CAL.

	LAC LOC.2	/LOC+2

	DAC EXITAD	/RETURN ADDRESS

	LAC WREXSW	/BACKSPACING AN OUTPUT FILE

	SZA		/ON DISK IS ILLEGAL

	JMP IOPS6	/ILLEGAL HANDLER FUNCTION.

/

/DATAPT IS POINTING TO THE CURRENT IOPS LINE.  A BACKSPACE

/WANTS TO GO BACK TO THE PREVIOUS LINE.  THE DATA STRUCTURE

/IS SUCH THAT A LINE ALWAYS STARTS AT THE TOP OF A DATA

/BLOCK.  IF WE START WORKING OUR WAY DOWN THE DATA BUFFER

/BY USING HEADER WORD PAIR COUNTS WE CAN FIND THE LINE

/WE WANT (BACKSPACE=CURRENT LINE-1).

/

/IF DATAPT=DATABK ALREADY, READ IN THE PREVIOUS BLOCK.

/IF THERE IS NO PREVIOUS BLOCK IGNORE THE BACKSPACE

/COMMAND COMPLETELY.

/

MAXSET	LAW -MAXBUF	/MAX DATA IN BLOCK.

	DAC WDSLFT

	DZM EOF		/USER MAY HAVE REACHED END.

	LAC DATAPT

	DAC WIPOUT	/PTR TO CURRENT LINE.

BACKSP	LAC DATABK

	SAD DATAPT

	SKP

	JMP CBLOCK	/STAY WITH CURRENT BLOCK.

	.EJECT

/IF THE BACKWARD DATA LINK IS TCAATIVE, NO BACKSPACING

/CAN BE DONE.IGNORE THE BACKSPACE AND EXIT TO USER.

/

	LAC* BAKWRD	/PREVIOUS BLOCK#.

	SPA

	JMP NORMXT	/NO PREVIOUS BLOCK#.

/

/START AT THE TOP OF THE DATA BLOCK.

/

	JMS RDRIVE	/READ & RESET DATAPT

	LAC DATAPT	/USE 'GETWPC' TO CHECK WORD-

CBLOCK	DAC TEMP1

	LAC* TEMP1	/IS WPC LEGAL?

	JMS GETWPC

/

/THE WORD-PAIR-COUNT (WPC) FROM THE DATA BUFFER IS

/LEGAL AND LIVING AT WPC.  WPC+TEMP1 POINTS TO

/THE NEXT RECORD.  IF THE SUM PTS TO 0 TEMP1 IS

/POINTING TO THE DESIRED LINE.  IF THE SUM IS

/EQUAL TO OR GREATER THAN BAKWRD TEMP1 IS

/POINTING TO THE DESIRED LINE.

/

	LAC WPC

	TAD TEMP1

	SAD WIPOUT	/PREVIOUS LINE POINTER

	JMP RITLIN

	SAD BAKWRD

	JMP RITLIN	/DATAPT IS POINTING TO RIGHT LINE.

	DAC TEMP2	/SAVE THE SUM.

	LAC* TEMP2	/IS IT POINTING TO NULL AREA?

	SNA

	JMP RITLIN	/POINTING TO HDR OF 0,

	LAC TEMP2			/

	TCA

	TAD BAKWRD

	SPA

	JMP RITLIN

	LAC WPC		/THIS IS HERE FOR THE USER WHO

	TAD WDSLFT	/IS MIXING MODES(DUMP,ASCII)

	DAC WDSLFT	/NO OF WORDS LEFT IN BUFFER.

	LAC TEMP2	/SUM OF WPC AND TEMP1.

	JMP CBLOCK	/KEEP LOOKINK.

RITLIN	LAC TEMP1	/BACKSPACING ALL DONE

	DAC DATAPT	/AND READY FOR READING

	JMP NORMXT

/

	.ENDC

	.ENDC

	.TITLE (10)-READ

/

/WHEN A .READ (NON-DUMP MODE) HAS BEEN COMPLETED,

/THE USER PROGRAM SHOULD INTERROGATE BITS 12 AND 13

/OF THE FIRST WORD OF THE LINE BUFFER HEADER.

/THE FIRST OP OF THE READ  CHECKS THE EOF SWITCH.

/IF ON, NO MORE DATA EXISTS THE CALL IS IGNORED.

/IF NOT, GET THE USER'S LINE BUFFER

/HEADER AND VALIDATE IT AT 'SETUP'.

/

	.IFUND	RSX

READ	LAC EOF		/EOF SWITCH SET?

	SZA

	JMP IGNORE	/YES - IGNORE CALL

	LAC* LOC.3	/IS THE USER BUFF SIZE 0?

	.ENDC

	.IFDEF	RSX

READ	JMS	ADJ	/ADJUST PARAMETERS

	LAC	EOF	/EOF SWITCH SET?

	SZA

	JMP	IGNORE	/YES - IGNORE CALL

	LAC	11,X	/IS THE USER BUFFER SIZE 0?

	.ENDC

	SZA		/YES IGNORE THE CALL(NOP).

	JMP WC.OK	/NO WORD COUNT IS OK.

	.IFUND	RSX

	LAC LOC.4	/USER RETURN ADDRESS.

	DAC EXITAD

	.ENDC

	JMP NORMXT	/EXIT BACK TO USER.

WC.OK	LAC DATAPT	/BUF HEADER POINTER

	JMS SETUP	/READ/WRITE COMMON SETUP,

	.IFUND	RSX

	LAC* LOC.2	/XCT'ED BY SETUP.

	JMP RDUMP1	/DUMP MODE INPUT

	.ENDC

	.IFDEF	RSX

	LAC*	(R3)	/PICK UP THE STARTING ADDRESS OF I/O

	NOP		/DUMP NOT IMPLEMENTED

	.ENDC

/

/RETURN HERE FOR IOPS OR IMAGE MODES

/

	JMS LINFIT	/USE LINFIT TO TCAATE?

	NOP		/THE WPC.

/TRANSFER AS MUCH DATA TO THE USER AS HIS LINE-BUF

/WILL HOLD UNTIL WPC OVERFLOWS OR DATA RUNS OUT.

/

	.IFUND	RSX

	DZM* CKSMPT	/CHECKSUM PTR IN DATA BUFF.

	.ENDC

	.IFDEF	RSX

	DZM	1,X	/CHECKSUM POINTER IN DATA BUFFER MUST BE CLAAR.

	.ENDC

	DZM FLAG	/CLEAR LINE ERROR FLAG.

FILLIN	JMS PWORDS	/SUBR TO PASS WORDS.

	SKP		/SHORT LINE EXIT.

	JMP ENDIN1	/LINE ALMOST DONE.

/

/THE USER'S SHORT LINE HAS BEEN FILLED. THE DATA

/LINE IS POINTING TO MORE DATA FOR THE SAME LINE

/THIS DATA MUST BE PASSED OVER AND THE CKECKSUM 

/COMPUTED AS WELL SO THAT THE NEXT READ REQ

/DOES NOT START IN THE MIDDLE OF THE PREVIOUS LINE.

/

	LAC ENDPT	/FUDGE PWORDS RET ADDR.

	DAC PWORDS

	LAC DONOR1	/FIX SO THAT NO WORDS

	DAC RECEV1	/ARE TRAN TO USER LINE.

MINUS1	LAW -1		/PASS THE REST AT PWORDS+1

	DAC FLAG	/SET SHORT LINE FLAG.

	JMP PASLUP	/USERWC CAN'T OVERFLOW.

/

/READ DRIVER SUBROUTINE.

/THE AC HAS THE BLOCK # ARG TO DRIVER AS THE ARGUMENT.

/

RDRIVE	0

	DZM WORD	/TRANSFER STARTING AT WORD 0.

	JMS DRIVER	/INPUT BLOCK TRANSFER.

	LAC DATABK	/ADDRESS TO STORE BLOCK.

	LAC (FRD	/INPUT DIRECTION

	JMP* RDRIVE	/RETURN AT COMPLETION OF I/O.

	.IFUND	RSX

/

/DUMP MODE READ.

/

RDUMP1	LAC WDSLFT	/WORDS LEFT IN DATA BUFFER.

	DAC WPC		/SET FOR PWORDS.

	JMS PWORDS	/PASS DATA TO LINE BUFFER.

	JMP NORMXT	/USER CALL SATISFIED.

			/WPC OVERFLOWED,BUFFER EXPIRED.

	LAC* DATALK	/GET THE NEXT BLOCK IF THERE

	SPA		/IS ONE,IF NOT ITS AN END OF

	JMP REDEOF	/FILE (FLAGGED BY NXT READ)

	JMS RDRIVE	/MORE DATA BLOCKS LEFT

	LAC DATAPT	/AND MORE DATA TO GIVE TO 

	DAC DONOR1	/THE USER'S LINE BUFFER.

	ISZ USERWC	/DID THE ARG # OF WORDS

	JMP RDUMP1	/END EXACTLY AT THE END

	JMP NORMXT	/OF THE DATA BLOCK?YES IF OVFLO.

	.ENDC

	.TITLE 	END INPUT LINE ROUTINE.

/

/THE NON DUMP MODE TRANSFER IS COMPLETE.

/NEXT, SET THE USER HEADER IF ERRORS OCCURRED.

/THE ERRORS ARE FLAGGED IN THE USER HEADER AT

/BITS 12 AND 13: 	00=DATA CORRECT

/			01=PARITY ERROR

/			10=CHECKSUM ERROR

/			11=SHORT LINE.

ENDPT	ENDIN1-1		/FOR L-HANDLER.

/

/

ENDIN1	LAC RECEV2	/PTR TO WRD0 OF LINE.

	.IFDEF	RSX

	TAD	XADJ	/SET UP TO USE XR

	PAX

	LAC	RECEV2	/SET UP POINTER TO WORD ZERO AGAIN

	.ENDC

	IAC	

	DAC RECEV1	/CHECKSUM POINTER.

	LAC SAVSUM	/SAVED CHECKSUM.

	.IFUND	RSX

	DAC*	CKSMPT

	DAC* RECEV1

	LAC* RECEV2	/WORD 0 OF USER HEADER

	.ENDC

	.IFDEF	RSX

	DAC	1,X

	LAC	0,X

	.ENDC

	AND (7

	SAD (5		/EOF?

	JMP REDEOF	/YES

	ISZ FLAG	/SHORT LINE FLAG SET

	JMP ENDIN2	/NO

	LAC (60

	JMS SETVAL	/SET D.V. BITS FOR SHORT LINE

ENDIN2	LAC PARITY	/PARITY RETRY COUNT.

	SMA!CLA

	JMP RDPERR	/SET D.V. BITS=PARITY

/

/IF BIT 0 OF WORD0 OF THE HEADER WORD PAIR IS ONE

/THE CHECKSUM CAN BE IGNORED. THE 'CKSUM' FOR

/THIS LINE WAS SET BY 'SETUP'.THE ORIGINAL IS 

/ALWAYS IN 2'S COMP. WHEN ALL THE DATA WORDS

/ARE ADDED TO IT A RESULT OF 0 SHOULD BE 

/PRODUCED, OTHERWISE THE LINE HAS A PARITY ERROR.

/

	.IFUND	RSX

	LAC* RECEV2	/HEADER, WD 0

	.ENDC

	.IFDEF	RSX

	LAC	0,X

	.ENDC

	SPA

	JMP CKNXTB	/IGNORE CKSUM ALREADY SET

	LAC CKSUM

	SNA		/SET D.V. BITS=CKSUM ERROR

	JMP CKNXTB

	LAC (20		/CHECKSUM ERR. IN LINE, 12,13=10

RDPERR	TAD (20		/PARITY ERROR IN A BLOCK 12,13=01

	JMS SETVAL

	.EJECT

/

/THE ERROR CHECKING AND SETTING IS NOW COMPLETE.

/'DATAPT' IS POINTING TO THE NEXT LINE, IF IT 

/POINTS TO 0 ,NO MORE DATA EXITS IN THIS BLOCK.

/IF THERE IS NO MORE DATA CHECK FOR END OF DATA.

/SET THE END-OF-FILE SWITCH IF NOBLOCKS LEFT

/IN THIS FILE.

/

CKNXTB	LAC DATAPT	/DID IT END EXACTLY AT

	SAD BAKWRD	/THE BACKWARD DATA LINK?

	JMP BKEMTY	/YESS GET NEXT DATA BLOCK.

	LAC* DATAPT	/ANYTHING LEFT?

	SZA!CLC

	JMP NORMXT	/NORM EXIT

	SAD* DATALK	/DATA LINK= -1?

	JMP REDEOF	/YES END OF FILE.

BKEMTY	LAC* DATALK	/THE BLOCK IS EMPTY BRING 

	JMS RDRIVE	/IN THE NEXT ONE

	JMP NORMXT

/

/THE ONLY TIME CONTROL GOES TO 'IGNORE' IS WHEN THE

/USER DOES A 'READ' WHERE THE PREVIOUS

/READ WAS AN EOF.

/

	.IFUND	RSX

IGNORE	LAC* LOC.2	/ADDR OF USER BUFF

	.ENDC

	.IFDEF	RSX

IGNORE	LAC*	(R3)	/PICK UP THE STARTING ADDRESS OF THE I/O

	TAD	XADJ	/ADD THE XR ADJUSTMENT

	PAX		/SAVE IT IN XR

	.ENDC

	DAC EOF

	LAC EOF1	/EOF HEADER

	.IFUND	RSX

	DAC* EOF	/WORD0 OF USER BUFF.

	IDX EOF

	LAC EOF2

	DAC* EOF

	LAC LOC.4

	DAC EXITAD

	.ENDC

	.IFDEF	RSX

	DAC	0,X	/SET UP THE END OF FILE HEADER

	TCA

	DAC	1,X	/SET THE CHECKSUM ALSO

	.ENDC

REDEOF	DAC EOF

	JMP NORMXT

/

/SUBR. TO SET DATA VALIDITY BITS

/

SETVAL	0

	DAC TEMP1	/SAVE MASK

	.IFUND	RSX

	LAC* RECEV2	/MASK ALL BUT BITS 0, 12,13

	.ENDC

	.IFDEF	RSX

	LAC	0,X

	.ENDC

	AND (777717

	XOR TEMP1

	.IFUND	RSX

	DAC* RECEV2	/HEADER, WD0

	.ENDC

	.IFDEF	RSX

	DAC	0,X

	.ENDC

	JMP* SETVAL

/

/SUBROUTINE FIT COMPARES THE USER LB AND THE ACTUAL

/WORD PAIR COUNT AND TCAATES WPC.

/

LINFIT	0

	LAC WPC

	TAD USERWC

	SNA!SPA

	IDX LINFIT

	LAC WPC

	TCA

	DAC WPC

	JMP* LINFIT

	.TITLE 	READ/WRITE COMMON SETUP.

/

/.READ, .WRITE COMMON SETUP SUBR.

/CALLING SEQ:

/LOC-1	LAC* ADDR	/PTR TO ARG BUFFER.

/LOC	JMS SETUP	/SUBR CALL.

/LOC+1	LAC ADDR	/RECEIVER L.B.

/LOC+2	XX		/ DUMP MODE EXIT 

/LOC+3	XX		/NON DUMP MODE EXIT.

/

SETUP	0

	DAC DONOR1	/HEADER POINTER.

	DAC DONOR2	/WORKING DATA POINTER.

	DAC CKSMPT	/DONOR CHECKSUM PTR.

	.IFUND	RSX

	LAC LOC.4

	DAC EXITAD

	IDX CKSMPT

	LAC* CKSMPT	/ACTUAL CKSM.

	.ENDC

	.IFDEF	RSX

	PXL		/SAVE XR IN LR

	TAD	XADJ	/ADD XR ADJUSTMENT TO ADDRESS

	PAX		/PUT IT IN XR

	LAC	1,X	/PICK UP CHECKSUM

	PLX		/RESTORE XR

	.ENDC

	DAC CKSUM

	DAC SAVSUM	/SAVE THE USERS CHECKSUM.

	LAC SKNTSW	/WAS A SEEK/ENTER EXECUTED?

	SNA

	JMP IOPS11	/.SEEK, .ENTER NOT EXECUTED ()

	XCT* SETUP	/GET RECEIVER ADDR.

	DAC RECEV1

	DAC RECEV2

	LAC*	LOC.2	/GET USER BUFFER STARTING ADR. (BR-149)
	AND (700000)		/(RCHM-156 IS BUFFER START BEYOND 32K?
	SZA			/(RCHM-156) 0 => NO.
	JMP	IOPS67	/ERROR-GREATER THAN 32K (BR-149)

	IDX SETUP	/PT TO DUMP MODE EXIT.

	.IFUND	RSX

	LAC* LOC.3	/USER WC

	.ENDC

	.IFDEF	RSX

	LAC	11,X

	.ENDC

	DAC USERWC

	.IFUND	RSX

	LAC SUBFUN	/DUMP MODD?

	SAD (4

	JMP	SETD	/DUMP MODE (BR-149)

	LAC* DONOR1	/COMPUTE W.C. FROM L.B.H. W.P.C

	.ENDC

	.IFDEF	RSX

	LAC	DONOR1	/SET UP TO ACCESS DONOR

	TAD	XADJ	/ADD XR ADJUSTMENT

	PAX		/XR DOSE NOT HAVE TO BE SAVED

	LAC	0,X	/PICK UP THE DONOR

	.ENDC

	IDX SETUP	/IOPS, IMAGE EXIT

	JMS GETWPC	/GET AND TEST WPC.

	JMP* SETUP	/SETUP ALL DONE.

SETD	LAC*	LOC.3	/GET -WDC (BR-149)

	TCA		/MAKE POSITIVE (BR-149)

	TAD*	LOC.2	/ADD BUFFER START (BR-149)
	AND (700000)		/(RCHM-156) WILL BUFFER EXTEND  ABOVE 32K
	SNA			/(RCHM-156) 0 => BELOW 32K.
	JMP*	SETUP	/BUFFER OK-RETURN (BR-149)
	JMP	IOPS67	/BUFFER BAD - ERROR (BR-149)

	.EJECT

/

GETWPC	0

	JMS RIGHT8

			/FROM HEADER TO 'WPC'.

	AND (776

	DAC WPC		/T. STORE L.B.W.P.C.

	SNA

	JMP IOPS23	/ILLEGAL WORD PAIR COUNT

/

	AND (400

	SNA!CLA

	JMP* GETWPC	/L.B.W.C. INAC

	JMP IOPS23

/SUBR. TO ADD TO CHKSUM AND INDEX COUNTS

/AND TO PASS WORDS FROM THE USER TO OR FROM 

/THE DATA BLOCK.

/

PWORDS	0

	.IFUND	RSX

PASLUP	LAC* DONOR1	/DONOR

	DAC* RECEV1	/RECEIVER

	.ENDC

	.IFDEF	RSX

	LAC	DONOR1	/MOVE WITH 17 BIT ADDRESS

	AAC	-1	/SUBTRACT 1 FOR AUTO XR'S

	DAC*	(X10)	/SET IT IN AUTO XR

	LAC	RECEV1	/SET UP THE RECEVER ALSO

	AAC	-1

	DAC*	(X11)

PASLUP	LAC*	X10

	DAC*	X11

	.ENDC

	TAD CKSUM

	DAC CKSUM

	ISZ WDSLFT	/2'S COMP OF WORDS LEFT.

NOPLIT	NOP		/(IN CASE OF OVFLO)

	IDX DATAPT	/INDEX DOWN DATA BLOCK.

	IDX DONOR1	/NEXT POINTER.

	IDX RECEV1	/NEXT RECEIVER.

	ISZ WPC		/DONOR DONE?

	SKP		/NO TRY RECEIVER.

	JMP DONORD

	ISZ USERWC

	JMP PASLUP	/PASS NEXT WORD.

	JMP* PWORDS

DONORD	IDX PWORDS

	JMP* PWORDS

/

/SUBROUTINE MOVER MOVES N WORDS FROM 

/TEMP1 TO TEMP2

/

MOVER	0

	DZM TEMP15

	DAC COUNT

MOVERL	LAC* TEMP1

	DAC* TEMP2

	IDX TEMP1

	IDX TEMP2

	SZA		/LOOK FOR NULL NAMES.

	SET TEMP15

	ISZ COUNT

	JMP MOVERL	/MOVER LOOP.

	JMP* MOVER

RIGHT8	0

	RTR

	RTR

	RTR

	RTR

	JMP* RIGHT8

LEFT8	0

	RTL

	RTL

	RTL

	RTL

	JMP* LEFT8

	.IFUND	RSX

	.ENDC

	.TITLE	(11)-WRITE

/

	.IFUND %CVERSION

	.IFUND %LVERSION

/

/IF A .ENTER WAS EXECUTED THE WRITE EXECUTED SWITCH'WREXSW'

/IS NON 0. IF ITS 0 TERMINATE WITH IOPS11.

/

WRITE	LAC WREXSW	/WAS A .ENTER EXEC?

	SNA		/YES IF NON 0.

	JMP IOPS11	/NO..TERMINATE.

	.IFUND	RSX

	LAC* LOC.2

	.ENDC

	.IFDEF	RSX

	PXA	/SAVE THE XR

	DAC	XRSV

	LAC	DPNODE	/SET UP THE VXAJ REQUEST

	DAC*	(R2)

	LAC	10,X	/CHECK THE FIRST WORD

	DAC*	(R3

	DAC	SAVAD	/SAVE THE ADDRESS OF THE UNRELOCATED I/O

	CLA!IAC		/CHECK ONLY 1 WORD

	DAC*	(R4)

	JMS*	(VXAJ)	/THE HEADER

	JMP	IOPS30	/INVALID EVENT VARIABLE -30

	LAC*	(R3)	/PICK UP THE ADJUSTED ADDRESS

	TAD	XADJ	/SET IT UP FOR XR

	PAX

	LAC	0,X	/PICK UP THE USER'S FIRST WORD

	SWHA		/TO FIND OUT HOW MANY WORDS TO BE

	AND	(177)	/TRANSFERRED

	CLL!RAL		/MULTIPLY BY 2

	DAC*	(R4)

	LAC	SAVAD	/PICK UP THE I/O ADDRESS AGAIN

	DAC*	(R3)	/SET IT IN R3 TO BE UPDATED AGAIN

	JMS*	(VXAJ)	/VERIFY AND ADJUST AGAIN

	JMP	IOPS30	/ILLEGAL REQUEST

	LAC	XRSV	/RESTORE XR

	PAX

	LAC*	(R3)	/PICK UP THE I/O ADDRESS

	.ENDC

	JMS SETUP

	LAC DATAPT	/RECEIVER (DATA BUFFER).

	.IFUND	RSX

	JMP WDUMP1	/DUMP MODE WRITE.

	.ENDC

	.IFDEF	RSX

	NOP

	.ENDC

/RETURN HERE FOR IOPS OR IMAGE MODES.

/

/FIND OUT IF THIS LINE WILL FIT IN THE DATA

/BUFFER.  IF IT DOES, USE PWORDS TO MOVE IT IN,

/IF NOT, WRITE OUT THE EXISTING DATA BLOCK

/

/THE USERWC IS NOT USED WHEN OUTPUTTING IOPS ASCII.

/INSTEAD THE NO OF WORDS LEFT IN THE BUFFER IS USED.

/

	.IFUND	RSX

	LAC* DONOR1	/WORD 0 OF USER'S LINE

	.ENDC

	.IFDEF	RSX

	LAC	0,X

	.ENDC

	AND (777740

	.IFUND	RSX

	XOR SUBFUN

	.ENDC

	.IFDEF	RSX

	DAC	STATUS	/SAVE AC TEMP

	PXA		/SAVE THE XR

	DAC	XRSV

	PLX		/RESTORE THE SAVED XR POINTING TO THE NODE

	LAC	STATUS	/RESTORE THE AC

	XOR	7,X	/MASK IN THE FUNCTION CODE

	DAC	STATUS	/SAVE THE STATUS AGAIN

	LAC	XRSV	/RESTORE THE XR

	PAX

	LAC	STATUS	/RESTORE THE AC

	DAC	0,X

	.ENDC

	.IFUND	RSX

	DAC* DONOR1

	.ENDC

	LAC WDSLFT

	DAC USERWC

	JMS LINFIT	/WILL THE LINE FIT?

	JMP NOFIT	/NO, GET RID OF DATA BLOCK.

	.IFUND	RSX

AWORDS	DZM* CKSMPT	/CLEAR CHECKSUM FROM L.B.

	.ENDC

	.IFDEF	RSX

AWORDS	DZM	1,X

	.ENDC

	DZM CKSUM	/BUILD CHECKSUM

	JMS PWORDS	/PASS THE WORDS.

	NOP		/CONTROL NEVER GETS HERE.

	.EJECT

/

/THE IOPS TRANSFER IS COMPLETE. LOOK AT THE LINE AGAIN

/AND SET THE EOF SWITCH IF THIS WAS AN END OF FILE LINE.

/ALSO STORE THE 27S COMP OF THE CHECKSUM JUST BUILT.

/

	LAC CKSUM	/2'S COMP OF CHECKSUM.

	TCA

	IDX RECEV2	/2ND WORD OF RECEIVER

	DAC* RECEV2

	.IFUND	RSX

	LAC* DONOR2	/WORD0 OF LINE.

	.ENDC

	.IFDEF	RSX

	LAC	0,X	/WORD 0 OF THE LINE

	.ENDC

	AND (7

	SAD (5

	DAC EOF		/SET EOF SWITCH FOR SLOT.

	JMP NORMXT	/END OF FUNCTION.

/

/THE CURRENT IOPS LINE WILL NOT FIT IN THE EXISTING 

/DATA BUFFER. PUT IN THE LINK TO COMPLETE THE LINE

/AND WRITE IT OUT.

/

	.IFUND	RSX

NOFIT	JMS SETWDR

	LAC DATAPT

	DAC RECEV2

	DAC RECEV1

	LAC WDSLFT

	DAC USERWC

	JMP AWORDS	/PASS ASCII WORDS.

	.ENDC

	.IFDEF	RSX

NOFIT	PXA		/SAVE XR WHILE DOING I/O

	DAC	XRSV

	JMS	SETWDR	/WRITE THE BLOCK AND GET ANOTHER

	LAC	XRSV	/RESTORE XR

	PAX

	LAC	DATAPT	/RESET THE BUFFER POINTERS

	DAC	RECEV2

	DAC	RECEV1

	LAC	WDSLFT	/RESET THE WORDS LEFT COUNT

	DAC	USERWC	/IN THE USER WORD COUNT

	JMP	AWORDS	/PASS ASCII WORDS.

	.ENDC

	.IFUND	RSX

/DUMP MODE WRITE. NO TEST HAS BEEN MSDE TO DETERMINE

/WHETER OR NOT THIS LINE WILL FIT IN THE EXISTING

/SPACE IN THE DATA BUFFER.

/

WDUMP1	LAC USERWC	/ARG WORD COUNT 0?

	SNA		/IF YES IGNORE CALL(NOP).

	JMP NORMXT

	LAC WDSLFT	/NO OF WORDS LEFT IN BUFF.

	DAC WPC		/USED BY PWORDS.

	JMS PWORDS	/PASS FROM LINE BUFFER.

	JMP NORMXT	/CALL SATISFIED,EXIT.

			/DATA BLOCK COMPLETELY FULL.

	JMS SETWDR	/WRITE THE FULL BLOCK.

	LAC DATAPT	/TOP OF FREED UP BLOCK.

	DAC RECEV1	/READY FOR MORE DATA.

	ISZ USERWC	/DID LINE FINISH EXACTLY AT

	JMP WDUMP1	/END OF LAST BLOCK?

	JMP NORMXT	/YES WRITE COMPLETE,EXIT.

	.ENDC

	.EJECT

/SUBROUTINE TO SET UP THE WRITE DRIVER CALL.

/GET THE NEXT BLOCK NUMBER FROM THE TEMP BLOCK LIST

/BELOW THIS SLOT'S CURRENT SET AND STORE IT AS THE 

/400TH WORD OF THIS DATA BLOCK. THAT COMPLETES IT 

/WRITE OUT THE BLOCK.

/

SETWDR	0

	JMS GETNXT	/GET THE NEXT BLOCK.

	DAC* DATALK	/400TH WORD.

	.IFUND	RSX

	DAC DISPCH	/SAVE IT FOR NXTBLK.

	.ENDC

	.IFDEF	RSX

	DAC	DISPCA

	.ENDC

	LAC NXTBLK

	DAC PWORDS	/SAVE FOR BAKWRD.

	SPA

	JMP IOPS15	/NO MORE LEFT.

	JMS WR.OUT	/WRITE AND CLEAR BUFFER.

	INC FILSIZ

/

/THE DATA BLOCK IS NOW AVAILABLE FOR USE. IF THE TEMP

/BLOCK LIST HAS BEEN EXPIRED. SAVE THE LINK AS THE

/NEXT BLOCK NUMBER TO WRITE. IF THE BLOCK LIST HAS BEEN

/EXPIRED,GET MORE BLOCKS FROM THE BIT MAPS. IF THERE ARE NO

/MORE TERMINATE WITH IOPS 15.

/

	.IFUND	RSX

	LAC DISPCH	/PREVIOUS BLOCKS DATA LINK

	.ENDC

	.IFDEF	RSX

	LAC	DISPCA

	.ENDC

	SAD MINUS1		/FULL???

	JMP IOPS15	/YES.DISK IS FULL.

	DAC NXTBLK	/CURRENT BLOCK TO FILL.

	LAC BLKLFT	/ANY BLOCKS LEFT IN

	SZA		/THE TEMP LIST?

	JMP* SETWDR	/YES..ALL DONE EXIT.

/

/THE BLOCK LIST HAS EXPIRED. FILL IT UP AND

/CONTINUE BUILDING THE RIB.

/

MORBLK	JMS LSTFIL	/FILL THE LIST.

	LAC BLKLFT	/ANY BLOCKS PUT IN?

	SNA		/YES IF NON 0.

	JMP DSKFUL	/NO DISK IS FULL!

	JMS BLDRIB	/YES BUILD RIB.

SETBAK	LAC PWORDS	/RESET THE BAKWRD LINK.

	DAC* BAKWRD

	JMP* SETWDR	/ALL DONE EXIT.

DSKFUL	LAW -1		/SETUP THE TEMP LIST SO

	DAC* NXTLST	/THE NEXT SETWDR CALL WILL

	JMP SETBAK	/AN IOPS 15.

/WRITE DRIVER SUBROUTINE. BLOCK # IN AC.

/THIS WRITE CANNOT FAIL. A BIT MAP,RIB,UFD, OR MFD

/IS BEING WRITTEN. 

/

WDRIVE	0

	DZM WORD	/TRANSFER STARTING AT WORD 0.

	DAC RDRIVE

	JMS OUTPUT

OUTOK	JMS ZFILL	/CLEAR THE BUFFER.

	LAC DATABK	/CLEAR IT TO 0.

	DAC TEMP2

	LAC RDRIVE	/PREV DATA BLOCK.

	DAC* BAKWRD

	JMP* WDRIVE

/WRITE ON DISK BUT DON'T CLEAR THE BUFFER AFTERWARDS.

/

OUTPUT	0

	DAC TEMP16

	.IFUND %RB09

	LAC WRCHEK	/SAVE USER'S ARG WRITE CHECK.

	DAC SAVWRC

	SET WRCHEK

	LAC TEMP16

	.ENDC

	JMS DRIVER	/BLOCK# IN AC ON CALL.

	LAC DATABK	/WORD 0 OF 400 WORD BLOCK.

	LAC (FWR	/WRITE FUNCTION

	.IFUND %RB09

	LAC SAVWRC	/RESTORE USER WRITE CHECK.

	DAC WRCHEK

	LAC PARITY	/DID IT FAIL.

	SNA		/NO IF NON 0.

	JMP IOPS61	/YES..DIRECTORY TYPE INFO IS BAD.

	JMP* OUTPUT

/

/THE ONLY WRITE THAT DOES NOT FORCE WRITE CHECKING.

/

WR.OUT	0

	DZM WORD

	DAC RDRIVE

	JMS DRIVER

	LAC DATABK

	LAC (FWR	/WRITE FUNCTION.

	LAC WR.OUT	/USE WDRIVE STUFF.

	DAC WDRIVE

	JMP OUTOK

	.ENDC

	.IFDEF %RB09

	JMP* OUTPUT

WR.OUT=WDRIVE

	.ENDC

	.ENDC

	.ENDC

	.IFUND	RSX

	.TITLE	(12)- .WAIT, .WAITR

/

/THE WAIT(R)  FUNCTION DOES NOT GO 

/ THROUGH THE DISPATCH TABLE.  A .WAITR FUNCTION IS

/THE ONLY ACCEPTABLE ONE THAT CAN BE PROCESSED WHILE SOME

/I/O IS UNDERWAY.

/

/LOC	CAL+SUBFUNCTION+DAT SLOT

/LOC+1	12

/LOC+2	ADDRESS TO RECEIVE CONTROL IF WAITR AND DAT IS BUSY

/LOC+3	NORMAL 'NOT BUSY' EXIT

/

/LOC+2 IS THE NORMAL EXIT IF THIS IS NOT A .WAITR AND THE DAT

/SLOT IS NOT BUSY.  IF THE SLOT IS BUSY, CONTROL IS GIVEN

/BACK TO THE USER AT 'LOC' WHERE THE CAL IS EXECUTED AGAIN UNTIL

/THE 'I/O UNDERWAY' FLAG 'IOUND'=0 OR IS NOT BUSY.

/THE I/O UNDERWAY FLAG IS TESTED AT 'TSTIOU' IF NON0

/CONTROL DOES NOT COME BACK TO THE WAIT ROUTINE BUT

/IMMEDIATELY EXITS TO THE ADDRESS POINTED TO BY 'CALPTR'.

/AT ENTRY TO 'WAITS' ARGPTR=LOC+2, CALPTR=LOC

/
WAITS	LAC B.5678	/SUBFUNCTION IS NON 0 IF WAITR

	SNA	 	/YES

	JMP TSTBSY	/NO...GO TO THE BUSY TEST

/

/THIS IS A WAITR.  FUDGE CALPTR TO POINT TO THE ADDRESS

/SPECIFIED BY THE USER AT LOC+2.  IF THIS SLOT IS BUSY

/CONTROL WILL GO THERE BY CALLING THE 'TSTIOU' ROUTINE.

/OTHERWISE THIS SLOT IS NOT BUSY, USE THE NORMAL

/EXIT FOR .WAITR.

/
	LAC CALPTR	/(RCHM-156) SAVE LINK , MODE, ETC FROM ENTRY
	XOR* ARGPTR	/(RCHM-156) AND COMBINT THEM WITH RETURN ADDRESS
	AND (700000)	/(RCHM-156) POINTED TO BY ARGPTR.
	XOR* ARGPTR	/(RCHM-156)
	DAC CALPTR
	IDX ARGPTR	/POINT TO LOC+3(GO THERE IF NOT BUSY).

TSTBSY	JMS TSTIOU	/IS THIS SLOT BUSY ALREADY?

	DBR		/NO.  IF CONTROL COMES BACK

	JMP* ARGPTR	/LOC+2 IF WAIT, LOC+3 IF WAITR

	.ENDC

	.TITLE	(13) .TRAN ROUTINE

/

	.IFUND %NOTRN

/THE .TRAN ROUTINE DOES NOT REQUIRE A BUFFER.

/DATA IS TRANSFERRED DIRECTLY FROM THE USER AREA TO

/THE DISK.

/

/ALL TRANSFERS START AT WORD 0 OF A 256 WORD DATA BLOCK.

/

/LOC	CAL+D(7-8)+A(9-17)

/LOC+1	13	

/LOC+2	B	/16-BITS OF BLK #

/LOC+3	L

/LOC+4	-W

/

	.IFUND	RSX

TRAN	LAC LOC.5

	DAC EXITAD

	.ENDC

	.IFDEF	RSX

TRAN	PAL		/SAVE DIRECTION 30 GET -- 31 PUT

	.ENDC

	DZM CSLOT

	.IFUND	RSX

	LAC* LOC.4	/USED BY DRIVER.

	.ENDC

	.IFDEF	RSX

	LAC	11,X	/PICK UP THE NUMBER OF WORDS

	TCA		/GET TCA

	.ENDC

	DAC NUMWDS

	.IFUND	RSX

	SNA		/IF WORD COUNT=0 (NOP)

	JMP NORMXT

	LAC SUBFUN	/INPUT OR OUTPUT

	SNA

	.ENDC

	.IFDEF	RSX

	JMS	ADJ	/ADJUST PARAMETERS

	PLA		/PICK UP THE FUNCTION

	SAD	(30)	/IS IT A READ?

	.ENDC

	JMP INTRAN

	LAC (FWR

TRANIO	DAC TEMP2

	.IFUND	RSX

	LAC* LOC.2	/LOC+2 BLK #.

	.ENDC

	.IFDEF	RSX

	LAC	7,X	/PICK UP THE STARTING BLOCK

	.ENDC

	DZM WORD	/TRANSFER STARTING AT WORD 0.

	JMS DRIVER

	.IFUND	RSX

	LAC* LOC.3	/L ADDRESS.

	.ENDC

	.IFDEF	RSX

	LAC*	(R3

	.ENDC

	LAC TEMP2

	JMP NORMXT

INTRAN	LAC (FRD

	JMP TRANIO

	.ENDC

	.IFDEF RSX

	.TITLE SUBROUTINE TO VERIFY AND ADJUST CPB

/THIS SUBROUTINE CALLS VAJX IN THE MONITOR

ADJ	0

	PXA		/SAVE XR

	DAC	XRSV

	LAC	11,X	/PICK UP THE USER'S BUFFER SIZE

	DAC*	(R4

	LAC	10,X	/PICK UP STARTING ADDRESS OF I/O

	DAC*	(R3

	LAC	DPNODE

	DAC*	(R2

	JMS*	(VXAJ	/VERIFY REQUEST

	JMP	IOPS30	/ILLEGAL REQUEST, EVENT VARIABLE -30

	LAC	XRSV

	PAX		/RESTORE XR

	JMP*	ADJ

	.ENDC

	.LST

	.IFUND %LVERSION

	.TITLE * FINDBY *--FIND BUSY TABLE ENTRY FOR CSLOT.

/

/THE BUSY TABLE REPRESENTS THE DATSLOT NUMBER (WORD 1) AND THE

/DATA BUFFER POINTER OF EVERY BUSY FILE CURRENTLY BEING

/PROCESSED BY THIS HANDLER.  A FILE IS 'BUSY' IF AN .INIT HAS

/BEEN EXECUTED AND A CORRESPONDING .CLOSE HAS NOT YET

/BEEN EXECUTED.  A CLOSE CAUSES THE ENTRIES IN THIS BUSY

/TABLE, WHICH CORRESPOND TO THE ARGUMENT DAT SLOT, TO BE

/CLEARED TO ZERO.  

/

/

/THE BUSY TABLE IS POINTED TO BY 'BUSYTB'.

/THE SIZE OF THE ENTRIES IN THE BUSY TABLE

/IS POINTED TO BY 'BUSYSZ'  AND THE NUMBER OF

/BUSY TABLE ENTRIES BY 'BUSYNO' .

/

/

/ WORD0=DAT SLOT + CONTROL BITS

/	BITS 0-2 =DEVICE TYPE

/	BITS 3-5 =UNIT NO (RP02 ONLY).

/	BIT   6  =WRITE CHECK(FROM INIT CAL).

/	BITS 9-17=DAT SLOT

/ WORD1=BUFFER ADDRESS( OR 0 ).

/ WORD2=3-CHAR UIC.

/ WORD3=FIRST UFD BLOCK FOR THIS UIC.

/ WORD4=UFD ENTRY SIZE FOR FILES IN THIS UFD.

/

/SUBROUTINE FINDBY SEARCHES THE BUSY TABLE FOR THE 

/CURRENT DAT SLOT AND AUTO INIT'S

/CALLING SEQ:

/LOC	JMS FINDBY	/SUBR CALL.

/LOC+1	XX		/ FOUND ADDRESS.

/LOC+2	XX		/NOT FOUND ADDRESS.

/

/IF THERE ARE NO AVAILABLE ENTRIES EVERYTHING

/TERMINATES WITH A FATAL IOPS 17 MESSAGE.

/

FINDBY	0

	LAC CSLOT	/IS THIS A LEGAL UIC?

	GETUIC		/YES IF CONTROL COMES BACK.

	.EJECT

/ THE UIC IS LEGAL. FIND IT OR A FREE ENTRY AREA.

/

	LAC CSLOT

	JMS TABSET	/IS THERE A BUSY TAB ENTRY ALREADY?

L777	777		/MATCH ONLY RIGHT 9 BITS.

	SKP!CLA		/NOT FOUND, FIND A PLACE FOR IT.

	JMP FINDIN	/ENTRY FOUND.

	IDX FINDBY	/POINT TO NOT FOUND EXIT

	JMS TABSET

	777

	JMP IOPS17	/NO ROOM LEFT IN BUSY TABLE.

	LAC TEMP2	/SAVE THE POINTER

	JMS BSYSET

/

/THERE IS NO ENTRY FOR THIS SLOT.  BEFORE PUTTING IT IN

/MAKE ONE MORE PASS THROUGH TO FIND A MATCHING

/UIC,DEVICE TYPE, AND UNIT NO. ** THIS WILL SAVE

/A MFD DISK ACCESS AT 'FINDER'.

/

	LAC (DEVTYP	/BITS 0-2=DEVICE TYPE.

	XOR CSLOT

	.IFDEF %RP02

	XOR SHUNIT	/SHIFTED UNIT#.

	.ENDC

	DAC TEMP6	/SAVE DEVICE AND UNIT#.

	JMS TABSET	/MATCH TO FIND UFD BLOCK.

L774ZS	770000

	JMP BWDS02	/PUT IN WORDS 0 1ND 2.

	.IFUND	RSX

	LAC UIC		/DO THE UIC'S MATCH?

	.ENDC

	.IFDEF	RSX

	LAC	UICRSX

	.ENDC

	SAD* TEMP3

	JMP UICMTC	/YES..GET THE UFD BLOCK

	ISZ TEMP1	/NO..HAS TABLE BEEN COMP SCANNED?

NOTDON	JMP FSHARE	/NO..GOTO SHARED AREA OF TABSET.
BWDS02	LAC TEMP6	/DEVICE TYPE AND UNITNO

	DAC* BSYWD0

	.IFUND	RSX

	LAC UIC

	.ENDC
	DAC* BSYWD2
	LAC	(SIZUFD	/(SCR-158)?!?ESTABLISH SIZE IN CASE NOT
	DAC*	BSYWD4	/(SCR-158)DONE LATER!
	JMP* FINDBY

	.EJECT

/

/A UIC HAS BEEN MATCHED.  TEMP3 IS POINTING

/TO WORD 2 OF THAT ENTRY.  INDEX IT TO GET TO

/THE UFD BLOCK.

/

UICMTC	IDX TEMP3	/POINT TO WORD 3 OF MATCHED ENTRY.

	LAC* TEMP3	/0 OR A LEGAL UFD BLOCK.

	DAC* BSYWD3

	IDX TEMP3	/POINT TO UFD ENTRY SIZE.

	LAC* TEMP3

	DAC* BSYWD4	/STORE AS UFD SIZE FOR THIS UIC ALSO.

	JMP BWDS02	/FINISH WITH WORDS 0+2.

FINDIN	LAC TEMP2

	JMS BSYSET

	JMP* FINDBY

BSYSET	0

	DAC BSYWD0

	IAC	

	DAC BSYWD1

	IAC	

	DAC BSYWD2

	IAC	

	DAC BSYWD3

	IAC	

	DAC BSYWD4

	JMP* BSYSET

/

/

/

/SUBROUTINE TABSET SETS UP AND SEARCHES

/THE BUSY TABLE WITH THE INPUT ARG TO FIND

/A MATCH FROM WORD0 OF ENTRIES IN THE TABLE

/CALLING SEQUENCE:

/	LAC ARGUMENT

/	JMS TABSET

/	XXX		/'AND' VALUE

/	XX		/NOT FOUND EXIT

/	XX		/FOUND EXIT

/THE FOLLOWING VARIABLES ARE USED:

/ TEMP1=NO OF BUSY TABLE ENTRIES

/ TEMP2=PTR TO WORD 0 OF EACH ENTRY

/ TEMP3=PTR TO WORD 2 OF EACH ENTRY

/ TEMP4=INPUT ARG TO FIND.

/

TABSET	0

	DAC TEMP4	/SAVE INPUT ARGUMENT

	.IFUND	RSX

	LAC* (BUSYNO	/NO OF POSSIBLE ENTRIES

	.ENDC

	.IFDEF	RSX

	LAC	BUSYNO

	.ENDC

	TCA		/SETUP TEMP1 AS COUNTER.

	DAC TEMP1

	.IFUND	RSX

	LAC* (BUSYTB	/WORD 0 OF 1ST ENTRY

	.ENDC

	.IFDEF	RSX

	LAC	(BUSYTB

	.ENDC

TABLUP	DAC TEMP2	/PTR TO WORD 0 OF EACH ENTRY

	TAD (2

	DAC TEMP3	/PTR TO WORD 1 OF ENTRY

	LAC* TEMP2	/GET THE ENTRY

	AND* TABSET	/COMPARE ONLY SELECTED BITS

	SAD TEMP4	/MATCH THE INPUT ARG?

	JMP TABYES	/YES..INDEX AND EXIT

	ISZ TEMP1	/HAS THE ENTIRE TABLE BEEN SEARCHED?

	SKP		/NO..GET NEXT ENTRY.

	JMP TABNOT	/YES..INPUT ARG NOT IN.

FSHARE	LAC TEMP2	/CONTROL GETS HERE FROM 'NOTDON' 

	.IFUND	RSX

	TAD* (BUSYSZ	/ALSO VIA DIRECT JUMP

	.ENDC

	.IFDEF	RSX

	AAC	BUSYSZ

	.ENDC

	JMP TABLUP

TABYES	IDX TABSET

TABNOT	IDX TABSET

	JMP* TABSET

	.ENDC

	.IFDEF	RSX

UICRSX	.SIXBT	'RSX'	/RSX UIC

BUSYNO	NUMFIL

BUSYTB	.BLOCK	NUMFIL*5

	.ENDC

	.TITLE * FINDER *--DO ALL THE SETUP FOR SEARCHING.

/

/SUBROUTINE FINDER DOES ALL THE SETUP FOR THE 'SEARCH'

/SUBROUTINE.  IT SEARCHES THE MFD FOR THE ARGUMENT

/UIC, IF FOUND IT THEN READS IN THE UFD AND SEARCHES

/IT FOR THE ARGUMENT NAME.  IN BOTH CASES (UFD AND

/MFD) IT FINDS A PLACE FOR A DUMMY NAME(UNLESS

/IT FINDS THE ARGUMENT NAME FIRST).

/LOC   JMS FINDER

/LOC+1 XX	/RET HERE IF UIC NOT FOUND

/LOC+2 XX	/RET HERE IF UIC IS EMPTY

/LOC+3	XX	/RET HERE IF NAME NOT FOUND.

/LOC+4		/RET HERE IF NAME IS FOUND.

/SET BY FINDER:

/ MFD1=MFD BLOCK#.

/ MFD2=WORD IN MFD WHRE UIC LIVES.

/ UFD1=UFD BLOCK#

/ UFD2=WORD 0 OF ARGUMENT NAME ENTRY

/ DUM.BK=BLOCK# OF AVAIL ENTRY

/ DUM.WD=WORD 0 OF ENTRY

/

FINDER	0

	.IFUND %NOOUT

	DZM DUMSW	/DUMMY FOUND SWITCH

	.ENDC

	.IFUND %LVERS	/NO BSY TABLE IN L-VERS.

	LAC* BSYWD3	/PTR TO 1ST UFD BLK OR 0.

	SPA!SNA		/IF POS AND NOT 0 THE

	JMP GETMFD	/UFD BLK EXITS.

	IDX FINDER	/PT TO LOC+2 OF SUBR CALL.

	JMS NAMSAV	/MOVE IN AND TEST THIS NAME.

	LAC* BSYWD3	/GET THE 1ST UFD BLOCK.

	.ENDC

	.IFDEF %LVERS	/USE OLDUIC TO AVOID ACCESSES.

	LAC UIC		/SET AT .INIT TIME.

	SAD OLDUIC	/SET AT PREVIOUS .CLOSE.

	SKP		/IF THEY MATCH USE THE

	JMP GETMFD	/OLD UFD BLOCK(SET AT FINDER).

	LAC OLDUFD	/THE LAST TIME THROUGH HERE.

	SPA!SNA		/IF 0 OR TCA GO TO MFD.

	JMP GETMFD

	IDX FINDER	/LUCK OUT! AVOIF THE MFD ACCESS.

	JMS NAMSAV	/MOVE IN THE NEW NAME.

	LAC OLDUFD	/OLD UFD BLOCK(1ST ONE THAT IS).

	.ENDC

	JMP GETUFD

GETMFD	LAC (MFDBLK	/1ST MFD BLOCK.

	JMS BAKTST	/READ AND TEST BACKWARD LINK.

	SKP

MFDAG	JMS RDRIVE

	CLL		/MFD INDICADOR (FOR SEARCH)

	LAW -1		/FIND A 1 WORD MATCH

	JMS SEARCH

	LAC UICPT	/MATCH THE UIC

	JMP MFDIN	/FOUND MFD

	.IFUND %NOOUT

	CLL		/WAS A DUMMY ENTRY FOUND?

	.ENDC

	JMS DUMSET	/NO IF 0

	.IFUND %NOOUT

	LAW -MFDSIZ	/YES..ARE THERE ANY MORE?

	.ENDC

	JMP MFDAG	/NEXT MFD BLOCK IN AC
MFDIN	LAC BLOCK
	DAC MFD1	/SAVE MFD BLOCK#
	LAC TEMP2
	DAC MFD2	/SAVE WRD0 OF THIS ENTRY.
	TAD (MPREBK
	DAC DUMSET
	IAC			/POINT TO UFDSIZE.
	DAC TEMP3
	LAC* TEMP3	/IF 0 UFDSIZ DOESN'T EXIST.
	DAC DPRO	/DIRECTORY PROTECTION.
	AND (77		/BITS 12-17=UFDSIZ.
	SNA		/NON0 UIC FOUND.
	LAC (SIZUFD	/MUST BE INSERTING UIC.
	.IFUND	%LVERS	/(SCR-159)RETURN THIS LINE TO PREVIOUS POSITION
	DAC* BSYWD4
	.ENDC
	.IFDEF %LVERS
	DAC OLDSIZ
	.ENDC

/

/THE UIC HAS BEEN FOUND IN THE MFD.

/

	IDX FINDER	/POINT TO LOC+2

	JMS NAMSAV	/MOVE IN AND TEST THE NAME.

	LAC* DUMSET

	SAD MINUS1

	JMP* FINDER

	TSTB00		/BLOCK 0 CANNOT BE A UFD.

	.IFUND %LVERSION

	DAC* BSYWD3

	.ENDC

	.IFDEF %LVERSION

	DAC OLDUFD

	.ENDC

GETUFD	IDX FINDER	/POINT TO LOC+3 OF SUBR CALL.

	JMS BAKTST	/READ IN 1ST UFD BLOCK

	SKP		/AND CHECK THE BACK WARD LINK.

UFDAG	JMS RDRIVE

	.IFUND %NOOUT

	DZM DUMSW

	.ENDC

	.IFDEF	RSX

	LAC	DPNODE	/PICK UP ARGUMENT ADDRESS

	AAC	7	/POINT TO SEEK CODE

	PAL	/SAVE IT IN LR

	.ENDC

	STL

	LAW -3		/FIND MATCH FOR 3-WORD NAME

	JMS SEARCH

	.IFUND	RSX

	LAC* LOC.2

	.ENDC

	.IFDEF	RSX

	PLA		/PICK UP ARGUMENT ADDRESS

	.ENDC

	JMP UFDIN

	.IFUND %NOUT

	STL

	.ENDC

	JMS DUMSET

	.IFUND %NOOUT

	LAW -SIZUFD

	.ENDC

	JMP UFDAG

UFDIN	LAC BLOCK

	DAC UFD1

	LAC TEMP2

	DAC UFD2

	JMS SETPNT	/SET UP UDF POINTERS

	IDX FINDER	/POINT TO LOC+3

	.IFUND %LVERS

	LAC* U.RBWD	/GET THE FILE PROTECTION CODE.

	RTL

	RTL		/BITS 0-2

	AND (7

	DAC FPRO

	.ENDC

	JMP* FINDER

NAMSAV	0		/SAVE ARG NAME

	.IFDEF	RSX

	LAC	DPNODE	/POINT TO NODE

	AAC	7

	.ENDC

	.IFUND	RSX

	LAC* LOC.2	/ADDRESS OF NAME.

	.ENDC

	DAC TEMP1

	LAC NAMEPT

	DAC TEMP2

	LAW -3

	JMS MOVER

	LAC TEMP15	/SET AT MOVER; NULL NAME 

	SNA		/(ALL 3 WORDS) IS ILLEGAL.

	JMP IOPS73

	JMP* NAMSAV

/

/ SUBROUTINE BAKTST READS IN THE 1ST MFD OR UFD

/ BLOCK AND CHECKS THE BACKWARD LINK FOR -1. IF ITS

/ NOT -1 THE FILE STRUCTURE IS CONTAMINATED. CORE MAY

/ BE CLOBBERED,EAE MAY BE DOWN, THE BUSY TABLE MAY BE

/ CLOBBERED OR THERE IS A HANDLER BUG.

/

BAKTST	0

	JMS RDRIVE	/ARG BLOCK NO IN AC.

	LAC* BAKWRD	/BACKWARD DATA LINK.

	SAD MINUS1	/-1?

	JMP* BAKTST	/YES..ALL OK CONTINUE.

	.IFUND	RSX

	LAW 76		/IOPS 76.

	JMS E.PRNT

	LAW -5

	JMP* BAKTST	/USER IS WARNED CONTINUE.

	.ENDC

	.IFDEF	RSX

	ERR	76

	.ENDC

	.TITLE * DUMSET *--FIND ROOM FOR DUMMY ENTRY.

/

/SUBROUTINE 'DUMSET' TEST THE 'DUMSW' SET BY THE

/FINDER SUBROUTINE IF 0 IT SEARCHES THE MFD OR

/THE UFD FOR A DUMMY NAME.  IF NON 0 A DUMMY

/ENTRY LOCATION HAS ALREADY BEEN FOUND AND THE

/SEARCH DOES NOT TAKE PLACE.  IT THEN CHECKS

/THE DATA LINK FOR MORE BLOCKS TO CHECK, IF -1

/(NO MORE BLOCKS) IT EXITS TO THE ***FINDER***

/CALLER.  IF MORE BLOCKS EXIST, EXIT IS MADE TO THE

/'DUMSET' CALLER WITH THE NEXT BLOCK# IN THE AC.

/

/CALLING SEQ:

/

/LOC-1	STL OR CLL	/LINK MUST BE SET BEFORE

/LOC	JMS DUMSET	/THE SUBR. CALL

/LOC+1	LAW -N		/-MFDSIZ OR UFDSIZ

/RETURN HERE WITH NEXT BLOCK# IN THE AC.

/IF NO NEXT BLOCK---JMP* FINDER---.

/

/

DUMSET	0		/LINK ALREADY SET

	.IFUND %NOOUT

	LAC DUMSW	/WAS THE DUMMY

	SZA		/ALREADY FOUND?

	JMP DUMFND	/YES..TEST FOR NEXT BLOCK.

	XCT* DUMSET

	JMS SEARCH

	LAC FAKER	/TABLE 0F ZEROES

	SKP		/FOUND EXIT

	JMP DUMFND

	SET DUMSW	/DUMMY FOUND

	LAC BLOCK

	DAC DUM.BK

	LAC TEMP2

	DAC DUM.WD

DUMFND	IDX DUMSET	/POINT TO DUMSET RETURN

	.ENDC

	LAC* DATALK	/ANY BLOCKS IN?

	SMA

	JMP* DUMSET

	JMP* FINDER

	.TITLE * SEARCH *--SEARCH BOTH TYPES OF DIRECTORIES.

/

/CALLING SEQUENCE:

/LOC-N  CLL OR STL	/SOME WHERE BEFORE THE CALL.

/LOC-1	LAW	-N	/#OF WORDS TO MATCH

/LOC	JMS	SEARCH	/SUBR. CALL

/LOC+1	LAC	ADDR	/ADDRESS OF ARGUMENT NAME

/LOC+2	XX		/ FOUND EXIT

/LOC+3	XX		/NOT FOUND EXIT.

/SEARCH THROUGH A USER FILE DIRECTORY OR

/MASTER FILE DIRECTORY.  THE DIRECTORY IS IN CORE

/AND IS POINTED TO BY 'DATABK' (POINTS TO WD 0 OF

/400(8) WORD BLOCK).  'DATALK' IS POINTING TO THE LAST

/WORD OF THIS BUFFER AND IS USED BY THIS ROUTINE

/TO DETERMINE WHETHER OR NOT IT CAN TERMINATE THE

/SEARCHING OPERATION.  A ZERO LINK = SEARCH MFD, NON 0 = UFD

/

SEARCH	0

	DAC COUNT	/SETUP FOR ALGORITHM

	DAC TEMP3	/SAVE FOR RESTORING AT BIGLOOP.

	XCT* SEARCH	/POINTER TO SEARCH ARGUMENT.

	.IFUND	RSX

	DAC DISPCH

	.ENDC

	.IFDEF	RSX

	DAC	DISPCA

	.ENDC

	DAC TEMP1	/SAVE FOR LOOP RESTORING.

	IDX SEARCH	/POINT TO  FOUND EXIT.

	LAC (MFDSIZ	/ASSUME MFD SEARCH.

	SZL		/IF (LINK=NON 0) UFD

	.IFUND %LVERSION

	LAC* BSYWD4	/SETUP BY SEEK OR ENTER.

	.ENDC

	.IFDEF %LVERSION

	LAC OLDSIZ

	.ENDC

	DAC OFFSET

	LAC DATABK	/WRD 0 OF 400.

SRCBIG	DAC TEMP2

	DAC TEMP4	/USE TEMP4 TO SEARCH.

SRCLIT	LAC* TEMP1	/ARGUMENT WORD.

	SAD* TEMP4	/DIRECTORY WORD.

	JMP MATCH	/A MATCH IS FOUND.

	.IFUND	RSX

	LAC DISPCH	/NOMATCH RESTORE ARG PTR.

	.ENDC

	.IFDEF	RSX

	LAC	DISPCA

	.ENDC

	DAC TEMP1

	.EJECT

/

/TEMP2+OFFSET POINTS TO THE NEXT ENTRY.

/TEST IT TO SEE IF WE'VE GONE PAST THE DATA LINK PTR.

/IF SO, THE ENTRY CAN'T BE FOUND IN THIS BLOCK. GO TO 'NOT

/FOUND' EXIT.

/

	LAC TEMP2

	TAD OFFSET

	DAC TEMP4

	TCA		/2' COMP

	TAD BAKWRD	/IF(NEXT.GE.DATALK)GOTO NOMATCH

	SPA!SNA

	JMP NOTFND	/CAN'T BE FOUND.

	LAC COUNT	/RESTORE COUNT

	DAC TEMP3

	LAC TEMP4

	JMP SRCBIG	/BIGLOOP TRY AGAIN.

/

/MATCHING WORDS HAVE BEEN FOUND.TEMP3

/INDICATES WHETHER OR NOT MORE MATCHES ARE REQUIRED. IF

/IT OVESEMNUQ)HR[); INCREMENT THE SEARCH RETURN

/ADDRESS TO POINT TO THE 'FOUND' EXIT.

/

MATCH	IDX TEMP1	/POINT TO NEXT ARG WORD.

	IDX TEMP4	/NEXT DIR WORD.

	ISZ TEMP3	/DONE??

	JMP SRCLIT	/NO..CONT AT LITTLE LOOP.

	LAC TEMP2	/YES.. POINT FOUND ENTRY.

	JMP* SEARCH

NOTFND	IDX SEARCH	/POINT TO NOT FOUND EXIT.

	JMP* SEARCH

/

	.TITLE	ONCE ONLY CODE

/

/THE FOLLOWING CODE IS EXECUTED ONLY ONCE BY THIS HANGLER.

/THE .SETUP CAL IS EXECUTED WITH 'INT' AS THE INTERRUPT

/ADDRESS. THE FIRST OPERATION IN THIS

/THIS SECTION IS TO INHIBIT FURTHER JMPS INTO THIS

/AREA BY PUTTING A 'NOP' AT LOCATION 'F1ONCE'.  ONCE THE

/FOLLOWING CODE IS EXECUTED, IT IS USED FOR TEMP STORAGE.

/
ONCELY=.

	.IFDEF %LVERSION

	JMS .		/GET THE BANK BITS.

	LAC .-1		/BITS 5,6

	AND L64Z	/(60000).

	DAC DRIVER

	.IFUND	%RK05

	BITS56 TEMP5

	.ENDC

	BITS56 DROP.5						/EAG:150

	BITS56 NAMEPT

	BITS56 DATALK	/PTR TO DATA LINK.

	BITS56 BAKWRD	/PTR TO BACKWARD LINK.

	BITS56 UICPT

	.IFDEF %RP02

	.IFUND %RK05

	BITS56 LOC.5

	.ENDC

	.IFDEF %RK05

	BITS56	IBLOCK		/WHY NOT "TEMP5	INT	/...." FOR RK05????

	.ENDC

	.ENDC

	BITS56 ENDPT

	BITS56 RETRPT

	BITS56 CDESC

	BITS56 BEGBUF

	JMP TEMP2

L17777	17777

L64Z	60000

BDONE=.

RESIDU=BDONE-ONCELY

RESIDU=400-RESIDU
	.BLOCK RESIDU
/
	.ENDC
	.IFUND	RSX
	.IFUND	%RK05		/(SCR-156)
TEMP2	LAC NOPLIT
	.ENDC			/(SCR-156)
	.IFDEF	%RK05		/(SCR-156)TEMPORARY SHUNT FOR RK05
TEMP2	LAC	IRKWC		/(SCR-156)LOAD   JMP   IOPS12
	.ENDC			/(SCR-156)
LOC.0	DAC F1ONCE	/(HIGHEST DISK PLATTER)

	.IFUND %RP02

LOC.1	CAL APIAD

TEMP3	16		/SETUP CAL FUNCTION

TEMP4	DSSF		/SKIP CHAIN IOT

TEMP5	INT		/PI AND API INTERRUPT LOCATION.

	.IFDEF %RB09

TRACK	DSCF

	.ENDC

	.ENDC

	.EJECT

	.IFDEF %RF15

/THE REST OF THE 'ONLY ONCE' CODE DETERMINES HOW MANY

/DISK PLATTERS ARE AVAILABE.  IT DOES THIS BY

/CLEARING THE FUNCTION REGISTER AND INHIBITING THE PI,

/AND THEN SELECTING DISK PLATTER 0, 1, 2, ETC.

/UNTIL NO DISK IS FOUND.

/

PLATER	CLA		/CLEAR THE FUNCTION REGISTER AND
LOC.2	DSCF!DSCN	/DISABLE PROGRAM INTERRUPT.

DONOR1	IOT		/ DELAY

DONOR2	IOT		/DELAY

	IOT		/ DELAY

LOC.3	DLAH!DSCF	/LOAD AC AS DISK # INTO AP1

SAVEQ	IOT		/*TIMER* .

	IOT		/ DELAY

LOC.4	DSSF		/SKIP IF ERROR OR DISK DONE

LOC.5	JMP EXITAD	/DISK PLATTER IS IN.

	DSCD

CKSMPT	JMP FLAGON	/NO DISK

EXITAD	DSCD		/CLR STATUS + DISK FLAG.

OFFSET	IAC	

SAVSUM	SAD (10		/IF NO CONTROLLER CONNECTED

TRANSW	JMP IOPS21	/AVOID PERPETUAL LOOP(0-7 DISKS ONLY).

WRCHEK	JMP LOC.3

/

/THE FLAG IS ON. SINCE THE FUNCTION WAS 00 (NO-FUNCTION)

/THE ONLY POSSIBLE ERROR IS ILLEGAL DISK ADDRESS.

/IF AC IS 0 NO DISK ATTACHED.

/

FLAGON	DAC PLATER	/CLEAR STATUS REGISTER AND DISK FLAG.

TEMP6	SNA!CLL		/ANY PLATTERS?

TEMP7	JMP IOPS21	/NONE!!

/

/MULTIPLY THE HIGHEST UNIT NUMBER BY THE NUMBER OF

/BLOCKS PER UNIT TO GET THE HIGHEST BLOCK NUMBER.

HI.BLK	JMS LEFT8

TRK.WD	RTL

STATUS	DAC HI.BLK

	.ENDC

	.IFDEF %RP02

	.IFUND	%RK05

BSTAT	DPCS		/CLEAR DISK PACK FLAGS

UNITNO	DPCF		/CLEAR FUNCTION REGS(INT'S ALSO).

LOC.1	CAL	APIAD	/.SETUP CAL ADDR

TEMP3	16		/.SETUP CODE

TEMP4	DPSE		/SKIP ON DISK ERROR

TEMP5	INT		/INTERRUPT CODE ADDR

LOC.2	CAL	APIAD	/NOW SET UP JOB DONE OK

LOC.3	16

LOC.4	DPSJ		/SKIP ON JOB DONE

LOC.5	INT		/SAME INTERRUPT CODE

	.ENDC

	.IFDEF	%RK05

/

/	THERE FOLLOW 11 POINTERS TO TCB AREA IN MONITOR, TO

/  BE SET UP AT ONCE ONLY TIME. THE LOCATIONS ARE OCCUPIED BY CODE

/  AFTER THAT ARE THE TEMPORARIES TEMPX AND LOC.X. THE 11 POINTERS

/  ARE IN SERIAL ORDER TO THE LOCATIONS THEY POINT TO, FOR

/  CONVENIENCE.

/
ITCB	CAL	APIAD	/.SETUP FOR RK05

ITCB1	16

IDEV	SAPI0		/SKIP ON FLAG, EITHER DONE OR ERROR

IBLOCK	INT		/INTERRUPT CODE

ISTADD	LAC*	(.SCOM+100 /ADDR OF TABLE OF TCB POINTERS
ISTAD1	SNA!SPA		/(SCR-154)SKIP IF UC15 ON
IRKWC	JMP	IOPS12	/(SCR-154)UC15 OFF;ERROR OUT
IRKUNF	DAC	ITCB	/(SCR-154)EXTRA INDIRECT
ISTATS	LAC*	ITCB	/(SCR-154)OUR TCB ADDR
IBSTAT	SNA!SPA		/(SCR-154)IS A TCB FOR US??
IRKDS	JMP	IOPSE5	/(SCR-154)NO AREA, IOPS55
UNITNO	DAC	ITCB	/(SCR-154)THE PUTTER OF ADDR'S IN THE I TABLE
LOC.1	SKP!IAC		/INCREMENT ADDR IN AC, SKIP OVER CONTROL COUNT
LOC.2	-13		/CONTROL COUNT , ONCE ONLY, FOR LOOP
LOC.3	ISZ	UNITNO	/(SCR-154)BUMP DEPOSIT INSTR.
LOC.4	ISZ	LOC.2	/(SCR-154)CONTROL THE LLOOOOP
LOC.5	JMP	UNITNO	/(SCR-154)NOT THRU YET
	LAC	(47*400+0 /(SCR-154)FILL FIRST TWO TCB LOC'S
TEMP3	DAC*	ITCB	/47 API SLOT, 0 IS API LEVEL
TEMP4	LAC	(0+202	/0 FUNCTION CODE, 2 IS DRVER, 200=NOTSPOOLED
TEMP5	DAC*	ITCB1
	LAC	NOPLIT	/(SCR-156)NOW REALLY DONE! NOP ONCLY ENTRY
	DAC	F1ONCE	/(SCR-156)
	.ENDC
	.ENDC

	.EJECT

/THE BUFFERS GIVEN BY THE MONITOR TAKE THE FOLLOWING

/FORMAT:

/---------------------------------

/CURRENT SET OF DESCRIPTORS TO THE

/FILE ASSOCIATED WITH THIS BUFFER

/---------------------------------

/TEMPORARY OUTPUT BLOCK LIST

/---------------------------------

/

/400(8) WORD DATA BUFFER

/---------------------------------

/THE SIZE OF THE BUFFER, CAN BE CHANGED AT SYSTEM

/GENERATION TIME.  THE ONLY FIXED PARAMETER IS THE

/400 WORD DATA BLOCK.  THE CURRENT SIZE + 400 MINUS

/THE TOTAL SIZE OF THE BUFFER PRODUCES THE SIZE OF

/THE TEMPORARY BLOCK LIST.

/

/*********************************************

/*  PIP SEARCHES THROUGH TEXT DATA FOR (1005, *

/*  776773) IN DUMP MODE. THE L-VERSION CANNOT*

/* BE TRANSFERED FOR THAT REASON. TO GET      *

/* AROUND THIS EOF2 IS ASSEMBLED AS 776772    *

/* AND IS INCREMENTED ONCE BY THIS ONCE ONLY  *

/* CODE TO MAKE IT 776773                     *

/*********************************************

/

DUM.WD	INC EOF2	/MAKE IT 776773

AC	LAC* (BSIZE	/BUUFER SIZE SET BY .SGEN.

MFD1	TCA

MFD2	DAC BUFSIZ	/NO OF WORDS TO CLEAR.

WC	TAD (400	/SIZE OF DATA BLOCK.

CKSUM	TAD (NODESC	/SIZE OF CURRENT SET.

DUM.BK	DAC LSTSIZ	/#OF BLOCKS TO PRE ALLOCATE.

WPC	TAD (LOWEST	/LOWEST REASONABLE NO OF BLOCKS.

	.IFUND	%RK05

BLOCK=.

	.ENDC

	DAC BUF.OK	/SET BUFFER SIZE OK SWITCH.

FLAG	LAC LSTSIZ	/GET POSITIVE VALUE FOR LSTSIZ.

RECEV2	TCA

END1CE	DAC LSTSIZ

WORD1	TAD TEMP10	/(-253) 'BLDRIB ALGORITHM DOES

WORD2	SPA!SNA		/WORK IF LSTSIZ IS .GT.253(10).

WORD3	JMP F1ONCE+1	/ITS .LE.253(10) ACCEPT IT

RECEV1	LAC TEMP9	/TOO BIG USE 253(10)

FITIND	DAC LSTSIZ

USERWC	JMP F1ONCE+1

	.ENDC

	.EJECT

	.IFDEF	RSX

MFD1	0

MFD2	0

FITIND	0

DUM.BK	0

DUM.WD	0

AC	0

WC	0

CKSUM	0

WPC	0

	.IFUND	%RK05

BLOCK	0

	.ENDC

FLAG	0

RECEV2	0

ENDICE	0

WORD1	0

WORD2	0

WORD3	0

RECEV1	0

TIND	0

USERWC	0

DPNODE	0

ABTNOD	0

ABTPDV	0

PDVCT	0

WFSTAT	20

STATUS		/EVENT VARIABLE ADDRESS

SAVAD	0	/ADDRESS OF UNRELOCATED I/O

XRSV	0	/XR SAVED FOR VXAJ

DISPCA	0

	.ENDC

TEMP9	375

TEMP10	-375

	.IFUND	RSX

	.TITLE * TSTIOU *-I/O UNDERWAY? AND SAVEAE SUBR.

/

/IF IO IS ALREADY UNDERWAY CONTROL GOES BACK TO THE USER

/AT LOC(AN IMPLICIT .WAIT IS PERFORMED) WHERE HIS CAL

/WILL BE EXECUTED AGAIN UNTIL ALL BUSY IO IS COMPLETE.

/

TSTIOU	0

	LAC UNDWAY	/I/O UNDERWAY?

	SNA

	JMP* TSTIOU

	DBR		/RETURN AT SAME LEVEL.

	JMP* CALPTR

/

/SAVE THE EAE STEP COUNTER AND MQ.

/

SAVEAE	0

	SAVER SAVEQ,RES.SC

	JMP* SAVEAE

/

RESEAE	0

	REST

	JMP* RESEAE

	.TITLE * DIRPRO *-PROTECTION CHECKING.

/

DIRPRO

	LAC* (LOGMIC	/SYSTEM OWNER LOGGED IN?

	SPA

	JMP* DIRPRO

	LAC* (LOGGED	/UIC=LOGGED IN UIC

	SAD UIC

	JMP* DIRPRO

	LAC DPRO	/WAS DIRECTORY PROTECTED?

	SPA		/NO IF NOT TCA

	IDX DIRPRO

	JMP* DIRPRO

/

CKDIRP	0

	JMS DIRPRO

	JMP* CKDIRP

	JMP IOPS63

	.ENDC

	

	.IFUND %LVERSION

	.IFUND %CVERSION

	.TITLE * LSTFIL *--FILL THE TEMP BLOCK LIST.

/

/'LSTFIL' READS IN THE CURRENT SUBMAP AND STARTS SEARCHING

/IT FOR AVAILABLE BLOCKS.  THE STARTING WORD LIVES IN 'START'

/SO THAT SEARCHING DOES NOT ALWAYS START AT WORD 0  OF

/THE SUBMAP.  MOST OF THE POINTERS AND COUNTERS USED BY

/THE OUTPUT ROUTINES CONCERNING BLOCKS TO WRITE ARE SET

/HERE.  THE FORMAT OF SUBMAPS:

/

/ WORD 0	TOTAL # OF RF BLOCKS (# PLATTERS *2000)

/ WORD 1	# OF BLOCKS DESCRIBED BY THIS MAP.

/ WORD 2	# OF OCCUPIED BLOCKS DESCR. BY THIS MAP.

/ WORD 3	18 BIT WORD DESCRIBING 18 BLOCKS.

/ WORD N

/

LSTFIL	0		/MULTI SUBMAPS ARE POSSIBLE.

	LAW -MAPNO

	DAC MAPS

	DZM BLKLFT	/# OF BLOCKS PUT IN LIST.

	LAC BKPTRS

	DAC NXTLST	/PTR TO LIST OF BLOCKS

	DAC LSTPNT	/PTR TO LIST, INDEXED WHILE BUILDING

	LAC LSTSIZ	/SIZE OF TEMP LIST, COMPUTED AT

	TCA		/ONCE ONLY CODE.

	DAC LSTCNT	/2'S COMP OF # OF BLOCKS TO GET.

NXTMAP	LAW	-DELTA-1	/MAX # TIMES TO TRY THIS SUBMAP

	DAC	MAPTRY

	LAC CSBMAP	/GET THE CURRENT SUBMAP

	JMS RDRIVE	/FOR THIS FILE.

	JMS	WRDCHK	/CHECK COUNTS ON TOP OF MAP

/			/RETURN HERE IF OK. IOPS75 IF WRONG.

/			/GO TO NONLFT FROM WRDCHK IF MAP FULL

/

/THE CURRENT SUBMAP IS IN.  MULTIPLY 'START-3' BY 22 TO GET

/THE BLOCK # OF THE BIT POINTED TO BY C(START+DATABK).

/

RESET	LAC WORD3	/1ST WORD TO LOOK AT PER MAP.

	TCA		/SUBR FROM START WORD TO

	TAD START	/GET THE STARTING BLOCK NUMBER.

	DAC TEMP1

	MULT22 TEMP1

	DAC WBLOCK	/BLOCK # OF BIT 0 AT TEMP4

WRKDWN	LAC START	/WORK DOWN FROM START.

	DAC TEMP4

/TOP OF MAJOR LOOP.

/

MIN22=.

LSTLP1	LAW -22		/18 BITS/WORD.

	DAC COUNT

	LAC* TEMP4	/IS THIS WORD COMPLETELY

	SAD MINUS1	/OCCUPIED? IF SO SAVE SOME

	JMP LSTWRD	/BY GETTING THE NEXT WORD .

	LAC L45ZS	/ (400000)/

	SKP!CLL

LSTLP2	RCR		/ONE BIT IS ON IN WORKER,

	DAC WORKER	/IT MOVES LEFT TO RIGHT.

	LAC* TEMP4	/WORD OF SUBMAP.

	AND WORKER

	SZA

	JMP LSTBSY	/THIS BLOCK IS BUSY.

BFOUND	LAC WORKER

	XOR* TEMP4	/NOT BUSY, USE IT AND

	DAC* TEMP4	/MAKE IT BUSY.

	INC* WORD2	/INCREMENT USED BLOCK CNT.

	INC BLKLFT	/BLOCK COUNT.

	LAC WBLOCK	/THIS IS THE AVAIL BLK #.

	.IFUND %RB09

	TAD MAPOFF	/GET 'REAL' BLOCK NO.

	.ENDC

	DAC* LSTPNT	/STORE IN BLOCK LIST.

	IDX LSTPNT	/PT TO NXT WRD IN BLK LIST.

	ISZ LSTCNT	/HAVE WE FILLED THE LIST?

	SKP

	JMP LSTFUL

/

/AT LEAST ONE MORE BLOCK IS REQUIRED BEFORE 'TLIST'

/IS FILLED.  IF THE NEXT BLOCK 'DELTA' BLOCKS AWAY

/IS AVAILABLE AND DOES NOT EXCEED THE HIGHEST BLOCK

/IN THIS MAP USE IT.  IF IT IS NOT AVAILABLE OR

/GREATER THAN THE HIGHEST BLOCK NO TRY TO USE THE

/NEXT BLOCK # AFTER THE ONE JUST PICKED UP.

/

	LAC TEMP4	/CURRENT WORD.

	DAC START	/POTENTIAL NEW WORD FOR DELTA.

	LAC COUNT	/WILL THE DELTA VALUE.

	TAD (DELTA	/OVERFLOW THIS WORD?

	DAC TEMP1	/IF 0 OR TCA STAY WITH THIS WORD.

	SMA!CLL		/LINK IS CLEARED FOR 'WSHIFT'

	JMP DELOVF	/DELTA OVERFLOWED 18-BIT WORD.

	LAW -DELTA	/# OF BITS TO RIGHT SHIFT

	DAC TEMP2

	LAC WORKER	/LAST POSITION OF BIT

WSHIFT	RAR

	ISZ TEMP2

	JMP WSHIFT

	DAC TEMP3	/NEW POSITION FOR WORKER

	AND* START	/IS THIS BLOCK AVAIL?

	SZA		/YES IF 0

	JMP LSTBSY	/TAKE NEXT BIT AT WORKER.

	LAC (DELTA	/DOES THIS EXCEEP C(WORD1)?

	JMS TOPTST

	JMP LSTBSY	/YES...GO BACK TO LAST 'WORKER'.

	LAC START	/USE THIS WORD.

	DAC TEMP4

	LAC TEMP3	/NEW WORKER BIT POSITION

	DAC WORKER

	LAC TEMP1

	DAC COUNT	/NEW 18-BIT (LESS) COUNTER

	JMP BFOUND	/TURN ON BIT AND CONTINUE.

/

/AT 'DELOVF' THE 18-BIT WORD HAD BEEN

/EXCEEDED FOR EXAMPLE IF WORKER WAS POINTING

/TO BIT 15 (000000000000000'0'00) AND DELTA

/WAS 3 THE NEXT BIT WOULD BE BIT 0 OF THE

/NEXT WORD.

/

DELOVF	IAC	

	TCA

	DAC TEMP2	/# OF BITS TO MOVE

	IDX START	/PT TO NEXT WORD.

	LAC TEMP1	/RESET T1 (COUNT FOR NEW WORD)

	TAD MIN22

	DAC TEMP1

	STL!CLA

	JMP WSHIFT

LSTBSY	LAC L1		/HAVS THE HIGHEST BLOCK NO 

TSTEND	JMS TOPTST	/BEEN EXCEEDED OR EQUALED?

	JMP TOPMAP	/YES..END OF MAP

	LAC COUNT	/MAY ALREADY BE 0 BECAUSE

	SNA		/DELTA IS ADDED TO IT AS WELL

	JMP WRDONE	/BEING ISZ'ED BELOW.

	LAC WORKER	/NO..LOOP AGAIN UNLESS THE

	ISZ COUNT	/18TH BIT WAS JUST CHECKED.

	JMP LSTLP2	/MINOR LOOP.

WRDONE	IDX TEMP4

	JMP LSTLP1

/

/AT LSTWRD A WORD IN THE MAP IS SET TO -1.  ITS COMPLETELY

/OCCUPIED.  ADD 22 TO THE WORKING BLOCK COUNT, THEN FUDGE

/'COUNT' TO WORK IN THE MINOR LOOP.

/

LSTWRD	DAC COUNT	/-1, WILL OVFLO

	LAC (22

	JMP TSTEND

/

/AT TOPMAP THE WORKING BLOCK# IS .GE.THE HIGHEST BLOCK #.

/ALTHOUGH 'START' STARTED AT WORD 3 WHEN THE .ENTER WAS

/EXECUTED THERE MAY STILL BE SOME BLOCKS LEFT BECAUSE

/FILES MAY HAVE BEEN DELETED.

/

TOPMAP	JMS	WRDCHK	/CHECK FULL, AND LEGALITY

	LAC WORD3	/RESET START ADDRESS TO 1ST WORD

	DAC START

	DZM WBLOCK	/STARTING BLOCK #

	ISZ	MAPTRY	/HAVE WE DONE THIS ENUF ALREADY?

	JMP WRKDWN	/NO, TRY AGAIN

	JMS	IOPS75	/YES, ASSUME BIT COUNT IN WORD 1-2

/			/NOT = ACTUAL BIT COUNT

/

/

/  SUBROUTINE WRDCHK

/

/ WORD1 OF MAP IS TOTAL BLOCK IT REFERENCES

/ WORD 2 IS NUMBER OF BUSY BLOCKS

/

/ IF WORD1 = WORD2, GO TO NONLFT TO GET A NEW MAP, THIS ONE FULL.

/ IF WORD1 < WORD2 STRUCTURE DEGRADATION, IOPS75

/ IF WORD1 > TOTAL SYSTEM BLOCKS, AGAIN A IOPS75

/ IF NONE OF THE ABOVE, THIS MAP SHOULD HAVE BLOCKS,

/  RETURN TO CALLER SO HE CAN GET THEM.

/

WRDCHK	0

	LAC*	WORD1	/DO WE SAY WE HAVE TOO MANY?

	TCA

	TAD*	DATABK	/THIS HAS SYSTEM MAX.

	SPA		/SKIP ON OK

	JMS	IOPS75	/STRUCTURE DEGRATION, DO MESSAGE

	LAC*	WORD1	/CHECK BITS LEFT IN MAP

	TCA

	TAD*	WORD2	/WORD2 IS BUSY, WORD1 MAX

	SNA		/SKIP UNLESS EVERY BLOCK BUSY

	JMP	NONLFT	/ALL BLOCKS BUSY, NEXT MAP

	SMA		/SKIP IF SOME BLOCKS LEFT

	JMS	IOPS75	/MORE BUSY THAN THERE ARE, ERROR

	JMP*	WRDCHK	/RETURN TO CALLER

/

/

/AT LSTFUL THE TEMPORARY LIST HAS BEEN FILLED.  'START' IS 

/POINTING TO THE WORD IN THE SUBMAP WHERE THE NEXT LIST

/FILLING STARTS.  WRITE OUT THE MAP AND RETURN TO THE

/CALLER.

/

LSTFUL	LAC CSBMAP

	JMS WDRIVE

	JMP* LSTFIL

	.IFDEF %RB09

NONLFT=LSTFUL

	.ENDC

/

/TEST WBLOCK FOR GOING OVER WORD1.

/

TOPTST	0

	TAD WBLOCK	/CONSTANT TO ADD IS ARG TO SUBR.

	DAC TEMP5	/SAVE IT HERE.

	TCA		/GET ITS 2!COMP.

	TAD* WORD1	/.GE. C(WORD1).

	SPA!SNA		/IF 0 OR TCA ITS TOO BIG.

	JMP* TOPTST

	IDX TOPTST

	LAC TEMP5	/NEW WBLOCK.

	DAC WBLOCK

	JMP* TOPTST

	.EJECT

	.IFUND %RB09

/

/AT NONLFT THIS SUBMAP IS COMPLETELY FULL.  IF WORD 0 (TOTAL

/RF BLOCKS IN SYSTEM)=WORD 1 (TOTAL IN THIS MAP) THEN THERE

/ARE NO MORE BLOCKS AVAILABLE ANYWHERE.

/

NONLFT=.

	.IFDEF %RF15

	LAC* DATABK	/BLOCKS IN TOTAL SYSTEM.

	SAD* WORD1	/BLOCKS IN THIS MAP.

	JMP LSTFUL

	.ENDC

ENDMAP	LAC* WORD1	/NO OF BLOCKS IN MAP.

	SPA!SNA		/FILE STRUCTURED CLOBBERED IF

	JMS IOPS75	/0 OR TCAATIVE.

	TAD MAPOFF	/INCREMENT OFFSET FOR 'REAL' BLOCK#S.

	DAC MAPOFF

	LAC* DATALK	/GET NEXT SUBMAP NO.

	SPA		/IF TCA THERE IS NO 'NEXT' MAP.

	DZM MAPOFF	/GO BACK TO ZERO.

	DAC COUNT	/SAVE IT FOR WDRIVE RETURN.

	LAC CSBMAP	/MORE BLOCKS IN OTHER MAP.

	JMS WDRIVE	/WRITE THIS ONE OUT.

	LAC COUNT	/PREVIOUS FOR LINK.

	SPA		/ANY MORE FORWARD?

	LAC SBMAP1	/NO..WRAP AROUND TO MAP1.

	DAC CSBMAP	/NEXT SUBMAP.

	LAC WORD3	/RESET START TO WORD 3 OF SUBMAP.

	DAC START

/

/IF MAP1 IS FULL AND MAP2 IS FULL AND ENDLESS LOOP

/COULD RESULT GOING FROM ONE BLOCK TO THE NEXT.  FOR THIS

/REASON  THE 'LSTFIL' CODE IS EXECUTED ONLY MAPNO TIMES.

/PER CALL.  IF 'MAPS' OVERFLOWS ALL BLOCKS ON ALL BIT

/MAPS ARE OCCUPIED.

/

	ISZ MAPS	/BOTH MAPS SCANNED?

	JMP NXTMAP	/NO..GET NEXT ONE.

	JMP* LSTFIL	/YES..EXIT.

	.ENDC

	.TITLE LIST OF ALL SUBMAPS (RB,RF,RP,RK).

	.IFUND %NOOUT

/

/UP TO 8 PLATTERS CAN BE DESCRIBED

/

	.IFDEF %RF15

MAPTAB	MAPTAB

SBMAP1	1776		/FIRST MAP.

SBMAP2	1775		/SECOND BIT MAP.

	.ENDC

/

/RB09 HAS ONLY ONE SUBMAP.

/

	.IFDEF %RB09

MAPTAB	MAPTAB

SBMAP1	1776

	.ENDC

	.IFDEF %RP02

	.EJECT

	.IFUND	%RK05

/	 DISK PACK SUBMAPS

/

/COMPUTE THE # OF BIT MAPS BY CHANGING CPM

/

	.DEC

	.IFUND CPM

CPM=5

	.ENDC

EVNMAP=203/CPM		/EVEN # OF BLOCKS.

MAPNO=EVNMAP

REMCYL=EVNMAP*CPM	/ANY LEFT OVER CYLINDERS?

REMCYL=203-REMCYL	/YES IF NOT 0.

	.IFNZR REMCYL

MAPNO=MAPNO+1

	.ENDC

BITMAX=CPM*200		/# OF BITS DESCR BY EVEN MAPS.

MAP1=BITMAX/2		/FIRST BIT MAP NUMBER.

LASTSB=EVNMAP*BITMAX	/LAST MAP.

	.OCT

LFTOVR=MAPNO-1*BITMAX	/COMPUT # OF LEFTOVER BLOCKS.

LFTOVR=TOTALB-LFTOVR	/USED BY .CLEAR CODE

MAPTAB	MAPTAB

	.REPT EVNMAP,BITMAX

SBMAP1	MAP1

	.IFNZR REMCYL

LAST1	LASTSB

	.ENDC

	.ENDC

/

/ DISK CARTRIDGE SUBMAPS

/

	.IFDEF	%RK05

MAPTAB	MAPTAB

SBMAP1	1776		/1ST SUB MAP

SBMAP2	1775		/2ND SUB MAP

BITMAX=10646		/4518(10) BLOCKS DESCRIBED BY BIT MAP

LFTOVR=542		/354(10) BLOCKS LEFT OVER FOR 2ND BIT MAP

MAPNO=2			/2 MAPS FOR RK DISK

	.ENDC

	.ENDC

	.TITLE * BLDRIB *--CONTINUE BUILDING THE RIB.

/

/SUBROUTINE TO BUILD A RETRIEVAL INFORMATION BLOCK.

/'RIBBLK' IS THE CURRENT RIB.  'RIBWRD' IS THE STARTING

/WORD IN THE RIB WHERE THIS SET SHOULD GO.  IF RIBWRD

/IS 0 THE RIB IS EMPTY, IF NON 0 IT MUST BE READ IN

/AND UPDATED.  THE FORMAT OF THE RIB IS AS FOLLOWS

/

/	WRD0	# OF BLOCKS DESCR. BY RIB

/	WRD1	1ST BLOCK #

/	.

/	WRD376	-1 OR PTR TO PREV RIB

/	WRD377	-1 OR PTR TO NEXT BLK.

/

BLDRIB	0

	LAC RIBWRD	/WORD IN RIB WHERE FREE.

	SZA		/BLOCK # LOCATIONS START.

	JMP NOT1ST	/RIB ALREADY STARTED.

	JMS ZFILL	/CLEAR ENTIRE DATA BUFFER.

	IDX RIBWRD	/FIRST RECEIVER.

	JMP UPDRIB	/UPDATE THE RIB.

/

/READ IN THE RETRIEVAL INFORMATION BLOCK AND UPDATE IT.

/

NOT1ST	LAC RIBBLK

	JMS RDRIVE

UPDRIB	LAC RIBWRD

	TAD DATABK

	DAC TEMP2

	LAC NXTLST	/PTR TO RIB

	DAC TEMP1

	LAC BLKLFT	/BLOCKS IN TEMP LIST.

SET5	DAC TEMP5	/MOVE THEM INTO RIB.

/

/RIBBLK IS TYPICALLY CALLED AFTER THE SUBROUTINE 'LSTFIL'

/IS USED.  THESE BLOCK NUMBERS REPRESENT UNUSED (SO FAR)

/DATA BLOCKS.  IF THE NUMBER OF BLOCKS TO BE MOVED INTO

/THE RIB EXPIRES IT, ANOTHER ONE WILL BE REQUIRED FOR

/THE NEXT RIB.

/

TSTFIT	TAD ROOMRB	/ROOM LEFT IN RIB.

	SPA!SNA		/IF PERFECT FIT, PRETEND NOFIT

	JMP RIBFIT	/IT WILL FIT, MOVE LIST IN.

	DAC TEMP5	/# OF BLOCKS THAT DON'T FIT.

	JMS GETNXT	/USE FIRST BLOCK AS

	DAC* DATALK	/NEXT RIBBLK

	IDX TEMP1	/DON'T PASS NEXT BLOXK IN.

	DAC LSTFIL	/SAVE TEMPORARILY

	LAC ROOMRB	/FILL REST OF RIB

	SZA		/IF 0 RIB FILLED BY LAST CALL.

	JMS MOVER

	.EJECT

	LAC TEMP1	/TEMP1 IS CLOBBERED BY WDRIVE.

	DAC DIRPRO	/SAVE IT FOR LATER.

	LAC L1

	DAC RIBWRD

	LAC (RIBSIZ

	DAC* DATABK	/WORD 0.

	LAC RIBBLK

	JMS WDRIVE	/A RIB IS COMPLETE.

	LAC DIRPRO

	DAC TEMP1	/RESTORE PTR TO BLOCK LIST.

	IDX TEMP2

	LAC LSTFIL

	DAC RIBBLK

	LAW -RIBSIZ

	DAC ROOMRB

/

/TEMP5 IS THE NUMBER OF BLOCKS+1 LEFT FOR THE NEW BLOCK.

/ONE BLOCK WAS TAKEN AWAY FOR THE NEW ROB BLOCK.

/DECREASE THE COUNT BY 1 AND START OVER WITH THIS NEW

/RIB.

/

	LAW -1

	TAD TEMP5	/SUBRTARCT 1

	JMP SET5

RIBFIT	DAC ROOMRB

	LAC TEMP5

	TAD RIBWRD

	DAC RIBWRD

	LAC TEMP5

	TAD* DATABK

	DAC* DATABK

	LAC TEMP5

/

	TCA		/2'S COMP FOR MOVER SUBR.

	SZA		/IF 0 DON'T USE IT.

	JMS MOVER	/TEMP1 TO TEMP2.

	LAC RIBBLK	/RIB BLOCK NUMBER.

	JMS WDRIVE	/WRITE AND CLEAR BUFFER.

	JMP* BLDRIB 	/BUILDING COMPLETE

	.ENDC

	.ENDC

	.ENDC

	.EJECT

/

/SUBROUTINE 'SETPNT' USES UFD2 TO SETUP THE

/INDIVIDUAL UFD ENTRY WORD POINTERS.

/
SETPNT	0

	LAC UFD2	/PTR TO WORD 0 OF ENTRY
	AAC 2		/(RCHM-156)

	DAC U.EXT	/POINTER TO THE EXTENSION.

	IAC	

	DAC U.FBLK	/PTR TO 1ST BLK# ENTRY

	.IFUND %LVERS

	IAC	

	DAC U.SIZ	/PTR TO WORD 4, FILE SIZE

	IAC	

	DAC U.RIB	/PTR TO 1ST RIB BLK ENTRY

	IAC	

	DAC U.RBWD

	IAC	

	DAC U.DATE

	.ENDC

	JMP* SETPNT

	.IFUND %CVERSION

	.IFUND %LVERSION

/A TEMP BLOCK LIST EXISTS WITH BLOCK NUMBERS

/IN IT REPRESENTING BLOCKS THAT WILL BE USED BY THIS

/FILE.  'GETNXT' TAKES A BLOCK FROM THIS LIST, PUSHES

/THE POINTER DOWN AND DECREMENTS THE COUNTER 'BLKLFT'.

/

/

GETNXT	0	

	LAW -1

	TAD BLKLFT

	DAC BLKLFT

	LAC* NXTLST

	IDX NXTLST

	TSTB00		/BLOCK 0 CANNOT BE USED FOR OUTPUT.

	JMP* GETNXT

	.TITLE * WIPOUT *--DELETE THE FILE FROM DISK.

/

/UFD1 AND UFD2 MUST BE SETUP BEFORE THIS

/ROUTINE IS CALLED. UFD1 IS POINTING AT THE

/BLOCK # AND UFD2 THE WORD WITHIN THE BLOCK

/WHERE THIS ENTRY BEGINS (WORD 0 OF THE ENTRY).

/

WIPOUT	0

	JMS SETPNT	/SETUP ALL THE POINTERS.

	LAC* U.RIB

	DAC RIBBLK	/RIB BLOCK #

	LAC* U.RBWD

	AND (777

	DAC RIBWRD

/ 

/ SET RSXT1 WITH THE FILE SIZE AND RSXT2 WITH THE STARTING FILE BLOCK

/ IN CASE THE FILE TO BE DELETED IS AN RSX CREATED FILE I.E. AN RSX

/ RANDOM ACCESS FILE. THESE FILES CONSIST OF CONTIGUOUS DISK BLOCKS

/ AND HAVE NO BLOCK POINTERS OR RIB DATA. THIS TYPE OF FILE

/ IS INDICATED IF THE FILE SIZE IF LESS THAN ZERO.

/

	.IFUND %LVERS

	LAC*	U.SIZ

	DAC	RSXT1

	LAC*	U.FBLK

	DAC	RSXT2

	.ENDC

/

/THE RIB BLOCK # AND THE WORD-IN-RIB HAVE BEEN SAVED.

/THIS ENTRY CAN BE CLEARED TO ZERO

/

	LAC* BSYWD4

	TCA

	DAC GONNER

	LAC UFD2	/WORD 0 OF ENTRY

	JMS ZERO

GONNER	0

	LAC UFD1	/WRITE THE UPDATED UFD BLOCK.

	JMS WDRIVE

/ 

/ TEST TO SEE IF THE FILE IS AN RSX RANDOM ACCESS FILE AND IF SO

/ USE A SPECIAL ALGORITHM TO DEALLOCATE THE BLOCKS.

/ 

	LAC	RSXT1	/TEST TO SEE IF RSX RANDOM FILE

	SMA

	JMP	RDRIB-1	/IT'S NOT -- DEALLOCATE BLOCK BY BLOCK

	AND	(377777	/IT IS -- CONTIGUOUS BLOCKS

	TCA		/EDIT  ADD TCA (BR-149)

	DAC	RSXT1	/SAVE 2'S COMP OF REAL FILE SIZE

	DZM	CSBMAP

	LAC	RSXT2	/GET 1ST BLOCK NUMBER

	DAC	RSXT2

	JMS	OFFBIT	/DEALLOCATE THE BIT CORRESPONDING TO THIS BLK

	LAC	RSXT2	/INCREMENT BLOCK NUMBER

	IAC		/ REPLACE TAD (1 WITH IAC (BR-149)

	ISZ	RSXT1	/END OF FILE?

	JMP	.-5	/NO -- DEALLOCATE ANOTHER BLOCK

	LAC	RSXT3	/GET THE BLOCK NO. OF THE SAT BLOCK

	JMS	WDRIVE	/WRITE OUT SAT

	JMP*	WIPOUT	/RETURN -- ALL DONE

/

/READ IN THE FIRST RIB. IF RIBWRD IS NON 0

/THE RIB IS LIVING BEHIND THE LAST DATA BLOCK.

/

	LAC RIBBLK	/RIB BLOCK #

RDRIB	JMS RDRIVE	/READ IT IN.

	LAC RIBWRD	/IS THIS STAND ALONE?

	SNA!CLC		/NO IT SHARES A DATA BUFF.

	JMP NOMOVE	/YES NO MON;VE REQ.

	DAC RECEV1	/SET LINK SWITCH TO -1.

	JMS RIBADJ	/NO ADJUST RIB.

	LAC RIBBLK

	JMS OUTPUT	/WRITE BUT DON'T CLEAR.

	LAC* DATABK	/# OF BLOCK TO TURN OFF.

	TCA

	DAC FILSIZ

	LAC WORD1

	DAC DONOR1

	JMP LSTMOV

	.EJECT

/

/THE RIB IS LIVING AT DATABK, WORD 0 DESCRIBES

/THE NUMBER OF BLOCKS TO TURN OFF.

/

NOMOVE	LAC* DATABK	/NO. OF BITS TO TURN OFF.

	CMA		/USE 1'S COMP FOR # OF BLKS+1

	DAC FILSIZ

	LAC RIBBLK

	DAC* DATABK

	LAC* DATALK

	DAC RECEV1

	LAC DATABK

	DAC DONOR1

/

/FILSIZ=NUMBER OF BLOCKS IN THIS RIB

/IF FILSIZ OVERFLOWS BUT TEMP5 DOES NOT ALL THE BLOCKS ARE OFF.

/

LSTMOV	LAC BKPTRS	/WORD0 OF TEMP LIST.

	DAC NXTLST

	DAC TEMP2	/RECEIVER FROM DATA BLOCK

	LAC DONOR1	/DONOR OF MOVER SUBR.

	DAC TEMP1

	LAC LSTSIZ

	TCA

	DAC TEMP5

	JMS MOVER

	LAC TEMP1

	DAC DONOR1	/RESTORE PTR FOR NEXT MOVE

	DZM CSBMAP

TRNOFF	JMS GETNXT

	JMS OFFBIT

	ISZ FILSIZ	/HAS THE WHOLE RIB EXPIRED?

	SKP		/NO..TEST THE TEMP LIST.

	JMP RIBEXP	/YES..CHECK THE SAVED DATA LINK.

/

/TEST FOR TEMP LIST EXPIRED.

/

	ISZ TEMP5

	JMP TRNOFF

	LAC BLOCK	/WRITE THE BIT MAP

	JMS WDRIVE

	LAC RIBBLK

	JMS RDRIVE	/READ THE RIB

	JMP LSTMOV	/MOVE BLOCKS INTO TLIST

	.EJECT

/

/AT RIBEXP THE RIB HAS EXPIRED.  IF THE DATA LINK SAVED AT

/RECEV1 IS -1 THE WIPOUT IS COMPLETE.  IF NOT USE IT AS THE

/NEXT RIB.

RIBEXP	LAC BLOCK

	JMS WDRIVE

	LAC RECEV1

	SPA

	JMP* WIPOUT	/ALL DONE.

	DAC RIBBLK

	DZM RIBWRD

	JMP RDRIB

/THE FIRST RIB IS IN. IT IS STORED AT THE END OF

/THE DATA BLOCK (RIBWRD NON 0).

/

RIBADJ	0

	LAC DATABK	/WORD 0

	DAC TEMP2

	TAD RIBWRD

	DAC TEMP1

	LAC* TEMP1	/NUMBER OF BLOCK#S TO MOVE UP.

	CMA		/1'S COMP = # OF BLKS+1.

	JMS MOVER

	JMP* RIBADJ

	.TITLE * OFFBIT *-ZERO THE BIT ASSOCIATED WITH BLK#.

/

/SUBROUTINE TO UPDATE THE SAT BLOCK.

/

OFFBIT	0

	TSTB000		/BLOCK 0 CANNOT BE GIVEN BACK.

/

/THE BLOCK # IS IN THE AC.  FIND THE BIT MAP THAT IT BELONGS

/IN BY DIVIDING BY THE MAX NUMBER OF BLOCKS PER MAP.

/

	DIVREM BITMAX,OFFSAV

	DAC SETVAL	/SAVE QUOT(BIT MAP#-1).

	TAD (-MAPNO+1	/NO OF MAPS -1.

/

/TEMP2 IS THE BLOCK# RELATIVE TO THE BITMAP..

/

	SMA!SZA		/IF POS MAP DOES NOT EXIST

	JMS IOPS74	/BLOCK NO DOES NOT EXIST.

	LAC SETVAL

	TAD (SBMAP1	/TABLE OF MAPS

	DAC SETVAL	/PTR TO THIS MAP NO.

	LAC* SETVAL	/GET THE MAP NUMBER.

	DAC	RSXT3	/SAVE THE BLOCK NUMBER

	SAD CSBMAP

	JMP MAPIN

	LAC CSBMAP	/MAP #'S DO NOT MATCH IF CSBMAP

	SZA		/IS 0 NO MAP IS IN, IF NOT

	JMS WDRIVE	/WRITE OUT THE OLD ONE.

	LAC* SETVAL

	DAC CSBMAP

	JMS RDRIVE	/BIT MAP FOR THIS BLOCK

	.EJECT

MAPIN	LAC OFFSAV	/BLOCK # OF THIS FILE

	DIVREM 22,ZERO	/DIV BLK BY 22(8).

	TAD DATABK	/FIND WORD IN SUBMAP

	TAD (MAPDES	/QUOTIENT+WORD3=BIT MAP WRD.

DDD	DAC TEMP4

/

/THE REMAINDER LIVES AT 'ZERO'.

/IT POINTS TO THE BIT IN THE WORD THAT THE BLOCK

/REPRESENTS. LOOP FROM LEFT TO RIGHT 'ZERO'

/BITS TO GET THE CORRECR POSITION.

/

FNDBIT	LAC L45ZS	/SETUP THE BIT MOVER LOOP.

	DAC TEMP1

	LAC ZERO

	TCA

	DAC ZERO

	SNA!CLL		/IS IT BIT POSITION 0?

	JMP BITFND	/YES..DON'T GO INTO LOOP.

	LAC L45ZS	/START LEFT TO RIGHT

LOOP1	RCR

	ISZ ZERO

	JMP LOOP1

	DAC TEMP1	/SAVE THE WORD.

/

/THE ONLY BIT ON IN TEMP1 INDICATES THE BIT  IN THE 

/WORD POINTED TO BY TEMP4 THAT MUST BE TURNED OFF.

/IF THE BIT IS ALREADY OFF THIS WILL TURN IT ON.

/ITS AN INDICATION THAT THE STRUCTURE IS BAD.

/

BITFND	LAC TEMP1	/1 BIT 

	AND* TEMP4

	SNA		/OK IF NOT 0.

TST.74	JMS IOPS74	/FUDGED  BY .CLEAR CODE.

	XOR* TEMP4	/1 BIT IS TURNED OFF(ON IF .CLEAR).

	DAC* TEMP4	/THIS BIT LIVES.

	LAW -1		/UPDATE THE BUSY BLOCK COUNT.

	TAD* WORD2

	DAC* WORD2

	JMP* OFFBIT	/FINISHED WITH THIS BLOCK.

	.ENDC		/COND STARTED AT LSTFIL

	.ENDC

	.TITLE ERROR MESSAGES

/

	.IFUND	RSX

IOPS21	LAC BLOCK	/ILLEGAL DISK ADDRESS.

	DAC* (BADBLK

	LAW 21

	JMP RECOVR	/TRY TO RECOVER AFTER CNTRL R.

	.ENDC

	.IFDEF	RSX

IOPS21	ERR	21	/NEEDS TO RETURN STATUS REGISTER#############

	.ENDC

	.IFUND	RSX

IOPS20	LAW 20	/########NEEDS TO RETURN STATUS REGISTER ########

	SKP

IOPS4	LAW 4

	.IFDEF %RP02

	DZM UNDWAY

	.ENDC

RECOVR	JMS E.PRNT

	LAW -5

	JMP RETRY

	.ENDC

	.IFDEF	RSX

IOPS20	ERR	20

IOPS4	LAC	EVMM	/CHECK FOR MULTIPLE IOPS 4 MESSAGES

	SZA

	JMP	RETRAW	/BEEN HERE

	ISZ	EVMM	/PREVENT RE-ENTRY

	LAC*	UNITCN	/PICK UP THE UNIT NUMBER OF THIS REQUEST

	LRS	16	/MOVE IT TO BITS 14-16

	AND	(16)

	XOR	NTMSG+1	/PUT IT IN THE MESSAGE

	DAC	NOTMSG+5

	CAL	IOPS4M

	CAL	WFEV	/WAIT FOR EVENT VARIABLE

RETRAW	LAW	-5	/RETRY

	JMP	RETRY	/RETRY THE FUNCTION

/

WFEV	20	/WAIT FOR EVENT VARIABLE

	EVM

/

EVM	0

EVMM	0	/DOUBLE MESSAGE SWITCH

/

NOTMSG	.ASCII	' **** READY DP0'<15>

	.IFUND	%RK05

NTMSG	.ASCII	'Y DP0'

	.ENDC

	.IFDEF	%RK05

NTMSG	.ASCII	'Y RK0'

	.ENDC

IOPS4M	2700	/WRITE

	EVM	/EVENT VARIABLE ADDRESS

	3	/LUN 3

	2	/IOPS ASCII

	NOTMSG	/BUFFER ADDRESS

	.ENDC

	.EJECT

IOPS3	ERR 3	/ILLEGAL INTERRUPTS ARE OFFENSIVE!!

IOPS6	ERR 6	/ILLEGAL CAL FUNCTION.

IOPS7	ERR 7	/ILLEGAL DATA MODE.

IOPS11	ERR 11	/.INIT,.SEEK,.ENTER NOT EXECUTED.

	.IFDEF	%RK05

IOPS12	ERR 12	/UC15 NOT ENABLED ON RK CAL (BR-149)

	.ENDC

IOPS2A	LAC	BLOCK	/(SCR-153) ILLEGAL BLOCK # FOR PRINTOUT

	DAC*	(BADBLK	/(SCR-153)

	ERR	21	/(SCR-153) FATAL ERROR; ILLEGAL BLK #

IOPS17	DZM CSLOT

	ERR 56	/RSX ERROR 56

IOPS51	ERR 51

/			/(SCR-155)ALLOW CODE FOR RKL

IOPS55	DZM CSLOT

IOPSE5	ERR 55		/(SCR-154)ALTERNATE 55 ENTRY POINT

/			/(SCR-155)

IOPS61	ERR 61	/NEEDS RSX ERROR################

IOPS63	ERR 63

	.IFUND %LVERS

IOPS70	ERR 70

	.ENDC

IOPS73	ERR 73	/RSX ERROR NUMBER 53

	.IFDEF	RSX

IOPS10	ERR	10

IOPS13	ERR	13

IOPS15	ERR	15

IOPS23	ERR	23

IOPS30	ERR	30

IOPS66	ERR	66

IOPS67	ERR	67

IOPS71	ERR	13	/RSX ERROR NUMBER 13

IOPS74	NOP	/ENTERED VIA JMS

	ERR	74	/RSX ERROR NUMBER 74

IOPS75	NOP

	ERR	75	/RSX ERROR NUMBER 75

	.ENDC

	.IFUND	RSX

IOPS75	0	/MULTIPLE ENTRY POINTS.

	LAW 75	/IRRECOVERABLE ERROR.

FATAL	DAC MOVNAM

	JMS E.PRNT

	LAW -5

	LAC MOVNAM	/KEEP LOOPING WHEN USER

	JMP FATAL+1	/TYPES CONTROL R.

	.EJECT

E.PRNT	0

	DAC TEMP15	/SAVE/ ERROR NO.

	.IFDEF %RP02

	LAC UNITNO	/IF THIS IS DISK PACK (CARTRIDGE)

	RCR		/BUILD THE .SIXBT FOR

	RTR		/THE UNIT NUMBER AND PRINT IT.

	TAD (600040	/UNIT#,NULL,SPACE

	DAC UNITSP

	.ENDC

	LAC LOC.0

	DAC* (.MED

	XCT* E.PRNT

	DAC ERCNTX	/COUNT FOR EXPANDED ERRS.

	LAC FUNCTN	/PRINT THE FUNCTION FOR ALL ERRORS.

	LRSS 3		/BROUGT TO YOU BY RICK COOK.

	ALS 3

	LLS 3

	TAD (406060

	DAC ERRFUN

	LAC TEMP15

	CLL		/MAKE SURE NULLS ARE IGNORED.

	JMS* (EXERRS

	JMP* E.PRNT

ERCNTX	LAW -5

/

/****************************************

/

	TYPE		/DKX

UNITSP	40		/UNIT#(IF PACK),NULL,SPACE.

ERRFUN	0		/FUNCTION IN SIXBT.

	40		/1 SPACE AFTER FUNCTION.

UIC	0

	404040		/3SPACE .

NAMER1	0

NAMER2	0

L45ZS	400000		/1 SPACE 2 NULLS.

NAMER3	0

/

/***************************************

	.TITLE ERROR MESSAGES FOR NAMED FILES.

/

/

/

MOVNAM	0

	LAC NAME1

	DAC NAMER1

	LAC NAME2

	DAC NAMER2

	LAC NAME3

	DAC NAMER3

GTNUM	XCT* MOVNAM

	JMS E.PRNT

	LAW -12

	JMP GTNUM	/UNRECOVERABLE.

	.IFUND %NOOUT

IOPS15	JMS MOVNAM

	LAW 15

	.ENDC

IOPS23	JMS MOVNAM

	LAW 23

IOPS13	JMS MOVNAM

	LAW 13

IOPS10	JMS MOVNAM

	LAW 10

IOPS64	JMS MOVNAM

	LAW 64

	.IFDEF %AVERSION

IOPS66	JMS MOVNAM

	LAW 66

	.ENDC

IOPS67	JMS MOVNAM

	LAW 67

IOPS71	JMS MOVNAM

	LAW 71

IOPS74	0	/SAVE CALLING ADDRESS FOR CORE DUMPS.

	JMS MOVNAM

	LAW 74

/

/

/

	.ENDC

	.IFDEF	RSX

NORMXT=.

LOC3XT=.

FINREQ	CLA!IAC	/REQUEST FINISHED OK

FATALE	PAL		/SAVE ERROR OR GOOD EVENT VARIABLE

	LAC	DPUSEV	/PICK UP USER'S EVENT VARIABLE

	TAD	XADJ

	PAX		/PUT IT IN XR

	PLA		/RESTORE AC

	DAC	0,X	/SET EVENT VARIABLE

	LAC	(401000) /DECALRE A SIGNIFICANT EVENT

	ISA

	LAC	DPNODE	/RETURN EVENT VARIABLE

	DAC*	(R2)	/ TO POOL

	LAC	(POOL)

	DAC*	(R1)

	JMS*	(IOCD)	/COUNT DOWN I/O PENDING REQUEST'S

	JMS*	(NADD)	/ADD A NODE TO THE POOL

	JMP	DPNXT	/GO SEARCH FOR THE NEXT REQUEST

/

FATAL	DAC	EVM	/SAVE ERROR CODE

	JMS	GVBACK	/GIVE BACK THE BUFFER POINTER

	DZM	CSLOT	/CLEAR THE BUFFER POINTER

	LAC	CDESC

	JMS	ZERO	/CLEAR THE BUFFER

	LAW	-NODESC	/WORD COUNT

	LAC	EVM	/RESTORE ERROR CODE

	JMP	FATALE	/RETURN FATAL ERROR

	.IFDEF GLUNK	/PROBABLY WON'T NEED THIS CODE; DT DID NEED IT

IORD	LAC	DPEVA	/PICK UP THE EVENT VARIABLE AND RESET IT

	XOR	(100000)/MASK OFF THE I/O RUNDOWN BIT

	.ENB		/ENABLE INTERRUPTS

	DAC	DPEVA	/RESTORE EVENT VARIALBLE

	LAC	UNITAB	/DEQUE THE REQUEST

	TAD	MXADJ	/REMOVE XR ADJUSTMENT

	DAC*	(R1)

	JMS*	(DQRQ)

	JMS	WFDTW	/CAN'T HAPPEN BUT IF IT DOES ....

	DAC	ABTNOD	/SAVE THE ADDRESS OF THE ABORT NODE

	CLX		/FIND THE STL POINTER

	AXR	2

	LAC*	ABTNOD,X/PICK UP THE ABORTED TASK'S POINTER

	SAD*	DPNODE,X	/ARE WE SERVICING IT NOW?

	SKP

	JMP	NOTACT	/NO DON'T ABORT IT

	LAC	ABTFL	/ABORT LEGAL ANOW?

	SZA

	JMP	ABTCLA	/NO DON'T ABORT WHILE WRITING DIRECTORY

	DTRA		/STOP THE DT

	AND	(757777)

	DTLA		/UNCONDITIONALLY

	JMS	DETCH	/DETACH THE DECTAPE

	LAC	DTNODE	/RETURN THE DT NODE TO THE POOL

	DAC*	(R2)

	LAC	(POOL)

	DAC*	(R1)

	JMS*	(IOCD)	/I/O COUNTDOWN

	JMS*	(NADD)	/ADD NODE TO POOL

	JMS	DQALL	/DEQUEUE THE REST OF THE NODES

	JMP	CLEARQ	/FETCH NEXT REQUEST FINISHED HERE#WAS JMP FNR

/

ABTCLA	LAC	(DTUEVA	/ABORT WHILE WRITING DIRECTORY

	DAC	DTUEVA	/SET EVENT VARIABLE TO SELF AND PROCEED

NOTACT	JMS	DQALL	/DEQUE THE STACKED I/O REQUEST'S

	JMP	WFDTW	/WAIT FOR THE RUNNING DT TASK

	.ENDC

/

DQALL	0

	LAC	(UNITAB)/SET UP TO CLEAR ALL THE PHYSICAL DEVICE NODES

	DAC	ABTPDV

	LAW	-10

	DAC	PDVCT

DQLP	LAC*	ABTPDV	/PICK UP THE FIRST NODE

	SNA

	JMP	DQFIN	/FINISHED NO MORE NODES

	TAD	MXADJ

	DAC*	(R1)

	LAC	ABTNOD	/PICK UP THE ADDRESS OF THE ABORT NODE

	DAC*	(R2)

	JMS*	(DMTQ)	/DETACH AND EMPTY QUEUE

	ISZ	ABTPDV	/POINT TO NEXT QUEUE

	ISZ	PDVCT	/FINISHED?

	JMP	DQLP	/NO KEEP TRYING

DQFIN	LAC	(POOL)	/RETURN ABORT NODE TO POOL

	DAC*	(R1)

	LAC	ABTNOD

	DAC*	(R2)

	AAC	6	/ADD 6 TO POINT TO EVENT VARITBLE ADDRESS

	DAC	ABTNOD

	LAC*	ABTNOD	/PICK UP EVENT VARIABLE

	TAD	XADJ	/ADD XR ADJUSTMENT

	PAX

	CLA!IAC

	DAC	0,X	/SET EVENT VARIABLE

	JMS*	(IOCD)	/DO AN I/O COUNT DOWN

	JMS*	(NADD)	/ADD A NODE TO THE POOL

	JMP*	DQALL	/RETURN TO CALLER ALL DONE

/

ABORT	LAC	DPEVA	/CLEAR ABORT FLAG

	AND	(677777)

	.ENB		/ENABLE INTERRUPTS

	DAC	DPEVA

	LAC	UNITAB	/FIND THE ABORT NODE

	TAD	MXADJ

	DAC*	(R1)

	JMS*	(DQRQ)	/DEQUEUE A NODE

	JMP	CLEARQ	/CAN'T HAPPEN (I HOPE)#WAS JMP FNR

	DAC	ABTNOD	/SAVE THE NODE POINTER

	TAD	XADJ

	PAX

	LAC	5,X	/CHECK THE REQUEST TYPE

	SAD	(17)	/IS IT ABORT LUN 0

	SKP

	JMP	ATDETL	/ERROR ILLEGAL REQUEST KILL IT

	JMS	DQALL	/DO THE I/O RUNDOWN

	JMP	CLEARQ	/FETCH NEXT REQUEST#WAS JMP FNR

/

ABTDQD	XOR	5,X	/WAS IT A LEGAL ABORT

	SNA		/?

	JMP	NO6

	LAW	-6	/NO, RETURN -6 EV

	JMP	FATALE

NO6	LAC	DPNODE

	DAC	ABTNOD	/SAVE IT IN ABORT NODE

	.INH		/RESET DECTAPE EVENT VARIABLE

	LAC	DPEVA

	AND	(677777)

	.ENB

	DAC	DPEVA	/CLEARING TTHE I/O RUNDOWN FLAG

	JMS	DQALL	/DO THE I/O RUNDOWN

	JMP	CLEARQ	/FETCH TTHE NEXT REQUEST #WAS JMP FNR

	.ENDC

/

	.TITLE ZEROING OUT UTILITIES

/

/SUBROUTINE 'ZERO' STORES ZEROES INTO THE LIST SPECIFIED

/BY THE AC.

/

/CALLING SEQ:

/LOC-1	LAC ADDR	/CLEAR OUT THIS AREA.

/LOC	JMS ZERO

/LOC+1	LAW -N		/NO OF WORDS TO CLEAR.

/LOC+2	CONTROL RETURNS HERE.

/

ZERO	0

	DAC TEMP1		/STARTING ADDR.

	XCT* ZERO

	DAC TEMP2

ZEROLP	DZM* TEMP1

	IDX TEMP1

	ISZ TEMP2

	JMP ZEROLP	/ZERO LOOP

	JMP* ZERO

/

	.IFUND %CVERSION

	.IFUND %LVERSION

/

ZFILL	0

	LAC DATABK

	JMS ZERO

	LAW -400

	LAW -1

	DAC* DATALK

	DAC* BAKWRD

	JMP* ZFILL

	.ENDC

	.ENDC

	.TITLE GIVE BACK THE BUFFER

/

	.IFUND %LVERSION

/

/SUBROUTINE 'GVBACK' DELETES THE USER FROM THE BUSY 

/TABLE AND GIVES HIS BUFFER BACK TO THE MONITOR IF HE HAD ONE.

/

GVBACK	0

	DZM* BSYWD0

	LAC* BSYWD1

	DZM* BSYWD2

	DZM* BSYWD3

	DZM* BSYWD4	/UFD ENTRY SIZE.

	DZM* BSYWD1

	SNA

	JMP* GVBACK

	.IFUND	RSX

/

/** EMULATE .GVBUF ***

/

EMUL	DAC TEMP7	/SAVE THE BUFFER ADDRESS.

	LAC* (NUMBUF	/# OF BUFFER IN SYSTEM.

	TCA

	DAC TEMP1	/SEARCH COUNT

	LAC* (BFPOOL	/BUFFER POOL ADDRESS IN AC.

	DAC TEMP2	/ADDRESS TO TABLE OF ADDRESSES.

FNDBUF	LAC* TEMP2	/THE ADDRESS IS KEPT IN ONE'S

	CMA		/COMPLEMENT FORM BY THE MONITOR

	SAD TEMP7	/IF THAT BUFFER IS BUSY

	DAC* TEMP2

	IDX TEMP2

	ISZ TEMP1

	JMP FNDBUF

	JMP* GVBACK

	.ENDC

	.IFDEF	RSX

	DZM	TEMP18	/CLEAR TEMPORARY REGISTER

	PAL		/SAVE POINTER TO BUFFER

	SAD	(BUFTMP) /CHECK TO SEE IF THIS IS THE BUFFER NEEDED

	JMP	FND	/YES -- FOUND THE BUFFER ADDRESS

	TAD	(-500)	/SUBTRACT BUFFER SIZE

	ISZ	TEMP18	/UPDATE POINTER

	JMP	.-4	/TRY AGAIN

FND	LAC	TEMP18	/PICK UP BUFFER COUNT

	PAX		/SAVE IT IN XR

	PLA

	DAC	BUFFPT,X	/SAVE BUFFER POINTER IN TABLE

	JMP*	GVBACK	/RETURN

	.ENDC

	.TITLE  COMMON STORAGE

/

	.IFUND %LVERSION

	.IFUND %CVERSION

/

/***CONSTANTS***

/

FAKER	.+1		/# OF ZEROES USED TO

	.REPT SIZUFD	/FIND DUMMY ENTRIES

	0

	.ENDC

	.IFUND	RSX

LSTSIZ	0	/SET BY ONCE ONLY CODE.

BUFSIZ	0	/2'S COMP OF .SCOM +27(BUFFER SIZE).

	.ENDC

	.IFDEF	RSX

LSTSIZ	30

BUFSIZ	-500	/BUFFER SIZE AND LIST SIZE CONSTANT

	.ENDC

	.ENDC

	.ENDC

/

	.IFUND	RSX

UICPT	UIC

	.ENDC

	.IFDEF	RSX

UICPT	UICRSX

	.ENDC

L1	1

	.IFUND	RSX

BUF.OK	0	/BUFFER SIZE OK SWITCH.

	.ENDC

	.IFDEF	RSX

BUF.OK	-500+450

	.ENDC

NAMEPT	NAME1

EOF1	1005

/

	.IFUND	RSX

/*******************************

/* EOF2 IS BUMPED TO 776773 BY *

/* ONCE ONLY CODE              *

/*******************************

/

EOF2	776772	/BUMPED TO 776773

	.ENDC

	.IFDEF	RSX

EOF2	-1005

	.ENDC

	.IFDEF %RB09

HI.BLK	MAXBLK

	.ENDC

	.IFDEF	%RK05

HI.BLK	MAXBLK

	.ENDC

	.TITLE COMMON VARIABLES.

/

DPRO	0

DUMSW	0

CALPTR	0	/USER CAL POINTER

IOFUNC	0

FUNCTN	0

SAVWRC	0	/SAVE WRITEE CHECK STUFF.

ARGPTR	0

TEMP	0

CSLOT	0

COMPHI	0

WORD	0

TEMP15	0

TEMP16	0

COUNT	0

ASLOT	0	/ARGUMENT DAT SLOT.

	.IFUND	RSX

SUBFUN	0	/BITS 6,7,8 OF ARG CAL.

	.ENDC

B.5678	0	/SAVE CAL SUBFUNCTION WHILE UNDWAY.

UNDWAY	0

	.IFUND %LVERSION

BSYWD0	0

BSYWD1	0

BSYWD2	0

BSYWD3	0

BSYWD4	0

LSTPNT	0	/POINTER TO TEMP LIST DURING LSTFIL.

OFFSAV	0

BEGBUF	0	/PTR TO 400+X WORD BUFFER.

LSTCNT	0	/COUNTER USED BY 'LSTFIL'.

DATABK	0	/PTR TO WRD0 OF 400 DATA BLOCK.

DATALK	0	/PTR TO WRD 377(LINK) OF DATA BLOCK.

BAKWRD	0	/PTR TO WRD 376 IN DATA BLOCK.

BKPTRS	0

WORKER	0

MAPS	0

MAPTRY	0	/NUMBER OF TRIES PER MAP, MAX SET TO -DELTA-1

SAVSIZ	0

RIBSAV	0

WBLOCK	0

	.ENDC

NUMWDS	-400

	.EJECT

	.IFDEF	RSX

L45ZS	400000

UNITNO	0

DIRPRO	0

	.IFUND	%RK05

BSTAT	0

	.ENDC

TEMP1	0

TEMP2	0

TEMP3	0

TEMP4	0

TEMP5	0

	.ENDC

/

/DIRECTORY ENTRY POINTERS.

/

U.EXT	0	/WORD2 = EXTENSION NAME.

U.FBLK	0	/WORD3 = 1ST DATA BLOCK POINTER.

	.IFUND %LVERS

U.SIZ	0	/WORD4 = SIZE OF FILE MINUS RIBS.

U.RIB	0	/WORD5 = PTR TO 1ST RIB.

U.RBWD	0	/WORD6 = PTR TO WORD IN RIB WHERE LIST SRARTS.

U.DATE	0	/WORD7 = DATE.

RSXT1	0

RSXT2	0

RSXT3	0

	.ENDC

	.IFDEF %LVERSION

BUFSIZ	0

LSTSIZ	0

OLDUIC	0	/SET AT .CLOSE TIME.

OLDUFD	0	/SET AT 'FINDER' TIME.

OLDSIZ	0	/SET AT (FINDER'

MULMAP	0

OLEGAL	0

BEGBUF	ONCELY

DATABK=BEGBUF

BAKWRD	ONCELY+376	/PTR TO BAKWRD LINK.

DATALK	ONCELY+377	/PTR TO FORWRD LINK

	.ENDC

	.IFDEF %RB09

LOC.2	0

LOC.3	0

LOC.4	0

LOC.5	0

TRK.SR	0

	.ENDC

	.IFUND %RF15

DONOR1	0

DONOR2	0

SAVEQ	0

TRANSW	0

SAVSUM	0

CKSMPT	0

OFFSET	0

SECTOR	0

WRCHEK	0

TEMP6	0

TEMP7	0

EXITAD	0

	.IFUND	%RK05

STATUS	0

	.ENDC

	.ENDC

	.IFDEF %RP02

	.IFUND	%RK05

CYLAD	0	/CYLINDER ADDRESS 0-202(10)

HEDAD	0	/HEAD(TRACK) ADDRESS 0-9(10)

PAKAD	0	/COMBINED(CYL,HEAD,SECTOR)

	.ENDC

	.IFDEF	%RK05

RKUNIT	0		/RK UNIT # RIGHT JUSTIFIED

	.ENDC

SHUNIT	0	/SHIFTED DISK PACK UNIT NO.

	.ENDC

	.TITLE * CSAVE *--SAVE CURRENT SET.

/

	.IFUND %LVERSION

/

/CSAVE MOVES DESCRIPTORS TO OR FROM THE 'CURRENT SET'.

/THE LINK IS THE ONLY CALLING ARGUMENT.

/ALL THE DESCRIPTORS FOR THE FILE ARE SAVED AS PART

/OF THE CURRENT DATA BUFFER.

/IT USES THE SAME POINTERS AND COUNTERS EACH TIME ITS

/CALLED.  THE CRITICAL WORDS THAT MUST BE SET UP

/ARE AS FOLLOWS:

/ 1.  BEGBUF	IS ALWAYS POINTING TO WORD 0 OF THE CURRENT

/		(BUSY) DATA FILE.  BEGBUF IS SET UP AT SECTION

/		1 (S1) WHEN THE ARGUMENT CAL BECOMES THE CURRENT

/		CAL.

/ 2.  NODESC	THE NUMBER OF DESCRIPTORS REQUIRED PER OPEN FILE.

/		THIS WORD IS SETUP WHEN THE PROG. IS ASSEMBLED

/		AND DOES NOT CHANGE.

/ 3.  CDESC	IS ALWAYS POINTING TO THE FIRST WORD OF THE

/		'CURRENT SET'.  THIS WORD IS USED FOR MOVING

/		DESCRIPTORS IN OR OUT OF THE 'CURRENT SET'.

/

/LINK=1		SAVE CURRENT SET AT BEGBUF

/

/LINK=0		MOVE CURRENT SET FROM BEGBUF TO CDESC.

/

/

CSAVE	0

	LAC BEGBUF	/TOP OF DATA BUFFER

	SZL

	JMP MOVCIN	/LINK=1 SAVE CSET.

	DAC TEMP1

	LAC CDESC

	DAC TEMP2

CSAV1	LAC (NODESC	/NO OF DESCRIPTORS TO MOVE

	TCA		/TCAATE THE AC.

	DAC TEMP3

MOVLUP	LAC* TEMP1	/ALWAYS CLEAR THE 'CURRENT SET'

	DZM* TEMP1	/BEFORE LEAVING IN CASE NOTHING

	DAC* TEMP2	/HAS TO BE MOVED IN, SUCH WOULD

	IDX TEMP1	/BE THE CASE IF THE ARGUMENT

	IDX TEMP2	/SLOT 'ASLOT' REPRESENTS A FILE

	ISZ TEMP3	/THAT IS NOT BUSY (NEVER BEEN

	JMP MOVLUP	/CALLED OR PREVIOUSLY 'CLOSED').

	JMP* CSAVE

MOVCIN	DAC TEMP2	/CSET TO BEGBUF

	LAC CDESC

	DAC TEMP1

	JMP CSAV1

/

	.ENDC

/

	.TITLE	CURRENT SET---OF DESCRIPTORS

/

CDESC	CURBEG	/PTR TO CURRENT SET.

CURBEG=.

NAME1	0	/1ST 3 CHARS OF PROPER NAME.

NAME2	0	/2ND 3 CHARS OF PROPER NAME.

NAME3	0	/EXTENSION NAME.

EOF	0	/END OF FILE SWITCH.

	.IFUND %LVERS

ROOMRB	0	/ROOM LEFT IN RIB.

FPRO	0	/FILE PROTECTION CODE.

BLKLFT	0	/# OF BLOCKS LEFT.

FILSIZ	0	/# OF DATA BLOCKS IN FILE.

OLDFIL	0	/WORD 0 OF OLD FILE ENTRY.

OLDBLK	0	/UFD BLK # OF OLD FILE(OLDFIL LIVES HERE).

OLDSW	0	/OLD FILE FOUND SWITCH.

CSBMAP	0	/CURRENT SUBMAP#.

NXTLST	0	/PTR TO NEXT BLOCK IN T-LIST.

RANDHI	0	/HIEST REL BLK # OF FILE.

RANDSW	0	/.RAND EXECUTED SWITCH.

	.IFDEF RSX

RENSW	0	/RENAME IN PROGRESS SWITCH

	.ENDC

FRSTRB	0		/!!134!! FIRST RIB BLOCK OF MANY

RIBBLK	0

RIBNUM	0	/RESIDENT RIN AT RTRAN TIME.

RIBWRD	0

START	0

	.ENDC

DATAPT	0	/DATA LINE BUFFER HEADER (.READ).

WDSLFT	0	/WORDS LEFT IN DATA BUFFER.

SKNTSW	0	/SEEK/ENTER EXECUTED SWITCH.

NXTBLK	0	/NEXT BLOCK OF FILE.

FSTSWH	0	/FILE ALREADY FSTAT'ED(SAVES ACCESSES).

	.IFUND %RB09

MAPOFF	0	/OFFSET BY C(WORD1) FOR EACH SUBMAP.

	.ENDC

UFD1	0

UFD2	0

PARITY	0

	.IFUND %NOOUT

WREXSW	0

	.ENDC

CUREND=.

NODESC=CUREND-CURBEG

	.IFDEF %RF15

	.TITLE RF15 - DRIVER ** START I/O TRANSFER

/

DSSF=707001	/SKIP IF DISK FLAG.

DSCC=707021	/CLR DISK CONTROL,DISABLING 'FREEZE'.

DRAL=707022+10	/CLEAR AC,XOR AP0 INTO AC.

DRAH=707062+10	/CLEAR AC,XOR AP1 INTO AC.

DLAL=707024	/LOAD AC(BITS 0-17) INTO AP0

DLAH=707064	/LOAD AC(BITS 15-17)INTO AP1.

DSCF=707041	/CLEAR FUNCTION REGISTER.

DSFX=707042	/XOR AC(BITS 15-17)INTO FUNCTION REGISTER.

DSCN=707044	/EXECUTE CONDITION IN FR.

DSCD=707242	/CLEAR STATUS REG AND DISK FLAG.

DSRS=707262+10	/CLEAR AC,XOR STATUS INTO AC.

/

/THERE ARE THREE BITS IN THE FUNCTION REGISTER, WHICH IS

/DOUBLE BUFFERED.  BITS 15 AND 16 SPECIFY THE FUNCTION THAT

/IS TO BE PERFORMED BY THE CONTROLLER.  THE FUNCTION IS LOADED

/INTO THE FIRST BUFFER, AND AN EXECUTE IOT (DSCN) IS ISSUED TO

/LOAD IT INTO THE SECOND BUFFER FOR EXECUTION.  AT THE END

/OF AN OPERATION, OR IF AN ERROR OCCURS, THE SECOND BUFFER

/IS CLEARED AND EXECUTION STOPS.  THE OPERATION CAN THEN

/BE CONTINUED BY ISSUING A DSCN IOT EXECUTE.  BIT 16, ALSO

/CONTAINED IN THE FUNCTION REGISTER, ENABLES THE PROGRAM

/INTERRUPT AND API LOGIC OF THE CONTROL.

/THE FUNCTION REGISTER BIT CONFIGURATION IS AS FOLLOWS:

/	FUNCTION	BIT 15	BIT 16

/	--------	------	------

/	NO EFFECT	  0	  0

/	READ		  0	  1

/	WRITE		  1	  0

/	WRITE CHECK	  1	  1

/SUBROIUTINE DRIVER STARTS SOME I/O GOING. CONTROL GOES

/BACK TO THE CALLER VIA THE INTERRUPT SERVICE.

/CALLING SEQUENCE:

/LOC-2	DAC WORD	/'WORD' ***MUST***BE SETUP.

/LOC-1	LAC BLOCK	/WORD IS ALWAYS 0 EXCEPT  

/LOC	JMS DRIVER	/FOR RF15 .RTRAN'S 

/LOC+1	LAC ADDR	/ARG ADDRESS (XCT'ED BR DRIVER)

/LOC+2	LAC (FUNC	/GET FUNCTION (XCT'ED BY DRIVER)

/LOC+3 RETURN CONTROL HERE WHEN DONE.

/

DRIVER	0

	DAC BLOCK	/BLOCK # TO TRANSFER.

	AND	(760000	/(SCR-153)ILLEGAL BLOCK??

	SZA		/(SCR-153) SKIP IF OK

	JMP	IOPS2A	/(SCR-153) FATAL IOPS21, NO RETRY

	XCT* DRIVER	/GET DONOR/RECEIVER ADDR.

	IDX DRIVER

	TAD MINUS1

	DAC ZERO	/ADDR.-1

	LAW -12

	DAC PARITY	/SET PARITY RETRY COUNT

	.EJECT

/LOGICAL BLOCK  AND PHYSICAL DISK ADDRESS RELATIONSHIP.

/DISK# 	TRACK(0-6)   +   WORD(7-17)   =   BLOCK

/    0	   0		    0		    0

/    0	   0		    400		    1

/    0	   2		    1000	    22

/    .	   .		    .		    .

/    2	   400,000	    0		    5000

/    7	   774,000	   3,400	    17,777

/THE BLOCK NUMBER MUST BE MAPPED INTO THE PLATTER NUMBER

/'PLATER', THE TRACK ADDRESS (BITS 0-6), AND THE WORD

/ADDRESS (BITS 7-17) INTO TRK.WD.

/

DRVDIV	LAC BLOCK	/DIVIDE BY 2000 TO GET

	JMS RIGHT8

	RTR

	AND (7

	DAC PLATER

	LAC BLOCK	/MULT BY 400 TO GET

	JMS LEFT8

	AND MIN400	/(777400)

	TAD WORD	/WORD TO START AT.

	DAC TRK.WD

	LAC DATABK

	DAC DATAPT

	XCT* DRIVER	/GET THE I/O FUNCTION.

	DAC IOFUNC	/CAN ONLY BE READ OR WRITE.

RETRY	LAC ZERO

	DAC* (37	/CORE ADDR.

	CLC

	DAC UNDWAY

	LAC NUMWDS

	DAC* (36	/W.C.

	DSCC		/CLEAR DISK.

	LAC TRK.WD

	DLAL		/TRACK, SECTOR ADDR.

	LAC PLATER	/DISK NUMBER.

	DLAH

	.EJECT

	SETAPI

NORMXT	RESTORE		/AC,MQ, AND STEP COUNTER.

	.TITLE	 RF15--- INTERRUPT SERVICE ROUTINE.

/

/THE 10-BIT STATUS REGISTER REFLECTS THE STATE

/OF THE DEVICE AFTER IT HAS PERFORMED ITS SPECIFIED

/OPERATION.  ANY TIMING OR PARITY ERRORS THAT HAVE

/OCCURRED DURING THE OPERATION ARE INDICATED HERE.

/

/RF15	DISK STATUS REGISTER.

/		0-ERROR FLAG.*

/		1-DISK HARDWARE ERROR (FREEZE).

/		2-ADDRESS PARITY ERROR (FREEZE).

/		3-MISSED TRANSFER.

/		4-WRITE CHECK ERROR.

/		5-DATA PARITY ERROR.

/		6-WRITE LOCK OUT.

/		7-NON-EXISTANT DISK.

/		8-DCH TIMING ERROR (0 NOT SET).

/		9-PROGRAM ERROR (0 NOT SET).

/		10-TRANSFER COMPLETE.*

/		* CAUSES API OR PI.

/

	INTERRUPT

	DSRS		/READ DISK STATUS.

	DAC STATUS

	DSCD		/CLEAR DISK STATUS.

	DROP			/ DROP TO HANDLER LEVEL		/EAG:150

	LAC STATUS	/<139>

	SPA!RTL		/<139> CHECK STATUS HERE

	JMP ERRORS	/<139>

	FATAL3

	.IFUND %LVERSION

	LAC IOFUNC	/WAS THIS A WRITE?

	SAD (FWR	/WRITE FUNCTION.

	JMP CHK.WR	/YES TEST FOE WRITE CHECKING.

	.ENDC

	DREXIT		/EXIT FROM DRIVER

	.IFUND %LVERSION

/

/A WRITE HAS JUST COMPLETED. SHOULD A WRITE CHECK BE DONE?

/

CHK.WR	LAC (FWC	/SET FUNCTION FOR WR-CHEK.

	DAC IOFUNC

	LAC WRCHEK	/WAS WRITE CHECKING ASKED FOR?

	SNA		/NO IF 0.

	JMP MIN400

	JMP RETRY	/YES WRITE CHECK!

	.ENDC

	.TITLE RF15---DISK ERROR PROCESSOR.

/

RETRPT	RETRY		/15-BIT VECTOR.

/

ERRORS	DZM UNDWAY

	DAC TEMP10

	DSCD		/CLEAR THE STATUS.

	SNL!SMA!RTL	/OR CONDITION.

	JMP ER1

	HRDFAL		/MISSED TRANSFER ETC.

ER1	SZL!RAL

	JMP EROR20	/MISSED TRANSFER.

	SZL

	JMP E.CHEK	/WRITE CHECK ERROR.

	SPA!RTL

	JMP DPARIT	/DATA PARITY ERROR.

	SZL

	JMP IOPS4	/WRITE LOCKOUT.

	JMP IOPS21

/

/WRITE CHECK ERROR. TRY THE WRITE AGAIN (DO THIS

/12(8) TIMES BEFORE TELLING THE USER).

/

E.CHEK	LAC (FWR	/REPLACE WRITE CHECK FUNCTION.

	DAC IOFUNC

DPARIT	ISZ PARITY	/IF OVERFLOW, TAKE DATA ANYWAY

	JMP RETRY

	I.OERR 72	/IOPS72

	.ENDC

	.IFDEF	%RB09

	.TITLE RB09 ... DRIVER

/

/

DSCF=707101	/CLEAR FLAGS.BITS 0-5 OF THE STATUS REG ARE CLEARED.

DSRD=707112	/CLEAR AC;READ THE 'TA' AND 'SAC'INTO THE AC.

DSLD=707104	/CLEAR AND LOAD 'TA' AND 'SAC' FROM THE AC.

		/INFO LOADED MUST BE IN BCD FORMAT!

DSSF=707121	/SKIP ON FLAGS-ERROR AND DONE FLAG.

DSRS=707132	/READ THE STATUS REG INTO THE AC.

DSLW=707124	/CLEAR AND LOAD THWE WC.

DSCS=707141	/CLEAR THE STATUS REG AND 'TRAN' FLIP-FLOP.

DSLM=707142	/CLEAR AND LOAD THE 'MAC' FROM THE AC.

DSLS=707144	/LOAD THE STATUS REG FROM THE AC.

		/(BITS 6,7,8 ARE LOADED INTO THE REG

/		/BY AN XOR OPERATION).

/

/THE 9-BIT STATUS REGISTER SPECIFIES A READ OR WRITE

/OPERATION,ENABLES OR DISABLES THE INTERRUPT  

/AND SPECIFIES WHEN THE DISK IS TO START THE TRANSFER

/UPON FINDING THE CORRECT SEGMENT BY SETTING THE BUSY

/BIT (7) ,IN ADDITION THE REGISTER CONTAINS ALL OF THE ERROR 

/FLAGS AND THE 'DONE' FLAG WHICH IS RAISED AT

/COMPLETION OF A TRANSFER.

/

/STATUS REG:

/

/BIT 6=INT ENABLE IF 1.

/BIT 7=BUSY IF 1(GO AHEAD WITH TRANSFER).

/BIT 8=READ/WRITE (0 OR 1 RESPECTIVELY).

/

/SUBR. TO SET UP CA, WC AND TRANSFER

/

/SUBROIUTINE DRIVER STARTS SOME I/O GOING. CONTROL GOES

/BACK TO THE CALLER VIA THE INTERRUPT SERVICE.

/CALLING SEQUENCE:

/

/LOC-2	DAC WORD	/'WORD' ***MUST***BE SETUP.

/L0C-1	LAC BLOCK

/LOC	JMS DRIVER

/LOC+1	AC ADDR		/ARG ADDRESS

/LOC+2	LAC (FUNC	/GET THE FUNCTION

/LOC+3 RETURN CONTROL HERE WHEN DONE.

/

DRIVER	0

	DAC BLOCK	/BLOCK # TO TRANSFER.

	XCT* DRIVER	/GET DONOR/RECEIVER ADDR.

	IDX DRIVER	/POINT TO DIRECTION SWITCH.

	DAC ZERO	/ADDR.

MIN12	LAW -12

	DAC PARITY	/SET PARITY RETRY COUNT

	.EJECT

/LOGICAL BLOCK  AND PHYSICAL DISK ADDRESS RELATIONSHIP.

/   BLOCK#	TRACK	SECTOR

/	0	0	0

/	1	4	0

/	10	40	0

/	20	100	0

/	23	114	0

/	24	0	1

/	25	4	1

/THE HARDWARE FORMAT IS ORGANIZED INTO 80 SECTORS

/OF 64 WORDS ON EACH OF THE 200 TRACKS.  8*64=5120

/WORDS OR 20 BLOCKS. AT 20 BLOCK PER TRACK THE RB09

/CAN HOLD 4,000(10) BLOCKS.

/

/DIVIDE THE LOGICAL BLOCK BY 20 TO GET THE RIGHT TRACK.

/MULT THE REMAINDER BY 4 TO GET THE RIGHT SECTOR.

/ONCE THE TRACK AND SECTOR HAS BEEN DETERMINED CONVERT

/BOTH OF THEM TO BCD.

/

DRVDIV	LAC BLOCK

	DIVREM 24,SECTOR

	JMS BCD		/CONVERT QUOTIENT TO BCD.

	CLL

	JMS LEFT8

	DAC TRACK

	LAC SECTOR	/MULT BY 4 (SECTORS PER BLOCK).

	RTL		/TO GET THE RIGHT SECTOR.

	AND (774

	JMS BCD		/CONVERT TO BCD.

	XOR TRACK	/COMBINE ADDRESSES.

	DAC TRK.SR

	LAC DATABK

	DAC DATAPT

RETRY	LAC ZERO

	DSLM		/CORE ADDRESS.

	LAC PARITY

	DAC UNDWAY

	LAC NUMWDS

	DSLW		/WORD COUNT(2'COMP).

	LAC TRK.SR

	DSLD		/TRACK, SECTOR ADDR.

	XCT* DRIVER	/GET FUNCTION IN AC.

	DAC IOFUNC	/SAVE THE FUNCTION.

	.EJECT

	SETAPI

NORMXT	RESTORE		/AC,MQ, AND STEP COUNTER.

/

/OCTAL TO BCD CONVERSION ROUTINE.

/

BCD	0

	DIVREM 144,STATUS

	JMS LEFT8	/SHIFT QUOTIENT 8 BITS.

	DAC TRK.SR	/SAVE HERE TEMPORARILY.

/

/

SMALL	DIVAR STATUS,12,NAMER1,NAMER2,4

	XOR NAMER1

	XOR TRK.SR

	JMP* BCD

	.TITLE	RB09 ... INTERRUPT SERVICE ROUTINE.

/

	INTERRUPT

	DSRS		/READ DISK STATUS.

	DSCS

	DAC STATUS	/TEMP

	DROP			/ DROP TO HANDLER LEVEL		/EAG:150

	LAC STATUS	/<139>

	SPA!RTL		/<139> CHECK STATUS HERE

	JMP ERRORS	/<139>

	FATAL3

	DREXIT		/EXIT FROM DRIVER SUBR.

	.TITLE RB09 DISK ERROR PROCESSOR.

/

/STATUS REG.

/ BIT 0=INCLUSIVE OR OF BITS 1-4

/ BIT 1=PARITY ERROR

/ BIT 2=ILLEGAL ADDRESS

/ BIT 3=TIMING ERROR

/ BIT 4=NOT READY.

/ BIT 5=DONE FLAG.

/

RETRPT	RETRY		/15-BIT VECTOR.

/

ERRORS	DZM UNDWAY	/CLEAR FOR RESTARTING.

	SPA		/BITS 0,1,2 SHIFTED LEFT TWICE.

	JMP IOPS21	/BIT 2 IS ON ILLEGAL ADDRESS.

	SZL		/PARITY ERROR. ?

	JMP DPARIT	/YES.. BIT 1 IS ON.

	RTL		/SHIFT 3,4 TO LINK AND BIT 0.

	SPA		/TIMING ERROR OR NOT READY.

	JMP IOPS4	/BIT 4= NOT READY.

	HRDFAL

DPARIT	ISZ PARITY	/IF OVERFLOW, TAKE DATA ANYWAY

	JMP RETRY

	I.OERR 72	/DON'T TRY ANY MORE.

	.ENDC

	.IFDEF %RP02

	.IFUND	%RK05

	.TITLE DISK PACK DRIVER ROUTINES.

/

/

/ DISK PACK ADDRESSING

/

/ EACH TRACK IS DIVIDED INTO TEN EQUAL SECTORS.  THESE SECTORS ARE

/ ADDRESSED BY A FOUR BIT SECTOR ADDRESS REGISTER.  THE SECTOR

/ ADDRESSES ARE CODED 00(8) THROUGH 11(8) WHICH LEAVES ILLEGAL CODES

/ OF 12(8) THROUGH 17(8) WHICH MAY APPEAR IN THE SECTOR ADDRESS RE-

/ GISTER.  ILLEGAL CODES RAISE AN ERROR FLAG.  

/

/ A SEPARATE READ/WRITE HEAD IS PROVIDED FOR EACH OF THE TWENTY INNER

/ RECORDING SURFACES.  THESE HEADS ARE MOUNTED PARALLEL AND IN VERTICAL

/ ALIGNMENT TO EACH OTHER, ATTACHED TO A COMMON HEAD TOWER. THE HEAD

/ ARE SELECTED BY A 5-BIT REGISTER CALLED HEAD ADDRESS REGISTER. HEAD

/ ADDRESSES ARE CODED 00(8) THROUGH 23(8).  ILLEGAL CODES 24(8) THROUGH 

/ 37(8), WHEN DETECTED BY THE CONTROLLER, RAISE AN ERROR FLAG WHICH 

/ RESULTS IN THE APPROPRIATE INTERRUPTS.

/

/ THE POSITION OF ALL HEADS, VERTICALLY ALIGNED, WITH RESPECT TO THE

/ VERTICAL AXIS WHICH PASSES THROUGH THE CENTER OF ALL SURFACES, IS

/ CALLED A CYLINDER.  HEAD POSITIONING IS CONTROLLED BY A LINEAR PO-

/ SITIONING MOTOR AND A DETENTING MECHANISM WHICH IS DESIGNED TO STOP

/ THE HEADS IN TWO HUNDRED AND THREE DIFFERENT SUCH CYLINDERS.  THESE

/ CYLINDERS ARE CODED 00(8) THROUGH 312(8) FROM THE OUTER-MOST CYLINDER

/ TO THE INNER-MOST CYLINDER RESPECTIVELY.  CYLINDERS ARE ADDRESSED

/ BY AN 8-BIT REGISTER CALLED CYLINDER ADDRESS REGISTER.  ILLEGAL CODES

/ 313(8) THROUGH 377(8), WHEN DETECTED BY THE CONTROLLER, RAISE AND ERROR

/ FLAG WHICH RESULTS IN THE APPROPRIATE INTERRUPTS.

/

/ THE INTERSECTION OF A CYLINDER HEAD AND SECTOR ADDRESS DEFINES A

/ UNIQUE SECTOR WHICH IS THE SMALLEST ADDRESSABLE UNIT IN THE SYSTEM

/ EACH SECTOR HAS A DATA FIELD OF 256 WORDS.

/

/

/DISK PACK STRUCTURE:

/

/	1 BLOCK= 1 SECTOR

/	10 SECTORS = 1 TRACK(ADDRESSABLE BY 1 HEAD).

/	20 TRACKS = 1 CYLINDER(200(10)) BLOCKS.

/	203(10) CYLINDERS= 1 DISK PACK.

/

	.TITLE	DISK PACK IOT'S

/

DPSF=706301	/SKIP ON DISK FLAG

/	 1. THE JOB DONE FLAG IS SET

/	 2. THE ATTENTION FLAG IS SET

/	 3. ERROR FLAG IS SET.

DPLA=706304	/LOAD THE CYLINGER, HEAD, AND SECTOR

/	ADDRESS REGISTERS FROM THE ACCUMULATOR

/	AC BITS 0 THROUGH 7 LOAD THE CYLINDER

/	ADDRESS.  AC BITS 8 THROUGH 12 LOAD

/	THE HEAD ADDRESS.  AC BITS 13 THROUGH

/	17 LOAD THE SECTOR ADDRESS

DPCS=706324	/CLEAR STATUS, THE FOLLOWING BITS ARE CLEARED.

/	1.  FORMAT ERROR

/	2.  WORD ERROR

/	3.  LONGITUDINAL ERROR

/	4.  WRITE CHECK ERROR

/	5.  TIMING ERROR

/	6.  PROGRAMMING ERROR

/	7.  HEADER NOT FOUND

/	8.  END OF PACK

DPSJ=706341	/SKIP ON JOB DONE FLAG.

DPSE=706361	/SKIP ON ERROR FLAG

DPLF=706464	/LOAD STATUS REGISTER A.

/	AC BITS 0-8 ARE LOADED INTO STATUS

/	REGISTER A BITS 0-8.  THE NEW

/	CONTENTS ARE EXECUTED IF GO BIT IS SET

DPLO=706444	/LOAD THE ACCUMULATOR ONES ONTO STATUS

/	REGISTER A BITS 0 THROUGH 8 AND EXECUTE.  AC

/	BITS 0 THROUGH 8 ARE ONES INCLUSIVE ORED WITH

/	STATUS REGISTER A BITS 0 THROUGH 8.  THE NEW

/	CONTENTS OF THE FUNCTION IS THEN EXECUTED IF

/	THE GO BIT IS SET.

DPWC=706364	/LOAD THE WORD COUNT REGISTER FROM AC

DPCA=706344	/LOAD CURRENT ADDRESS REGISTER FROM AC

DPRSA=706312	/READ THE STATUS REGISTER A INTO AC.

DPRSB=706332	/READ STATUS REGISTER B INTO AC.

DPCF=706404	/CLEAR FUNCTION. THE FUNCTION REGISTER IS SET T

DPSA=706321	/SKIP ON ATTENTION FLAG.

/	IDLE MODE,UNIT ZERO IS SELECTED,ATTENTION ERROR

/	AND DONE INT ENABLES ARE CLEARED. THE WORD COUNT, 

/	CURRENT ADDRESS, BUFFER, SHIFT, LONG.,CLY,HEAD,AND

/	SECTOR ADDRESS ARE CLEARED.

	.EJECT

/ THE BLOCK NUMBER IS DIVIDED BY 200(10) TO GET THE

/ CYLINDER ADDRESS.  THE REMAINDER IS DIVIDED BY

/ 10(10) TO GET THE HEAD (TRACK) ADDRESS.  THE RE-

/ MAINDER OF THAT REPRESENTS THE SECTOR ADDRESS.

/

/	BLOCK		CYL	HEAD		SECTOP

/	-----		---	----		------

/	  0		 0	  0		   0

/	  1		 0	  0		   1

/	 11		 0	  0		  11

/	 12		 0	  1		   0

/

DRIVER	0

	DAC BLOCK	/ARGUMENT BLOCK#

	SMA!CMA!CLL!CML	/(SCR-153)SKP - BLOCK; MAKE BLK -, -1

	TAD	(117230	/(SCR-153)SIZE OF DISK PACK

	SPA!SZL		/(SCR-153)LEGAL SKIPS IF SATISFY BOTH CONDIT.

	JMP	IOPS2A	/(SCR-153)IOPS21 WITH NO RETRY

	XCT* DRIVER	/GET DONOR/RECIEVER ADDR.

	IDX DRIVER	/PT. FUNCTION (READ, WRITE, WRITE CHECK)

	DAC ZERO	/USE ACTUAL ADDR (NOT ADDR-1)

	XCT* DRIVER

	DAC IOFUNC

MIN12	LAW -12		/PARITY AND WRITE-CHECK RETRY COUNT.

	DAC PARITY

	LAC DATABK	/RESTORE DATA POINTER.

	DAC DATAPT

/

/ GET CYLINDER ADDRESS.

/

GETCYL	DIVAR BLOCK,310,HEDAD,CYLAD,12

/

/ THE CYLINDER ADDRESS IS AT 'CYLAD'  THE REMAINDER 

/ FROM THE DIVISION BY 200(10) IS AT 'HEDAD'.

/ GET THE HEAD (TRACK) ADDRESS.

/

FNDHED	DIVAR HEDAD,12,SECTOR,HEDAD,5

	.EJECT

/ THE CYLINDER 'CYLAD', HEAD 'HEDAD', AND SECTOR

/ ADDRESS ARE COMBINED AS FOLLOWS:

/	BITS:  0-7 = CYLINDER ADDRESS (8 BITS)

/	BITS:  8-12 = HEAD ADDR

/	BITS:  14-17 = SECTOR ADDRESS

/	** BIT 13 IS NOT USED **

/

COMBIN	AND (001740	/HEAD ADDR IN AC.

	XOR CYLAD	/CYLINDER ADDRESS.

	XOR SECTOR	/SECTOR ADDRESS.

	DAC PAKAD	/ACTUAL PACK ADDR.

/

RETRY	DPCS		/CLEAR STATUS

	LAC UNITNO	/DESELECT THE ARGUMENT UNIT NO.

	TAD L45ZS	/THE WRITE DISABLE CONSOLE

	DPLF		/SWITCH NEEDS THIS TO EFFECT WRITE

	DPRSB		/PROTECT *DELAY*

	DPRSB		/        *DELAY*

IDLE	LAC UNITNO	/BITS 0-2=UNIT#,3-15=IDLE FUN.

	DPLF

	.IFUND	RSX

	LAW -12

	DAC UNDWAY

	.ENDC

	LAC PAKAD

	DPLA		/LOAD CYLINDER, HEAD, AND SECTOR ADDRESSES.

	LAC NUMWDS

	DPWC		/WORD COUNT.

	LAC ZERO

	DPCA		/CURRENT ADDR FOR SINGLE CYCLE BREAK.

	DPRSB		/READ STAT B SET FROM 'IDLE'

	RAR

	SZL		/BIT 17 INDICATES UNIT OFF LINE.

	JMP IOPS4

	DPCS		/CLEAR STATUS

	.EJECT

	SETAPI

	.IFUND	RSX

NORMXT	RESTORE		/AC,MQ, STEP COUNTER.

	.ENDC

	.IFDEF	RSX

	DZM	STATUS	/CLEAR THE STATUS OF THE LAST OPERATION

	CAL	WFSTAT	/WAIT FOR EVENT VARIABLE TO BE SET

	JMP	EVFND	/SET LOOK AT IT

	.ENDC

	.TITLE RP15 DISK PACK INTERRUPT SERVICE

/

/THE DISK PACK ERROR FLAG IS RAISED BY:

/	1 JOB DONE FLAG.

/	2 ERROR FLAG

/	3 ATTENTION FLAG.

/THE DISK PACK FLAG OPERATES AT API LEVEL 1.

/

	INTERRUPT

	DPRSA		/READ STATUS REG A.

	DAC STATUS	/TEMP

	DPRSB		/##142##GET REG. B BEFORE ION

	DAC	BSTAT	/##142##

	.IFUND	RSX

	LAC UNITNO	/DO AN IDLE TO REMOVE FROM API,PI.

	DPLF

	DROP			/ DROP TO HANDLER LEVEL		/EAG:150

	LAC STATUS	/<139>

	RCR		/<139> BIT 17 IS ERROR FLAG

	SZL!RAL		/<139> CHECK ERROR STATUS HERE

	JMP ERRORS	/<139>

	FATAL3

	.IFUND %LVERSION

	LAC IOFUNC	/WAS THIS A WRITE?

	SAD (FWR	/WRITE FUNCTION.

	JMP CHK.WR	/YES TEST FOE WRITE CHECKING.

	.ENDC

	.ENDC

	DREXIT

	.IFUND	%LVERSION

CHK.WR	LAC (FWC	/SET FUNCTION FOR WR-CHEK.

	DAC IOFUNC

	LAC WRCHEK	/WAS WRITE CHECKING ASKED FOR?

	SNA		/NO IF 0.

	JMP MIN400

	JMP RETRY	/YES WRITE CHECK!

	.ENDC

	.TITLE RP15---DISK ERROR PROCESSOR.

/

RETRPT	RETRY		/15-BIT VECTOR.

/

	.IFUND	RSX

ERRORS	DPCF		/CLEAR DISK FLAG

	LAC STATUS	/A STATUS

	.ENDC

	.IFDEF	RSX

ERRORS	LAC	STATUS

	.ENDC

	.IFUND	RSX

	DZM UNDWAY

	.ENDC

	AND (340	/BITS 10,11,12=ILLEGAL ADDR.

	SZA		/BIT10=ILL CYL,11=ILL HEAD

	JMP IOPS21

	.IFUND %LVERSION

	LAC STATUS

	AND (410	/WRITE PROTECT ERROR?

	SZA

	JMS	CIOPS4

	.ENDC

	LAC STATUS	/WAS THE HARD HEADER FND?

	AND (24		/BIT 13 AND 15 OF REG A.

	SZA		/YES IF 0.

	JMP EROR20	/NO DISK FAILURE.

TSTRGB	LAC	BSTAT	/READ STATIS REG B.

	RCR

	SZL!RAL		/NOT READY?

	JMS	IOPS4

	AND (114	/##142##INCLUDE TIMING ERROR IN PARITY RETRY

/			/##142##IT SHOULD HAVE ITS OWN CODE; A RETRY IS

/			/##142##VITAL,SINCE ON A WRITE TIMING ERROR(MOSTLIKELY)

/			/##142##BAD DATA HAS !!ALREADY!! BEEN WRITTEN ON DISK!

/			/##142## BITS 14,15 PARITY ERROR

	SZA		/14=WORD PARITY.

	JMP DPARIT	/15=LONGITUDINAL PARITY.

	LAC BSTAT

	AND (20

	SZA

	JMP E.CHEK	/WRITE CHECK ERROR.

	LAC BSTAT	/##147##CHECK FOR PROGRAMMING ERROR

	AND (600	/##147##OFF DISK OR PROGRAMMING ERROR

	SZA		/##147## SKIP IF NOT

	JMP IOPS21	/##147## 21 IS PROGRAMMING ERROR

	JMP EROR20	/##142## FORMAT ERROR IS IOPS20. TIMING

/			/##142## ERROR NOW GOES WITH PARITY FOR RETRY

/			/##142##CHANGE. IF WE GET HERE, FINDING AN ERROR

/			/##142##BUT NO BIT TO DESCIBE IT, TEMPORARILY CALL

/			/##142## IT AN IOPS20, IT REALLY SHOULD HAVE NEW #

	.IFUND %LVERSION

/

CIOPS4	0

	LAC	IOFUNC		/WRITE FUNCTION?

	AND	(20000

	SZA

	JMP	IOPS4		/YES. REPORT

	JMP*	CIOPS4

	.ENDC

	.EJECT

	HRDFAL	/HARDWARE FAILURE.

/

/WRITE CHECK ERROR. TRY THE WRITE AGAIN (DO THIS

/12(8) TIMES BEFORE TELLING THE USER).

/

E.CHEK	LAC (FWR	/REPLACE WRITE CHECK FUNCTION.

	DAC IOFUNC

DPARIT	ISZ PARITY	/IF OVERFLOW, TAKE DATA ANYWAY

	JMP RETRY

	.IFUND	RSX

	I.OERR 72	/IOPS72

	.ENDC

	.IFDEF	RSX

	.LTORG

BUFTMP	.BLOCK	NUMFIL*500	/BUFFERS AT END TO PREVENT BOUNDARY PROBLEMES

	.ENDC

	.IFDEF	RSX

	ERR	72

	.ENDC

/

/

	.ENDC

	.ENDC

	.IFDEF	%RK05

	.TITLE DISK CARTRIDGE DRIVER ROUTINES.

/

/

/ DISK CARTRIDGE ADDRESSING

/

/ EACH TRACK IS DIVIDED INTO TWELVE EQUAL SECTORS.  THESE SECTORS ARE

/ ADDRESSED BY A FOUR BIT SECTOR ADDRESS REGISTER.  THE SECTOR

/ ADDRESSES ARE CODED 00(8) THROUGH 14(8) WHICH LEAVES ILLEGAL CODES

/ OF 15(8) THROUGH 17(8) WHICH MAY APPEAR IN THE SECTOR ADDRESS RE-

/ GISTER.  ILLEGAL CODES RAISE AN ERROR FLAG.  

/

/ A SEPARATE READ/WRITE HEAD IS PROVIDED FOR EACH

/ RECORDING SURFACE.  THIS HEAD IS MOUNTED PARALLEL AND IN VERTICAL

/ ALIGNMENT TO EACH SURFACE.

/

/ THE POSITION OF THE HEAD, VERTICALLY ALIGNED, WITH RESPECT TO THE

/ VERTICAL AXIS WHICH PASSES THROUGH THE CENTER OF THE SURFACE, IS

/ CALLED A CYLINDER.  HEAD POSITIONING IS CONTROLLED BY A LINEAR PO-

/ SITIONING MOTOR AND A DETENTING MECHANISM WHICH IS DESIGNED TO STOP

/ THE HEADS IN TWO HUNDRED AND THREE DIFFERENT SUCH CYLINDERS.  THESE

/ CYLINDERS ARE CODED 00(8) THROUGH 312(8) FROM THE OUTER-MOST CYLINDER

/ TO THE INNER-MOST CYLINDER RESPECTIVELY.  CYLINDERS ARE ADDRESSED

/ BY AN 8-BIT REGISTER CALLED CYLINDER ADDRESS REGISTER.  ILLEGAL CODES

/ 313(8) THROUGH 377(8), WHEN DETECTED BY THE CONTROLLER, RAISE AND ERROR

/ FLAG WHICH RESULTS IN THE APPROPRIATE INTERRUPTS.

/

/ THE INTERSECTION OF A CYLINDER HEAD AND SECTOR ADDRESS DEFINES A

/ UNIQUE SECTOR WHICH IS THE SMALLEST ADDRESSABLE UNIT IN THE SYSTEM

/ EACH SECTOR HAS A DATA FIELD OF 256 WORDS.

/

/

/DISK CARTRIDGE STRUCTURE:

/

/	1 BLOCK = 1 SECTOR

/	12 SECTORS = 1 TRACK(ADDRESSABLE BY 1 HEAD).

/	01 TRACK = 1 CYLINDER.

/	203(10) CYLINDERS = 1 DISK CARTRIDGE.

/

/ ALL PARAMETERS ARE TRANSFERRED TO THE PDP-11 THROUGH THE TCB.

/

/ RK IOT'S

/

SIOA=706001		/SKIP ON I/O DATA ACCEPTED

CIOD=706002		/CLEAR I/O DATA FLAG

LIOR=706006		/LOAD I/O DATA REGISTER AND CLEAR DONE FLAG

CAPI0=706104		/CLEAR API LEVEL 0 REQUEST FLAG

SAPI0=706101		/SKIP ON API LEVEL 0 REQUEST FLAG

/

	.EJECT

/

DRIVER	0

	DAC BLOCK	/ARGUMENT BLOCK#

	.IFUND	RSX

	DAC*	IBLOCK	/DOS, BLOCK TO TCB IN MONITOR

	.ENDC

	AND	(600000	/(SCR-153)PDP-11 MAKES FULL CHECK, WE JUST

	SZA		/(SCR-153)CHECK IF FITS IN PDP-11 WORD

	JMP	IOPS2A	/(SCR-153)NOPE, IOPS21 WITH NO RETRY

	XCT*	DRIVER	/GET DONOS/RECEIVER ADDR.

	IDX DRIVER	/PT. FUNCTION (READ, WRITE, WRITE CHECK)

	DAC	DRIVAD	/USE ACTUAL ADDR (NOT ADDR-1)

	XCT* DRIVER

	DAC IOFUNC

	LAC DATABK	/RESTORE DATA POINTER.

	DAC DATAPT

	LAW -12		/RESET PARITY COUNTER

	DAC PARITY

/

	.IFUND	RSX

RETRY	LAC	RKUNIT	/UNIT

	XOR	IOFUNC	/& FUNCTION

	DAC*	IRKUNF	/TO TCB

	DZM*	IDEV	/CLEAR EVENT VARIABLE (NECESSARY?)

	LAW	-12	/SET BUSY (WHY -12)

	DAC	UNDWAY

	LAC	NUMWDS	/HOW MUCH TO TRASFER

	DAC*	IRKWC	/TO TCB

	RTL		/GET 64K BIT (BR-148)

	CML		/LINK=1 IF EXTRA 64 K TO BE TRANSFERED (BR-148)

	LAC	DRIVAD	/WHERE IS BUFFER

	DAC	DRIVT1	/##TEMPORARY FOR TEST FOR ZERO BUFFER##!!

	DAC*	ISTAD1	/LOW HALF OF ADDR WORD PAIR TCB

	RTL		/TOP TWO BITS TO STADD

	RAL

	AND	(7	/SINCE PDP-11 READS ONLY 16 BITS, BUT DISK

	DAC*	ISTADD	/CAN SEE 18 BIT ADDR - ALSO LEAVE EXTRA 64K BIT ALONE (BR-148)

/

	SETAPI

NORMXT	RESTORE		/AC,MQ,STEP

	.ENDC

/

/  NOW RSX

/

	.IFDEF RSX

/

RETRY	LAC	RKUNIT	/UNIT #

	XOR	IOFUNC	/& I/O FUNCTION

	DAC	RKUNFN	/HERE TCB IS IN HANDLER, NOT ELSEWHERE

	DZM	DEV	/CLEAR EVENT VARIABLE, CRITICAL HERE

	LAC	NUMWDS	/HOW MANY

	DAC	RKWC

	LAC	DRIVAD	/WHERE IS BUFFER

	DAC	STADD+1	/LOW 16 BITS OF BUFFER ADDR

	RTL

	RAL		/TOP TWO BITS IN ANOTHER WORD

	AND	(3	/AS PDP-11 CAN FETCH ONLY 16 BITS

	DAC	STADD	/BUT DISK CAN CATCH 18 BIT ADDR

	SETAPI

	CAL	WFSTAT	/RSX WAIT

	JMP	EVFND

/

/  TCB - TASK CONTROL BLOCK

/    THIS IS THE PDP-15/11 TCB.

/

/  THE DOS TCB LOOKS JUST LIKE THIS, BUT IS IN MONITOR, POINTED

/  TO BY ITCB, ITCB1,IDEV, ETC. WE SOMETIMES BRING CONTENTS

/  OF MONITOR TCB TO LOCATIONS IN HANDLER FOR COMMON CODE CONVENINCE.

/

/

TCB	47*400+000	/TRAP ADDRESS = 47, API LEVEL = 0

	0+202		/DEVICE CODE = 202, FUNCTION CODE = 0

	.ENDC

DEV	000000		/DEVICE EVENT VARIABLE

BLOCK	000000		/PHYSICAL BLOCK #

STADD	000000		/STARTING MEMORY ADDRESS (M.S. 2 BITS)

	000000		/                        (L.S. 16 BITS)

RKWC	000000		/NUMBER OF WORDS

RKUNFN	000000		/UNIT NUMBER * 400 + FUNCTION

STATUS	000000		/RK CONTROL STATUS REGISTER (RKCS)

BSTAT	000000		/RK ERROR REGISTER (RKER)

RKDS	000000		/RK DRIVE STATUS REGISTER (RKDS)

/

DRIVAD	0		/HOLD CORE ADDR HERE

DRIVT1	0		/TWO TEMPORARIES FOR ZERO BLOCK CHECK

DRIVT2	0

/

/

	.TITLE RK15 DISK CARTRIDGE INTERRUPT SERVICE

/

/THE DISK CARTRIDGE FLAG IS RAISED BY THE PDP-11 DONE SIGNAL.

/THE DISK CARTRIDGE FLAG OPERATES AT API LEVEL 0.

/

	INTERRUPT

	LAC*	ISTATS	/STATUS FROM MONITOR TCB

	DAC	STATUS	/SAVE HERE

	.IFUND	RSX

	DROP			/ DROP TO HANDLER LEVEL		/EAG:150

	LAC STATUS	/<139>

	RTL		/<139> BIT 2 = ERROR FLAG

	SPA		/<139> CHECK FOR ERRORS HERE

	JMP ERRORS	/<139>

	FATAL3

	.IFUND %LVERSION

	LAC IOFUNC	/WAS THIS A WRITE?

	SAD (FWR	/WRITE FUNCTION.

	JMP CHK.WR	/YES TEST FOE WRITE CHECKING.

	.ENDC

	.ENDC

	DREXIT

	.IFUND	%LVERSION

CHK.WR	LAC (FWC	/SET FUNCTION FOR WR-CHEK.

	DAC IOFUNC

	LAC WRCHEK	/WAS WRITE CHECKING ASKED FOR?

	SNA		/NO IF 0.

	JMP MIN400

	JMP RETRY	/YES WRITE CHECK!

	.ENDC

	.TITLE RK15---DISK ERROR PROCESSOR.

/

RETRPT	RETRY		/15-BIT VECTOR.

/

	.IFUND	RSX

ERRORS	LAC*	IRKDS	/DOS, MOVE CONTENTS FROM THERE TO HERE

	DAC	RKDS

	LAC*	IBLOCK

	DAC	BLOCK	

	LAC*	IBSTAT

	DAC	BSTAT

	DZM	UNDWAY	/?DON'T LIKE, BUT GUESS IS OK

	.ENDC

	.IFDEF	RSX

ERRORS	LAC	BSTAT

	.ENDC

	AND	(200	/(151-SCR) ILL. DSK=NOT RDY

	SZA		/(151-SCR) SKIP IF NOT FINDING

	JMP	IOPS4	/(151-SCR)GOT, GO TO NOT READY

	LAC	BSTAT	/(151-SCR) FETCH UP BITS AGAIN

	AND	(140	/(151-SCR)REMAINING BITS ILL. BLOCK

	SZA		/(151-SCR)SKIP ON NOT ILL BLOCK

	JMP	IOPS21	/(151-SCR)11=ILL CYL;12=ILL SECT

	.IFUND %LVERSION

	LAC BSTAT	/BIT 14.

	AND (20000	/WRITE PROTECT ERROR?

	SZA

	JMS CHWRFN

	.ENDC

	LAC BSTAT	/CAN WE POSSIBLY GO ON?

	AND (11400	/BITS 5, 8 AND 9 OF RKER.

	SZA

	JMP EROR20	/YES: DISK FAILURE.

TSTRGB=.

	LAC	RKDS

	AND	(12000

	SZA		/NOT READY?

	JMP EROR20

	LAC BSTAT

	RTR

	SZL!SPA		/SKIP IF NEITHER ERROR

	JMP	E.CHEK	/GO SPLIT THE TWO

	AND (1000	/BIT 11=PROGRAMMING ERROR(REMEMBER RTR)

	SZA

	JMP	EROR20	/PROGRAMMING ERROR

	JMP	IOPS21	/NONE OF ALL ABOVE, ASSUME OFF PACK ERROR

	.IFUND %LVERSION

CHWRFN	0

	LAC IOFUNC

	SAD (FWR

	JMP IOPS4

	SAD (FWC

	JMP IOPS4

	JMP* CHWRFN

	.ENDC

	.EJECT

	HRDFAL	/HARDWARE FAILURE.

/

/WRITE CHECK ERROR. TRY THE WRITE AGAIN (DO THIS

/12(8) TIMES BEFORE TELLING THE USER).

/

E.CHEK	LAC (FWR	/REPLACE WRITE CHECK FUNCTION.

	SNL		/BUT NOT FOR A READ!

	DAC IOFUNC

DPARIT	ISZ PARITY	/IF OVERFLOW, TAKE DATA ANYWAY

	JMP RETRY

	.IFUND	RSX

	I.OERR 72	/IOPS72

	.ENDC

	.IFDEF	RSX

	.LTORG

BUFTMP	.BLOCK	NUMFIL*500	/BUFFERS AT END TO PREVENT BOUNDARY PROBLEMES

	.ENDC

	.IFDEF	RSX

	ERR	72

	.ENDC

/

/

	.ENDC

 

 

 

	.END
