/RX01 (RX02) SYSTEM HANDLER
/
/  THIS HANDLER WAS DESIGNED TO WORK WITH RX01, RX02, RX03
/
/  HOWEVER, ONE SINGLE BINARY CANNOT SUCCESSFULLY BE USED IN A
/  VIRGIN BUILD FOR ALL THREE DEVICES. IT IS CURRENTLY SET UP
/  TO BUILD AN RX02.
/  TO GENERATE A BINARY TO BUILD AN RX01, CHANGE THE RXTYP
/  EQUATE TO 1. FOR AN RX03 BUILD, CHANGE RXTYP TO 3.
/
RXTYP=1			/THIS IS THE SINGLE DENSITY TWO PAGE HANDLER
/
/
/
VERSION="M&77
/
/
AC1=CLL CLA IAC
AC2=CLL CLA CML RTL
AC6=CLL CLA CML IAC RTL		/RX02'S MUST RUN ON AN OMNI-BUS !!
AC4000=CLL CLA CML RAR
AC3777=CLL CLA CMA RAR
AC7775=CLL CLA CMA RTL
/
/  DEVICE IOT SYMBOLIC EQUATES
/
LCD=6751		/LOAD COMMAND
XDR=6752		/TRANSFER DATA
STR=6753		/SKIP IF READY TO TRANSFER
SER=6754		/SKIP ON ERROR
SDN=6755		/SKIP ON DONE
/
/  HEADER BLOCK FOR BUILD
/
	*0
	-1		/ONE ENTRY
	DEVICE	RX8E
	DEVICE	SYS
	4320		/MULTI-TYPE RX HANDLER ----- CHANGED FROM 4270
	SYS&177+6000	/TWO PAGE HANDLER
	0		/UNUSED
	IFZERO	RXTYP-1	<756>	/SIZE FOR BUILD
	IFZERO	RXTYP-2	<1734>
	IFZERO	RXTYP-3	<3670>
/
	STBOOT-NDBOOT+12	/-SIZE (+12 FOR GAP)
/
/  HERE IS A LISTING OF THE PRIMARY BOOT FOR CONVENIENCE
/
	NOPUNCH
/
	*20
/
READ,	TAD	UNIT	/TRY NEXT COMBINATION OF DENSITY AND UNIT
	TAD	CON360	/ADDING IN 360
	AND	CON420	/KEEPING ONLY 420 BITS
	DCA	UNIT	/CYCLES 400,420,0,20,400,,,,,,,,
	AC6		/COMMAND TO READ DISK
	TAD	UNIT	/UNIT AND DENSITY
	LCD		/COMMAND TO CONTROLLER
	AC1		/TO SET SECTOR AND TRACK TO 1
	JMS	LOAD	/SECTOR TO CONTROLLER, LEAVES AC ALONE
	JMS	LOAD	/AND TRACK
LITRAL,	7004		/LEAVING A 2 IN AC; SERVES AS LITERAL
/
/  FOLLOWING IS PART OF WAIT LOOP, SAME SECONDARY BOOTS, OLD PRIMARY BOOT
/
START,	SDN		/HAS DONE COME UP; CODE STARTS HERE!
	JMP	LOAD+1	/NO, GO CHECK FOR READY TO TRANSFER
/
/  NOW, DONE OR ERROR
/
	SER		/SKIP ON AN ERROR, TRY ANOTHER DENSITY ETC.
	SNA		/NASTY, AC=2 FOR ABOUT TO DO SILO, 0 ON START-UP
	JMP	READ	/START-UP, GO SET UP UNIT, THEN READ TO SILO
	TAD	UNIT	/AC ALREADY 2, PUT IN UNIT, DENSITY
	LCD		/TO EMPTY THE SILO
	TAD	UNIT	/SET UP LOC 60 FOR OLD SECONDARY BOOT
	AND	CON360	/KEEPING UNLY DENSITY BIT
	TAD	LITRAL	/ADDING IN 7004, BECAUSE THAT'S WHAT SYS WANTS
	DCA	RX1SAV	/OLD SECONDARY BOOT MOVES IT TO HANDLER
