Google
 

Trailing-Edge - PDP-10 Archives - bb-x130a-sb - netdmp.mac
There are no other files named netdmp.mac in the archive.
	TITLE	NETDMP - PROGRAM TO DUMP NETSER'S DATA BASE
	SUBTTL	DEFINITIONS
	SALL				;SAVE THE FORESTS
	SEARCH	JOBDAT,UUOSYM,NETPRM

;STEVEN M. WOLFE/DAVID S. WEAVER
;
; MODIFIED FROM STEVEN WOLFE'S FILSER DUMPING PROGRAM (FIL) TO HANDLE
; NDB'S.  David Weaver 7-Apr-81.

;DEFINE AC'S
	F=0				;FLAGS
	T1=1				;TEMPS
	T2=2
	T3=3
	T4=4
	U=5				;MUST AGREE WITH MONITOR "U" DEFINITION
	P1=6				;PRESERVED
	NDB=7				;ADDRESS OF CURRENT NDB
	PCB=10				;ADDRESS OF CURRENT PCB
	SFD=11				;COUNTS SFD'S
	C=12				;CURRENT CHAR
	P=17				;PDL

;ASSEMBLY PARAMETERS
	IFNDEF	ABSTAB<ABSTAB==410>	;ADDR OF ADDR OF NUMTAB
	IFNDEF	PMTC<PMTC=="*">		;PROMPT CHAR
	BLKSIZ==200			;SIZE OF A DISK BLOCK
	IFNDEF	NBPP<NBPP==4>		;NUMBER OF BLOCKS PER "PAGE"
	PAGSIZ==BLKSIZ*NBPP		;SIZE OF A "PAGE"
	IFNDEF	NSTR<NSTR==^D36>	;NUMBER OF STRS
	PDLSIZ==100			;SIZE OF PDL
	IFNDEF	BRKMSK<BRKMSK=1401016200>;MASK FOR BREAK CHARS
	IFNDEF	SFDS<SFDS==10>		;MAX SFD LEVEL
	PTHSIZ==SFDS+2+1		;SIZE OF PATH BLOCK

;CHANNELS
	TTY==1				;OUTPUT CHANNEL TO TTY
	DSK==2				;INPUT CHANNEL FOR DUMP

;FLAGS
	F.SFD==1			;CURRENT NMB IS AN SFD
	F.EXE==2			;READING AN EXE FILE
	F.SPY==4			;SPY UUO SUCCESSFUL
	F.TMP==10			;ALL PURPOSE FLAG

;FILESPEC
	.SBDEV==0			;OPEN BLOCK
	.SBFIL==.SBDEV+3		;LOOKUP/ENTER BLOCK
	.SBPTH==.SBFIL+.RBEXT+1		;PATH (INCLUDING 2 WORD HEADER)
	.SMNAM==.SBPTH+PTHSIZ		;FILENAME MASK
	.SMEXT==.SMNAM+1		;EXT MASK
	.SMPPN==.SMEXT+1		;PATH MASK
	SPCSIZ==.SMPPN+SFDS+1		;SIZE OF FILESPEC

	SUBTTL	EDIT HISTORY

	VWHO==0
	VMAJOR==1	;CREATED FOR 5.07
	VMAJOR==2	;5.07 AND 6.02 VERSION
	VMAJOR==3	;6.02 ONLY VERSION
	VMAJOR==4	;EXE FILE SUPPORT
	VMAJOR==5	;NEW COMMAND SCANNER
	VEDIT==100	;FIRST RELEASE OF VERSION 5
	VMINOR==1
	VEDIT==101	;FIX RETRIEVAL POINTER BUG
	VEDIT==102	;7 SERIES VERSION
	VEDIT==103	;MORE 7 SERIES
	VEDIT==104	;MORE 7 SERIES (ACC)
	VEDIT==105	;HOW TO SPELL SUPERSEDE

	LOC	.JBVER
	BYTE	(3)VWHO(9)VMAJOR(6)VMINOR(18)VEDIT

	LOC	.JB41			;LUUO DISPATCH
	PUSHJ	P,LUUO
	SUBTTL	INITIALIZATION
	RELOC	0

NETDMP:	JFCL				;NO CCL ENTRY
	RESET
	MOVE	P,[IOWD PDLSIZ,PDL]	;INITIALIZE PDL
	PUSHJ	P,IPRS			;DUMP FILE
	PUSHJ	P,IOPN			;LOOKUP THE DUMP
	PUSHJ	P,FNDTAB		;FIND THE TABLES
	PUSHJ	P,SPYER			;GET SPY SEGMENT
	PUSHJ	P,OPRS			;OUTPUT FILE
	PUSHJ	P,OOPN			;OPEN THE OUTPUT FILE
	PUSHJ	P,BUFO			;BREAK OUTPUT
	PUSHJ	P,DOIT			;DUMP NETSER'S DATA BASE
	CLOSE	TTY,			;FINISH OUTPUT
	STATZ	TTY,IO.ERR		;ERRORS DURING CLOSE?
	 HALT				;YES
	MONRT.
	JRST	NETDMP
	SUBTTL	MAINSTREAM

;ROUTINE TO TYPE OUT NETSER'S DATA BASE
DOIT:	MOVE	T1,[%CNNDB]
	PUSHJ	P,GTTB
	MOVE	NDB,T1			;GET START OF NDB
NDBLUP:	PUSHJ	P,LNDB			;TYPE OUT THIS NDB
	XHRRZ	NDB,NDBNNM(NDB)		;GET NEXT NDB
	JUMPN	NDB,NDBLUP		;IF ZERO, DONE
	POPJ	P,			;RETURN

