BADCHK - CHECK, VERIFY AND MATC	MACRO M1110  22-AUG-78 02:06  PAGE 2





      1					.TITLE	BADCHK - CHECK, VERIFY AND MATCH SUBROUTINES

      2					.IDENT	/04/

      3					;

      4					;

      5					; COPYRIGHT (C) 1974,1975,1976,1977

      6					;

      7					;

      8					; THIS  SOFTWARE  IS  FURNISHED  UNDER A LICENSE FOR USE ONLY ON A

      9					; SINGLE COMPUTER SYSTEM AND MAY BE COPIED ONLY WITH THE INCLUSION

     10					; OF  THE  ABOVE COPYRIGHT  NOTICE.  THIS SOFTWARE, OR  ANY  OTHER

     11					; COPIES THEREOF, MAY NOT BE PROVIDED OR OTHERWISE  MADE AVAILABLE

     12					; TO  ANY  OTHER PERSON  EXCEPT  FOR USE ON SUCH SYSTEM AND TO ONE

     13					; WHO AGREES TO THESE LICENSE TERMS.  TITLE  TO  AND  OWNERSHIP OF

     14					; THE SOFTWARE SHALL AT ALL TIMES REMAIN IN DIGITAL.

     15					;

     16					; THE  INFORMATION  IN THIS DOCUMENT IS SUBJECT  TO CHANGE WITHOUT

     17					; NOTICE AND SHOULD NOT BE CONSTRUED AS A  COMMITMENT  BY  DIGITAL

     18					; EQUIPMENT CORPORATION.

     19					;

     20					; DIGITAL ASSUMES NO  RESPONSIBILITY FOR THE USE OR RELIABILITY OF

     21					; ITS SOFTWARE ON EQUIPMENT WHICH IS NOT SUPPLIED BY DIGITAL.

     22					;

     23					;

     24					; VERSION 04

     25					;

     26					; J. MASSE 01-JUL-74

     27					;

     28					; MODIFIED BY:

     29					;

     30					;	P. J. BEZEREDI 01-NOV-76

     31					;

     32					;		PB010 -- BREAK BAD INTO SEPERATE MODULES.  ADD

     33					;			/LI SWITCH.

     34					;

     35					;

     36						.IF DF	R$$11M!R$$11S

     37					.MACRO	SOB	REG,LABEL

     38						DEC	REG

     39						BNE	LABEL

     40					.ENDM	SOB

     41						.ENDC