CON360,	360		/LITERAL; EXECUTES IN LINE AS A NO-OP
/			/FALLS THRU TO NEXT PAGE OF LISTING
/
/
/  FOLLOWING CODE SAME AS OLD PRIMARY BOOT
/
	JMS	LOAD	/GRAB NEXT ITEM FROM SILO
	DCA	2	/TRADITION; SECONDARY BOOT STARTS LOADING AT 2 !
	ISZ	50	/INCREMENT LOAD ADDRESS
	JMP	47	/GO BACK FOR ANOTHER
/
/  SECONDARY BOOT LOADS OVER PRIMARY BOOT UNIT LOCATION 47 IS LOADED,
/  THEN CONTROL PASSES TO SECONDARY BOOT
/
LOAD,	0		/SUBROUTINE TO GIVE AND TAKE DATA FROM CONTROLLER
	STR		/IS HE READY TO TALK TO US?
	JMP	START	/NO, IS HE PERHAPS DONE WITH SILO, OR IN ERROR?
	XDR		/YES, DATA IN OR OUT;IF DATA TO CONTROLLER, AC UNCHANGED
	JMP I	LOAD	/NO MAGIC, JUST EXIT FROM SUBROUTINE
/
/  60 GOES TO OLD SECONDARY BOOT
/  61 HAS DENSITY AND UNIT THAT BOOTED SUCCESSFULLY
/
/
CON420,			/USE IT TO HOLD 420 LITERAL TO START OUT
RX1SAV,	420		/UNIT^20+7004 TO GO TO SYS HANDLER
UNIT,	20		/<DENSITY^400>+<UNIT^20> THAT BOOTED OK
/
	ENPUNCH
/
/	##  SECONDARY BOOT  ##
/
	RELOC	2	/SECTION LOADING OVER PRIMARY BOOT 2 - 47
/
STBOOT=.
/
/  ONCE-ONLY CODE AFTER FIRST SECTOR IS TRANSFERED
/
ONCE,	TAD	XR	/SINGLE=113, DOUBLE=213
	CLL RAR		/SINGLE=45, DOUBLE=105
	TAD	YR	/SETTING UP POINTER TO SECTOR, TRACK, FIELD, ADDR DATA
	DCA	YR	/DAT01-1 OR DAT02-1
	TAD I	YR	/GETTING SINGLE=774, DOUBLE=1374 (IN CASE OLD
	TAD	RX1SAV	/ADD IN 20^UNIT+7004		  PRIMARY BOOT)
	DCA	UNIT	/PUT INTO 61: <DENSITY^400>+<UNIT^20>
	JMS	NEXSEC	/DESTROY LINKAGE TO ONCE ONLY CODE!
XTRA,	0		/EXTRA TO MAKE ALL FIT
/
/
/  AUTO INCREMENT REGISTERS
/
XR,	61		/CONTINUE TO LOAD FIRST SECTOR AT 62
YR,	DAT01-45-1	/SET UP POINTER TO DATA AREA
/
/  SECTOR DONE, SET UP FOR NEXT
/
NEXSEC,	JMP	ONCE	/END OF FIRST SECTOR, DO SET-UP CODE
	CDF	0	/DATA FIELD HERE TO USE AUTO INCR REGISTERS
	TAD I	YR	/GET DATA FIELD FOR PLACEMENT OF NEXT SECTOR
	SMA		/SKIP IF MORE TO DO
	JMP	EBOOT	/END OF BOOT, 
	DCA	XFIELD	/PLACE IN LINE TO SET DATA FIELD
	AC6		/GET AC OF 6 TO SET UP FLOPPY READ
	TAD	UNIT	/DENSITY AND UNIT NUMBER
	LCD
	TAD I	YR	/SECTOR FOR NEXT READ
	JMS	LOAD	/LOAD LEAVES AC ALONE
	TAD I	YR	/TRACK-SECTOR FOR NEXT READ
	JMS	LOAD	/LOAD REMAINS FROM PRIMARY BOOT
	TAD I	YR	/ADDRESS-TRACK-1 FOR NEXT READ