LNDB:	STNGO	[ASCIZ /Node	/]
	XHLRZ	T1,NDBSNM(NDB)		;GET ADDRESS OF NODE NAME
	XMOVE	T1,(T1)			;AND GET NAME
	SIXO	T1			;OUTPUT IT
	STNGO	[ASCIZ /	(/]
	XHLRZ	T1,NDBNNM(NDB)		;GET NODE NUMBER
	OCTO	T1
	STNGO	[ASCIZ /)	/]
	PUSHJ	P,LTOP			;GO PRINT NGH FOR THIS NDB
	STNGO	CRLF
	STNGO	TAB
	XHRRZ	T1,NDBSID(NDB)		;GET SOFTWARE ID
	PUSHJ	P,ASCCPY		;GET INTO OUR ADDRESS SPACE
	STNGO	ASCBUF			;AND OUTPUT IT
	STNGO	TAB
	XHLRZ	T1,NDBSID(NDB)		;GET DATE
	PUSHJ	P,ASCCPY
	STNGO	ASCBUF
	STNGO	CRLF
	STNGO	TAB
	PUSHJ	P,LDEV			;LIST ALL DEVICES ON NODE
	STNGO	CRLF
	STNGO	TAB
	PUSHJ	P,LACK			;LIST ACK MESSAGE NUMBERS
	STNGO	CRLF
	XMOVE	T1,NDBFLG(NDB)		;GET FLAG WORD
	STNGO	[ASCIZ/Flags: /]
	LDB	T1,[POINT 9,T1,9]	;GET FLAGS
	OCTO	T1			;OUTPUT THEM
	STNGO	[ASCIZ/	Timer: /]
	LDB	T1,[POINT 9,T1,18]	;GET TIMER
	DECO	T1			;OUTPUT IT
	STNGO	CRLF
	XMOVE	T1,NDBMOM(NDB)		;GET MAX OUTSTANDING MESSAGE COUNTER
	STNGO	[ASCIZ/Max outstanding message counter: /]
	DECO	T1
	STNGO	CRLF
	PUSHJ	P,LPCBQ			;LIST PCB QUEUE
	STNGO	CRLF
	XHLRZ	PCB,NDBQUE(NDB)
	PUSHJ	P,LPCB			;LIST PCB
	XHRRZ	PCB,NDBQUE(NDB)
	PUSHJ	P,LPCB			;LIST PCB
	STNGO	CRLF
	POPJ	P,			;RETURN

LPCBQ:
IPCB:	STNGO	[ASCIZ/Input PCB Q: /]
	XHLRZ	PCB,NDBQUE(NDB)
	PUSHJ	P,PCBQ			;GO OUTPUT THE PCB LIST

OPCB:	STNGO	[ASCIZ/	Output PCB Q: /]
	XHRRZ	PCB,NDBQUE(NDB)
	PUSHJ	P,PCBQ			;GO OUTPUT THE PCB LIST
	POPJ	P,

PCBLUP:	XHRRZ	PCB,(PCB)		;GET NEXT ON LIST (IF ANY)
PCBQ:	OCTO	PCB
	JUMPE	PCB,PCBDUN		;NONE, DONE
	XHRRZ	T1,PCBNNM(PCB)		;GET NODE NUMBER FROM PCB
	COI	"("
	OCTO	T1
	STNGO	[ASCIZ/), /]
	JRST	PCBLUP
PCBDUN:	POPJ	P,

LPCB1:	JUMPE	PCB,PCBFIN
	STNGO	CRLF
	STNGO	[ASCIZ/PCB: /]
	OCTO	PCB
	XHRRZ	T1,PCBNNM(PCB)		;GET NODE NUMBER FROM PCB
	COI	"("
	OCTO	T1
	COI	")"
	XMOVE	T1,PCBBLK(PCB)		;GET FIRST WORD
	MOVEI	T2,[ASCIZ/ numbered /]
	TLNN	T1,PCB.NM		;NUMBERED MESSAGE?
	 MOVEI	T2,[ASCIZ/ unnumbered /];NO,
	STNGO	(T2)			;OUTPUT THE MESSAGE
	STNGO	CRLF
	STNGO	[ASCIZ/Conversion: /]
	MOVE	U,PCB			;COPY ADDRESS OF PCB
	XLDB	T1,[PC%PCV]		;GET CONVERSION TYPE
	OCTO	T1
	STNGO	[ASCIZ/	Message # /]
	XLDB	T1,[PC%MSN]		;GET MESSAGE NUMBER
	OCTO	T1			;OUTPUT IN OCTAL
	STNGO	CRLF
	STNGO	[ASCIZ/BufLen: /]
	XHLRZ	T1,PCBICT(PCB)		;GET BUFFER SIZE
	DECO	T1
	XHRRZ	T2,PCBIAD(PCB)		;GET ADDRESS OF BUFFER
	PUSHJ	P,PCBCPY		;AND COPY BUFFER INTO PCBBUF
	STNGO	[ASCIZ/	NumBytes: /]
	XHRRZ	T1,PCBICT(PCB)		;GET BYTES IN BUFFER
	DECO	T1
	STNGO	CRLF
	XMOVE	T2,PCBIAD(PCB)		;GET POINTER INFO
	HRRI	T2,PCBBUF		;MAKE IT POINT TO PCBBUF
	PUSH	P,T1			;SAVE ARGS
	PUSH	P,T2
	TRO	F,F.TMP			;SET FLAG FOR OCTAL OUTPUT
	PUSHJ	P,PCBOUT		;OUTPUT THE CONTENTS OF PCB BUFFER
	POP	P,T2			;RESTORE ARGS
	POP	P,T1
	TRZ	F,F.TMP			;SET FLAG FOR OCTAL OUTPUT
	PUSHJ	P,PCBOUT		;OUTPUT THE CONTENTS OF PCB BUFFER
	STNGO	[ASCIZ/Tag: /]
	XMOVE	T1,PCBTAG(PCB)		;GET TAG
	SIXO	T1
	STNGO	[ASCIZ/	End: /]		;Get end of PCB
	XMOVE	T1,PCBLEN(PCB)
	SIXO	T1
	STNGO	CRLF
	XHRRZ	PCB,PCBBLK(PCB)		;GET NEXT PCB ADDRESS
LPCB:	JUMPN	PCB,LPCB1
PCBFIN:	POPJ	P,

;ROUTINE TO COPY FROM MONITOR PCB BUFFER TO PROGRAM PCB BUFFER
;	T1/	NUMBER OF WORDS
;	T2/	START OF MONITOR BUFFER

PCBCPY:	SETZ	T3,			;START WITH ZERO
PCBCP1:	CAML	T3,T1			;MOVED ENOUGH YET?
	 JRST	PCBCP2
	MOVE	T4,T3			;GET OFFSET
	ADD	T4,T2			;ADD IN MONITOR ADDRESS
	XMOVE	T4,(T4)			;GET CONTENTS
	MOVEM	T4,PCBBUF(T3)		;SAVE IN OUR BUFFER
	AOJA	T3,PCBCP1		;LOOP FOR MORE
PCBCP2:	POPJ	P,

;ROUTINE TO OUTPUT CONTENTS OF PCB BUFFER
;	F/	F.TMP set for octal, clear for character
;	PCB/	POINTS TO PCB
;	T1/	NUMBER OF BYTES
;	T2/	BYTE POINTER

PCBOUT:	STNGO	[ASCIZ/Buffer:/]
	TRNE	F,F.TMP			;DOING OCTAL?
	 STNGO	[ASCIZ/ (octal)/]	;YES, SPECIFY
	STNGO	CRLF
	SETO	T3,			;BACKUP THE POINTER
	ADJBP	T3,T2
PCBOU1:	SOJLE	T1,PCBOU3		;DECREMENT BYTE COUNT
	ILDB	T4,T2			;GET THE FIRST BYTE
	TRNN	F,F.TMP			;WANT OCTAL OUTPUT?
	 JRST	PCBOUC			; NO, GO OUTPUT 7 BIT CHARS
	COI	"<"			;OUTPUT OCTAL FIRST
	OCTO	T4
	COI	">"
	ANDI	T4,177			;STRIP TO 7 BITS
	CAIN	T4,12			;<LF>?
	 STNGO	CRLF			;YES, OUTPUT <CRLF>
	JRST	PCBOU1			;LOOP BACK FOR MORE
PCBOUC:	ANDI	T4,177			;STRIP TO 7 BITS
	CAIL	T4," "			;CONTROL CHARACTER?
	 JRST	PCBOU2			;NO, JUST OUTPUT WHAT IT IS
	STNGO	CTRTBL(T4)		;OUTPUT SPECIAL CHARS
	JRST	PCBOU1			;LOOP BACK FOR ALL
PCBOU2:	CO	T4			;OUTPUT IT
	JRST	PCBOU1			;LOOP BACK FOR ALL
PCBOU3:	STNGO	CRLF
	POPJ	P,

;ROUTINE TO LIST NEIGHBORS FOR NDB

LTOP:	SETZ	T1,			;START WITH 0
	MOVEI	T1,NDBTOP(NDB)		;GET ADDRESS OF FIRST TOP WORD
TOPLUP:	XMOVE	T2,(T1)			;GET THE FIRST WORD
	HRLZI	T3,(POINT 9,0,-1)	;GET BYTE POINTER
	HRRI	T3,T2
	PUSHJ	P,LNDCST		;LIST NODE(COST)
	 JRST	TOPDUN
	PUSHJ	P,LNDCST
	 JRST	TOPDUN
	CAIE	T1,NDBTOP+<NGHMAX/2>(NDB) ;HAVE WE REACHED THE END OF LIST?
	AOJA	T1,TOPLUP
TOPDUN:	POPJ	P,

LNDCST:	ILDB	T4,T3			;GET FIRST NODE
	JUMPE	T4,CSTDUN		;IF ZERO MUST BE DONE
	OCTO	T4			;OUTPUT NODE NUMBER
	COI	"("
	ILDB	T4,T3			;GET COST
	DECO	T4
	STNGO	[ASCIZ /) /]
	AOS	(P)
