/FLOPPY DISK (RX01,RX71) SYSTEM HANDLER FOR OS/8
/
/
/
/
/
/
/
/
/
/COPYRIGHT  (C)  1977 BY DIGITAL EQUIPMENT CORPORATION
/
/
/
/
/
/
/
/
/
/
/THE INFORMATION IN THIS DOCUMENT IS SUBJECT TO CHANGE WITHOUT NOTICE
/AND SHOULD NOT BE CONSTRUED AS A COMMITMENT BY DIGITAL EQUIPMENT
/CORPORATION.  DIGITAL EQUIPMENT CORPORATION ASSUMES NO RESPONSIBILITY
/FOR ANY ERRORS THAT MAY APPEAR IN THIS DOCUMENT.
/
/THE SOFTWARE DESCRIBED IN THIS DOCUMENT IS FURNISHED TO THE PURCHASER
/UNDER A LICENSE FOR USE ON A SINGLE COMPUTER SYSTEM AND CAN BE COPIED
/(WITH INCLUSION OF DIGITAL'S COPYRIGHT NOTICE) ONLY FOR USE IN SUCH
/SYSTEM, EXCEPT AS MAY OTHERWISE BE PROVIDED IN WRITING BY DIGITAL.
/
/DIGITAL EQUIPMENT CORPORATION ASSUMES NO RESPONSIBILITY FOR THE USE
/OR RELIABILITY OF ITS SOFTWARE ON EQUIPMENT THAT IS NOT SUPPLIED BY
/DIGITAL.
/
/
/
/
/
/
/
/
/
/
/FLOPPY DISK HANDLER SYSTEM

/DEFINITIONS OF RX8/E IOT'S

RXSVER=	"E&77

DEVCOD=	750	/DEVICECODE

LCD=	6001+DEVCOD	/LOAD COMMAND REGISTER
XDR=	6002+DEVCOD	/TRANSFER DATA REGISTER
STR=	6003+DEVCOD	/SKIP ON TRANSFER REQUEST FLAG, CLEAR FLAG
SER=	6004+DEVCOD	/SKIP ON ERROR FLAG, CLEAR FLAG
SDN=	6005+DEVCOD	/SKIP ON DONE FLAG, CLEAR FLAG
INTR=	6006+DEVCOD	/INTERRUPT ENABLE/DISABLE
INIT=	6007+DEVCOD	/INITIALIZE CONTROLLER AND RECALIBRATE DRIVES


/NOTES ON THIS HANDLER:

/THIS HANDLER READS AND WRITES THE DISK IN "12-BIT" MODE, IN WHICH
/ONLY 6 BITS OF EVERY 8-BIT BYTE ARE USED. AN RX01 CARTRIDGE
/CONTAINS 494 OS/8 BLOCKS UNDER THIS METHOD

/TO MAXIMIZE SPEED ON THE DEVICE, THE HANDLER READS AND WRITES DATA
/ON A TRACK WITH A TWO-WAY INTERLEAVE - I.E. RECORDS 1-26 ON A TRACK
/ARE WRITTEN IN THE SEQUENCE:
/  1,3,5,7,9,11,13,15,17,19,21,23,25,2,4,6,8,10,12,14,16,18,20,22,24,26

/IN THIS WAY THE HANDLER CAN TRANSFER DATA AT A 5KHZ WORD RATE
/MAIN CHANGE FROM RX01SY IS THAT THE NEXT DISK ADDRESS IS
/CALCULATED DURING THE DATA TARNSFER TO/FROM THE DISK TO ITS
/SECTOR BUFFER. THIS IS NEEDED FOR SLOW 8S !.
	*0		/ORIGIN FOR BUILD

	-1		/ONE ENTRY POINT
	DEVICE	RX8E	/"RX8E" IS THE GROUP NAME
	DEVICE	SYS	/"SYS" IS THE ENTRY POINT NAME
	4250		/DCB WORD - DEVICE TYPE 25, DIRECTORY DEVICE
	2007		/2000 MEANS SYS HANDLER,7 IS ENTRY POINT OFFSET
	0		/THIS WORD ALWAYS SEEMS TO BE 0
	DECIMAL
	76^26%4		/THE NUMBER OF OS8 BLOCKS ON THE DEVICE
	OCTAL

	BOOTST-BOOTND	/LENGTH OF THE BOOTSTRAP

	RELOC 	2
BOOTST,
X7577,	7577
SECT,	1
FAKRET,	JMS GET1
	DCA 	CDF10
	CDF 0
	TAD 	X7577
	DCA XR
	JMS GET1
	JMS GET1
	TAD 	UNIT
	DCA I 	PUNIT
	INIT
	JMS I 	X7577
XR,	7600+BOOTND-BOOTST-1	/LOC 17
PUNIT,	S4UNIT

GET1,	FAKRET
	STL RTL
	TAD 	UNIT
	LCD
	CLA STL RTL
	TAD SECT
	JMS LOAD
	DCA 	SECT
	CLA IAC
	JMS 	LOAD
HANGGG,	SDN
	JMP 	LOAD+1
	SER
	SKP
	HLT
	SNA
	JMP I 	GET1
	CLA STL RTL
	LCD
CDF10,	CDF 10
	JMS 	LOAD
	DCA I 	XR
LP,	JMP 	CDF10
BOOTND,
	RELOC


	NOPUNCH
	*24
BOOT,	STL RTL
	TAD 	UNIT
	LCD
	CLA IAC
	JMS LOAD
	JMS LOAD
	CLL RAL

START,
HANGGG,	SDN
	JMP 	LOAD+1
	SER
	SNA
	SKP CLA
	JMP GOODRD
	TAD UNIT
	CIA
	TAD 	X6030
	DCA 	UNIT
	JMP BOOT
GOODRD,	LCD
LP,	JMS LOAD
	DCA 	BOOTST
	ISZ 	.-1
	JMP 	LP

LOAD,	0
	STR
	JMP 	HANGGG
	XDR
	JMP I 	LOAD
UNIT,	7024
X6030,	6030

	ENPUNCH
	*200
	RELOC	7600

	ZBLOCK	7	/SYSTEM SPACE

/  OVERALL COMMENTS:
/
/  LINK REMAINS 0 THROUGH THE MAIN PROCESSING LOOP
/  EXCEPT AS MANIPULATED BY DIVSUB
/
/  OVERALL LOOP CONTROL THROUGH BC IS MILDLY ODD.
/  BC STARTS WITH MINUS COUNT OF THE # OF WORDS TO BE TRANSFERRED.
/  BC IS INCREMENTED 77 TIMES AT THE SILO CODE, AND 1 TIME AFTER
/  THE I/O OPERATION. 
/  A READ OPERATION STARTS AND FINISHES AT THE MIDDLE OF THE LOOP.
/  A WRITE OEPRATION STARTS AT THE TOP, AND FINISHES AT BOTTOM.
/  THUS, A 1 BLOCK READ INCREMENTS 1, 77, 1, 77 AND EXITS FROM MIDDLE.
/  AND, A 1 BLOCK WRITE INCREMENTS 77, 1, 77, 1 AND EXITS FROM BOTTOM.
/
/  DIVISION IS CARRIED OUT IN PARALLEL WITH I/O OPERATION BECAUSE OF
/  TIMING CONSIDERATIONS OF THE VT78.
/
/  THERE IS NO ERROR RETRY, NOT PARTICULARLY CRITICAL FOR A FLOPPY.

SYS,	RXSVER
	CLL CML CLA RAR	/SET LINK=0, AC=4000
	TAD I	SYS	/TO PUT READ-WRITE BIT TO LINK
S33,	AND	S70	/KEEP BITS FOR CDF
	TAD	SCDF0	/ADDING IN CDF LITERAL
	DCA	BUFCDF	/CDF INSTRUCTION TO USER'S BUFFER
	CML RTL		/FUNCTION CODE, 0=WRITE, 2=READ
	DCA	FN
	RDF		/FETCH CALLER'S FIELD
	TAD	SCDIF0	/MAKE CDF CIF TO HIS FIELD
	DCA	SRET	/FOR RETURN
	TAD I	SYS	/MAKE CONTROL COUNT
S4UNIT,	RAL		/7004 (7024 FOR UNIT #1) DOUBLES AS
			/LITERAL FOR READ-WRITE COMMAND
	AND	S7600	/MAKE CONTROL COUNT FOR TOTAL
	CIA		/NUMBER OF WORDS
	DCA	BC
	ISZ	SYS
	TAD I	SYS	/FETCH BUFFER ADDRESS
	DCA	BUF
	ISZ	SYS
S70,	70		/THIS LITERAL MUST BE AT LOCATION 33!
	IFNZRO	S70&177-33	<.ERROR.>
	TAD I	SYS	/OS8 BLOCK #
	CLL RTL		/TIMES 4 TO BE FLOPPY SECTOR #
	DCA	REC
	ISZ	SYS	/ERROR EXIT FROM I/O CALL
	JMS	DIVSUB	/COMPUTE TRACK/SECTOR FOR FIRST I/O
	TAD	FN	/READ OR WRITE START DIFFERENTLY
	SZA CLA		/SKIP ON WRITE
	JMP	STREAD	/GO TO READ
/
/  WRITE FALLS THRU.......
/
/
/
/ TOP OF MAIN PROCESSING LOOP
/
SETSLO,	TAD	FN	/SET SILO TO LOAD-UNLOAD DEPENDING
	JMS	LDCMD
	TAD	S7700	/SILO CONTROL COUNT 100 OCTAL
	DCA	FLPWC
BUFCDF,	HLT		/CDF TO USER'S BUFFER PLACED HERE
TRLOOP,	TAD I	BUF	/FETCH A WORD IN CASE WRITE
	STR		/WAIT
	JMP	.-1
	XDR		/AC TO SILO; OR; SILO TO AC
	DCA I	BUF	/PLACE A WORD IN CASE READ; WRITE REPLACES SAME.
	ISZ	BUF	/MOVE TO NEXT BUFFER LOCATION (MAY SKIP)
S77,	77		/LITERAL 77, EXECUTES AS A NOP
	ISZ	FLPWC	/DONE WITH 100 OCTAL SILO OPERATION
	JMP	TRLOOP	/NO
	TAD	BC	/INCREMENT BC BY 77 HERE, AND 1 LATER
	TAD	S77
MAGIC,	SNA		/SKIP UNLESS READ DONE;NO-OP FOR LDCMD!
	JMP	OKEX	/READ EXIT.
	DCA	BC	/
/
/  MIDDLE OF MAIN PROCESSING LOOP
/
STREAD,	TAD	FN	/READ STARTS HERE
	TAD	S4UNIT	/SET UP DO DO READ OR WRITE I/O
	JMS	LDCMD
	TAD	MQ	/LOAD PRECOMPUTED SECTOR INFO
	STR
	JMP	.-1	/IN CASE NOT READY
	XDR
S7700,	7700		/CLEAR AC, CAN'T SKIP (XDR LEAVES AC ALONE)
	TAD	QUO	/TRACK
	STR		/ILLEGAL 7700 ENTRY WILL HANG; THE FUNCTION
	JMP	.-1	/IS NOT SET UP (LDCMD)
	XDR
S7600,	7600
	ISZ	REC	/MOVE TO NEXT FLOPPY SECTOR
	JMS	DIVSUB	/COMPUTE NEXT TRACK AND SECTOR DURING THIS I/O
	TAD	MAGIC	/WAIT FOR I/O TO COMPLETE
	JMS	LDCMD
	ISZ	BC	/CHECK FOR WRITE EXIT
	JMP	SETSLO	/NO, BACK TO TOP
OKEX,	ISZ	SYS	/BUMP TO REGULAR EXIT
SRET,	HLT		/CDF CIF FOR USER'S CALLING FIELD
	JMP I	SYS	/GONE
/
/
/
/  LITERALS
/
SM15,	-15
SCDF0,	CDF 0
SCDIF0,	CDF CIF 0
/
/  DIVSUB
/
/  MUST ENTER WITH LINK AND AC 0
/  COMPUTES TRACK IN 'QUO', SECTOR IN 'MQ', FROM # IN 'REC'
/
/  REPEATED SUBTRACTS OF 13 DECIMAL LEAVE THE HIGH N-1 BITS OF
/  QUOTIENT IN QUO, THE LOW BIT OF QUOTIENT IN LINK, AND THE
/  REMAINDER IN AC. THE INTERLEAVE IS ACCOMPLISHED BY SHIFTING
/  LOW QUOTINET BIT INTO LOW REMAINDER BIT.
/
DIVSUB,	0
	DCA	QUO	/INIT QUOTIENT FOR DIVIDE
	TAD	REC	/RECORD # MASSAGED IN AC
DIVLP,	SNL		/LINK USAGE REVERSED FROM RICHIE'S CODE
	ISZ	QUO	/ISZ EVERY OTHER TIME, ==DIVIDE BY 26
	TAD	SM15	/THE -13 DECIMAL
	SMA		/SKIP ON DONE
	JMP	DIVLP	/MORE
	RAL		/LINK USAGE REVERSED; INTERLEAVE!!
	TAD	S33	/ADD 233 (200 IRREL) MAKING SECTOR
	DCA	MQ
	JMP I	DIVSUB	/LEAVING LINK AND AC 0
/
/  LDCMD
/
FLPWC=.		/COUNTER IN ENTRY POINT FOR SILO LOOP ONLY
LDCMD,	0
	SDN		/WAIT
	JMP	.-1
	LCD		/COMMAND FROM AC, WHICH IS CLEARED
	SER		/SKIP IF ERROR (I/O ONLY)
	JMP I	LDCMD	/OK, RETURN
	CLL CML CLA RAR	/CONVENTIONAL ERROR RETURN 4000 IN AC
	JMP	SRET	/SET CDF AND EXIT
/
/  USE DATA BREAK LOCATIONS FOR TERMPORARIES
/
MQ=7750
BC=7751
FN=7752
QUO=7753
REC=7754
BUF=7755

	RELOC