/			/FALL TO HANGGG WITH AC NON0 TO SHOW READ
/
/  FOLLOWING TWO LOCATIONS MUST MATCH PRIMARY BOOT
/
HANGGG,	SDN		/SKIP IF DONE
	JMP	LOAD+1	/NO, GO CHECK FOR TRANSFER READY
/
/  SORT OUT ERROR, SILO DONE, READ DONE
/
	SER		/SKIP IF ERROR
	SKP		/IS GOOD, CHECK WHETHER READ OR SILO
	HLT		/ANY ERROR IS FATAL!!
	SNA		/SKIP IF READY TO SILO (AC HAS LOAD ADDR)
	JMP	NEXSEC	/DONE WITH SILO (AC=0) GO TO NEXT SECTOR
	DCA	XR	/USE AUTO-INCR TO LOAD CORE
	JMP	OVRFLW	/GO TO LOCATIONS NOT FITTING UNDER 47
/
/  CODE TO EMPTY THE SILO TO CORE
/
XFIELD,	CDF	0	/FIELD FOR TRANSFER PLACED HERE
	JMS	LOAD	/LOAD REMAINS FROM PRIMARY BOOT
	DCA I	XR	/PLACE NEXT WORD
	JMP	XFIELD	/WHEN THIS LOCATION IS PLACED, SECONDARY BOOT
/			/TAKES CONTROL, CONTINUE FIRST SECTOR AT 62
/
/  PRIMARY BOOT LOCATIONS 50-61 REMAIN INTACT
/
STATUS=.		/REUSE FOR TEMPORARY
/
/	##  REST OF SECONDARY BOOT  ##
/
	RELOC	62	/SECTION LOADING 62 - 213
/
/  LOCATIONS NOT FITTING WITHIN 2-47 SPACE
/
OVRFLW,	XDR		/FETCH READ STATUS FOR LATER
	DCA	STATUS	/TO FIGURE OUT IF A DOUBLE SIDED FLOPPY
	AC2		/CODE FOR SILO OPERATION
	TAD	UNIT	/UNIT AND DENSITY
	LCD		/SET TO EMPTY SILO
	JMP	XFIELD	/GO TO SILO UNLOADING LOOP
/
/
/
/  SINGLE DENSITY LOADING DATA
/
DAT01,	774		/CANCEL OUT 7004 WHEN ADDED TO 70X4
	CDF	0	/2ND SECTOR FOR SINGLE DENSITY, FIELD 0
	3		/SECTOR 3, INTERLEAVED AT 2
	1-3		/TRACK 1  (MINUS SECTOR 3)
	114-1-1		/2 THRU 47 + 62 THRU 113 FOR FIRST SECTOR
/			/-1 FOR TRACK, -1 FOR AUTO INCR
	CDF	0	/3RD SECTOR TO 7600 FIELD 0
	5
	1-5
	7600-1-1
	CDF	0	/4TH SECTOR, SECOND HALF OF PAGE
	7
	1-7
	7700-1-1
	CDF	10	/5TH SECTOR, TOP OF FIELD 1
	21		/SECTOR 21
	11-21		/OF TRACK 11
	7600-11-1	/TO 7600
	CDF	10	/6TH SECTOR, REST OF FIELD 1
	23
	11-23
	7700-11-1
	CDF	20	/7TH SECTOR, TOP OF FIELD 2
	25
	11-25
	7600-11-1
	CDF	20	/10TH SECTOR, REST OF FIELD 2
	27
	11-27
	7700-11-1
	16		/MARKER AND LITERALS TO MAKE DAT02=DAT01+40