CSTDUN:	POPJ	P,			;RETURN

LDEV:	MOVEI	T1,NDBLEN-NDBDEV	;START WITH HIGHEST
DEVLP1:	MOVE	T3,T1
	ADD	T3,NDB
	XMOVE	T2,NDBDEV(T3)		;GET THE FIRST WORD
	MOVEM	T2,DVBUF(T1)		;SAVE IN BUFFER
	SOJGE	T1,DEVLP1

	MOVEI	T1,DEVTRM
	PUSH	P,T1			;STORE ON STACK
	MOVEI	T1,DEVLEN		;GET LENGTH OF TABLE
	PUSH	P,T1			;STORE ON STACK
	MOVEI	T1,DEVTBL		;GET ADDRESS OF TABLE
	PUSH	P,T1
	HRLZI	T1,(POINT 9,0,-1)	;GET BYTE POINTER
	HRRI	T1,DVBUF
	TRZ	F,F.TMP			;SPECIFY DECIMAL OUTPUT
	PUSHJ	P,BYTOUT		;AND OUTPUT THE BYTES
	POPJ	P,			;RETURN

LACK:	XMOVE	T2,NDBMNM(NDB)		;GET THE FIRST WORD
	MOVEM	T2,DVBUF		;SAVE IN BUFFER
	XMOVE	T2,NDBMNM+1(NDB)
	MOVEM	T2,DVBUF+1

	HRROI	T1,ACKTRM		;GET TERMINATOR
	PUSH	P,T1			;STORE ON STACK
	MOVEI	T1,ACKLEN		;GET LENGTH OF TABLE
	PUSH	P,T1			;STORE ON STACK
	MOVEI	T1,ACKTBL		;GET ADDRESS OF TABLE
	PUSH	P,T1
	HRLI	T1,(POINT 8,0,-1)	;GET BYTE POINTER
	HRRI	T1,DVBUF
	TRO	F,F.TMP			;SPECIFY OCTAL OUTPUT
	PUSHJ	P,BYTOUT		;AND OUTPUT THE BYTES
	POPJ	P,			;RETURN

;ROUTINE TO OUTPUT A GROUP OF BYTES
;
;	CALL WITH:
;
;	TRO	F,F.TMP			;SET FOR OCTAL, CLEAR FOR DECIMAL
;	MOVEI	T1,TBLTRM		;GET TERMINATOR STRING
;	    or
;	HRROI	T1,TBLTRM		;TO INDICATE ZEROS ARE TO PRINT
;	PUSH	P,T1			;STORE ON STACK
;	MOVEI	T1,TBLLEN		;GET LENGTH OF TABLE
;	PUSH	P,T1			;STORE ON STACK
;	MOVEI	T1,TBL			;GET ADDRESS OF TABLE
;	PUSH	P,T1		    	;STORE ON STACK
;	MOVE	T1,[POINT s,addr,b]	;GET BYTE POINTER
;	PUSHJ	P,BYTOUT
;