BADCHK - CHECK, VERIFY AND MATC	MACRO M1110  22-AUG-78 02:06  PAGE 3





     43					;+

     44					; **-$BADCK-CHECK FOR BAD BLOCKS

     45					;

     46					; SUBROUTINE TO CHECK INDIVIDUALLY ALL THE BLOCKS THAT WERE

     47					; TRANSFERRED IN THE LAST WHOLE BUFFER WRITE OR VERIFY OPERATION.

     48					; IF THE WRITE OR VERIFY FAILS FOR ANY BLOCK, THE BLOCK IS

     49					; CONSIDERED TO BE BAD AND IS ADDED TO THE BAD BLOCK POINTER

     50					; TABLE. THE FOLLOWING ALGORITHM IS USED IN THE CARE AND FEEDING

     51					; OF THE BAD BLOCK POINTERS:

     52					;

     53					;	1.  IF THE BLOCK IS NOT BAD, THE LBN IN THE DISK I/O

     54					;	    DPB IS INCREMENTED BY ONE.  THEN -- SINCE A GOOD BLOCK

     55					;	    HAS BEEN FOUND -- THE COUNT OF BAD BLOCKS IN THE CURRENT

     56					;	    POINTER IS CHECKED.  IF THE COUNT IS NON-ZERO, IT MEANS

     57					;	    THAT THE POINTER POINTER MUST BE ADVANCED TO POINT TO

     58					;	    THE NEXT BAD BLOCK POINTER, BECAUSE THE POINTERS REPRESENT

     59					;	    CONTIGUOUS GROUPS OF BAD BLOCKS.  REGARDLESS OF WHETHER

     60					;	    THE COUNT IS NON-ZERO, THE STARTING BLOCK NUMBER FOR

     61					;	    THIS POINTER IS RESET TO THE CURRENT VALUE OF THE LBN

     62					;	    (WHICH HAS ALREADY BEEN BUMPED) SINCE THIS IS NOW THE

     63					;	    NEXT POSSIBLE BAD BLOCK.  THE COUNT BIAS OF -1 IS ALSO

     64					;	    TAKEN INTO ACCOUNT AT THIS POINT.

     65					;

     66					;	2.  IF THE BLOCK IS BAD, THE LBN IS FIRST INCREMENTED BY ONE.

     67					;	    THEN A CHECK IS MADE FOR BLOCK ZERO -- IF BLOCK ZERO IS

     68					;	    BAD, A SPECIAL WARNING MESSAGE WILL BE PRINTED WHEN THE

     69					;	    PROGRAM FINISHES.  NOTE THAT BLOCK ZERO WILL NOT BE INCLUDED

     70					;	    IN ANY BAD BLOCK POINTER IF IT IS BAD, SINCE 'INITVOL'

     71					;	    WOULD CONSIDER THIS TO BE AN ERROR.  OTHER BLOCKS THAT

     72					;	    ARE FOUND TO BE BAD CAUSE THE TOTAL BAD BLOCK COUNT TO

     73					;	    BE INCREMENTED.  IF THE POINTER POINTER IS POINTED PAST

     74					;	    THE LAST POINTER, AN ERROR MESSAGE IS IMMEDIATELY PRINTED,

     75					;	    AND THE PROGRAM TERMINATES FATALLY.  OTHERWISE, THE BAD

     76					;	    BLOCK IS INCLUDED IN THE CURRENT POINTER, AND THE COUNT

     77					;	    IN THE POINTER IS INCREMENTED BY ONE.  IF THERE IS ANY MORE

     78					;	    ROOM IN THE POINTER FOR MORE BAD BLOCKS, NOTHING MORE NEEDS

     79					;	    TO BE DONE.  IF NOT, THE POINTER POINTER MUST BE ADVANCED TO

     80					;	    POINT TO THE NEXT BAD BLOCK POINTER, AND THE STARTING

     81					;	    BLOCK NUMBER OF THE NEW POINTER MUST BE INITIALIZED, IN CASE

     82					;	    ANY MORE BAD BLOCKS ARE FOUND.

     83					;

     84					;

     85					; INPUTS:

     86					;

     87					;	R4 -- MUST POINT TO THE CURRENT BAD BLOCK POINTER

     88					;	R5 -- BUFFER ADDRESS

     89					;

     90					; OUTPUTS:

     91					;

     92					;	BAD BLOCK POINTER TABLE UPDATED WITH NEW BAD BLOCKS.

     93					;

     94					;-

     95

     96	000000	010146 			$BADCK::MOV	R1,-(SP)	;SAVE R1

     97	000002	012701 	000000G			MOV	#$NBLKS,R1	;ERROR DURING WRITE OR READ OF WHOLE BUFFER --

     98									;NOW TRY THE BLOCKS ONE AT A TIME TO FIND THE

     99									;ONES THAT ARE BAD.