MAGIC,	7623		/THIS WORD IN HANDLER HAS DENSITY, UNIT WORD
L7605,	7605		/STARTING ADDR FOR HANDLER
/
/  DOUBLE DENSITY LOADING DATA
/
DAT02,	1374		/MAKE 400+UNIT WHEN ADDED TO 70X4
	CDF	0	/2ND SECTOR TO 7600
	4		/INTERLEAVE OF 3
	1-4
	7600-1-1
	CDF	10
	15
	5-15
	7600-5-1
	CDF	20	/3RD SECTOR TO 7600 OF FIELD 2
	20		/SECOND HALF OF BLOCK 66 OCTAL
	5-20		/ON TRACK 5
	7600-5-1
	16		/MARKER TO STOP WHOLE THING, ALSO LITERAL 16
/
/  I/O DONE, GO TO HANDLER
/
EBOOT,	TAD	UNIT	/ENTER WITH AC=16
	LCD		/SET DONE FLAG FOR HANDLER
	TAD	STATUS	/FIND OUT IF DOUBLE SIDED DISK
	RTR		/DOUBLE SIDED BIT TO LINK
	CLA RAR		/DOUBLE SIDED BIT TO AC0
	TAD	UNIT	/REST OF CONTROL WORD
	DCA I	MAGIC	/TO 7623 OF SYSTEM HANDLER
	JMP I	L7605	/TO START UP SYSTEM
/
NDBOOT=.
/
/  CODE THAT IS LOCATION SPECIFIC HAS !! IN COMMENTS
/
/	##  CODE FOR SYSTEM HANDLER  ##
/
	RELOC
	*200
	RELOC	7600
/
/			/USE DATA BREAKS FOR TEMPORARIES
/
QUO=7750		/QUOTIENT FOR DIVIDE == TRACK
REMD=7751		/REMAINDER FOR DIVIDE == SECTOR
REC=7752		/CURRENT LOGICAL SECTOR NUMBER
RETRY=7753		/RETRIES COUNT
/
	ZBLOCK	7	/REQUIRED BY BUILD
/
/
/  ENTRY POINT
/
SYS,	VERSION
L32,	32		/FALL THRU SOME LITERALS
L1734,	1734		/WHICH MAY PUT STRAY STUFF IN AC
	3		/!!REQUIRED AT 7612!! TO SHOW OS8 TWO PAGE HANDLER
	AC7775		/SET UP RETRY COUNTER
	DCA	RETRY	/RETRIES ARE OVER ENTIRE OPERATION
	RDF		/GRAB CALLER'S FIELD
	TAD	LLCDF0	/MAKE CDF TO IT
	DCA	RESTOR	/PUT IT BACK, GOING TO I/O ROUTINE ON PAGE 2
IOTYP,	JMP	FIRST	/GO TO ONCE ONLY CODE, LATER USED AS VARIABLE
/			/HAS HEAD, DENSITY, UNIT FOR I/O REQUEST
	JMP	RSTART	/GO CALL SECOND PAGE, IOTYP FALLS THRU TO HERE
/
/  LITERALS ETC.
/
L5000,	5000		/
BOOTYP,			/!!MUST BE AT 7623!! SECONDARY BOOT PUTS AT BOOT TIME
/			/4000 IF QUAD, 400 IF DOUBLE, AND 20 IF UNIT 1
	IFZERO	RXTYP-1	<0>	/INITIAL VALUE MATCHES DEVICE TO ALLOW
	IFZERO	RXTYP-2	<400>	/BUILD ONTO VIRGIN MEDIA
	IFZERO	RXTYP-3	<4400>	/OTHERWISE, SECONDARY BOOT PUTS IN RIGHT STUFF
LDENSW,	DENSW		/LOCATION ON SECOND PAGE
L4110,
LM3670,	4110		/VALUE WITH TWO USES
LM32,	-32
LLCDF0,	CDF	0
/
/  ONCE ONLY CODE
/
FIRST,	JMP	MORE	/LEAVING ADDITIONAL ONCE-ONLY SPACE
/
/  FIX CDF TO 7642
/
	*7642		/!!CDF OR CIF MUST BE AT 7642!!