BYTOUT:	SETZ	T2,
BYTLP1:	CAML	T2,-2(P)		;REACHED END OF TABLE?
	 JRST	BYTDUN			;YES, DONE
	ILDB	T4,T1			;GET NUMBER
	SKIPL	-3(P)			;DO WE WANT 0'S PRINTED?
	 JUMPE	T4,BYTLUP		; NO, MAKE SURE WE DON'T
	MOVE	T3,T2			;COPY
	ADD	T3,-1(P)		;CONVERT TO OFFSET
	STNGO	(T3)
	TRNE	F,F.TMP			;WANT OCTAL OUTPUT?
	OCTO	T4			;YES
	TRNN	F,F.TMP			;WANT DECIMAL OUTPUT?
	DECO	T4			;YES
	HRRZ	T3,-3(P)
	STNGO	(T3)			;OUTPUT TERMINATOR
BYTLUP:	AOJA	T2,BYTLP1		;LOOP FOR ALL DEVICES
BYTDUN:	ADJSP	P,-4			;RESET THE STACK
	JRST	@4(P)			;AND RETURN

	SUBTTL	STRMOV

;ROUTINE TO COPY AN ASCIZ STRING FROM DUMP TO ASCBUF
;
;	CALL WITH T1 CONTAINING POINTER IN MEMORY
;
ASCCPY:	SETZ	T4,			;START WITH COUNT 0
ASCLUP:	CAIL	T4,ASCLEN		;OUT OF BUFFER?
	 POPJ	P,			; YES, RETURN
	MOVE	T3,T1			;GET ADDRESS
	ADD	T3,T4			;ADD IN OFFSET
	XMOVE	T2,(T3)			;GET FIRST WORD
	MOVEM	T2,ASCBUF(T4)		;SAVE IN BUFFER
	TRNN	T2,376			;LAST CHAR?
	 POPJ	P,			; YES, RETURN
	AOJA	T4,ASCLUP		;GO GET MORE

	SUBTTL	GETTAB

;ROUTINE TO DO A GETTAB
;T1 PASSES ARG
;T1 RETURNS RESULT
;ALWAYS RETURNS CPOPJ
GTTB:	HLRZ	T2,T1			;GET INDEX
	ADD	T1,NMTB			;ADDR IN NUMTAB
	XHRRZ	T3,(T1)			;GET ADDR OF TABLE
	ADD	T2,T3			;ADDR OF WORD
	XMOVE	T1,(T2)			;GET WORD
	POPJ	P,

;ROUTINE TO FIND THE ADDR OF NUMTAB
FNDTAB:	TRZ	F,F.SPY			;WE CAN'T SPY YET
	XMOVE	T1,ABSTAB		;GET ADDR OF NUMTAB
	MOVEM	T1,NMTB
	MOVE	T1,[XWD .GTSLF,.GTSLF]	;CHECK THAT
	PUSHJ	P,GTTB
	TLZ	T1,-1
	CAME	T1,NMTB
	HALT
	POPJ	P,

	SUBTTL	OUTPUT ROUTINES

;OUTPUT A DATE
;T1 PASSES THE DATE (15 BIT FORMAT)
;((YY-^D64)*12+MM-1)*^D31+DD-1
DATEO:	IDIVI	T1,^D31			;REMAIN IS DD-1
	ADDI	T2,1			;OUTPUT DD
	DECO	T2
	COI	"-"
	IDIVI	T1,^D12			;REMAIN IS MM-1
	SIXO	MONTH(T2)		;OUTPUT MONTH NAME
	COI	"-"
	ADDI	T1,^D64			;OUTPUT YY
	DECO	T1
	POPJ	P,

;TYPE STR NAME GIVEN FSN
;T1 PASSES FSN
STRO:	COI	" "
	SIXO	STRN-1(T1)		;TYPE IT
	COI	":"
	POPJ	P,

;TYPE STR NAMES GIVEN THEIR MASK BITS
;T1 PASSES MASK
STRBIT:	MOVEI	T2,1			;START WITH 1ST STR
STRBT1:	SKIPN	STRN-1(T2)		;IS THERE ANY SUCH STR?
	JRST	STRBT2			;NO
	MOVEI	T3,1			;BUILD MASK
	LSH	T3,-1(T2)
	TDNN	T3,T1			;MASKS MATCH?
	JRST	STRBT2			;NO, TRY NEXT STR
	COI	" "
	SIXO	STRN-1(T2)		;YES, TYPE STR NAME
	COI	":"
STRBT2:	CAIE	T2,NSTR			;LOOP FOR EACH STR
	AOJA	T2,STRBT1
	POPJ	P,

;OUTPUT A PPN
;T1 PASSES THE PPN
PPNO:	PUSH	P,T1
	COI	"["
	HLRZ	T1,(P)			;P
	OCTO	T1
	COI	","
	HRRZ	T1,(P)			;PN
	OCTO	T1
	COI	"]"
T1POPJ:	POP	P,T1
	POPJ	P,
	SUBTTL	COMMAND SCANNER

;ROUTINE TO PARSE THE OUTPUT FILESPEC
OPRS1:	CLRBFI
;ENTER HERE
OPRS:	OUTSTR	[ASCIZ /List: /]	;PROMPT USER
	INCHWL	C			;INPUT 1ST CHAR
	MOVEI	P1,OSPC			;ADDR OF OUTPUT FILE
	MOVEI	T1,.IOASC		;MODE
	MOVEM	T1,.SBDEV+.OPMOD(P1)
	MOVSI	T1,'TTY'		;DEVICE
	MOVEM	T1,.SBDEV+.OPDEV(P1)
	MOVSI	T1,OBUF			;BUFFER
	MOVEM	T1,.SBDEV+.OPBUF(P1)
	MOVEI	T1,.RBEXT		;COUNT
	MOVEM	T1,.SBFIL+.RBCNT(P1)
	SETZM	.SBFIL+.RBPPN(P1)
	SKIPN	T1,INAME		;DEFAULT OUTPUT NAME TO INPUT NAME
	 MOVSI	T1,'NET'		;FILENAME
	MOVEM	T1,.SBFIL+.RBNAM(P1)
	MOVSI	T1,'LST'		;EXTENSION
	MOVEM	T1,.SBFIL+.RBEXT(P1)
	PUSHJ	P,SPCI			;INPUT THE FILESPEC
	 JRST	OPRS1
	PUSHJ	P,BP			;CHECK FOR BREAK
	 JRST	OPRS1
	POPJ	P,

