Google
 

Trailing-Edge - PDP-10 Archives - cust_sup_cusp_bb-x130c-sb - 10,7/unscsp/dmpfil/dmpfil.mac
There are 6 other files named dmpfil.mac in the archive. Click here to see a list.
	TITLE	DMPFIL - A PROGRAM FOR DUMPING FILES - V 006A(7)
	SUBTTL	DON BLACK/PFC/DBK		5-OCT-70




;COPYRIGHT (C) 1970,1978,1979 BY
;DIGITAL EQUIPMENT CORPORATION, MAYNARD, MASS.
;
;
;THIS SOFTWARE IS FURNISHED UNDER A LICENSE AND MAY BE USED AND COPIED
;ONLY  IN  ACCORDANCE  WITH  THE  TERMS  OF  SUCH LICENSE AND WITH THE
;INCLUSION OF THE ABOVE COPYRIGHT NOTICE.  THIS SOFTWARE OR ANY  OTHER
;COPIES THEREOF MAY NOT BE PROVIDED OR OTHERWISE MADE AVAILABLE TO ANY
;OTHER PERSON.  NO TITLE TO AND OWNERSHIP OF THE  SOFTWARE  IS  HEREBY
;TRANSFERRED.
;
;THE INFORMATION IN THIS SOFTWARE IS SUBJECT TO CHANGE WITHOUT  NOTICE
;AND  SHOULD  NOT  BE  CONSTRUED  AS A COMMITMENT BY DIGITAL EQUIPMENT
;CORPORATION.
;
;DIGITAL ASSUMES NO RESPONSIBILITY FOR THE USE OR RELIABILITY  OF  ITS
;SOFTWARE ON EQUIPMENT WHICH IS NOT SUPPLIED BY DIGITAL.

VDMPFL==6	;MAJOR VERSION NUMBER
VEDIT==7	;EDIT NUMBER
VMINOR==1	;MINOR VERSION NUMBER
VWHO==0		;WHO LAST EDITED

; . . . EDIT HISTORY . . .
; VERSION 6:
;
; EDITS 2 THROUGH 6 ARE IN VERSION 6B(7).  VERSION 6A(7) CONTAINS
; ONLY EDIT # 7, A DATE75 BUG FIX.
;
; EDIT # 7 -	DATE75 FIX.  INSURES DEFAULT CREATION DATE IS USED
;		FOR OUTPUT FILE. AREA AFFECTED: DUMP

	LOC	137
	BYTE	(3)VWHO(9)VDMPFL(6)VMINOR(18)VEDIT
	RELOC

;ACCUMULATOR ASSIGNMENTS

F=0		;FLAGS
CH=1		;CHARACTER FOR I/O TRANSFERS
A=2		;CH+1
T=3		;TEMPORARY ACCUMULATORS
T1=4
T2=5
T3=6
T4=7
CNT=10		;COUNTER
P=11		;PUSHDOWN LIST POINTER

;FLAG BITS IN LEFT HALF OF F

CDET==1		;COLON DETECTED IN COMMAND SWITCH
PDET==2		;PERIOD DETECTED IN COMMAND SWITCH
DSW==4		;D SWITCH SPECIFIED - DEC TAPE DUMP
KSW==10		;K SWITCH SPECIFIED - CORE DUMP
HSW==20		;H SWITCH SPECIFIED - HIGH SEG CORE DUMP
SSW==40		;S SWITCH SPECIFIED - SUPER USETI DISK DUMP
DEVERR==40000	;DEVICE ERROR MESSAGE OUTPUT
SAMELN==100000	;SET IF NEW LINE IN CORE DUMP DIFFERENT FROM PREVIOUS
ASTOUT==200000	;SET IF ASTERISKS ALREADY PRINTED FOR CURRENT OUTPUT SUPPRESSED
DSKFRM==400000	;SET IF SAVE FILE IS IN OLD DISK FORM (3 SERIES MON)
;ASCII CODES

LEFARR==137	;ASCII FOR  LEFT ARROW
CR==15		;           CARRIAGE RETURN
LF==12		;           LINE FEED
SP==40		;           SPACE
SLASH==57	;           SLASH
PERIOD==56	;           PERIOD
COLON==72	;           COLON
FORM==14	;	    FORM FEED
RGTBRK==135	;	    RIGHT BRACKET
ALT==33		;	    ALT-MODE
ALT175==175	;	    ALT-MODE
ALT176==176	;	    ALT-MODE
VTAB==13	;	    VERT. TAB
EQUAL=="="	;	    EQUAL SIGN

;CONSTANTS

EOFBIT==20000	;EOF BIT IN STATUS
DTA==100	;DECTAPE BIT IN DEVICE CHARACTERISTICS
DTAL==200	;LENGTH OF A DECTAPE BLOCK
DIBLOK==^D100	;BLOCK NUMBER OF DECTAPE DIRECTORY
PAGELN==^D60	;NUMBER OF LINES PER PRINTED PAGE
ERRBIT==740000	;ERROR BITS IN STATUS WORD
DUMP:	RESET
	EXTERN	.JBREN
	MOVE	T,[JRST P5B]
	MOVEM	T,.JBREN	;SET UP FOR REENTER COMMAND
	MOVE	P,PDLPT		;SET UP PUSH-DOWN LIST POINTER
	OPEN	0,TTYQ		;OPEN TTY
	HALT	.		;SHOULD NEVER HAPPEN
	PUSHJ	P,CRLF		;OUTPUT CR,LF TO TTY
	MOVEI	CH,"*"
	PUSHJ	P,TTYOUT	;OUTPUT *
	OUTPUT	0,		;MAKE SURE IT GETS DONE
	HRLI	F,0		;CLEAR ALL FLAGS TO START
	MOVEI	T,10
	MOVEM	T,ST1		;SET INPUT MODE TO 10 TO START
	PUSHJ	P,SCAN		;GET INPUT AND OUTPUT UNITS FROM TTY
	OPEN	2,ST2		;OPEN OUTPUT UNIT
	JRST	P6		;CANT OPEN IT
