	TITLE	AM29116 / AM9520 - BASED DISK CONTROLLER
;
; CREATED 9/81 TABLER-KITSON
;
;
;
; This SRC file was created for the AMD application note:
; "A High-Performance Intelligent Disk Controller"
; by Otis Tabler and Brad Kitson.
;
; Mnemonics and word format are defined in DISKCTLR.DEF 
;
; Advanced Micro Devices reserves the right to make changes in its  
; product without notice in order to improve design or performance
; characteristics.  The company assumes no responsibility for the
; use of any circuits or programs described herein.
;
; Am29116 Mnemonics Copyright  c  1982 Advanced Micro Devices
;
;
;
;
EJECT
;
;    SECTOR READ / WRITE SUBROUTINE
;******************************************
;
;	INPUTS:
;
;		FUNCTION CODE IN R0:
;
;			0 TO READ SECTOR
;
;			+1 TO WRITE SECTOR
;
;		HEAD NUMBER IN MSB OF R1
;
;		MSB OF TRACK NUMBER IN LSB OF R1
;
;		LSB OF TRACK NUMBER IN MSB OF R2
;
;		SECTOR NUMBER IN LSB OF R2
;
;		START ADDRESS OF RAM SECTOR BUFFER IN R3
;
EJECT
;
;	OUTPUT:
;
;		R0 CONTAINS:
;
;			0	IF THE FUNCTION SPECIFIED WAS COMPLETED
;				EITHER WITHOUT ERROR OR WITH A
;				SUCCESSFULLY CORRECTED READ ERROR
;
;			+1	IF THE SECTOR'S HEADER IS BAD
;
;			+2	IF AN UNCORRECTABLE ERROR WAS DETECTED IN
;				READING THE SECTOR'S DATA SEGMENT
EJECT
;
;  ADDITIONAL MNEMONICS        
; *********************
;
;
CRCMSK:	EQU	16H#C001	; CRCF POLYNOMIAL MASK
CRCNIT:	EQU	16		; CRCF NUMBER OF ITERATIONS (D#16 <-- default base)
NSPASS:	EQU	64		; NUMBER OF SECTOR PASSES (SET THIS EQUAL 
;				  TO THE NUMBER OF SECTORS PER TRACK.)
RDITCT:	EQU	65		; READ ITERATION COUNT, EQUAL TO THE NUMBER
;				; OF 16-BIT WORDS (DATA PLUS MODIFIED FIRE
;				; CODE) PER SECTOR, DIVIDED BY TWO, MINUS 1.
PF1:	EQU	22		; PERIOD FACTOR ONE
PF2:	EQU	13		; PERIOD FACTOR TWO
PF3:	EQU	89		; PERIOD FACTOR THREE
PF4:	EQU	23		; PERIOD FACTOR FOUR
;
A1LSW:	EQU	H#E723		; A1 CONSTANT(LEAST SIG. WORD)
A1MSW:	EQU	6		; A1 CONS.(MOST SIG. WORD)
A2LSW:	EQU	H#BFA8		; A2 CONS.(LEAST SIG. WORD)
A3LSW:	EQU	H#D530		; A3' CONS.(LEAST SIG. WORD)
A4LSW:	EQU	H#A928		; A4' CONS.(LEAST SIG. WORD)
;
KL128:	EQU	H#7100		; K(LEAST SIG. WORD) SHIFTED UP
				; BY SEVEN PLACES
KM128:	EQU	H#0477		; K(MOST SIG. WORD) SHIFTED UP
				; BY SEVEN PLACES.
KLSW:	EQU	H#EEE2		; K(LEAST SIG. WORD)
KMSW:	EQU	8		; K(MOST SIG. WORD)
;
EJECT
;
;
;	IF THE FUNCTION CODE IN R0 EQUALS +1 (WRITE SECTOR), PRECALCULATE
;	THE MODIFIED FIRE CODE'S PARTIAL CHECKSUM FOR THE FIRST HALF OF
;	THE DATA SEGMENT TO BE WRITTEN.
;
SECTIO:	BOR2	W,0,S2NR,R0
/	&NODLE	&NOIEN	&NOOEY	&NOSRE ;<------  note use of overlayed 
/	&CT	Z	&NOJMPI        ;         DEF statements
/	&IFNOT	CT16	&CJP	CFCODE ;	 signified by "&"
;
;
;	RESET THE AM9520 AND THEN PLACE IT IN COMPUTE CHECK BITS MODE.
;	INITIALIZE COUNTER FOR CHECK BITS PRECALCULATION LOOP.
;
	SONR	W,MOVE,SOI,NRY
/	&NODLE	&NOIEN	&OEY	&NOSRE
/	&NOJMPI
/	&CONT
;
	IMME	H#0000
/	&NODLE	&NOIEN	&OEY	&NOSRE
/	&BT20	&NOJMPI
/	&CONT
;
	SONR	W,MOVE,SOI,NRY
/	&NODLE	&NOIEN	&OEY	&NOSRE
/	&NOJMPI
/	&CONT
;
	IMME	H#0010
/	&NODLE	&NOIEN	&OEY	&NOSRE
/	&BT20	&NOJMPI
/	&LDCT	127
;
;
;	(R3) TO R4
;
	SOR	W,MOVE,SORY,R3
/	&DLE	&NOIEN	&OEY	&NOSRE
/	&NOJMPI
/	&CONT
;
	SOR	W,MOVE,SODR,R4
/	&NODLE	&IEN	&NOOEY	&NOSRE
/	&NOJMPI
/	&CONT
EJECT
;
;	BEGIN CHECK BITS PRECALCULATION LOOP.
;	(R4) TO THE MAR.
;
PCPREL:	SOR	W,MOVE,SORY,R4
/	&NODLE	&NOIEN	&OEY	&NOSRE
/	&MADR	&NOJMPI
/	&CONT
;
;
;	CLOCK THE LESS SIGNIFICANT BYTE OF ((MAR)) INTO THE AM9520.
;
	NOOP
/	&NODLE	&NOIEN	&NOOEY	&NOSRE
/	&BT2L	&NOJMPI
/	&CONT
;
	NOOP
/	&NODLE	&NOIEN	&NOOEY	&NOSRE
/	&CP20	&NOJMPI
/	&CONT
;
;
;	NOOP FOR TIMING PURPOSES
;
	NOOP
/	&NODLE	&NOIEN	&NOOEY	&NOSRE
/	&NOJMPI
/	&CONT
;
;
;	CLOCK THE MORE SIGNIFICANT BYTE OF ((MAR)) INTO THE AM9520.
;
	NOOP
/	&NODLE	&NOIEN	&NOOEY	&NOSRE
/	&BT2U	&NOJMPI
/	&CONT
;
;
;	INCREMENT (R4).
;	END CHECK BITS PRECALCULATION LOOP.
;
	SOR	W,INC,SORR,R4
/	&NODLE	&IEN	&NOOEY	&NOSRE
/	&CP20	&NOJMPI
/	&RPCT	PCPREL
EJECT
;
;	PLACE THE AM9520 IN WRITE CHECK BITS MODE.
;	INITIALIZE COUNTER FOR STORE CHECK BITS IN BUFFER LOOP.
;
	SONR	W,MOVE,SOI,NRY
/	&NODLE	&NOIEN	&OEY	&NOSRE
/	&NOJMPI
/	&CONT
;
	IMME	H#0011
/	&NODLE	&NOIEN	&OEY	&NOSRE
/	&BT20	&NOJMPI
/	&LDCT	2
;
;
;	BEGIN STORE CHECK BITS IN BUFFER LOOP.
;	(R4) TO THE MAR.
;	CLOCK OUT NEXT MODIFIED FIRE CODE BYTE TO THE
;	LESS-SIGNIFICANT MEMORY BUS INTERFACE REGISTER.
;
SCBIBL:	SOR	W,MOVE,SORY,R4
/	&NODLE	&NOIEN	&OEY	&NOSRE
/	&CP20	&MADR	&NOJMPI
/	&CONT
;
	NOOP
/	&NODLE	&NOIEN	&NOOEY	&NOSRE
/	&CE2L	&NOJMPI
/	&CONT
;
;
;	NOOP FOR TIMING PURPOSES
;
	NOOP
/	&NODLE	&NOIEN	&NOOEY	&NOSRE
/	&NOJMPI
/	&CONT
;
;
;	CLOCK OUT NEXT MODIFIED FIRE CODE BYTE TO THE
;	MORE-SIGNIFICANT MEMORY BUS INTERFACE REGISTER.
;
	NOOP
/	&NODLE	&NOIEN	&NOOEY	&NOSRE
/	&CP20	&NOJMPI
/	&CONT
;
;
;	NOOP FOR TIMING PURPOSES
;
	NOOP
/	&NODLE	&NOIEN	&NOOEY	&NOSRE
/	&NOJMPI
/	&CONT
;
EJECT
;	(BUS INTERFACE REGISTER PAIR) TO (MAR).
;	INCREMENT (R4).
;	END STORE CHECK BITS IN BUFFER LOOP.
;
	SOR	W,INC,SORR,R4
/	&NODLE	&IEN	&NOOEY	&NOSRE
/	&BF2L	&BF2U	&MWRT	&NOJMPI
/	&RPCT	SCBIBL
;
;
;	ZERO THE UPPER BYTE OF (R5) AND THEN CLOCK THE 7TH AND LAST
;	BYTE OF THE MODIFIED FIRE CODE INTO ITS LOWER BYTE.
;
	SOR	W,MOVE,SOZR,R5
/	&NODLE	&IEN	&NOOEY	&NOSRE
/	&CP20	&NOJMPI
/	&CONT
;
	NOOP
/	&NODLE	&NOIEN	&NOOEY	&NOSRE
/	&CE2L	&NOJMPI
/	&CONT
;
	SOR	B,MOVE,SODR,R5
/	&DLE	&IEN	&NOOEY	&NOSRE
/	&BF2L	&BT16	&NOJMPI
/	&CONT
;
;
;	(R4) TO MAR.
;
	SOR	W,MOVE,SORY,R4
/	&NODLE	&NOIEN	&OEY	&NOSRE
/	&MADR	&NOJMPI
/	&CONT
;
;
;	(R5) TO (MAR).
;
	SOR	W,MOVE,SORY,R5
/	&NODLE	&NOIEN	&OEY	&NOSRE
/	&BF16	&MWRT	&NOJMPI
/	&CONT
;
EJECT
;
;	CONVERT THE FUNCTION CODE IN R0 TO A MICROCODE BRANCH ADDRESS.
;
CFCODE:	SONR	W,MOVE,SOI,NRA
/	&NODLE	&IEN	&NOOEY	&NOSRE
/	&NOJMPI
/	&CONT
;
	IMME	BRTABL
/	&NODLE	&IEN	&NOOEY	&NOSRE
/	&NOJMPI
/	&CONT
;
	TOR1	W,ADD,TORAA,R0
/	&NODLE	&IEN	&NOOEY	&NOSRE
/	&NOJMPI
/	&CONT
;
;
;	CRCF POLYNOMIAL MASK TO ACC.
;
	SONR	W,MOVE,SOI,NRA
/	&NODLE	&IEN	&NOOEY	&NOSRE
/	&NOJMPI
/	&CONT
;
       	IMME	CRCMSK
/	&NODLE	&IEN	&NOOEY	&NOSRE
/	&NOJMPI
/	&CONT
;
;
;	CLEAR REGISTER USED TO ACCUMULATE CRCF.
;
	SOR	W,MOVE,SOZR,R4
/	&NODLE	&IEN	&NOOEY	&NOSRE
/	&NOJMPI
/	&CONT
;
;
;	COPY HEAD BYTE AND TRACK BYTE 1 TO R5.
;	SET CRCF LOOP COUNTER.
;
	SOR 	W,MOVE,SORY,R1
/	&DLE	&IEN	&NOOEY	&NOSRE
/	&NOJMPI
/	&LDCT	CRCNIT
;
	SOR	W,MOVE,SODR,R5
/	&NODLE	&IEN	&NOOEY	&NOSRE
/	&NOJMPI
/	&CONT
EJECT
;
;	SHIFT R5 AND SET QLINK.
;
CRCFL1:	SHFTR	W,SHUPZ,SHRR,R5
/	&NODLE	&IEN	&NOOEY	&NOSRE
/	&NOJMPI
/	&CONT
;
;
;	ACCUMULATE CRCF.
;
	CRCF	R4
/	&NODLE	&IEN	&NOOEY	&NOSRE
/	&NOJMPI
/	&RPCT	CRCFL1
;
;
;	COPY TRACK BYTE 2 AND SECTOR BYTE TO R5.
;	SET CRCF LOOP COUNTER.
;
	SOR	W,MOVE,SORY,R2
/	&DLE	&IEN	&NOOEY	&NOSRE
/	&NOJMPI
/	&LDCT	CRCNIT
;
	SOR	W,MOVE,SODR,R5
/	&NODLE	&IEN	&NOOEY	&NOSRE
/	&NOJMPI
/	&CONT
;
;
;	SHIFT R5 AND SET QLINK.
;
CRCFL2:	SHFTR	W,SHUPZ,SHRR,R5
/	&NODLE	&IEN	&NOOEY	&NOSRE
/	&NOJMPI
/	&CONT
;
;
;	ACCUMULATE CRCF.
;
	CRCF	R4
/	&NODLE	&IEN	&NOOEY	&NOSRE
/	&NOJMPI
/	&RPCT	CRCFL2
EJECT
;
;	INITIALIZE SECTOR PASS LOOP COUNTER.
;	ENTER INPUT MODE.
;	TURN ON READ GATE.
;
;
	NOOP
/	&NODLE	&NOIEN	&NOOEY	&NOSRE
/	&INPT	&NOJMPI	&RDGA
/	&LDCT	NSPASS
;
;
;	BEGIN SECTOR PASS LOOP.
;	TURN ON ADDRESS MARK CONTROL.
;	RESET BYTE SYNC ACQUISITION CIRCUITRY AND FIFO ARRAY.
;
SECTL1:	NOOP
/	&NODLE	&NOIEN	&NOOEY	&NOSRE
/	&ADMC	&INPT	&NOJMPI	&RDGA	&RFIF
/	&CONT
;
;
;	PASS WHEN ADDRESS MARK DETECTED.
;
	NOOP
/	&NODLE	&NOIEN	&NOOEY	&NOSRE
/	&ADMC	&INPT	&NOJMPI	&RDGA
/	&IFNOT	SAMD	&CJP	$
;
;
;	TURN OFF ADDRESS MARK CONTROL.
;	PASS WHEN INPUT AVAILABLE FROM FIFO ARRAY.
;
	NOOP
/	&NODLE	&NOIEN	&NOOEY	&NOSRE
/	&INPT	&NOJMPI	&RDGA
/	&IFNOT	RDYI	&CJP	$
EJECT
;
;	INPUT RECORDED HEAD NUMBER AND MSB OF RECORDED TRACK NUMBER
;	TO R5 AND D-LATCH.
;	PASS WHEN INPUT AVAILABLE FROM FIFO ARRAY.
;
	SOR	W,MOVE,SODR,R5
/	&DLE	&IEN	&NOOEY	&NOSRE
/	&BF03	&BT16	&INPT	&NOJMPI	&RDGA
/	&IFNOT	RDYI	&CJP	$
;
;
;	COMPARE THE CONTENTS OF R1 AND R5.
;	IF THEY DISAGREE, EXAMINE THE NEXT SECTOR.
;
	TOR1	W,EXOR,TODRR,R1
/	&NODLE	&NOIEN	&NOOEY	&SRE	&CT	Z
/	&INPT	&NOJMPI	&RDGA
/	&IF	CT16	&CJP	SECTL2
;
;
;	INPUT LSB OF RECORDED TRACK NUMBER AND RECORDED SECTOR NUMBER
;	TO R5 AND D-LATCH.
;	PASS WHEN INPUT AVAILABLE FROM FIFO ARRAY.
;
	NOOP
/	&NODLE	&NOIEN	&NOOEY	&NOSRE
/	&PF03	&INPT	&NOJMPI	&RDGA
/	&CONT
;
	SOR	W,MOVE,SODR,R5
/	&DLE	&IEN	&NOOEY	&NOSRE
/	&BF03	&BT16	&INPT	&NOJMPI	&RDGA
/	&IFNOT	RDYI	&CJP	$
EJECT
;
;	COMPARE THE CONTENTS OF R2 AND R5;
;	IF THEY DISAGREE, EXAMINE THE NEXT SECTOR.
;
	TOR1	W,EXOR,TODRR,R2
/	&NODLE	&NOIEN	&NOOEY	&SRE	&CT	Z
/	&PF03	&INPT	&NOJMPI	&RDGA
/	&IF	CT16	&CJP	SECTL2
;
;
;	INPUT RECORDED CRCF BYTES 1 AND 0 TO R5 AND D-LATCH.
;
	SOR	W,MOVE,SODR,R5
/	&DLE	&IEN	&NOOEY	&NOSRE
/	&BF03	&BT16	&INPT	&NOJMPI	&RDGA
/	&CONT
;
;
;	COMPARE THE TWO CRCFS.
;	IF THEY AGREE, PROCEED TO READ OR WRITE AS SPECIFIED BY R0.
;	OTHERWISE, ASSUME BAD HEADER, TRUE ID UNKNOWN,
;	AND CONTINUE LOOP.
;
	TOR1	W,EXOR,TODRR,R4
/	&NODLE	&NOIEN	&NOOEY	&SRE	&CT	Z
/	&INPT	&NOJMPI	&RDGA
/	&IF	CT16	&CJP	MATCH1
;
;
;	TURN OFF READ GATE.
;	LEAVE INPUT MODE.
;	END SECTOR PASS LOOP.
;	NOTICE WE HAVE THREE MICROINSTRUCTION CLOCKS LEFT BEFORE
;	IT IS TIME TO BEGIN WRITING OR RE-SYNC AND BEGIN READING.
;
SECTL2:	SOR	W,MOVE,SORY,R0
/	&NODLE	&NOIEN	&NOOEY	&NOSRE
/	&NOJMPI
/	&RPCT	SECTL1
;
;
;	IF SECTOR SEARCH COUNT EXHAUSTED, LOAD +1 INTO R0 AND RETURN
;
	BOR2	W,LD2NR,0,R0
/	&NODLE	&IEN	&NOOEY	&NOSRE
/	&NOJMPI
/	&RTN
EJECT
;
;	SUCCESSFUL MATCH.
;
MATCH1:	SOR	W,MOVE,SORY,R0
/	&NODLE	&NOIEN	&OEY	&NOSRE
/	&JMPI
/	&CONT
;
BRTABL:	SOR	W,NEG,SORA,R3
/	&NODLE	&IEN	&NOOEY	&NOSRE
/	&NOJMPI	&RFIF
/	&JP	RDSEC1
;
	SOR	W,NEG,SORA,R3
/	&NODLE	&IEN	&NOOEY	&NOSRE
/	&NOJMPI	&RFIF
/	&JP	WRSEC1
EJECT
;
;	READ SECTOR
;
;	(R3) TO R4 AND MAR.
;	ENTER INPUT MODE AGAIN.
;	TURN READ GATE BACK ON.
;	INITIALIZE COUNTER FOR READ DATA SEGMENT LOOP.
;	DURING THAT LOOP, AM9520 READ HIGH SPEED IS PERFORMED ON THE
;	FIRST HALF OF THE SEGMENT BUFFER.  THE SECOND HALF OF THE BUFFER
;	IS PROCESSED BY THE AM9520 IN THE READ HIGH SPEED COMPLETION LOOP.
;
RDSEC1:	SOR	W,NEG,SOAR,R4
/	&NODLE	&IEN	&OEY	&NOSRE
/	&INPT	&NOJMPI	&MADR	&RDGA	&RFIF
/	&LDCT	RDITCT
;
;
;	(R3) - 1 TO R5.
;	PASS WHEN INPUT AVAILABLE FROM FIFO ARRAY.
;
	SOR	W,COMP,SOAR,R5
/	&NODLE	&IEN	&NOOEY	&NOSRE
/	&INPT	&NOJMPI	&RDGA
/	&IFNOT	RDYI	&CJP	$
EJECT
;
;	RESET THE AM9520 AND THEN PLACE IT IN READ HIGH SPEED MODE.
;
	SONR	W,MOVE,SOI,NRY
/	&NODLE	&NOIEN	&OEY	&NOSRE
/	&INPT	&NOJMPI	&RDGA
/	&CONT
;
	IMME	H#0003
/	&NODLE	&NOIEN	&OEY	&NOSRE
/	&INPT	&NOJMPI	&RDGA
/	&CONT
;
	SONR	W,MOVE,SOI,NRY
/	&NODLE	&NOIEN	&OEY	&NOSRE
/	&INPT	&NOJMPI	&RDGA
/	&CONT
;
	IMME	H#0013
/	&NODLE	&NOIEN	&OEY	&NOSRE
/	&BT20	&INPT	&NOJMPI	&RDGA
/	&CONT
;
	NOOP
/	&NODLE	&NOIEN	&NOOEY	&NOSRE
/	&INPT	&NOJMPI	&PF03	&RDGA
/	&CONT
EJECT
;
;	BEGIN READ DATA SEGMENT LOOP.
;	TRANSFER NEXT WORD FROM FIFO ARRAY TO (MAR).
;	PASS WHEN FIFO INPUT AGAIN BECOMES AVAILABLE.
;
RDSEC2:	NOOP
/	&NODLE	&NOIEN	&NOOEY	&NOSRE
/	&BF03	&INPT	&NOJMPI	&MWRT	&RDGA
/	&IFNOT	RDYI	&CJP	$
;
;
;	INCREMENT (R5) AND TRANSFER THIS TO THE MAR.
;
	SOR	W,INC,SORR,R5
/	&NODLE	&IEN	&OEY	&NOSRE
/	&INPT	&NOJMPI	&MADR	&RDGA
/	&CONT
;
;
;	CLOCK LESS SIGNIFICANT BYTE OF ((MAR)) INTO THE AM9520.
;	INCREMENT (R4) AND TRANSFER THIS TO THE MAR.
;
	SOR	W,INC,SORR,R4
/	&NODLE	&IEN	&OEY	&NOSRE
/	&BT2L	&CP20	&INPT	&NOJMPI	&MADR	&MREA	&PF03	&RDGA
/	&CONT
;
;
;	TRANSFER NEXT WORD FROM FIFO ARRAY TO (MAR).
;	PASS WHEN FIFO INPUT AGAIN BECOMES AVAILABLE.
;
	NOOP
/	&NODLE	&NOIEN	&NOOEY	&NOSRE
/	&BF03	&INPT	&NOJMPI	&MWRT	&RDGA
/	&IFNOT	RDYI	&CJP	$
EJECT 
;
;	TRANSFER (R5) TO THE MAR AGAIN.
;
	SOR	W,MOVE,SORR,R5
/	&NODLE	&IEN	&OEY	&NOSRE
/	&INPT	&NOJMPI	&MADR	&RDGA
/	&CONT
;
;
;	THIS TIME, CLOCK THE MORE SIGNIFICANT BYTE OF ((MAR))
;	INTO THE AM9520.
;	END READ DATA SEGMENT LOOP.
;
	SOR	W,INC,SORR,R4
/	&NODLE	&IEN	&OEY	&NOSRE
/	&BT2U	&CP20	&INPT	&NOJMPI	&MADR	&MREA	&PF03	&RDGA
/	&RPCT	RDSEC2
;
;
;	INITIALIZE COUNTER FOR READ HIGH SPEED COMPLETION LOOP.
;
	NOOP
/	&NODLE	&NOIEN	&NOOEY	&NOSRE
/	&NOJMPI
/	&LDCT	RDITCT
EJECT
;
;	BEGIN READ HIGH SPEED COMPLETION LOOP.
;	INCREMENT (R5) AND TRANSFER THIS TO THE MAR.
;
RDSEC3:	SOR	W,INC,SORR,R5
/	&NODLE	&IEN	&OEY	&NOSRE
/	&NOJMPI	&MADR
/	&CONT
;
;
;	NOOP FOR TIMING PURPOSES
;
	NOOP
/	&NODLE	&NOIEN	&NOOEY	&NOSRE
/	&NOJMPI
/	&CONT
;
;
;	CLOCK LESS SIGNIFICANT BYTE OF ((MAR)) INTO THE AM9520.
;
	NOOP
/	&NODLE	&NOIEN	&NOOEY	&NOSRE
/	&BT2L	&CP20	&NOJMPI	&MREA
/	&CONT
;
;
;	NOOP FOR TIMING PURPOSES
;
	NOOP
/	&NODLE	&NOIEN	&NOOEY	&NOSRE
/	&NOJMPI
/	&CONT
;
;
;	NOOP FOR TIMING PURPOSES
;
	NOOP
/	&NODLE	&NOIEN	&NOOEY	&NOSRE
/	&NOJMPI
/	&CONT
EJECT
;
;	CLOCK MORE SIGNIFICANT BYTE OF ((MAR)) INTO THE AM9520.
;	END READ HIGH SPEED COMPLETION LOOP.
;
	NOOP
/	&NODLE	&NOIEN	&NOOEY	&NOSRE
/	&BT2U	&CP20	&NOJMPI	&MREA
/	&RPCT	RDSEC3
;
;
;	WAS AN ERROR DETECTED BY THE AM9520?
;
	NOOP
/	&NODLE	&NOIEN	&NOOEY	&NOSRE
/	&NOJMPI
/	&IF	ER20	&CJP	RDSEC4
;
;
;	NO; LOAD 0 INTO R0 AND RETURN.
;
	SOR	W,MOVE,SOZR,R0
/	&NODLE	&IEN	&NOOEY	&NOSRE
/	&NOJMPI
/	&RTN
;
;
;	YES; IF THE ERROR IS A CORRECTABLE ONE, LOCATE AND CORRECT IT.
;	THE ERROR IS LOCATED USING THE CORRECT HIGH SPEED EQUATION:
;	
;		L=NK - (M1A1 + M2A2 + M3A3 + M4A4)
;	
;	WHERE  K,A1,A2,A3,A4 ARE CONSTANTS
;	AND  M1,M2,M3,M4 MUST BE CALCULATED.
;	
;	THE ERROR IS CORRECTED BY PERFORMING AN EXOR
;	FUNCTION ON THE BURST ERROR IN MEMORY WITH AN
;	ERROR PATTERN(EP) PROVIDED BY THE BEP(9520).
;
;	INITIALIZE CORRECT HIGH SPEED,SET P0=1,& REP=1
EJECT
RDSEC4:	SONR	W,MOVE,SOI,NRY
/	&NODLE	&NOIEN	&OEY	&NOSRE
/	&NOJMPI	
/	&CONT
;
	IMME	H#001F
/	&NODLE	&NOIEN	&OEY	&NOSRE
/	&NOJMPI	&BT20	&BF16
/	&CONT
;
;
;	CLEAR R8(M1).
;
	SOR	W,MOVE,SOZR,R8
/	&NODLE	&IEN	&NOOEY	&NOSRE
/	&NOJMPI
/	&CONT
;
;
;	PERIOD FACTOR 1(PF1) TO ACC.
;
	SONR	W,MOVE,SOI,NRA
/	&NODLE	&IEN	&NOOEY	&NOSRE
/	&NOJMPI
/	&CONT
;
	IMME	PF1
/	&NODLE	&IEN	&NOOEY	&NOSRE
/	&NOJMPI	
/	&CONT
EJECT
;
;	TEST FOR ERROR PATTERN PRESENT.
;
M1:	NOOP
/	&NODLE	&NOIEN	&NOOEY	&NOSRE
/	&NOJMPI
/	&IF	EP20	&CJP	M234I
;
;
;	EP NOT PRESENT,
;	DECREMENT ACC.
;	TEST FOR ALIGNMENT EXCEPTION(AE).
;
	BONR	W,0,S2NA
/	&NODLE	&IEN	&NOOEY	&SRE
/	&NOJMPI	&CP20
/	&IF	AE20	&CJP	AE
;
;
;	AE NOT PRESENT,
;	ADD 8 TO R8.
;
	BOR2	W,3,A2NR,R8
/	&NODLE	&IEN	&NOOEY	&NOSRE
/	&NOJMPI
/	&JP	LINK
;
;
;	AE PRESENT;
;	INC R8.
;
AE:	BOR2	W,0,A2NR,R8
/	&NODLE	&IEN	&NOOEY	&NOSRE
/	&NOJMPI
/	&CONT
EJECT
;
;	TEST FOR PERIOD FACTOR EXCEEDED (UNCORRECTABLE ERROR).
;
LINK:	NOOP
/	&NODLE	&NOIEN	&NOOEY	&NOSRE	&CT	N
/	&NOJMPI
/	&IFNOT	CT16	&CJP	M1
;
;
;	PERIOD FACTOR EXCEEDED (UNCORRECTABLE ERROR);
;	SET R0 = 2.
;	RETURN.
;
ERR:	BOR2	W,1,LD2NR,R0
/	&NODLE	&IEN	&OEY	&NOSRE
/	&NOJMPI	&BT20	&BF16
/	&RTN
;
;
;	EP PRESENT, CALCULATE M2,M3,M4.
;
;	PERIOD FACTOR 2(PF2) TO R9(M2).
;	PERIOD FACTOR 3(PF3) TO R10(M3).
;	PERIOD FACTOR 4(PF4) TO R11(M4).
;
M234I:	SOR	W,MOVE,SOI,R9
/	&NODLE	&IEN	&NOOEY	&NOSRE
/	&NOJMPI
/	&CONT
;
	IMME	PF2
/	&NODLE	&IEN	&NOOEY	&NOSRE
/	&NOJMPI
/	&CONT
EJECT
	SOR	W,MOVE,SOI,R10
/	&NODLE	&IEN	&NOOEY	&NOSRE
/	&NOJMPI
/	&CONT
;
	IMME	PF3
/	&NODLE	&IEN	&NOOEY	&NOSRE
/	&NOJM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	&NOSRE
/	&NOJMPI	&BT16	&BF2U	&BF2L
/	&JP	XOR
;
REP25:	IMME	H#E000
/	&DLE	&IEN	&NOOEY	&NOSRE
/	&NOJMPI	&BT16	&BF2U	&BF2L
/	&JP	XOR
;
REP26:	IMME	H#C000
/	&DLE	&IEN	&NOOEY	&NOSRE
/	&NOJMPI	&BT16	&BF2U	&BF2L
/	&JP	XOR
;
REP27:	IMME	H#8000
/	&DLE	&IEN	&NOOEY	&NOSRE
/	&NOJMPI	&BT16	&BF2U	&BF2L
/	&JP	XOR
EJECT
;
; 	SUBROUTINE MULTIPLY
;
;	THIS SUBROUTINE MULTIPLIES A DOUBLE PRECISION
;	WORD BY A SINGLE PRECISION WORD AND ASSUMES
;	A DOUBLE PRECISION ANSWER.  THE MULTIPLIER
;	IS IN D, THE MULTIPLICAND IS IN R12,R13, AND
;	THE ANSWER APPEARS IN R6,R7(LAC). NOTE, UPON
;	RETURNING TO THE MAIN PROGRAM THE SUBROUTINE
;	INITIATES AN IMMEDIATE MOVE TO R12.
;
MUL:	SHFTR	W,SHDR,SHDNZ,R8
/	&NODLE	&IEN	&NOOEY	&SRE
/	&NOJMPI
/	&CONT
;
	SOR	W,MOVE,SORY,R13
/	&DLE	&NOIEN	&OEY	&NOSRE
/	&NOJMPI
/	&CONT
;
CYC:	SOR	W,MOVE,SORA,R12
/	&NODLE	&IEN	&NOOEY	&NOSRE	&CT	L
/	&NOJMPI
/	&IFNOT	CT16	&CJP	NOTQ	
;
	TOR1	W,TORAR,ADD,R6
/	&NODLE	&IEN	&NOOEY	&SRE
/	&NOJMPI
/	&CONT
;
	TOR1	W,TODRR,ADDC,R7
/	&NODLE	&IEN	&NOOEY	&NOSRE
/	&NOJMPI
/	&CONT
EJECT
NOTQ:	SHFTR	W,SHRR,SHUPZ,R12
/	&NODLE	&IEN	&NOOEY	&SRE
/	&NOJMPI
/	&CONT
;
	SHFTR	W,SHRR,SHUPL,R13
/	&DLE	&IEN	&OEY	&NOSRE
/	&NOJMPI
/	&CONT
;
	SHFTR	W,SHRR,SHDNZ,R8
/	&NODLE	&IEN	&NOOEY	&SRE
/	&NOJMPI
/	&RPCT	CYC
;
	SOR	W,MOVE,SOI,R12
/	&NODLE	&IEN	&NOOEY	&NOSRE
/	&NOJMPI
/	&RTN
EJECT
;
;	SUBROUTINE DIVIDE
;	THIS SUBROUTINE DIVIDES A DOUBLE PRECISION
;	NUMBER BY A DOUBLE PRECISION NUMBER LEAVING
;	ONLY A REMAINDER.  THE DIVISOR IS IN R12,R13,D
;	AND THE DIVIDEND/REMAINDER APPEARS IN R6,R7.
;	NOTE, UPON RETURN AN IMMEDIATE SUBTRACT IS 
;	INITIATED.
;
DIV:	SOR	W,MOVE,SORA,R12
/	&NODLE	&IEN	&NOOEY	&NOSRE
/	&NOJMPI
/	&CONT
;
CYC1:	TOR1	W,TORAR,SUBS,R6
/	&NODLE	&IEN	&NOOEY	&SRE
/	&NOJMPI
/	&CONT
;
	TOR1	W,TODRR,SUBSC,R7
/	&NODLE	&IEN	&NOOEY	&SRE
/	&NOJMPI
/	&CONT
;
	NOOP
/	&NODLE	&IEN	&NOOEY	&NOSRE	&CT	N
/	&NOJMPI
/	&IFNOT	CT16	&CJP	POS	
;
	TOR1	W,TORAR,ADD,R6
/	&NODLE	&IEN	&NOOEY	&SRE
/	&NOJMPI
/	&CONT
;
	TOR1	W,TODRR,ADDC,R7
/	&NODLE	&IEN	&NOOEY	&NOSRE
/	&NOJMPI
/	&CONT
EJECT
POS:	SHFTR	W,SHRR,SHDNZ,R13
/	&DLE	&IEN	&OEY	&SRE
/	&NOJMPI
/	&CONT
;
	SHFTR	W,SHA,SHDNL,R12
/	&NODLE	&IEN	&NOOEY	&NOSRE
/	&NOJMPI
/	&RPCT	CYC1
;
	TOR1	W,TORIR,SUBR,R6
/	&NODLE	&IEN	&NOOEY	&SRE
/	&NOJMPI
/	&RTN
EJECT
;
;	WRITE SECTOR
;
;	(R3) TO R4 AND MAR.
;	ENTER OUTPUT MODE. (TURNS ON WRITE CLOCK.)
;	INITIALIZE COUNTER FOR OUTPUT DATA PREAMBLE LOOP.
;
WRSEC1:	SOR	W,NEG,SOAR,R4
/	&NODLE	&IEN	&NOOEY	&NOSRE
/	&MADR	&NOJMPI	&OUPT
/	&LDCT	5
;
;
;	BEGIN WRITE DATA PREAMBLE LOOP.
;	TURN ON WRITE GATE.
;	PASS WHEN FIFO ARRAY READY FOR OUTPUT.
;
WRSEC2:	NOOP
/	&NODLE	&NOIEN	&NOOEY	&NOSRE
/	&NOJMPI	&OUPT	&WRGA
/	&IFNOT	RDYO	&CJP	$
;
;
;	OUTPUT H#0000 TO FIFO ARRAY.
;
	SONR	W,MOVE,SOZ,NRY
/	&NODLE	&NOIEN	&OEY	&NOSRE
/	&NOJMPI	&OUPT	&WRGA
/	&CONT
;
;
;	END WRITE DATA PREAMBLE LOOP.
;
	SONR	W,MOVE,SOZ,NRY
/	&NODLE	&NOIEN	&OEY	&NOSRE
/	&BF16	&BT03	&NOJMPI	&OUPT	&PL03	&WRGA
/	&RPCT	WRSEC2
;
;
;	OUTPUT LAST DATA PREAMBLE BYTE AND THE H#FE DATA SYNC BYTE.
;	INITIALIZE COUNTER FOR WRITE DATA SEGMENT LOOP.
;	PASS WHEN FIFO ARRAY AGAIN READY FOR OUTPUT.
;
WRSEC3:	SONR	W,MOVE,SOI,NRY
/	&DLE	&NOIEN	&OEY	&NOSRE
/	&NOJMPI	&OUPT	&WRGA
/	&LDCT	131
;
	IMME	H#FE00
/	&DLE	&NOIEN	&OEY	&NOSRE
/	&NOJMPI	&OUPT	&WRGA
/	&IFNOT	RDYO	&CJP	WRSEC3
;
	SONR	W,MOVE,SOD,NRY
/	&NODLE	&NOIEN	&OEY	&NOSRE
/	&BF16	&BT03	&NOJMPI	&OUPT	&PL03	&WRGA
/	&CONT
EJECT
;
;	BEGIN WRITE DATA SEGMENT LOOP.
;	(R4) TO MAR.
;
WRSEC4:	SOR	W,MOVE,SORY,R4
/	&NODLE	&NOIEN	&OEY	&NOSRE
/	&MADR	&NOJMPI	&OUPT	&WRGA
/	&CONT
;
;
;	INCREMENT (R4).
;
	SOR	W,INC,SORR,R4
/	&NODLE	&IEN	&NOOEY	&NOSRE
/	&NOJMPI	&OUPT	&WRGA
/	&CONT
;
;
;	((MAR)) TO FIFO ARRAY.
;	END WRITE DATA SEGMENT LOOP.
;
	NOOP
/	&NODLE	&NOIEN	&NOOEY	&NOSRE
/	&BT03	&MREA	&NOJMPI	&OUPT	&PL03	&WRGA
/	&RPCT	WRSEC4
;
;
;	CLEAR (R4).
;	INITIALIZE COUNTER FOR WRITE DATA POSTAMBLE LOOP.
;
	SOR	W,MOVE,SOZR,R4
/	&NODLE	&IEN	&NOOEY	&NOSRE
/	&NOJMPI	&OUPT	&WRGA
/	&LDCT	1
EJECT
;
;	BEGIN WRITE DATA POSTAMBLE LOOP.
;	OUTPUT H#0000 TO FIFO ARRAY.
;
WRSEC5:	SOR	W,MOVE,SORY,R4
/	&NODLE	&NOIEN	&OEY	&NOSRE
/	&NOJMPI	&OUPT	&WRGA
/	&IFNOT	RDYO	&CJP	$
;
	SOR	W,MOVE,SORY,R4
/	&NODLE	&NOIEN	&OEY	&NOSRE
/	&BF16	&BT03	&NOJMPI	&OUPT	&PL03	&WRGA
/	&CONT
;
;
;	(NOOP FOR TIMING PURPOSES)
;	END WRITE DATA POSTAMBLE LOOP.
;
	NOOP
/	&NODLE	&NOIEN	&NOOEY	&NOSRE
/	&NOJMPI	&OUPT	&WRGA
/	&RPCT	WRSEC5
;
;
;	TURN OFF WRITE GATE.
;
	NOOP
/	&NODLE	&NOIEN	&NOOEY	&NOSRE
/	&NOJMPI	&OUPT
/	&CONT
;
;
;	THEN LEAVE OUTPUT MODE. (TURNS OFF WRITE CLOCK.)
;	LOAD 0 INTO R0.
;	RETURN.
;
	SOR	W,MOVE,SOZR,R0
/	&NODLE	&IEN	&NOOEY	&NOSRE
/	&NOJMPI
/	&RTN
;
 	END
 