;ROUTINE TO OPEN THE OUTPUT FILE
OOPN:	OPEN	TTY,OSPC+.SBDEV
	 HALT
	ENTER	TTY,OSPC+.SBFIL
	 HALT
	POPJ	P,
;ROUTINE TO PARSE THE TARGET FILESPEC
XPRS1:	CLRBFI
;ENTER HERE
XPRS:	OUTCHR	[PMTC]			;PROMPT USER
	INCHWL	C			;INPUT 1ST CHAR
	MOVEI	P1,XSPC			;ADDR OF OUTPUT FILE
	SETOM	.SMPPN(P1)		;WILD PATH
	HRLZI	T1,.SMPPN(P1)
	HRRI	T1,.SMPPN+1(P1)
	BLT	T1,.SMPPN+SFDS(P1)
	SETOM	.SMNAM(P1)		;WILD FILENAME
	SETOM	.SMEXT(P1)		;EXTENSION
	PUSHJ	P,SPCI			;INPUT THE FILESPEC
	 JRST	XPRS1
	PUSHJ	P,BP			;CHECK FOR BREAK
	 JRST	XPRS1
	POPJ	P,
;ROUTINE TO PARSE THE INPUT FILESPEC
IPRS1:	CLRBFI
;ENTER HERE
IPRS:	OUTSTR	[ASCIZ /File: /]	;PROMPT USER
	INCHWL	C			;INPUT 1ST CHAR
	TRZ	F,F.EXE			;ASSUME RUNNING MONITOR
	PUSHJ	P,BP			;EOL?
	 TROA	F,F.EXE			;NO, INPUT THE FILESPEC
	POPJ	P,			;YES, LUCKY GUESS
	MOVEI	P1,ISPC			;ADDR OF INPUT FILE
	MOVEI	T1,.IODMP		;MODE
	MOVEM	T1,.SBDEV+.OPMOD(P1)
	MOVSI	T1,'DSK'		;DEVICE
	MOVEM	T1,.SBDEV+.OPDEV(P1)
	SETZM	.SBDEV+.OPBUF(P1)	;NO BUFFER
	MOVEI	T1,.RBEXT		;COUNT
	MOVEM	T1,.SBFIL+.RBCNT(P1)
	SETZM	.SBFIL+.RBPPN(P1)
	MOVE	T1,[SIXBIT /CRASH/]	;FILENAME
	MOVEM	T1,.SBFIL+.RBNAM(P1)
	MOVSI	T1,'EXE'		;EXTENSION
	MOVEM	T1,.SBFIL+.RBEXT(P1)
	PUSHJ	P,SPCI			;INPUT THE FILESPEC
	 JRST	IPRS1
	PUSHJ	P,BP			;CHECK FOR BREAK
	 JRST	IPRS1
	MOVE	T1,.SBFIL+.RBNAM(P1)	;GET INPUT FILE NAME
	MOVEM	T1,INAME		;SAVE FOR LATER
	POPJ	P,

;ROUTINE TO OPEN THE INPUT FILE
IOPN:	TRNN	F,F.EXE			;LOOKING AT A DUMP?
	POPJ	P,			;NOPE, NO FILE TO OPEN
	OPEN	DSK,ISPC+.SBDEV		;OPEN THE DEVICE
	 HALT
	LOOKUP	DSK,ISPC+.SBFIL		;LOOKUP THE FILE
	 HALT
	SETOM	CPAG			;NOTHING IN CACHE YET
	SETZM	CTTL			;CACHE HIT SCORES
	SETZM	CBD
	POPJ	P,

;ROUTINE TO GET THE SPY SEGMENT
SPYER:	TRNE	F,F.EXE			;LOOKING AT RUNNING MONITOR?
	POPJ	P,			;NOPE, DON'T NEED SPY SEGMENT
	MOVE	T1,[%CNSIZ]		;GET HIGHEST LOC IN MONITOR
	PUSHJ	P,GTTB
	SUBI	T1,1
	SPY	T1,			;SPY ON THAT MUCH CORE
	 HALT
	TRO	F,F.SPY			;WE CAN SPY NOW
	POPJ	P,
	SUBTTL	INPUT ROUTINES

;ROUTINE TO INPUT A WILD SIXBIT WORD
;T1 RETURNS THE WORD
;T2 RETURNS A WILDCARD MASK
WSIXI:	SETZB	T2,T3			;INITIAL MASK
	MOVEI	T4,6*6			;BIT COUNT
	PUSHJ	P,EATS			;EAT SPACES
WSIXI3:	SUBI	C,40			;CONVERT LOWER CASE TO UPPER
	CAIL	C,"A"			;UPPER CASE?
	CAILE	C,"Z"
	ADDI	C,40			;NO, OOPS CONVERT BACK
	CAIE	C,"*"			;VALID SIXBIT CHAR?
	CAIL	C,"0"
	CAILE	C,"9"
	CAIL	C,"A"
	CAILE	C,"Z"
	CAIN	C,"?"
	JRST	WSIXI1			;YES
WSIXI4:	LSH	T1,(T4)			;NO, LEFT JUSTIFY RESULTS
	LSHC	T2,(T4)
	POPJ	P,
WSIXI1:	JUMPE	T4,WSIXI2		;ONLY 1ST 6 CHARS SIGNIFICANT
	LSH	T1,6			;APPEND CHAR TO NAME
	ADDI	T1,-40(C)
	CAIN	C,"?"
	TLO	T3,770000
	CAIN	C,"*"
	SETO	T3,
	LSHC	T2,6
	SUBI	T4,6			;COUNT IT
WSIXI2:	INCHWL	C			;INPUT NEXT CHAR
	JUMPL	T3,WSIXI4		;QUIT IF "*"
	JRST	WSIXI3			;ELSE LOOP