; [EDIT #7] ADD TWO INSTRUCTIONS - INSURE DEFAULT DATE IS USED
	HLLZS	E2		;CLEAR HIGH-ORDER CREATION DATE
	SETZM	E2+1		;CLEAR LOW-ORDER BITS OF CREATION DATE
	ENTER	2,F2		;SET UP PROPER FILE
	JRST	P6A
	OPEN	1,ST1		;OPEN INPUT UNIT
	JRST	P5		;CANT OPEN IT
	TLNE	F,DSW+SSW	;TEST IF DEC TAPE DUMP OR SUPER USETI DUMP
	JRST	DUMP2		;DONT BOTHER WITH LOOKUP IF SO
	LOOKUP	1,F1		;LOCATE PROPER FILE
	JRST	P5A
DUMP2:	DATE	T,		;DATE TO T
	IDIVI	T,^D31		;SETS UP DATE AND TIME IN HEADER MESSAGE
	ADDI	T1,1
	IDIVI	T1,^D10
	ADDI	T1,60
	ROT	T1,7
	ADDI	T2,60
	ADD	T1,T2
	DPB	T1,[POINT 14,DATE,34]	;DAY
	IDIVI	T,^D12
	ADDI	T1,1
	IDIVI	T1,^D10
	ADDI	T1,60
	ROT	T1,7
	ADDI	T2,60
	ADD	T1,T2
	DPB	T1,[POINT 14,DATE,13]	;MONTH
	ADDI	T,^D64
	IDIVI	T,^D10
	ADDI	T,60
	ROT	T,7
	ADDI	T1,60
	ADD	T,T1
	DPB	T,[POINT 14,DATE+1,20]	;YEAR
	TIMER	T,		;TIME OF DAY TO T
	IDIVI	T,^D216000
	IDIVI	T1,^D3600
	IDIVI	T1,^D10
	ADDI	T1,60
	ROT	T1,7
	ADDI	T2,60
	ADD	T1,T2
	DPB	T1,[POINT 14,TIME,34]	;MINUTES
	IDIVI	T,^D10
	ADDI	T,60
	ROT	T,7
	ADDI	T1,60
	ADD	T,T1
	DPB	T,[POINT 14,TIME,13]	;HOURS
	MOVEI	CNT,PAGELN-3		;SET LINE COUNT
	MOVEI	T,^D76
	MOVE	T1,[POINT 7,CW8]
	ILDB	CH,T1
	PUSHJ	P,OUTPUT	;OUTPUT HEADER MESSAGE
	SOJG	T,.-2
	SETZM	MAX
	TLNE	F,DSW
	JRST	DECDMP		;JUMP IF DECTAPE DUMP
	TLNE	F,SSW
	JRST	SUPDMP		;SUPER USETI DISK DUMP
	TLNE	F,KSW+HSW
	JRST	CORDMP		;JUMP IF CORE DUMP
	MOVE	T,D1		;GET INPUT DEVICE
	DEVCHR	T,		;GET ITS CHARACTERISTICS
	MOVE	T1,BLKNUM	;GET STARTING BLOCK NUMBER
	TLNE	T,(2B2)		;SEE IF DISK
	USETI	1,(T1)		;YES--POSITION TO START (/NF)
	PUSHJ	P,PR0		;OUTPUT ONE BLOCK TO OUTPUT UNIT
	JRST	.-1		;GOES TO ENDF AT END OF FILE
PR0:	MOVE	CH,MAX		;TOTAL NUMBER OF BYTES IN THIS BLOCK
	MOVEM	CH,MAX		;SAVE MAXIMUM NUMBER OF BYTES IN BUFFER
	ADDI	CH,7		;EJECT PAGE FIRST
	LSH	CH,-3		;8 WORDS PER LINE
	ADDI	CH,2		;PLUS 2 BLANK LINES
	SUB	CH,CNT		;SEE IF WE MAKE IT
	JUMPL	CH,PR1		;JUMP IF YES
	JUMPE	CH,PR5		;JUMP IF JUST FITS (NO PAGE EJECT)
	MOVEI	CH,FORM		;FORM FEED
	PUSHJ	P,OUTPUT	;OUTPUT IT
PR5:	MOVEI	CNT,PAGELN	;EJECT PAGE AND RESET LINE COUNT
PR1:	MOVEI	T1,8		;8 WORDS PER LINE
PR2:	PUSHJ	P,SPACES	;3 SPACES
	MOVEI	T,^D12		;12 CHARACTERS PER WORD
	PUSHJ	P,INPUT		;GET NEXT INPUT WORD IN CH
	MOVE	A,CH		;MOVE IT TO A
PR3:	MOVEI	CH,0
	ROTC	CH,3		;ROTATE TOP 3 BITS OF A TO CH
	ADDI	CH,60		;CONVERT TO ASCII
	PUSHJ	P,OUTPUT	;OUTPUT THIS CHAR
	SOJG	T,PR3		;LOOP FOR THE WORD
	MOVE	T,IBUF+2
	CAIN	T,1		;SKIP UNLESS THAT WAS LAST WORD OF BUFFER
	JRST	PR4
	SOJG	T1,PR2		;LOOP FOR THE LINE
	PUSHJ	P,OCRLF		;WE MUST INSERT CR,LF
	SOJA	CNT,PR1		;ALWAYS KEEP TRACK OF THE LINE COUNT
PR4:	AOS	T,BLKNUM	;INCREMENT THE BLOCK NUMBER
	CAMLE	T,TERMBK	;COMPARE WITH END
	JRST	ENDF		;YES--EXIT
	PUSHJ	P,OCRLF		;FINISH LINE IF SO, THEN OUTPUT BLANK LINE
	PUSHJ	P,OCRLF
	SUBI	CNT,3		;ACCOUNT FOR 3 LINES


OCRLF:	MOVEI	CH,CR
	PUSHJ	P,OUTPUT	;OUTPUT CR
	MOVEI	CH,LF
	JRST	OUTPUT		;OUTPUT LF AND RETURN WITH POPJ


OOCT:	IDIVI	T,10		;PRINT OCTAL NUMBER IN T
	HRLM	T1,(P)
	SKIPE	T
	PUSHJ	P,OOCT
	HLRZ	CH,(P)
	ADDI	CH,"0"
	JRST	OUTPUT		;IT POPJ'S


P5:	MOVEI	T,ER1		;COMPLAIN ABOUT INPUT DEVICE
	JRST	ERROR
P5A:	MOVEI	T,ER1A		;COMPLAIN ABOUT INPUT FILE
	JRST	ERROR
P6:	MOVEI	T,ER2		;COMPLAIN ABOUT OUTPUT DEVICE
	JRST	ERROR
P6A:	MOVEI	T,ER2A		;COMPLAIN ABOUT OUTPUT FILE

ERROR:	PUSHJ	P,TMES		;ISSUE ERROR MESSAGE
	JRST	DUMP		;GO BACK AND START ALL OVER
ENDF:	TLNE	F,KSW
	JRST	ENDF1		;JUMP IF DOING CORE DUMP
ENDF2:	MOVEI	CH,14
	PUSHJ	P,OUTPUT	;OUTPUT FORM FEED FOR PAGE EJECT
P5B:	RELEASE	1,
	RELEASE 2,
	JRST	DUMP
ENDF1:	SUBI	T3,8		;MUST OUTPUT PARTIAL LINE IN LINBUF
	JUMPE	T3,ENDF2	;JUMP IF EMPTY LINE
	IMULI	T3,^D14		;ELSE MULTIPLY BY 14 CHARS PER WORD
	SUBI	T3,8	;TAKE INTO ACCOUNT ADDRESS (RESULT IS NEGATIVE WD CNT)
	MOVE	T,[POINT 7,LINBUF]
	ILDB	CH,T
	PUSHJ	P,OUTPUT	;OUTPUT THE CHARS
	AOJL	T3,.-2
	PUSHJ	P,OCRLF
	PUSHJ	P,OCRLF
	MOVSI	A,(JRST)
	HRR	A,T1
	CAME	A,T1
	JRST	ENDF2
	HRLZ	A,T1		;T1 CONTAINS JRST SA
	MOVEI	T,CW1
	PUSHJ	P,MES		;OUTPUT MESSAGE NOTING SA
	MOVEI	T,6
EN1:	MOVEI	CH,0		;OUTPUT LINE OF (T) CHARS FROM A
	ROTC	CH,3
	ADDI	CH,60
	PUSHJ	P,OUTPUT
	SOJG	T,EN1
	PUSHJ	P,OCRLF		;FOLLOWED BY CARRIAGE RETURN,LINE FEED
	JRST	ENDF2
SUPDMP:	SETSTS	1,17		;SET DUMP MODE FOR INPUT
	SKIPN	TERMBK
	HLLOS	TERMBK
	MOVE	T3,BLKNUM
	USETI	1,T3
	STATZ	1,ERRBIT	;SEE IF WE ARE SUCCESSFUL
	JRST	SUPERR		;NO--TELL USER
SUPD1:	PUSHJ	P,BLKOUT
	CAMGE	T3,TERMBK
	STATZ	1,EOFBIT
	JRST	ENDF
	AOJA	T3,SUPD1
SUPERR:	MOVEI	T,SUPERM	;COMPLAIN ABOUT USETI FAILURE
	JRST	ERROR

DECDMP:	USETI	1,DIBLOK	;NEXT BLOCK READ WILL BE DIRECTORY
	SUBI	CNT,3		;KEEP UP WITH LINES PRINTED ON THIS PAGE
	MOVEI	T,CW5
	PUSHJ	P,MES		;OUTPUT DIRECTORY HEADER
	MOVEI	T,^D17
	PUSHJ	P,SPACES
	SOJG	T,.-1
	MOVEI	T,CW5A
	PUSHJ	P,MES
	MOVEI	T,6
	PUSHJ	P,SPACES
	SOJG	T,.-1
	MOVEI	T,CW5B
	PUSHJ	P,MES
	MOVSI	CNT,-27
LINE1:	PUSHJ	P,SPACE
	PUSHJ	P,SPACE
	MOVEI	CH,1(CNT)
	PUSHJ	P,TWOCHR	;OUTPUT LINE OF BLOCK NUMBERS
	AOBJN	CNT,LINE1
	MOVEI	CH,RGTBRK
	PUSHJ	P,OUTPUT
	PUSHJ	P,OCRLF
	PUSHJ	P,OCRLF
	INPUT	1,COMLST	;READ THE DIRECTORY
	PUSHJ	P,CHKIN		;CHECK FOR INPUT ERRORS
	MOVE	T3,[POINT 5,DATAB]
	MOVEI	CNT,1		;CNT IS CURRENT FILE NUMBER (1-26)
LINE:	PUSHJ	P,SPACE		;OUTPUT ONE SPACE
	MOVE	CH,CNT
	PUSHJ	P,TWOCHR	;OUTPUT FILE NUMBER
	PUSHJ	P,SPACE2	;AND 2 SPACES	
	MOVE	A,DATAB+^D82(CNT)	;THIS FILE NAME
	MOVEI	T2,6
	PUSHJ	P,SIXOUT	;OUTPUT FILE NAME
	PUSHJ	P,SPACE		;OUTPUT A SPACE
	MOVE	A,DATAB+^D82+^D22(CNT)		;THIS EXT
	MOVEI	T2,3
	PUSHJ	P,SIXOUT
	PUSHJ	P,SPACE		;OUTPUT A SPACE
	MOVEI	T2,30
	PUSHJ	P,BLKBYT	;OUTPUT FILE INDEX FOR NEXT 30 BLOCKS OT THE TAPE
	CAIG	CNT,25
	AOJA	CNT,LINE	;LOOP FOR 26 LINES (26 FILES)
	MOVEI	T2,30
	AOJ	CNT,
	PUSHJ	P,LINE2	;NOW FINISH THE INDECES FOR BLOCKS NOT YET PRINTED
	MOVEI	T2,30
	AOJ	CNT,
	PUSHJ	P,LINE2		;SECOND LINE
	MOVEI	T2,2
	AOJ	CNT,
	PUSHJ	P,LINE2		;PLUS ONE LEFT OVER
	PUSHJ	P,OCRLF
	PUSHJ	P,OCRLF
	PUSHJ	P,P7A+1		;OUTPUT DIRECTORY
	SKIPE	T3,TERMBK
	CAILE	T3,^D577
	MOVEI	T3,^D577
	MOVEM	T3,TERMBK
	SKIPN	T3,BLKNUM	;MOVE FIRST BLOCK NUMBER TO T3
	SETSTS	1,110		;FOR BLOCK 0
	USETI	1,(T3)		;GET NEXT BLOCK
DECD1:	PUSHJ	P,BLKOUT	;OUTPUT THIS BLOCK
	CAMGE	T3,TERMBK	;TEST IF LAST BLOCK
	AOJA	T3,DECD1	;NO, GO BACK FOR MORE
	JRST	ENDF
BLKOUT:	CAIL	CNT,^D20	;SKIP UNLESS FITS ON THIS PAGE
	JRST	DECD2		;EVERYTHING OK
	JUMPE	CNT,DECD1A	;IF CNT IS 0, A PAGE EJECT IS COMING ANYWAY
	MOVEI	CH,FORM		;FORM FEED
	PUSHJ	P,OUTPUT	;PAGE EJECT
DECD1A:	MOVEI	CNT,PAGELN	;RESET LINE COUNT
DECD2:	MOVE	T2,BLANKS
	SUBI	CNT,3
	MOVEI	T,CW6
	PUSHJ	P,MES		;OUTPUT BLOCK HEADER
	MOVE	T,T3
	PUSHJ	P,OOCT		;OUTPUT BLOCK NUMBER
	PUSHJ	P,OCRLF
	TLNN	F,DSW		;SEE IF DECTAPE DUMP
	JRST	P7A		;N0--ALL BLOCKS THE SAME
	JUMPN	T3,P7A		;JUMP IF NOT BLOCK 0 THAT WE JUST DID
	INPUT	1,		;INPUT THE BLOCK
	PUSHJ	P,CHKIN		;CHECK FOR INPUT ERRORS
	MOVEI	T,DTAL		;THIS BLOCK IS 1 WORD SHORT
	MOVEM	T,IBUF+2	;SET CORRECT BLOCK SIZE
	PUSHJ	P,PR1		;OUTPUT IT
	SETSTS	1,116		;IF SO SET NON-STANDARD, DUMP MODE
	POPJ	P,
P7A:	INPUT	1,COMLST
	PUSHJ	P,CHKIN		;CHECK FOR INPUT ERRORS
	MOVE	T,[POINT 36,DATAB]
	MOVEM	T,IBUF+1
	MOVEI	T,DTAL+1
	MOVEM	T,IBUF+2	;SET UP BUFFER HEADER TO LOOK LIKE ORDINARY BLOCK
	JRST	PR1		;ROUTINE OUTPUTS THE BLOCK AND EXITS WITH POPJ

LINE2:	MOVEI	T,5
	PUSHJ	P,SPACES
	SOJG	T,.-1
	PUSHJ	P,SPACE		;SPACES IN FIRST PART OF LINE,
	JRST	BLKBYT		;THEN INTO BLKBYT FOR FILE INDECES

TWOCHR:	IDIVI	CH,10
	SKIPE	CH		;SKIP IF UPPER CHAR IS 0
	ADDI	CH,20		;IF SO LEAVE BLANK
	ADDI	CH,40		;CONVERT TO ASCII
	PUSHJ	P,OUTPUT
	MOVEI	CH,60(A)	;SECOND CHAR
	JRST	OUTPUT		;OUTPUT IT AND RETURN
BLKBYT:	MOVEI	T,CW2
	PUSHJ	P,MES		;OUTPUT LEFT BRACKET
	MOVEI	CH,-1(CNT)	;OUTPUT FOUR CHARACTER OCTAL VALUE
	IMULI	CH,30		;CH=TOTAL NUMBER OF BLOCKS PRINTED SO FAR
	JUMPE	CH,BLK5		;IF 0, SPECIAL CASE
	MOVEI	T,4
	IDIVI	CH,10
	PUSH	P,A		;PUSH DIGITS ONTO STACK
	SOJG	T,.-2
	MOVEI	T,4
BLK3:	POP	P,CH		;POP THEM BACK
	JUMPN	CH,BLK2
	PUSHJ	P,SPACE		;SPACES FOR LEADING ZEROS
	SOJG	T,BLK3		;SINCE NON-ZERO WILL ALWAYS EXIT
BLK4:	POP	P,CH
BLK2:	ADDI	CH,60		;MAKE ASCII NUMBER
	PUSHJ	P,OUTPUT
	SOJG	T,BLK4
	MOVEI	CH,RGTBRK	;RIGHT BRACKET
	PUSHJ	P,OUTPUT
BLK1:	PUSHJ	P,SPACE		;NOW OUTPUT FILE INDECES FOR NEXT (T2) BLOCKS
	PUSHJ	P,SPACE
	ILDB	CH,T3		;T3 CONTAINS BYTE POINTER FOR CURRENT INDEX
BLK6:	PUSHJ	P,TWOCHR	;OUTPUT IT
	SOJG	T2,BLK1
	JRST	OCRLF
BLK5:	PUSHJ	P,SPACES	;OUTPUT 3 LEADING SPACES
	MOVEI	T,CW3		;AND ONE ZERO
	PUSHJ	P,MES
	MOVEI	CH,37
	JRST	BLK6

SIXOUT:	MOVEI	CH,0		;OUTPUT (T2) SIXBIT CHARACTERS FROM TOP OF A
	ROTC	CH,6
	ADDI	CH,40
	PUSHJ	P,OUTPUT
	SOJG	T2,SIXOUT
	POPJ	P,
CORDMP:	SKIPN	TERMBK
	HLLOS	TERMBK
	SETZM	LSTOUT
	MOVE	T,[XWD LSTOUT,LSTOUT+1]
	BLT	T,LSTOUT+7	;ZERO OUT REPEATED LINE TEST BUFFER
	PUSHJ	P,INPUT
	MOVE	T1,CH		;T1=FIRST CONTROL WORD
	TLZ	F,SAMELN+ASTOUT+DSKFRM	;CLEAR SAME LINE AND ASTERISKS PRINTED 
					;AND DSK FORM SAVE FILE FLAGS
	TLNE	F,HSW		;IF FIRST CONTROL WORD IS POSITIVE,
	JRST	HGHDMP		;OR HIGH SEG DUMP, WE HAVE SPECIAL DISK FORM
	JUMPGE	CH,COR1
	HRRZ	T,CH		;START WITH T=CURRENT ADDRESS-1
	SKIPE	T2,BLKNUM
	PUSHJ	P,CSETUP
W1:	PUSHJ	P,WST		;SET UP NEXT ADDRESS IN OUTPUT BUFFER
W2:	PUSHJ	P,NXTWD		;GET NEXT WORD OF CORE
	CAMLE	T,TERMBK
	JRST	ENDF1
	CAME	CH,LSTOUT-1(T3)
	TLO	F,SAMELN  ;SET FLAG IF THIS LINE NOT SAME AS LAST LINE OUTPUT
	MOVEM	CH,LSTOUT-1(T3)	;IN ANY CASE SAVE THIS LINE
	MOVEI	CNT,^D12
	PUSHJ	P,OCTOUT	;MOVE THIS WORD TO LINE BUFFER
	SOJG	T3,W2
	TLZN	F,SAMELN
	JRST	AST		;IF SAME AS LAST LINE PRINTED, DONT REPEAT
	TLZ	F,ASTOUT	;NEW LINE, PRINT IT, CLEAR ASTERISKS PRINTED FLAG
W3:	MOVE	T3,[POINT 7,LINBUF]
	MOVEI	CNT,^D120
	ILDB	CH,T3
	PUSHJ	P,OUTPUT	;OUTPUT LINE BUFFER
	SOJG	CNT,.-2		;LOOP FOR 120 COLUMNS
	PUSHJ	P,OCRLF		;FOLLOWED BY CR,LF
	JRST	W1		;NEXT LINE
AST:	TLOE	F,ASTOUT	;IF ALREADY HAVE PRINTED ASTERISKS,
	JRST	W1		;FORGET THE WHOLE THING
	MOVE	CH,[ASCII /    */]	;ELSE MOVE ASTERISKS TO LINE BUFFER
	MOVEI	CNT,^D24
	MOVEM	CH,LINBUF-1(CNT)
	SOJG	CNT,.-1
	JRST	W3		;THEN BOUNCE OFF TO PRINT THEM
COR1:	MOVEI	T,73		;FIRST LOCATION OF DUMP IS 74
	TLZ	F,KSW		;DENY OUR HERITAGE TO SUPRESS SA= MESS AT END
COR2:	TLO	F,DSKFRM	;SET DISK FORM BIT
	SKIPE	T2,BLKNUM
	PUSHJ	P,CSETUP
	PUSHJ	P,WST		;MOVE FIRST ADDRESS TO OUTPUT BUFFER
	MOVE	CH,T1		;RESTORE FIRST WORD
	AOJA	T,W2+1		;OFFSET FOR MISSING CALL TO NEXTWD, TO MAINSTREAM
CSETUP:	CAIG	T2,1(T)
	POPJ	P,
	PUSHJ	P,NXTWD
	JRST	CSETUP

WST:	MOVE	T2,[POINT 7,LINBUF]
	HRLZI	CH,1(T)		;CH=CURRENT ADDRESS
	MOVEI	CNT,6
	PUSHJ	P,OCTOUT	;MOVE IT TO LINE BUFFER AS ASCII OCTAL DIGITS
	MOVEI	T3,8
	POPJ	P,


HGHDMP:	MOVEI	T,377777	;FIRST WORD OF HIGH SEG DUMP IS 400000
	JRST	COR2


NXTWD:	AOJ	T,		;T=ADDRESS OF WORD RETURNED
	TLNE	F,DSKFRM	;SKIP UNLESS SPECIAL DISK FORM, IN WHICH
	JRST	INPUT		;CASE WE ONLY NEED RETURN NEXT INPUT WORD
N2:	MOVEI	CH,0
	CAIG	T,(T1)
	JRST	N3		;RETURN 0 IF BETWEEN SEGMENTS
	JUMPL	T1,N1		;KEEP GOING IF STILL IN THIS SEGMENT
	PUSHJ	P,INPUT		;GET NEXT CONTROL WORD IF END OF SEGMENT
	MOVE	T1,CH		;SAVE IT IN T1 AND PLUNGE ON
	XOR	CH,[JRST 0]	;IF CONTROL WORD IS JRST, END OF FILE
	TLNE	CH,777777
	JRST	N2		;NO, KEEP GOING
	JRST	ENDF1		;IT IS JRST SA
N1:	AOBJN	T1,INPUT	;BUMP CONTROL WORD, GET NEXT WORD,
	JRST	INPUT		;AND RETURN VIA POPJ IN INPUT



OCTOUT:	PUSHJ	P,XSPACE	;MOVE 2 SPACES TO LINBUF
	MOVE	A,CH		;SAVE WORD IN A WHICH MUST BE CH+1
O1:	MOVEI	CH,0
	ROTC	CH,3
	ADDI	CH,60		;NEXT OCTAL DIGIT IN CH
	IDPB	CH,T2
	SOJG	CNT,O1		;LOOP FOR (CNT) CHARS
	POPJ	P,



XSPACE:	PUSHJ	P,.+1		;PUSHJ TO PUT IN 1 SPACE, THEN POPJ
	MOVEI	A,SP		;TO DO IT AGAIN, THEN RETURN VIA THE POPJ
	IDPB	A,T2
N3:	POPJ	P,
SCAN:	SETZM	F3
	MOVE	T2,[XWD F3,E3]
S0:	BLT	T2,TERMBK	;CLEAR ANY PREVIOUS GARBAGE
	MOVEI	T2,1		;PRESET START TO 1
	MOVEM	T2,BLKNUM	;  IN CASE NO /F
	HRLOI	T2,377777	;PRESET END TO LARGEST NUMBER
	MOVEM	T2,TERMBK	;  IN CASE NO /T
	SETZM	D3		;CLEAR DEVICE NAME
	TLZ	F,CDET+PDET
	MOVE	A,[POINT 7,AS1]
S1:	MOVEI	CNT,6
S1A:	MOVE	T2,[POINT 6,T3]
	SETZ	T3,
S2:	PUSHJ	P,INCHR		;GET NEXT CHARACTER FROM USER
	JUMPE	CH,S2		;IGNORE NULL CHARS
	CAIE	CH,EQUAL	;DO NOT STORE IF EQUAL SIGN
	CAIN	CH,LEFARR	;DO NOT STORE IF LEFT ARROW
	JRST	.+3
	CAIL	CH,40		;DO NOT STORE IF CONTROL CHARACTER
	PUSHJ	P,CHRSTR	;OTHERWISE STORE IN HEADER MESSAGE
	MOVE	T4,[XWD -DISPLN,DISPTB]
SLIST:	HLRZ	T,(T4)		;SEARCH TABLE FOR CHAR IN CH AND DISPATCH
	CAME	T,CH
	AOBJN	T4,SLIST	;ENTER T4= XWD -LENGTH OF TABLE, FWA OF TABLE
	MOVE	T4,(T4)
	JRST	(T4)		;DO IT

DISPTB:	XWD	COLON,COL
	XWD	PERIOD,PER
	XWD	SLASH,SLSH
	XWD	LEFARR,FIN2
	XWD	EQUAL,FIN2
	XWD	CR,FIN1
	XWD	ALT,FIN1
	XWD	ALT175,FIN1
	XWD	ALT176,FIN1
	XWD	FORM,FIN1
	XWD	LF,FIN1
	XWD	VTAB,FIN1
DISPLN=.-DISPTB
	JRST	CHAR		;ANYTHING ELSE


SWCHTB:	XWD	"D",DSWCH
	XWD	"F",SWCHX	;/NF SETS START OF FILE DUMP (DISK ONLY)
	XWD	"K",KSWCH
	XWD	"H",HSWCH
	XWD	"S",SSWCH
	XWD	"T",TSWCH
SWCHLN=.-SWCHTB
	JRST	SYNTAX

CHAR:	CAIL	CH,"0"		;CHECK FOR ALPHANUMERIC
	CAILE	CH,"Z"
	JRST	SYNTAX		;NO
	CAIGE	CH,"A"
	CAIG	CH,"9"
	JRST	.+2
	JRST	SYNTAX		;NO
	SOJL	CNT,SYNTAX
	SUBI	CH,40
	IDPB	CH,T2
	JRST	S2
COL:	TLNN	F,PDET
	TLOE	F,CDET
	JRST	SYNTAX
	MOVEM	T3,D3
	JRST	S1
PER:	TLOE	F,PDET
	JRST	SYNTAX
	MOVEI	CNT,3
	JUMPE	T3,S1A		;IF FILE NAME = 0, DO NOT CHANGE IT
	MOVEM	T3,F3
	JRST	S1A
SLSH:	SETZ	T1,
SLSH2:	PUSHJ	P,INCHR		;GET SWITCH
	PUSHJ	P,CHRSTR
	CAIGE	CH,"0"
	JRST	SLSH3
	CAILE	CH,"7"
	JRST	SLSH3
	ROT	T1,3
	ADDI	T1,-60(CH)
	JRST	SLSH2
SLSH3:	MOVE	T4,[XWD -SWCHLN,SWCHTB]
	JRST	SLIST
SSWCH:	TLO	F,SSW
	JRST	SWCHX
TSWCH:	MOVEM	T1,TERMBK
	JRST	S2
DSWCH:	TLO	F,DSW		;NOTE PRESENCE OF D SWITCH
	MOVEI	CH,116		;SELECT NON-STANDARD MODE FOR  LINK WORDS
	MOVEM	CH,ST1		;SELECT NON-BUFFERED MODE
	JRST	SWCHX		;NUMERIC ARG IS 1ST BLOCK OF DUMP
KSWCH:	TLOA	F,KSW		;K SWITCH REQUESTS CORE DUMP
HSWCH:	TLO	F,HSW		;H SWITCH REQUESTS HIGH SEG CORE DUMP
SWCHX:	MOVEM	T1,BLKNUM	;SAVE NUMERIC ARG
	JRST	S2
FIN2:	TLNN	F,PDET
	JRST	NULEXT
	MOVEM	T3,E3
FIN2A:	SKIPN	T3,D3		;D3 IS OUTPUT DEVICE
	MOVSI	T3,(SIXBIT /LPT/)
	MOVEM	T3,D2		;STORE IN OUTPUT OPEN ARRAY
	MOVE	T3,[XWD F3,F2]
	BLT	T3,E2		;MOVE FILE AND EXT INTO OUTPUT OPEN ARRAY
	MOVE	T3,[XWD AS1,ASNAMF]
	BLT	T3,ASNAMF+2
	SETZM	E3
	MOVE	T2,[XWD E3,AS1]		;WILL ZERO OUT EXT AND AS1
	JRST	S0
NULEXT:	MOVSI	T1,(SIXBIT /LST/)	;DEFAULT EXT IS LST
	MOVEM	T1,E3
	JUMPE	T3,FIN2A	;DON'T CLOBBER FILE NAME IF NULL
	MOVEM	T3,F3
	JRST	FIN2A
FIN1:	TLNN	F,PDET
	JRST	NULEX1
	MOVEM	T3,E3
FIN1A:	SKIPN	T3,D3		;D3 IS INPUT DEVICE
	MOVSI	T3,(SIXBIT /DSK/)
	MOVEM	T3,D1		;MOVE INPUT DEVICE TO OPEN ARRAY
	MOVE	T3,[XWD F3,F1]
	BLT	T3,E1		;MOVE FILE AND EXT INTO INPUT OPEN ARRAY
	MOVE	T3,[XWD AS1,ASNAME]
	BLT	T3,ASNAME+2
	CAIN	CH,CR		;IF CARRIAGE RETURN,
	PUSHJ	P,INCHR		;GET LF OUT OF BUFFER
	MOVSI	T3,(SIXBIT /LPT/)	;CHECK OUTPUT DEFAULTS
	SKIPN	D2
	MOVEM	T3,D2
	MOVSI	T3,(SIXBIT /LST/)
	SKIPN	E2
	MOVEM	T3,E2
	MOVE	T3,F1
	SKIPN	F2
	MOVEM	T3,F2
	POPJ	P,
NULEX1:	SETZM	E3		;CLEAR EXTENSION
	JUMPE	T3,FIN1A
	MOVEM	T3,F3
	JRST	FIN1A

SYNTAX:	POP	P,T		;POP AWAY RETURN WE DONT WANT
	MOVEI	T,ER3		;COMPLAIN ABOUT COMMAND SYNTAX ERROR
	JRST	ERROR

CHRSTR:	IBP	A
	HRRZ	T4,A
	CAIG	T4,AS1+2
	DPB	CH,A		;STORE THE SWITCH
	POPJ	P,
INPUT:	SOSLE	IBUF+2		;CH=NEXT BYTE FROM INPUT UNIT
	JRST	INPUT1
	INPUT	1,
	PUSHJ	P,CHKIN		;CHECK FOR INPUT ERRORS
	GETSTS	1,CH
	TRNE	CH,EOFBIT
	JRST	ENDF
	MOVE	CH,IBUF+2
	MOVEM	CH,MAX
INPUT1:	ILDB	CH,IBUF+1
	POPJ	P,


CHKIN:	STATO	1,ERRBIT	;CHECK FOR ERRORS ON INPUT
	POPJ	P,		;RETURN IF NO ERRORS
	MOVEI	T,ERRINM
	TLON	F,DEVERR	;OUTPUT TO TTY ONLY ONCE
	PUSHJ	P,TMES
	SUBI	CNT,2		;COUNT LINES ON PAGE
	MOVEI	T,ERRINP
	PUSHJ	P,MES		;OUTPUT TO LISTING
	GETSTS	1,T		;RE-FETCH STATUS
	MOVE	T1,T
	ANDI	T1,-1-ERRBIT	;CLEAR ERROR CODE
	SETSTS	1,(T1)		;CLEAR STATUS IN MONITOR
	PUSHJ	P,OOCT		;PRINT STATUS IN OCTAL
	JRST	OCRLF		;END WITH A CRLF AND A POPJ
SPACES:	PUSHJ	P,SPACE		;3 SPACES TO OUTPUT UNIT
SPACE2:	PUSHJ	P,SPACE
SPACE:	MOVEI	CH,SP		;1 SPACE TO OUTPUT UNIT
OUTPUT:	SOSG	OBUF+2		;ASCII CHAR IN CH TO OUTPUT UNIT
	OUTPUT	2,
	IDPB	CH,OBUF+1
	POPJ	P,


CRLF:	MOVEI	CH,CR		;CARRIAGE RETURN, LINE FEED TO TTY
	PUSHJ	P,TTYOUT
	MOVEI	CH,LF
TTYOUT:	SOSG	TOBUF+2		;ASCII CHAR IN CH TO TTY
	OUTPUT	0,
	IDPB	CH,TOBUF+1
	POPJ	P,

INCHR:	SOSG	TIBUF+2		;CH=NEXT CHAR READ FROM TTY
	INPUT	0,
	ILDB	CH,TIBUF+1
	CAIL	CH,"A"+40	;CHECK FOR LOWER CASE
	CAILE	CH,"Z"+40
	POPJ	P,		;NO
	SUBI	CH,40		;YES--CONVERT TO UPPER
	POPJ	P,


TMES:	PUSHJ	P,CRLF		;TYPE CARRIAGE RETURN, LINE FEED
	TLOA	T,440700	;TURN MESSAGE INTO BYTE POINTER
TMES1:	PUSHJ	P,TTYOUT
	ILDB	CH,T
	JUMPN	CH,TMES1
	PUSHJ	P,CRLF		;OUTPUT ANOTHER CR/LF
	OUTPUT	0,		;MAKE SURE IT ALL GETS THERE
CPOPJ:	POPJ	P,


MES:	TLOA	T,440700	;MAKE BYTE POINTER OF T
MES1:	PUSHJ	P,OUTPUT
	ILDB	CH,T
	JUMPN	CH,MES1
	POPJ	P,
TTYQ:	1		;SELECT AL MODE FOR TTY
	SIXBIT	/TTY/
	XWD	TOBUF,TIBUF
ER1:	ASCIZ	/?CANT OPEN INPUT/
ER1A:	ASCIZ	/?CANT LOOKUP INPUT/
ER2:	ASCIZ	/?CANT OPEN OUTPUT/
ER2A:	ASCIZ	/?CANT ENTER OUTPUT/
ER3:	ASCIZ	/?SYNTAX ERROR/
SUPERM:	ASCIZ	/?SUPER-USETI FAILURE/
ERRINM:	ASCIZ	/?INPUT ERROR/
ERRINP:	ASCIZ	/
	INPUT DEVICE ERROR	STATUS = /
CW1:	ASCIZ	/    SA = /
CW8:	ASCII	/DUMP OF FILE   /
ASNAME:	BLOCK	3
	ASCII	/ TO  /
ASNAMF:	BLOCK	3
BLANKS:	ASCII	/     /
DATE:	ASCII	/00-00-00  /
TIME:	ASCII	/00:00/
	ASCIZ	/


/
CW6:	ASCIZ	/    BLOCK /
CW5:	ASCIZ	.    DIRECTORY

.
CW5A:	ASCIZ	.FILE INDEX OF EACH BLOCK ON TAPE


.
CW5B:	ASCIZ	.[BLOCK NUM]

      FILE  EXT           [0.
CW2:	ASCIZ	.  [.
CW3:	ASCIZ	.0]  .
COMLST:	IOWD	DTAL,DATAB
	0
ST1:	10
D1:	0
	XWD	0,IBUF
F1:	0
E1:	0
	0
	0
ST2:	1
D2:	0
	XWD	OBUF,
F2:	0
E2:	0
	0
	0
D3:	0
F3:	0
E3:	0
AS1:	BLOCK	3	;AS1 MUST FOLLOW E3
TERMBK:	BLOCK	1		;TERMBK MUST FOLLOW AS1
PDLPT:	XWD	-31,PDLST-1
BLKNUM:	BLOCK	1
MAX:	BLOCK	1
LSTOUT:	BLOCK	8
LINBUF:	BLOCK	^D24
PDLST:	BLOCK	32
IBUF:	BLOCK	3
OBUF:	BLOCK	3
TIBUF:	BLOCK	3
TOBUF:	BLOCK	3
DATAB:	BLOCK	200
DMPEND:	END	DUMP