BADCHK - CHECK, VERIFY AND MATC	MACRO M1110  22-AUG-78 02:06  PAGE 3-1





    100	000006	012767 	001000 	000000G		MOV	#512.,$XFRSZ	;SET TRANSFER SIZE FOR ONE BLOCK

    101	000014				10$:	CALL	$INIT		;SET UP WORST CASE TEST PATTERN IN I/O BUFFER

    102	000020					CALL	$WRITE		;WRITE TEST PATTERN

    103	000024	103416 				BCS	30$		;IF CS BAD BLOCK

    104	000026					CALL	$VERFY		;TRY TO READ IT

    105	000032	103413 				BCS	30$		;IF CS BAD BLOCK

    106	000034	062767 	000001 	000000G	20$:	ADD	#1,$LBNL	;BUMP LBN BY 1 -- DOUBLE PRECISION

    107	000042	005567 	000000G			ADC	$LBNH

    108	000046	105764 	000000G			TSTB	BB.CNT(R4)	;ANY BAD BLOCKS IN THIS GROUP?

    109	000052	001476 				BEQ	70$		;IF EQ DON'T BUMP POINTER

    110	000054	105364 	000000G			DECB	BB.CNT(R4)	;ALLOW FOR BIAS OF -1

    111	000060	000466 				BR	60$		;GO ADVANCE TO NEXT BAD BLOCK POINTER,

    112									;SINCE A GOOD BLOCK HAS BEEN FOUND.

    113	000062	105767 	000000G		30$:	TSTB	$SWLST		;LIST BAD BLOCKS ON TI:?

    114	000066	001424 				BEQ	35$		;IF EQ NO

    115	000070	010146 				MOV	R1,-(SP)	;SAVE CURRENT BLOCK COUNT

    116	000072	010546 				MOV	R5,-(SP)	;SAVE BUFFER ADDRESS

    117	000074	012700 	000000G			MOV	#$MSG24,R0	;GET ADDRESS OF BLOCK # MESSAGE

    118	000100	012701 	000000G			MOV	#$LBNH,R1	;GET ADDRESS OF LBN

    119	000104	005002 				CLR	R2		;SUPPRESS LEADING 0'S

    120	000106					CALL	$CDDMG		;CONVERT TO DECIMAL ASCII

    121	000112	112720 	000056 			MOVB	#'.,(R0)+	;STUFF THE DECIMAL INDICATOR

    122	000116	105010 				CLRB	(R0)		;TERMINATE THE STRING

    123	000120	012700 	000000G			MOV	#$MSG23,R0	;GET ADDRESS OF FULL MESSAGE

    124	000124	012701 	000040 			MOV	#40,R1		;SET CARRIAGE CONTROL

    125	000130					CALL	$PRINT		;PRINT THE BAD BLOCK

    126	000134	012605 				MOV	(SP)+,R5	;RESTORE BUFFER ADDRESS

    127	000136	012601 				MOV	(SP)+,R1	;RESTORE BLOCK COUNT

    128	000140	062767 	000001 	000000G	35$:	ADD	#1,$LBNL	;BUMP LBN BY 1 -- DOUBLE PRECISION

    129	000146	005567 	000000G			ADC	$LBNH

    130	000152	005767 	000000G			TST	$LBNH		;WAS THIS BLOCK 0?

    131	000156	001007 				BNE	40$		;IF NE NO

    132	000160	022767 	000001 	000000G		CMP	#1,$LBNL	;MAYBE

    133	000166	001003 				BNE	40$		;IF NE NO

    134	000170	005267 	000000G			INC	$BK0FG		;YES, SET THE BLOCK 0 FLAG SO THAT

    135									;A WARNING MESSAGE WILL BE PRINTED AT THE END

    136	000174	000425 				BR	70$		;DO NEXT BLOCK, BUT DON'T INCLUDE BLOCK 0

    137									;IN THE BAD BLOCK FILE -- 'INITVOL' WON'T

    138									;APPRECIATE IT.

    139	000176	005267 	000000G		40$:	INC	$BBCNT		;BUMP CUMULATIVE BAD BLOCK COUNT

    140	000202	022704 	000000G			CMP	#$PTRND,R4	;ANY MORE POINTERS?

    141	000206	001004 				BNE	50$		;IF NE YES

    142	000210	012700 	000000G			MOV	#$MSG7,R0	;BAD BLOCK FILE OVERFLOW

    143	000214	000167 	000000G			JMP	$MESAG		;PRINT "BAD BLOCK FILE OVERFLOW"

    144	000220	122764 	000377 	000000G	50$:	CMPB	#255.,BB.CNT(R4)  ;256 BAD BLOCKS IN THIS GROUP?

    145	000226	001403 				BEQ	60$		;IF EQ DON'T BUMP COUNT

    146	000230	105264 	000000G			INCB	BB.CNT(R4)	;BUMP BY 1

    147	000234	000413 				BR	80$		;STILL ROOM IN THIS GROUP

    148	000236	062704 	000000G		60$:	ADD	#$PTRSZ,R4	;ADVANCE TO NEXT POINTER

    149	000242	062767 	000000C	000000G		ADD	#$PTRSZ/2,BB.USD  ;ADJUST WORD COUNT

    150	000250	116764 	000000G	000000G	70$:	MOVB	$LBNH,BB.NHI(R4)  ;SET STARTING BLOCK # FOR THIS GROUP

    151	000256	016764 	000000G	000000G		MOV	$LBNL,BB.NLO(R4)

    152	000264	005301 			80$:	DEC	R1		;LOOP FOR EACH INDIVIDUAL BLOCK

    153	000266	001252 				BNE	10$		;A "SOB" WILL NOT WORK HERE!!

    154	000270	012601 				MOV	(SP)+,R1	;RESTORE R1

    155	000272					RETURN

    156