;ROUTINE TO INPUT AN OCTAL NUMBER WITH WILDCARDS
;T1 RETURNS THE NUMBER
;T2 RETURNS A WILDCARD MASK
WOCTI:	SETZB	T1,T2			;DEFAULT TO ZERO
	PUSHJ	P,EATS			;EAT SPACES
	CAIE	C,"*"			;THE UNIVERSE?
	JRST	WOCTI3			;NO
	INCHWL	C			;YES, EAT IT
	SETOB	T1,T2			;RETURN THE WORLD
	POPJ	P,
WOCTI3:	CAIL	C,"0"			;VALID DIGIT OR WILDCARD?
	CAILE	C,"7"
	CAIN	C,"?"
	JRST	WOCTI1			;YES
	POPJ	P,
WOCTI1:	LSH	T1,3			;YES, APPEND TO NUMBER
	LSH	T2,3
	TRZE	C,10
	ADDI	T2,7
	ADDI	T1,-"0"(C)
	INCHWL	C			;INPUT NEXT CHAR
	JRST	WOCTI3			;TEST IF VALID

;ROUTINE TO EAT SPACES AND TABS
EATS1:	INCHWL	C			;GET NEXT CHAR
;ENTER HERE
EATS:	CAIE	C,11			;TAB?
	CAIN	C,40			;OR SPACE?
	JRST	EATS1
	POPJ	P,

;PREDICATE IF BREAK CHAR
BP:	PUSHJ	P,EATS			;EAT SPACES
	CAIN	C,15			;EAT <CR>
	INCHWL	C
	MOVEI	T1,1			;BREAK CHAR?
	LSH	T1,(C)
	TDNE	T1,[BRKMSK]
	AOS	(P)			;YES
	POPJ	P,			;NO
;ROUTINE TO INPUT A FILESPEC
;P1 PASSES ADDR OF FILESPEC
;SKIP IF OK
SPCI:	PUSHJ	P,WSIXI			;GET DEVICE OR FILENAME
	PUSHJ	P,EATS			;WHICH IS IT?
	CAIE	C,":"
	JRST	SPCI2			;FILENAME
	SKIPE	T1			;DEVICE, SAVE IT
	MOVEM	T1,.SBDEV+.OPDEV(P1)
	JUMPN	T2,CPOPJ		;NO WILDCARDS IN DEVICE
	INCHWL	C			;EAT THE COLON
	PUSHJ	P,WSIXI			;GET THE FILENAME
SPCI2:	JUMPE	T1,SPCI3		;STORE FILENAME
	MOVEM	T1,.SBFIL+.RBNAM(P1)
	MOVEM	T2,.SMNAM(P1)
SPCI3:	PUSHJ	P,EATS			;EXTENSION?
	CAIE	C,"."
	JRST	SPCI4			;NO
	INCHWL	C			;YES, EAT THE DOT
	PUSHJ	P,WSIXI			;INPUT THE EXTENSION
	JUMPE	T1,SPCI4		;STORE EXTENSION
	HLLZM	T1,.SBFIL+.RBEXT(P1)
	HLLZM	T2,.SMEXT(P1)
SPCI4:	PUSHJ	P,EATS			;PATH?
	CAIE	C,"["
	JRST	CPOPJ1			;NO
	INCHWL	C			;YES, EAT BRACKET
	HRREI	T1,.PTFRD		;READ DEFAULT PATH
	MOVEM	T1,.SBPTH+.PTFCN(P1)
	MOVEI	T1,.SBPTH(P1)
	MOVEM	T1,.SBFIL+.RBPPN(P1)
	HRLI	T1,PTHSIZ
	PATH.	T1,
	 HALT
	SETZM	.SMPPN(P1)		;NOT WILD
	HRLZI	T1,.SMPPN(P1)
	HRRI	T1,.SMPPN+1(P1)
	BLT	T1,.SMPPN+SFDS(P1)
	MOVEI	SFD,1			;1ST SFD
	PUSHJ	P,WOCTI			;GET THE PROJECT
	JUMPE	T1,SPCI5		;STORE IT
	HRLM	T1,.SBPTH+.PTPPN(P1)
	HRLM	T2,.SMPPN(P1)
SPCI5:	PUSHJ	P,EATS			;EAT COMMA
	CAIN	C,","
	INCHWL	C
	PUSHJ	P,WOCTI			;GET THE PROGRAMMER
	JUMPE	T1,SPCI6
	HRRM	T1,.SBPTH+.PTPPN(P1)
	HRRM	T2,.SMPPN(P1)
SPCI6:	PUSHJ	P,EATS			;MORE?
	CAIE	C,","
	JRST	SPCI7			;NO
	INCHWL	C			;YES, EAT THE COMMA
	CAILE	SFD,SFDS		;NOT TOO MANY
	POPJ	P,
	PUSHJ	P,WSIXI			;INPUT THE SFD
	JUMPE	T1,SPCI8		;STORE IT
	MOVE	T3,P1
	ADD	T3,SFD
	MOVEM	T1,.SBPTH+.PTPPN(T3)
	MOVEM	T2,.SMPPN(T3)
SPCI8:	AOJA	SFD,SPCI6		;COUNT IT, GET ANOTHER
SPCI7:	MOVE	T3,P1			;PATH IS ZERO TERMINATED
	ADD	T3,SFD
	SETZM	.SBPTH+.PTPPN(T3)
	CAIN	C,"]"			;EAT BRACKET
	INCHWL	C
CPOPJ1:	AOS	(P)			;SKIP RETURN
CPOPJ:	POPJ	P,			;NOSKIP RETURN
	SUBTTL	UUO DISPATCH

;RULES FOR WRITING A UUO
;1. NAMING CONVENTION, ROUTINE NAME STARTS WITH LETTER "U"
;2. UUO RECEIVES EFFECTIVE ADDRESS IN JBUUO AND/OR JBUUOR
;3. UUO MUST PRESERVE ALL AC'S EXCEPT T'S
;4. UUO EXITS WITH POPJ
;5. ROUTINE ADDRESS MUST BE ENTERED IN UUOTAB
;6. UUO RECEIVES ADDRESS OF AC IN ACR