MORE,	CDF	20	/POINT TO OUR SECOND PAGE
	TAD	BOOTYP	/PICK UP BOOT WORD
SNGDBL,	CLL RAL		/MAKE A WORD MINUS IF DOUBLE (OR QUAD) BOOTED
SIZE,	RTL		/REUSE FOR CONSTANTS
	DCA	SNGDBL	/JUST FOR CONVENIENCE, THE BIT IS IN BOOTYP ANYHOW
	TAD	QL3400	/ANY LITERAL IN RANGE 3400-3757 (LINK=0 HERE)
	TAD	BOOTYP	/FIGURE OUT SIZE OF MEDIA
	SMA SNL CLA	/SKIP IF DOUBLE OR QUAD
	TAD	L1734	/SINGLE
	TAD	L4110	/S=6044, D&Q=4110
	SNL		/SKIP IF QUAD, ITS SIZE ALREADY THERE
	CLL CML RAR	/OTHER TWO CASES DIVIDE BY TWO
	DCA	SIZE	/STORE S=7022, D=6044, Q=4110
	TAD	SNGDBL	/MAKE DENSW, 7600 IF DOUBLE, 7700 IF SINGLE
	SPA CLA		/SKIP IF SINGLE
	TAD	L7700
	TAD	L7700
QL3400,	DCA I	LDENSW	/MUST LIVE ON SECOND PAGE
/
/  END OF ONCE-ONLY, (RE)START I/O OPERATION
/
RSTART,			/AC MAY HAVE JUNK COMING IN!!
	AC3777		/MAKE A WORD WITH DENSITY AND UNIT BITS ONLY
	AND	BOOTYP	/FOR CONTRUCTING LCD ARGUMENTS
	DCA	IOTYP	/ALSO SHUTS OFF PATH TO ONCE-ONLY CODE!
	TAD	SYS	/AC HAS THE CALL ADDR
RESTOR,	HLT		/SET DATA FIELD TO THAT OF CALLER
	CIF	20
	JMP	PAGE2
/
/
/  CALL WITH AC NON0 TO DO DIVIDE
/  CALL WITH AC ZERO TO DO I/O RETRY (WHOLE OPERATION)
/
DIVSUB,	0
	SNA CLA		/SKIP IF REALLY A DIVIDE REQUEST
	JMP	RSTART	/NO, IT WAS AN ERROR RETRY!!
	DCA	QUO	/CLEAR DIVIDE QUOTIENT
	TAD	BOOTYP	/IS IT A TWO HEADER
	SKP		/!!FAULTY USR CALL DOES JMS HERE (7700)
	HLT		/HALT OUT SUCH AN OCCURRENCE!!
L7700,	SMA CLA		/SKIP IF YES
	JMP	SHUNT	/NO, GO DO DIVIDE
	CLL		/TO CHECK 12 BIT SIZE
	TAD	REC	/WHICH RECORD ARE WE WORKING ON
	TAD	LM3670	/NUMBER OF SECTORS ON FIRST SIDE
	SNL CLA		/SKIP IF SECOND SIDED IT
	JMP	SHUNT	/NO, JUST REGULAR
	TAD	BOOTYP	/MAKE IO FUNCTION WORD WITH SECOND HEAD BIT
	TAD	L5000	/CONVERTS TO 20^UNIT +1400
	DCA	IOTYP
	TAD	LM3670	/BUT DECREASE RECORD NUMBER