BADCHK - CHECK, VERIFY AND MATC	MACRO M1110  22-AUG-78 02:06  PAGE 3-2





    157

    158					;+

    159					; **-$VERFY-VERIFY BAD BLOCK PATTERN

    160					;

    161					; SUBROUTINE TO READ A BLOCK AND COMPARE IT WITH TEST PATTERN

    162					;

    163					;

    164					; INPUTS:

    165					;

    166					;	NONE.

    167					;

    168					; OUTPUTS:

    169					;

    170					;	CARRY -- CLEARED IF NO PARITY ERROR AND VERIFY OK

    171					;	CARRY -- SET IF PARITY ERROR OR VERIFY ERROR

    172					;

    173					;-

    174

    175	000274	010046 			$VERFY::MOV	R0,-(SP)	;SAVE REGISTERS

    176	000276	010246 				MOV	R2,-(SP)	;

    177	000300	010346 				MOV	R3,-(SP)	;

    178	000302	010546 				MOV	R5,-(SP)	;

    179	000304	012703 	000000C			MOV	#IO.RLB!IQ.X,R3	;GET READ WITHOUT RETRIES FUNCTION

    180

    181

    182						.IF NDF	R$$11M&R$$11S

    183

    184						TSTB	$LTDSK+1	;DOES DEVICE SUPPORT IQ.X?

    185						BNE	5$		;IF NE YES

    186						BIC	#IQ.X,R3	;CLEAR IQ.X BIT

    187

    188						.ENDC

    189

    190

    191	000310	012705 	000000G		5$:	MOV	#$BUF,R5	;PUT BUFFER ADDRESS IN R5

    192	000314					CALL	$DSKIO		;READ THE BLOCK SPECIFIED

    193	000320	103421 				BCS	30$		;EXIT WITH CARRY SET IF PARITY ERROR

    194	000322	016702 	000000G			MOV	$TSTPT,R2	;ELSE SET UP TO VERIFY THE READ

    195	000326	016703 	000002G			MOV	$TSTPT+2,R3	;

    196	000332	016700 	000000G			MOV	$XFRSZ,R0	;GET TRANSFER SIZE FROM DISK I/O DPB

    197	000336	006200 				ASR	R0		; R0 CONTAINS # OF TIMES PATTERN IS REPAETED

    198	000340	006200 				ASR	R0		;

    199	000342	020225 			10$:	CMP	R2,(R5)+	;VERIFY OK?

    200	000344	001006 				BNE	20$		;NO

    201	000346	020325 				CMP	R3,(R5)+	;MAYBE -- CHECK SECOND PATTERN

    202	000350	001004 				BNE	20$		;NO

    203	000352					SOB	R0,10$		;LOOP TO CHECK EACH WORD

    204	000356	000241 				CLC			;NO VERIFY ERRORS -- CLEAR CARRY

    205	000360	000401 				BR	30$		;EXIT WITH CARRY CLEAR

    206	000362	000261 			20$:	SEC			;SET CARRY FOR ERROR EXIT

    207	000364	012605 			30$:	MOV	(SP)+,R5	;RESTORE REGISTERS

    208	000366	012603 				MOV	(SP)+,R3	;

    209	000370	012602 				MOV	(SP)+,R2	;

    210	000372	012600 				MOV	(SP)+,R0	;

    211	000374					RETURN			;EXIT

    212

    213