;UUO DISPATCH
LUUO:	PUSH	P,T1			;SAVE AC'S
	PUSH	P,T2
	PUSH	P,T3
	PUSH	P,T4
	PUSH	P,JBUUO
	PUSH	P,JBUUOR
	PUSH	P,ACR
	HRRZ	T1,.JBUUO		;GET EFFECTIVE ADDRESS
	MOVEM	T1,JBUUO		;SAVE IT
	MOVEI	T2,-T1(T1)		;ASSUME RELOCATED
	ADDI	T2,-6(P)
	CAIL	T1,T1			;RELOCATED?
	CAILE	T1,T4
	MOVE	T2,T1			;NO, JUST REGULAR
	MOVEM	T2,JBUUOR		;SAVE IT
	LDB	T1,[POINT 4,.JBUUO,12]	;GET AC
	MOVEI	T2,-T1(T1)		;ASSUME RELOCATED
	ADDI	T2,-6(P)
	CAIL	T1,T1			;RELOCATED?
	CAILE	T1,T4
	MOVE	T2,T1			;NO, JUST REGULAR
	MOVEM	T2,ACR			;SAVE IT
	LDB	T1,[POINT 9,.JBUUO,8]	;GET OP CODE
	PUSHJ	P,@UUOTAB-1(T1)		;DO THE UUO
	POP	P,ACR			;RECALL AC'S
	POP	P,JBUUOR
	POP	P,JBUUO
	POP	P,T4
	POP	P,T3
	POP	P,T2
	POP	P,T1
	POPJ	P,

;TABLE OF UUO ADDRESSES
	DEFINE	XX(AA,BB)<
	EXP	BB
	OPDEF	AA[<.-UUOTAB>B8]
>
UUOTAB:	XX	CO,UCO			;OUTPUT A CHAR
	XX	STNGO,USTNGO		;OUTPUT A STRING
	XX	COI,UCOI		;OUTPUT A CHAR IMMEDIATE
	XX	OCTO,UOCTO		;OUTPUT AN OCTAL NUMBER
	XX	DECO,UDECO		;OUTPUT A DECIMAL NUMBER
	XX	SIXO,USIXO		;OUTPUT A SIXBIT WORD
	XX	XMOVE,UMOVE		;MOVE FROM SPYSEG
	XX	XHRRZ,UHRRZ		;HRRZ FROM SPYSEG
	XX	XHLRZ,UHLRZ		;HLRZ FROM SPYSEG
	XX	XLDB,ULDB		;LDB FROM SPYSEG (BP IN LOWSEG)
	SUBTTL	UUO'S

;COI UUO
UCOI:	MOVE	T1,JBUUO		;GET THE CHAR
	JRST	UCO3

;CO UUO
UCO2:	PUSHJ	P,BUFO			;OUTPUT A BUFFER
	JRST	UCO3
;ENTER HERE
UCO:	MOVE	T1,@JBUUOR		;GET CHAR
UCO3:	SOSGE	OBUF+.BFCTR		;ROOM IN OUTPUT BUF?
	JRST	UCO2
	IDPB	T1,OBUF+.BFPTR		;PUT IT IN BUF
	POPJ	P,
;ROUTINE TO OUTPUT A BUFFER
BUFO:	OUT	TTY,			;NO, GET NEW BUF
	 POPJ	P,			;TRY AGAIN
	HALT

;STNGO UUO
USTNGO:	HRRZ	T1,JBUUOR		;GET ADDR
	HRLI	T1,(POINT 7,0)		;MAKE INTO BP
UPT3:	ILDB	T2,T1			;GET NEXT CHAR
	JUMPE	T2,CPOPJ		;QUIT IF 0
	CO	T2			;OUTPUT THE CHAR
	JRST	UPT3			;LOOP

;DECO AND OCTO UUO'S
UDECO:	SKIPA	T3,[^D10]		;RADIX 10
UOCTO:	MOVEI	T3,10			;RADIX 8
	MOVE	T1,@JBUUOR		;GET THE NUMBER
;FALL TO NUMO

;ROUTINE TO OUTPUT A NUMBER
;T1 PASSES THE NUMBER
;T3 PASSES THE RADIX
NUMO:	IDIV	T1,T3			;DIVIDE BY RADIX
	HRLM	T2,(P)			;SAVE REMAINDER
	SKIPE	T1			;RECURSE UNTIL 0
	PUSHJ	P,NUMO
	HLRZ	T2,(P)			;RECALL HIGH ORDER DIGIT
	COI	"0"(T2)			;OUTPUT DIGIT
	POPJ	P,

;SIXO UUO
USIXO:	MOVE	T2,@JBUUOR		;GET THE WORD
;FALL TO SXO

;OUTPUT A SIXBIT WORD
;T2 PASSES THE WORD
SXO:	LSHC	T1,6			;GET HIGH ORDER CHAR
	ANDI	T1,77
	COI	40(T1)			;OUTPUT IT
	JUMPN	T2,SXO			;LOOP UNTIL NO MORE
	POPJ	P,
	SUBTTL	SPY UUO'S

;XMOVE UUO
UMOVE:	MOVE	T1,JBUUO		;GET ADDR
	TRNE	F,F.EXE			;LOOKING AT A DUMP?
	JRST	UMOVE1			;YES
	TRNN	T1,400000		;HIGH SEG ADDRESS?
	TRNN	F,F.SPY			;CAN WE SPY YET?
	 JRST	UMOVE0			; YES, NO, USE PEEK
	SKIPA	T1,400000(T1)		;YES, GET WORD FROM SPYSEG
UMOVE0:	PEEK	T1,			;NO, DO IT THE HARD WAY
	JRST	STORAC			;STORE IT

;HERE IF LOOKING AT A DUMP
;T1 HAS ADDR TO LOOK AT
UMOVE1:	IDIVI	T1,PAGSIZ		;CONVERT TO PAGE AND WORD
	CAMN	T1,CPAG			;PAGE ALREADY IN CACHE?
	JRST	UMOVE2			;YES
	MOVEM	T1,CPAG			;NO, IT WILL BE SOON
	AOS	CBD			;NOT IN CACHE
	IMULI	T1,NBPP			;CONVERT PAGE TO BLOCK
	USETI	DSK,4+1(T1)		;INPUT THAT PAGE
	IN	DSK,CMD
	 JRST	UMOVE2
	HALT