SHUNT,	TAD	REC	/THIS FOR TRACK-SECTOR
DIVLOO,	ISZ	QUO	/MAIN DIVIDE LOOP
	TAD	LM32	/DIVIDE BY 26 TO GET TRACK
	SMA		/SKIP IF DONE
	JMP	DIVLOO
	TAD	L32	/REMAINDER 0-25
	DCA	REMD	/USE AS TEMPORARY UNTIL FINAL VALUE
	TAD	SNGDBL	/FIND OUT IF SINGLE BOOT
	SPA CLA		/SKIP IF YES
	TAD 	REMD	/MULTIPLY BY THREE FOR DOUBLE
	TAD 	REMD	/AND BY TWO FOR SINGLE
	TAD 	REMD
	CLL IAC		/LINK CLEAR FOR FINAL TEST; +1 TO START AT 1 NOT 0
	TAD	LM32	/DIVIDE BY 26 TO GET SECTOR
	SMA SZA		/SKIP IF DONE
	JMP	.-2
	TAD	L32	/RESTORE POSITIVE VALUE TO BE SECTOR
	DCA	REMD	/WHEW, BUT WATCH IT, A FINAL CORRECTION COMING!
	TAD	SNGDBL	/IF LINK=0 AND SINGLE: 2,4,6,8,10,12,14,16... SERIES
	SMA SNL CLA	/SKIP IF NOT THE SINGLE DENS. 1,3,5,7,9,,, SERIES
	ISZ	REMD	/NOW HAVE IT 2,4,6,8,10,12,14,16...
	CIF	20	/POP BACK TO OTHER PAGE
	JMP I	DIVSUB	/!!THIS IS IN LAST USABLE LOCATION, EXEC NEEDS 7744!!
/
/

/
/	##  SECOND PAGE  ##
/
	RELOC
	*400
	RELOC	7600
/
/  FETCH ARGUMENTS, ETC.
/
PAGE2,	DCA	FETCH	/ENTER WITH ARGUMENT LIST ADDR IN AC
	RDF		/SAFE HERE?
	TAD	LCDIF0	/SET UP EXIT TO CALLER
	DCA	EXFLD
	AC4000		/SET UP TO PUT R/W BIT TO LINK
	TAD I	FETCH	/FIRST ARGUMENT HAS FIELD FOR TRANSFER
	AND	L70	/KEEPING ONLY FIELD
	TAD	LCDF0	/MAKE CDF TO TRANSFER FIELD
	DCA	BUFCDF	/PLACE IN LINE FOR SILO LOOP
	CML RTL		/0=WRITE, 2=READ
	DCA	FN
	TAD I	FETCH	/MAKE CONTROL COUNT FOR TRANSFER
	RAL
	AND	L7600	/COUNT OF WORDS
	CIA		/0 FOR WHOLE FIELD
	DCA	BC
	ISZ	FETCH	/NEXT ARGUMENT
	TAD I	FETCH	/BUFFER ADDRESS
	DCA	BUF
	ISZ	FETCH	/NEXT
	TAD	L100	/CARRY WITH DENSW IF SINGLE DENSITY
	TAD	DENSW	/SET TO COMPUTE SECTOR# FOR BLOCK#
	SMA CLA		/SKIP IF DOUBLE, MULTIPLE BY 2
	TAD I	FETCH	/SINGLE, MULTIPLY BY FOUR
	TAD I	FETCH
	ISZ	FETCH	/MOVING POINTER TO ERROR EXIT
	CDF	0	/INDIRECT TO FIRST PAGE FOR CONSTANTS
	CLL RAL		/FINAL PART OF MULTIPLY
	DCA I	LREC	/SAVE SECTOR NUMBER
	TAD I	LSIZE	/TOTAL SIZE OF MEDIA
	SZL		/SKIP IF LEGAL BLOCK #
	JMP	EXFLD	/EXIT TO CALLER WITH BLOCK # IN AC
LCDIF0,	CIF CDF 0	/GO BACK TO FIRST PAGE
	JMS	DIVSUB	/SET UP TRACK AND SECTOR
	TAD	FN	/SPLIT READ AND WRITE
	SZA CLA		/WRITE SKIPS
	JMP	STREAD	/READ STARTS IN MIDDLE OF LOOP
/			/WRITE FALLS TO NEXT LISTING PAGE

/
/WRITE FALLS THRU TO THIS LOOP
/
/  TOP OF MAIN LOOP
/
TOP,	TAD	FN	/SET SILO TO LOAD-UNLOAD
	JMS	LDCMD	/COMMAND TO CONTROLLER
	TAD	DENSW	/MAKE SILO LOOP COUNT, S=7700, D=7600
	DCA	FLPWC	/LDCMD ENTRY SAFE TEMPORARY