BADCHK - CHECK, VERIFY AND MATC	MACRO M1110  22-AUG-78 02:06  PAGE 3-3





    214					;+

    215					; **-$MATCH-MATCH BAD BLOCK FILE WITH ACTUAL BLOCK

    216					;

    217					; SUBROUTINE TO SEARCH BAD BLOCK FILE FOR DISK BLOCK # IN 'LBNL' & 'LBNH'

    218					;

    219					;

    220					; INPUTS:

    221					;

    222					;	NONE

    223					;

    224					; OUTPUTS:

    225					;

    226					;	CARRY -- CLEARED IF MATCH FOUND

    227					;	CARRY -- SET IF NO MATCH

    228					;

    229					;-

    230

    231	000376	005003 			$MATCH::CLR	R3		;SET BLOCKS FOUND

    232	000400	156703 	000000G			BISB	BB.USD,R3	;ANY BAD BLOCKS FOUND?

    233	000404	001430 				BEQ	30$		;IF EQ NO

    234	000406	006203 				ASR	R3		;R3 = # BAD BLOCK SETS USED

    235	000410	012704 	000000G			MOV	#BB.PTR,R4	;SET R4 FOR INDEXING INTO BAD BLOCK SETS

    236	000414	016701 	000000G		10$:	MOV	$LBNH,R1	;GET LBN WE'RE TRYING TO MATCH

    237	000420	016702 	000000G			MOV	$LBNL,R2

    238	000424	005005 				CLR	R5		;

    239	000426	156405 	000000G			BISB	BB.NHI(R4),R5	;GET HIGH ORDER BITS FROM THIS SET

    240	000432	166402 	000000G			SUB	BB.NLO(R4),R2	;SUBTRACT LOW ORDER BITS --

    241									;  LBN - BAD BLOCK # FROM SET

    242	000436	005601 				SBC	R1		;TAKE CARE OF BORROW

    243	000440	160501 				SUB	R5,R1		;AND SUBTRACT HIGH BITS

    244	000442	001005 				BNE	20$		;NOT IN THIS SET IF HIGH BITS NOT ZERO,

    245									;SINCE EACH SET ONLY SPANS UP TO 256. BLOCKS

    246	000444	005001 				CLR	R1		;

    247	000446	156401 	000000G			BISB	BB.CNT(R4),R1	;GET # OF BLOCKS IN SET

    248	000452	020102 				CMP	R1,R2		;IS LBN WITHIN RANGE OF SET?

    249	000454	103005 				BHIS	40$		;IF HIS YES (C=0)

    250	000456	062704 	000000G		20$:	ADD	#$PTRSZ,R4	;NO -- ADVANCE INDEX TO NEXT SET

    251	000462					SOB	R3,10$		;LOOP FOR NEXT SET

    252	000466	000261 			30$:	SEC			;NO MATCH FOUND -- SET CARRY

    253	000470				40$:	RETURN

    254

    255		000001 				.END

BADCHK - CHECK, VERIFY AND MATC	MACRO M1110  22-AUG-78 02:06  PAGE 3-4

SYMBOL TABLE



A$$CHK= 000000   	F$$LVL= 000001   	M$$MGE= 000000   	R$$NDL= 000001   	U$$MHI= 000040

A$$CPS= 000000   	G$$TPP= 000000   	M$$MUP= 000000   	R$$SND= 000000   	U$$MLO= 120000

A$$NSI= 000000   	G$$TSS= 000000   	M$$NET= 000000   	R$$VAX= 000000   	U$$MRN= 170324

A$$PRI= 000000   	G$$TTK= 000000   	M$$OVR= 000000   	R$$X11= 000001   	V$$CTR= 000400

A$$TRP= 000000   	IO.RLB= ****** GX	N$$CON= 000144   	R$$11M= 000000   	X$$DBT= 000000