UMOVE2:	AOS	CTTL			;TOTAL CACHE TRIALS
	MOVE	T1,BF(T2)		;PICK UP THE WORD
STORAC:	MOVEM	T1,@ACR			;STORE IT
	POPJ	P,
;XHRRZ UUO
UHRRZ:	XMOVE	T1,@JBUUO		;GET WORD FROM SPYSEG
	HRRZM	T1,@ACR			;STORE RH
	POPJ	P,

;XHLRZ UUO
UHLRZ:	XMOVE	T1,@JBUUO		;GET WORD FROM SPYSEG
	HLRZM	T1,@ACR			;STORE LH
	POPJ	P,

;XLDB UUO
ULDB:	MOVE	T1,@JBUUOR		;GET BP
	XMOVE	T2,@T1			;GET WORD FROM SPYSEG
	TLZ	T1,77			;POINT BP TO T2
	HRRI	T1,T2
	LDB	T3,T1			;GET THE BYTE
	MOVEM	T3,@ACR			;STORE IT
	POPJ	P,
	SUBTTL	DATA BLOCKS

;TABLE OF NAMES OF MONTHS
MONTH:	SIXBIT	/JAN/
	SIXBIT	/FEB/
	SIXBIT	/MAR/
	SIXBIT	/APR/
	SIXBIT	/MAY/
	SIXBIT	/JUN/
	SIXBIT	/JUL/
	SIXBIT	/AUG/
	SIXBIT	/SEP/
	SIXBIT	/OCT/
	SIXBIT	/NOV/
	SIXBIT	/DEC/

OBUF:	BLOCK	3			;BUFFER HEADER FOR TTY
STRSAV:	BLOCK	1			;SAVE ADDRESS OF 1ST STR
XSPC:	BLOCK	SPCSIZ			;TARGET FILESPEC
ISPC:	BLOCK	SPCSIZ			;INPUT FILESPEC
OSPC:	BLOCK	SPCSIZ			;OUTPUT FILESPEC
CPAG:	BLOCK	1			;PAGE NUMBER CURRENTLY IN CACHE
BF:	BLOCK	PAGSIZ			;THE CACHE BUFFER
CMD:	IOWD	PAGSIZ,BF		;I/O COMMAND LIST
	0
CBD:	BLOCK	1			;NUMBER OF TIMES NOT IN CACHE
CTTL:	BLOCK	1			;TOTAL NUMBER OF CACHE TRIALS
SCNP:	BLOCK	NSTR			;BP TO CLUSTER COUNT
SCKP:	BLOCK	NSTR			;BP TO CHECKSUM
SCLP:	BLOCK	NSTR			;BP TO CLUSTER ADDR
STRN:	BLOCK	NSTR			;TABLE OF STR NAMES
PDL:	BLOCK	PDLSIZ			;PDL
NMTB:	BLOCK	1			;ADDR OF NUMTAB
CRLF:	BYTE	(7)15,12,0		;CARRIAGE RETURN LINE FEED
TAB:	BYTE	(7)11,0
JBUUO:	BLOCK	1			;A COPY OF RH(.JBUUO)
JBUUOR:	BLOCK	1			;SAME AS JBUUO, EXCEPT RELOCATED.
					;I.E. IF JBUUO POINTS TO AN AC,
					;THAT AC MIGHT HAVE BEEN SAVED ON
					;THE STACK, IN WHICH CASE JBUUOR
					;POINTS TO THE ADDR ON THE STACK
					;WHERE THE AC WAS SAVED.
ACR:	BLOCK	1			;THE AC FIELD FROM .JBUUO
					;THIS COPY HAS BEEN "RELOCATED".

INAME:	EXP	0			;INPUT FILE TO DEFAULT OUTPUT NAME
ASCBUF:	BLOCK	100			;BUFFER TO COPY ASCIZ TEXT INTO
ASCLEN==.-ASCBUF			;LENGTH OF BUFFER
	EXP	0			;MAKE SURE WE END WITH 0

PCBBUF:	BLOCK	<2_<PCBLMX-1>>+1	;RESERVE STORAGE FOR PCB BUFFER

CTRTBL:	ASCIZ	/^@/
	ASCIZ	/^A/
	ASCIZ	/^B/
	ASCIZ	/^C/
	ASCIZ	/^D/
	ASCIZ	/^E/
	ASCIZ	/^F/
	ASCIZ	/^G/
	ASCIZ	/^H/
	BYTE	(7)11,0
	BYTE	(7)12,0
	ASCIZ	/^K/
	ASCIZ	/^L/
	BYTE	(7)15,0
	ASCIZ	/^N/
	ASCIZ	/^O/
	ASCIZ	/^P/
	ASCIZ	/^Q/
	ASCIZ	/^R/
	ASCIZ	/^S/
	ASCIZ	/^T/
	ASCIZ	/^U/
	ASCIZ	/^V/
	ASCIZ	/^W/
	ASCIZ	/^X/
	ASCIZ	/^Y/
	ASCIZ	/^Z/
	ASCIZ	/^[/
	ASCIZ	/^\/
	ASCIZ	/^]/
	ASCIZ	/^^/
	ASCIZ	/^_/
CTRLEN==.-CTRTBL

;TABLE OF NETWORK DEVICE NAMES

DEVTBL:	ASCIZ	/MCR[/
	ASCIZ	/TTY[/
	ASCIZ	/CDR[/
	ASCIZ	/LPT[/
	ASCIZ	/PTR[/
	ASCIZ	/PTP[/
	ASCIZ	/PLT[/
	ASCIZ	/MTA[/
	ASCIZ	/DTA[/
	ASCIZ	/TSK[/
	ASCIZ	/RDA[/
	ASCIZ	/CDP[/
DEVLEN==.-DEVTBL
DEVTRM:	ASCIZ	/] /

ACKTBL:	ASCIZ	/LAR(/
	ASCIZ	/LAP(/
	ASCIZ	/LMS(/
	ASCIZ	/LMA(/
	ASCIZ	/LAS(/
	ASCIZ	/LMR(/
	ASCIZ	/LMP(/
ACKLEN==.-ACKTBL
ACKTRM:	ASCIZ	/) /

DVBUF:	BLOCK	NDBLEN-NDBDEV

	END	NETDMP