BUFCDF,	HLT		/CDF TO BUFFER FIELD PLACED HERE
TRLOOP,	TAD I	BUF	/IN CASE WRITE, FETCH A WORD
	STR		/SKIP IF READY TO PASS DATA
	JMP	.-1	/NO
	XDR		/TO OR FROM AC
	DCA I	BUF	/PLACE WORD FOR READ, WRITE REPLACES SAME
	ISZ	BUF	/MOVE BUFFER POINTER, (MAY SKIP)
L70,	70
	ISZ	FLPWC	/DONE YET
	JMP	TRLOOP
	TAD	DENSW	/ADDING 77 (SINGLE) 177 (DOUBLE)
	CMA		/ONCE WE CMA, THAT IS
	TAD	BC	/LOOP CONTROL TO FINISH READ
	SNA
	JMP	OKEX	/OK, DONE
	DCA	BC	/REPLACE AND KEEP GOING
/
/  MIDDLE OF MAIN LOOP
/
STREAD,	TAD	FN	/READ STARTS HERE
	TAD	L4	/TURN SILO COMMAND INTO READ-WRITE COMMAND
	JMS	LDCMD	/I/O COMMAND TO CONTROLLER
	TAD I	LREMD	/PRECOMPUTED SECTOR #; LDCMD SET FIELD TO 0
	STR
	JMP	.-1
	XDR
L7600,	7600		/CLEAR AC, AND IS LITERAL
	TAD I	LQUO	/TRACK #
	STR
	JMP	.-1
	XDR		/TRACK # IS ALWAYS NON0 !!
	ISZ I	LREC	/MOVE TO NEXT RECORD NUMBER
BACKER,	CDF CIF 0	/GO BACK TO FIRST PAGE
	JMS	DIVSUB	/FOR TRACK AND SECTOR
	TAD	L16	/WAIT FOR OPERATION TO COMPLETE
	JMS	LDCMD
	ISZ	BC	/CHECK FOR WRITE EXIT
	JMP	TOP	/STILL MORE
OKEX,	ISZ	FETCH	/KICK TO OK EXIT
EXFLD,	HLT		/CDF CIF TO CALLER
	JMP I	FETCH	/OUT

/
/  LDCMD  SUBROUTINE
/
FLPWC=.			/ENTRY POINT A SAFE COUNT TEMPORARY
LDCMD,	0		/CALL TO GIVE COMMAND TO CONTROLLER
LCDF0,	CDF	0	/INDIRECTS BACK TO FIRST PAGE
	TAD I	LIOTYP	/PUT IN UNIT, DENSITY, HEAD
	SDN		/SKIP IF CONTROLLER READY
	JMP	.-1	/NO
	LCD		/COMMAND
	SER		/SKIP IF AN ERROR
	JMP I	LDCMD	/NO
	ISZ I	LRETRY	/TRIED ENOUGH TIMES ALREADY?
	JMP	BACKER	/TO DIVSUB WITH AC=0 TO RETRY !!!!!
	AC4000		/HARD ERROR, GIVE BACK MINUS RESULT
	JMP	EXFLD
/
/  VARIABLES ETC.
/
BUF,	0		/POINTER TO CALLER'S BUFFER
FETCH,	0		/POINTER TO CALL
BC,	0		/CONTROL COUNT, WORDS TO TRANSFER
FN,	0		/0 FOR WRITE, 2 FOR READ
DENSW,	0		/7700 IF SINGLE DENSITY, 7600 IF DOUBLE DENSITY
/
/  LITERALS
/
L4,	4
L16,	16
L100,	100
LIOTYP,	IOTYP		/POINTERS BACK TO FIRST PAGE
LRETRY,	RETRY
LSIZE,	SIZE
LQUO,	QUO
LREC,	REC
LREMD,	REMD

