Google
 

Trailing-Edge - PDP-10 Archives - decuslib10-01 - 43,50147/resdec.mac
There are no other files named resdec.mac in the archive.
	TITLE  RESDEC
	SUBTTL RESTORE A DECTAPE'S DIRECTORY


	BLOCKN=10	;SUBSCRIPTS WORD
	FCOUNT=12	;SUBSCRIPTS FILEN
	NUMOKF=14
	SIX=6

;**************************************************************

	LOC	124
JOBREN:	BITS
	RELOC

;**************************************************************

BEGIN:	CALL	[SIXBIT/RESET/]
	MOVE	14,[POINT 6,DTAN,17]
	SETZ	15,
	JSA	15,INITSR

START:	INIT	1,116
DTAN:	SIXBIT	/DTA  /
	0
	JSR	2,TTYOUT

	USETO	1,144		;ZERO "LINK" WORD OF DIR. BLOK
	OUTPUT	1,OUTZ
	MOVEI	15,STOREP-1	;USE ACC.15 FOR P/D LIST
	MOVEI	16,40		;(16)=R-J ASCII BLANK.
	SETZ	FCOUNT,		;(FCOUNT)=THEORETICAL NO. OF FILES
	MOVEI	BLOCKN,10	;(BLOCKN)=CURRENT BLOCK NO.  0-576(DEC.)
	SETZ	NUMOKF,		;(NUMOKF)=NO. OF COMPLETE FILES
	MOVE	7,[777777777641] ;-95(DEC). ACC7 COUNTS NO. OF D/T READS
	MOVEI	SIX,6
	MOVEI	13,700000	;WILL BE USED LATER TO SET FLAG
	TTCALL	3,HEADG1
	JRST	LOOP6

LOOP9:	ADDM	SIX,SETIBL
	AOSN	7		;CHECK FOR LAST READ. SKIP IF NOT
	JRST	LAST2B	   ;CHANGE READL FOR LAST READ(I.E. 2 BLKS+1 WD)
	ADDI	BLOCKN,14

LOOP6:	MOVEI	5,1200
SETIBL:	USETI	1,3		;BLOK #(FOR I/P)=3,9,15,21,...573(DEC.)
	INPUT	1,READL		;READ 5 BLOCKS+1 WORD INTO GARBIJ

LOOP3:	HRRZ	0,GARBIJ(5)	;(0)=R-H OF LINK WORD FROM BLOCKN
	LSH	0,-10 ;DISCARD BITS INDICATING # OF DATA WORDS IN BLOCKN
	JUMPE	0,CON3
	MOVEM	FCOUNT,CHECK	;(0)=BLOCK # OF 1ST BLOCK IN A FILE
COMPAR:	CAMN	0,FSTFBL(FCOUNT)      ;(I) IF (0) IN FSTFBL,FSTFBL+1,...
	JRST	EASY		      ;         CARRY ON WITH CON3: ETC.
	SOJG	FCOUNT,COMPAR
	MOVE	FCOUNT,CHECK
	ADDI	FCOUNT,1
	CAIN	FCOUNT,47	;ONLY ALLOW 39(DEC.) FILES
	JSR	4,TTYOUT
	MOVEM	0,FSTFBL(FCOUNT)      ;(II) IF NOT ADD TO LIST