BB.CNT= ****** GX	IQ.X  = ****** GX	N$$LDV= 000001   	S$$WPC= 000036   	$BADCK  000000RG

BB.NHI= ****** GX	I$$RAR= 000000   	N$$MOV= 000021   	S$$WPR= 000005   	$BBCNT= ****** GX

BB.NLO= ****** GX	I$$RDN= 000000   	N$$MXM= 000400   	S$$WRG= 000000   	$BK0FG= ****** GX

BB.PTR= ****** GX	K$$CNT= 177546   	N$$TMO= 000012   	S$$YSZ= 030000   	$BUF  = ****** GX

BB.USD= ****** GX	K$$CSR= 177546   	P$$D70= 000000   	T$$ACR= 000000   	$CDDMG= ****** GX

C$$CDA= 000001   	K$$LDC= 000000   	P$$GMX= 000000   	T$$BTW= 000000   	$DSKIO= ****** GX

C$$CKP= 000000   	K$$TPS= 000074   	P$$LAS= 000000   	T$$BUF= 000000   	$INIT = ****** GX

C$$ORE= 002000   	LD$DB = 000000   	P$$P11= 000001   	T$$CCA= 000000   	$LBNH = ****** GX

C$$OVL= 000000   	LD$DK = 000000   	P$$P45= 000000   	T$$CCO= 000000   	$LBNL = ****** GX

C$$RSH= 177564   	LD$DS = 000000   	P$$RFL= 000000   	T$$CTR= 000000   	$MATCH  000376RG

D$$BUG= 177514   	LD$DT = 000000   	P$$RTY= 000000   	T$$C11= 000001   	$MESAG= ****** GX

D$$H11= 000002   	LD$DX = 000000   	P$$R11= 000001   	T$$GMC= 000000   	$MSG23= ****** GX

D$$IAG= 000000   	LD$LP = 000000   	P$$SRF= 000000   	T$$GTS= 000000   	$MSG24= ****** GX

D$$ISK= 000000   	LD$MM = 000000   	P$$TPT= 000000   	T$$J16= 000001   	$MSG7 = ****** GX

D$$L11= 000001   	LD$PP = 000000   	Q$$OPT= 000014   	T$$KMG= 000000   	$NBLKS= ****** GX

D$$M11= 000001   	LD$PR = 000000   	R$$DER= 000000   	T$$LWC= 000000   	$PRINT= ****** GX

D$$SHF= 000000   	LD$TT = 000000   	R$$EXV= 000000   	T$$MAN= 016703   	$PTRND= ****** GX

D$$YNC= 000000   	L$$ASG= 000000   	R$$JPO= 000000   	T$$RNE= 000000   	$PTRSZ= ****** GX

D$$YNM= 000000   	L$$DRV= 000000   	R$$JP1= 000001   	T$$RPR= 000000   	$SWLST= ****** GX

E$$DVC= 000000   	L$$P11= 000001   	R$$JS1= 000001   	T$$RST= 000000   	$TSTPT= ****** GX

E$$NSI= 000000   	L$$11R= 000000   	R$$KWC= 000000   	T$$RUB= 000000   	$VERFY  000274RG

E$$PER= 000000   	M$$CRB= 000124   	R$$K11= 000001   	T$$SYN= 000000   	$WRITE= ****** GX

E$$XPR= 000000   	M$$CRX= 000000   	R$$LKL= 000000   	T$$TRW= 000000   	$XFRSZ= ****** GX

F$$AST= 000000   	M$$EXT= 000000   	R$$NDC= 000006   	T$$VBF= 000000   	$$$R4 = 000000

F$$LPP= 000000   	M$$FCS= 000000   	R$$NDH= 000144



. ABS.	000000	   000

      	000472	   001

ERRORS DETECTED:  0



VIRTUAL MEMORY USED:  3784 WORDS  ( 15 PAGES)

DYNAMIC MEMORY:  4884 WORDS  ( 18 PAGES)

ELAPSED TIME:  00:00:08

OBJ$:BADCHK,LIS$:BADCHK/-SP=SRC$:RSXMC/PA:1,BADCHK