CON3:	HLL	0,GARBIJ(5)
	MOVEM	0,WORD(BLOCKN)
	SUBI	BLOCKN,1	;STORE LINK WORD (MINUS INFO RE # DATA 
	SUBI	5,200		;            [WORDS) IN WORD(BLOCKN).
	JUMPGE	5,LOOP3
NEX:	JRST	LOOP9
EASY:	MOVE	FCOUNT,CHECK
	JRST	CON3

;*******************************************************

WORD:	BLOCK	1102
STOREP:	BLOCK	^D100
FSTFBL:	BLOCK	^D40
READL:	IOWD	1201,GARBIJ
	0
GARBIJ:	BLOCK	1201
READSP:	IOWD	601,GARBIJ

;***************************************************************

LAST2B:	MOVE	0,READSP	;MODIFY SOME LOC'S FOR THE LAST D/T READ
	MOVEM	0,READL
	MOVEI	5,400
	ADDI	BLOCKN,12
	MOVEI	0,REDABS
	HRRM	0,NEX
	JRST	SETIBL

PAGE


;***************************************************************
;	ALL LINK WORDS HAVE NOW BEEN READ.

REDABS:	SETZ	3,		;ACC3=COUNTER FOR # OF BLOKS IN A FILE
	MOVE	6,FSTFBL(FCOUNT)
	HRRM	6,COM1
LOOP2:	ADDI	3,1
	CAIL	3,^D575
	JSR	1,TTYOUT
	HRRZ	7,WORD(6)
COM1:	CAIE	7,6		;CHECK FSTFBL(FCOUNT)=R-H OF WORD(6)
	JRST	FORGET		;INCOMPLETE FILE
	HLRZ	7,WORD(6)	;(ACC)=BLOK# OF NEXT BLOK IN FILE
	CAIL	7,1102		;MAKE SURE IT'S NOT OUT OF BOUNDS. IT
	JRST	FORGET		;WILL BE IF BLOK HAS NEVER BEEN ACCESSED
	SKIPN	7
	JRST	CHEKNO		;IF (ACC7)=0 A COMPLETE FILE FOUND
	MOVEM	6,TEMPST-1(3)	;STORE BLOK #'S REFERENCING THE CURRENT
	MOVE	6,7			;   [FILE IN TEMPST,TEMPST+1,...
	JRST	LOOP2

CHEKNO:	AOJ	NUMOKF,
	CAIL	NUMOKF,27	;CHECK THAT # OF COMPLETE FILES <23(DEC)
	JRST	AKWARD		;  (1) IF NOT GO TO AKWARD
	JRST	OKFILE+3	;  (2) IF OK GO TO OKFILE+3

OKFILE:	SOSG	3
	JRST	ENTERN		;WHEN ALL SLOTS FILLED GO TO ENTERN
	MOVE	6,TEMPST-1(3)
	ADDM	13,WORD(6)	;SET FLAG FOR ALL BLOK#'S REFERENCING
				;COMPLETE FILES.
	JSR	BLOKPT		;DEPOSIT IN THE DECDIR SLOTS REFERRING
	DPB	NUMOKF,POINTD	;TO THE BLOCK #'S CONTAINED IN TEMPST,
	JRST	OKFILE		;TEMPST+1,... THE CURRENT (NUMOKF).


FORGET:	CAIN	3,1
	JRST	Z
	JSR	TTYSR
	MOVEM	17,NUMPR+3
	MOVE	3,FSTFBL(FCOUNT)
	JSR	TTYSR
	MOVEM	17,NUMPR+1
	TTCALL	3,NUMPR
Z:	PUSH	15,FSTFBL(FCOUNT)
Z2:	SOJG	FCOUNT,REDABS
	JRST	RERITE

;***************************************************************

BLOKPT:	0			;THIS S/R LOADS POINTD WITH
	IDIVI	6,7		;THE 'SLOT' ADDRESS REQ. BY OKFILE
	JUMPN	7,CON
	SUBI	6,1
	MOVEI	7,7
CON:	MOVEI	4,DECDIR(6)
	DPB	4,POINTA
	MOVEI	4,^D36		;44(OCTAL)
	IMULI	7,5
	SUB	4,7
	DPB	4,POINTB
	JRST	@BLOKPT


POINTA:	POINT	18,POINTD,35
POINTB:	POINT	6,POINTD,5
POINTD:	POINT	5,DECDIR
DECDIR:	BLOCK	^D128
TEMPST:	BLOCK	^D574

PAGE
;****************************************************************
MESINQ:	ASCIZ	/
DECTAPE DRIVE NO. = /
FIRSTQ:	ASCIZ	/
1ST. BLOK# = /


OUTLST:	IOWD	^D128,DECDIR
	0
OUTZ:	IOWD	1,CHECK
	0

NAMES:	SIXBIT	/FILE1 FILE2 FILE3 FILE4 FILE5 FILE6 FILE7/
	SIXBIT	/FILE8 FILE9 FILE10FILE11FILE12FILE13FILE14/
	SIXBIT	/FILE15FILE16FILE17FILE18FILE19FILE20FILE21FILE22/

PAGE
;***************************************************************

ENTERN:	MOVE	0,NAMES-1(NUMOKF)     ;ENTERN MOVES A 6-BIT FILE-NAME TO
	MOVEM	0,DECDIR+122(NUMOKF)  ;DECDIR EA. TIME A COMPLETE FILE
	JRST	Z		      ; IS FOUND

;***********************************************************

RERITE:	MOVEI	1,1736
	DPB	1,POINT1
	MOVE	1,[7777777]
	DPB	1,POINT2
	MOVEI	1,36
	DPB	1,POINT3

	USETO	1,144
	OUTPUT	1,OUTLST

	MOVE	1,[311224042212]	;(1)= '2) DE'  IN ASCII
	MOVEM	1,HEADG1+5
ALPHA:	TTCALL	3,HEADG1

OPTION:	POP	15,3		;(3)=FSTFBL OF INCOMPLETE FILE
	TLNN	15,777777
	JRST	TGTE		;HAVE COME TO END OF LIST OF FSTFBL'S
G:	MOVEI	1,2		;USE ACC.1 TO INDEX WORD
	SETZB	5,TEMPST+1	;
	SETZ	4,
LOOP4:	AOJ	1,		;
	CAIL	1,1102
	JRST	PROCES		;ALL FSTFBLS IN WORD CHECKED AGAINST (3)
	HRLZ	2,WORD(1)	;L-H OF AC2=FSTFBL REF. TO BY WORD(1)
	JUMPL	2,LOOP4		;          =-VE IF BLOK# IN COMPL. FILE
	HRRZ	2,WORD(1)	;R-H OF AC2=FSTFBL REF. TO BY WORD(1)
	CAME	2,3
	JRST	LOOP4		;IF (2)NE.(3) INVESTIGATE NEXT WORD
	ADDI	4,2		;(4)/2 = COUNT OF BLOK#'S IN GARBIJ
	MOVEM	1,GARBIJ(4)	;GARBIJ(N) CONTAINS BLOK#'S REF'G TO (3)
	HLRZ	2,WORD(1)	;GARBIJ(M) CONTAINS LINK-POINTERS ASSOC.
	MOVEM	2,GARBIJ+1(4)	;WITH ABOVE BLOK#'S. N=ODD. M=EVEN.
	TRNE	2,777777	;CHECK IF CURRENT BLOK=LAST FILE BLOK
	JRST	LOOP4		;IF NOT, INVESTIGATE NEXT WORD.
	AOJ	5,
	MOVEM	4,TEMPST(5)
	SETZM	,TEMPST+1(5)
	JRST	LOOP4

PROCES:	MOVEM	4,TEMPST	;STORE COUNT FOR FUTURE REFERENCE
	SETZB	7,1		;(3)=COUNTER FOR LAST BLOK#'S FOR A
LOOP5:	AOJ	7,		;                 [PARTICULAR FILE.
	MOVE	6,TEMPST(7)	;(6)=LAST BLOK# OF FILE,-INITIALLY
	CAIN	6,0		;CHEK FOR MORE THAN 1 LAST BLOK PER FILE
	JRST	OPTION
	MOVE	6,GARBIJ(6)

LOOP7:	CAME	6,GARBIJ+1(4)
	JRST	Y
	MOVE	6,GARBIJ(4)
	AOJ	1,		;(1)=# OF BLOKS LINKING TO LAST BLOK
	MOVE	4,TEMPST
	JRST	LOOP7
Y:	SUBI	4,2
	CAIE	4,2
	JRST	LOOP7
	AOJ	1,		;(1)=# OF LINKED BLOKS FOUND
	MOVE	3,6
X:	JSR	TTYSR
	MOVEM	17,NUMPR+1
	MOVEM	1,3
	JSR	TTYSR
	MOVEM	17,NUMPR+3
	TTCALL	3,NUMPR
	MOVE	4,TEMPST
D:	JRST	LOOP5

;************************************************************

TTYSR:	0			;TTYSR CONVERTS A BINARY
	MOVE	10,[POINT 3,3,20]
	MOVEM	10,ICHAR
	MOVE	10,[POINT 7,17]
	MOVEM	10,OCHAR
	MOVNI	10,5		;NO. IN ACC.3
LOOP10:	ILDB	0,ICHAR		;TO ASCII IN ACC17.
	JUMPN	0,MAJ		;E.G.  00107 WILL BE
	IDPB	16,OCHAR	;PUT OUT ON TTY AS:
	AOJN	10,LOOP10	;        (BLANK)(BLANK)(1)(0)(7)
	MOVE	17,[201004020140]
	JRST	@TTYSR
LOOP11:	ILDB	0,ICHAR
MAJ:	ADDI	0,60
	IDPB	0,OCHAR
	AOJN	10,LOOP11
	JRST	@TTYSR

ICHAR:	POINT	3,3,20
OCHAR:	POINT	7,17

;************************************************************

TGTE:	MOVE	15,[CALLI 12]
	MOVEM	15,OPTION
	JRST	G

POINT1:	POINT	10,DECDIR,9
POINT2:	POINT	21,DECDIR+^D82,35
POINT3:	POINT	5,DECDIR+^D14,9

;***********************************************************

AKWARD:	INIT	2,16		;1ST TIME FILE O/P ON DSK
	SIXBIT	/DSK/
	0
	JSR	5,TTYOUT

	MOVEI	1,AK2		;IN FUTURE JUMP TO AK2 WHEN A COMPLETE
	HRRM	1,CHEKNO+2	;FILE IS FOUND.
	MOVEI	1,1		;USE ACC.1 AS A COUNTER FOR NO.
	JRST	FIRST		;OF FILES O/P ON DSK

AK2:	AOJ	1,
	CAIN	1,^D18
	JSR	7,TTYOUT
FIRST:	MOVE	2,DNAMES-1(1)
	MOVEM	2,READDL
	LOOKUP	2,READDL
	JRST	GOAHED
	JRST	AK2

GOAHED:	MOVEM	6,TEMPST-1(3)	;STORE LAST BLOK# OF FILE
	MOVN	3,3		;INITIALLY, (3)=NO. OF BLOKS
	SETZ	2,
	ENTER	2,READDL
	JSR	6,TTYOUT
LOOPO:	MOVE	10,TEMPST(2)
	USETI	1,(10)
	ADDM	13,WORD(10)
	INPUT	1,READEC
	OUTPUT	2,RITEDL
	AOJ	2,
	AOJL	3,LOOPO
	JRST	Z

PAGE


;***************************************************************

DNAMES:	SIXBIT	/FILEX1FILEX2FILEX3FILEX4FILEX5FILEX6FILEX7FILEX8FILEX9/
	SIXBIT	/FILX10FILX11FILX12FILX13FILX14FILX15FILX16FILX17/
READDL:	SIXBIT	/DUMMY /
	SIXBIT	/   /
	0
	XWD	0
READEC:	IOWD	^D128,GARBIJ
	0
RITEDL:	IOWD	^D127,GARBIJ+1
	0

HEADG1:	ASCIZ	/

PARTIAL FILES OF TYPE(1) DETECTED:
 1ST. BLOK#   NO. OF BLOKS
/
NUMPR:	ASCIZ	/                    
/

;***********************************************************

	PAGE
;***********************************************************

BITS:	CALL	[SIXBIT/RESET/]

	MOVE	14,[POINT 6,DTAN2,17]
	SETZ	15,
	JSA	15,INITSR
START2:	INIT	1,116
DTAN2:	SIXBIT	/DTA  /		;INIT SPECIFIED DECTAPE
	0
	JSR	2,TTYOUT

	INIT	2,16
	SIXBIT	/DSK/		;INIT DSK
	0
	JSR	2,TTYOUT

	MOVE	2,[POINT 10,GARBIJ,27]
	MOVNI	4,12

FIND1:	MOVEI	15,5
	JSA	15,INITSR

X3:	USETI	1,(1)		;SET UP INITIAL DECTAPE BLOK# FOR I/P
	INPUT	1,READEC
	LDB	3,2		;(3)="FSTFBL"
	MOVEM	3,CHECK
	AOJE	4,TOOMAN	;(4)=COUNTER FOR # OF PARTIAL FILES REQ.
	MOVE	3,DNAMP+11(4)	;DURING A REE.  -ONLY 9 PERMITTED
	MOVEM	3,READDL	;SET UP FILE-NAME(1 OF BITSF1,...BITSF9)
	LOOKUP	2,READDL
	JRST	.+2
	JRST	.-5
	ENTER	2,READDL	;ON DSK.
	JSR	6,TTYOUT

OUT5:	OUTPUT	2,RITEDL	;O/P ON DSK LAST D'TAPE BLOK READ
	HLRZ	1,GARBIJ	;GET NEXT D'TAPE BLOK# = N
	CAIN	1,0		;IF N=0, JUMP TO ALLOUT
	JRST	ALLOUT
	USETI	1,(1)		;(1)=N
	INPUT	1,READEC	;READ NEXT BLOK FROM D'TAPE
	LDB	3,2		;FOR PARTIAL FILES CONSISTING OF THE 1ST
	CAMN	3,CHECK		;X BLOKS OF A FILE(RATHER THAN THE LAST)
	JRST	OUT5		;THE LAST BLOK IS DETECTED BECAUSE THE
				;FSTFBL REF. BY THE LINK-WORD OF THE
				;(X+1)TH BLOK IS NOT EQUAL TO (3)
ALLOUT:	CLOSE	2,
	JRST	FIND1

TOOMAN:	JSR	3,TTYOUT
CHECK:	0
DNAMP:	SIXBIT	/BITSF1BITSF2BITSF3BITSF4BITSF5BITSF6BITSF7BITSF8BITSF9/

;*************************************************************

TTYOUT:	0
	HRRZ	10,TTYOUT	;(10)=ADDRESS OF JSR INSTR'N.
	HLRZ	10,-1(10)	;(10)=L-H OF INSTR'N   JSR  N,TTYOUT
	LSH	10,-5	
	ANDI	10,17		;(10)=ACC#, USED FOR NOTE# IDENT'N.
	ADDI	10,60		;(10)=ACC# IN ASCII
	DPB	10,POINTX	;MOVE (10) TO TTYMES
	TTCALL	3,TTYMES	;TYPE OUT NOTE#
	CAIE	10,61		;IF NOTE# WAS 1, RETURN
	CALLI	12		;IF NOT, EXIT
	JRST	Z2

POINTX:	POINT	5,TTYMES+1,20
TTYMES:	ASCIZ	/
NOTE-1
/

;**************************************************************

INITSR:	0
	MOVEI	17,TEMPST-1	;USE ACC17 FOR P/D LIST
	MOVE	13,INITSR	;IF (13)=0, O/P MESINQ ON TTY
	TTCALL	3,MESINQ(13)	;IF (13)=5, O/P FIRSTQ ON TTY
X2:	TTCALL	0,0		;I/P A CHAR FROM TTY
	CAIN	0,15		;CHECK FOR CARRIAGE RETURN CHAR
	JRST	X1
	CAIN	0,177		;CHECK FOR RUB-OUT CHAR
	JRST	SCRUB
	PUSH	17,0		;STORE CHAR
	JRST	X2		;GET NEXT CHAR
SCRUB:	POP	17,0
	TTCALL	1,0		;ECHO BACK CHAR PRECEDING RUB-OUT
	JRST	X2
X1:	TTCALL	0,0		;EMPTY LINE-FEED CHAR FROM TTY BUFFER
	JUMPE	13,CONLOP	;IF SERVICING MESINQ START CHAR CONVERS'N
	SETZ	1,		; "     "     FIRSTQ SET UP POINTER AND
	MOVE	14,[POINT 3,1,23]      ;      CONV INSTR'N
	MOVE	0,[SUBI 0,60]
	MOVEM	0,CONV
CONLOP:	HLRZM	17,CHECK	;(CHECK)=NO. OF CHARS I/P
	SETZ	13,		;USE ACC13 AS A COUNTER
LOOP12:	MOVE	0,TEMPST(13)	;(0)=CHARS IN TURN,STARTING AT MOST SIG.
CONV:	ADDI	0,40		;CONVERT CHAR TO BINARY OR 6-BIT
	IDPB	0,14		;DEPOSIT IT
	AOJ	13,
	CAME	13,CHECK	;HAVE ALL CHARS BEEN CONVERTED?
	JRST	LOOP12		;IF NOT, GET NEXT.
	TRNE	14,777776	;IF MESINQ CALL, RETURN
	JRA	15,(15)
	SUBI	13,4		;IF FIRSTQ CALL, SHIFT (1) SO AS TO
	IMULI	13,3
	LSH	1,(13)		;RIGHT-JUSTIFY IT
	JRA	15,(15)		;RETURN

	END	BEGIN