Google
 

Trailing-Edge - PDP-10 Archives - SRI_NIC_PERM_SRC_3_19910112 - mit/monitor/postld.mac
There are 51 other files named postld.mac in the archive. Click here to see a list.
;<5.ISI.MONITOR>POSTLD.MAC.5010	17-Nov-82 03:19:00	Edit by JGOLDBERGER
;#501   Change ordering of PSECTS to agree with LINK.CCL
;#500	Add BBN mod to save half killed symbols, update to Rel 5
;
;#220	use octal value of VEDIT as generation number on output files
;
;#201	Use VEDIT as Generation number on files output by POSTLD 
;	(MONITR.EXE,BUGSTRINGS.TXT,SYSTEM-SYMBOLS.TXT)
;
;#20	OSVALS; output important symbol values to SYSTEM-SYMBOLS.TXT
;
;[BBND]<TP-MONITOR>POSTLD.MAC.8, 27-May-81 10:40:02, Ed: EONEIL
;Output sym not found by symbol uncruncher, try brute force if
;necessary to try to find it
;[BBND]<TP-MONITOR>POSTLD.MAC.3,  6-May-81 22:04:57, Ed: EONEIL
;Fixed calc. of crunched module sym tab length, in SYMLP
;[BBND]<TP-MONITOR>POSTLD.MAC.2, 27-Apr-81 11:15:34, Ed: MMAEDER
;Allow certain symbols to be saved from the symbol table cruncher
;and updated program table counts. 
;[BBND]<STRIPPED-MONITOR>POSTLD.MAC.4, 27-Jan-81 12:57:04, Ed:JDELSIGNORE
;removed code to check for bugstp's, they don't exist anymore...
;[BBND]<MONITOR>POSTLD.MAC.4, 22-Jan-81 13:06:42, Ed: RBASCH
;Completed merge with DEC's final Release 4 code, also including stripping
;out all conditional assembly depending on the values of %%BASE and %%MODS
;(deleting %%BASE code), and modifying all BUG's to be in the new DEC
;format.
;[BBNF]<4-PLUMMER>POSTLD.MAC.7,  3-Jun-80 09:27:17, Ed: PLUMMER
;[BBNF]<4-PLUMMER>POSTLD.MAC.6,  2-Jun-80 09:43:42, Ed: PLUMMER
; Rearranged order of space printout to match loadup
; Symbol crucher
; Fix PRSEG to not clobber literals
;[BBN-TENEXG]<BBN-4-MONITOR>POSTLD.MAC.2, 15-Apr-80 08:42:33, Ed: EONEIL
;MAKE BUGSTP'S PRINT OUT AS SUCH ON BUGSTRINGS
; UPD ID= 457, SNARK:<5.MONITOR>POSTLD.MAC.5,   2-Feb-82 09:48:06 by PAETZOLD
;TCO 5.1714 - Fix code so that BUGSTRINGS.TXT knows difference between
; BUGHLT, BUGCHK, and BUGINF
; UPD ID= 1457, SNARK:<5.MONITOR>POSTLD.MAC.4,  20-Jan-81 09:36:38 by DONAHUE
;TCO 5.1235 - add label BUGD:
; UPD ID= 796, SNARK:<5.MONITOR>POSTLD.MAC.3,  24-Jul-80 10:56:19 by HALL
;DEFINE FFF HERE SO THAT IT CAN BE THE LAST THING IN RSDAT
; UPD ID= 421, SNARK:<5.MONITOR>POSTLD.MAC.2,  11-Apr-80 13:51:20 by HALL
;CHANGES TO WRITE-PROTECT RESIDENT MONITOR
;	ADD RSDAT PSECT TO PEND INVOCATION
;	ADD RSDAT PSECT TO ARGUMENTS FOR SSAVE JSYS
;<4.1.MONITOR>POSTLD.MAC.16,  8-Nov-79 06:36:56, EDIT BY R.ACE
;<R.ACE>POSTLD.MAC.1,  7-Nov-79 12:25:39, EDIT BY R.ACE
;MAKE POSTLD TYPE NAME AND VERSION #
;<4.MONITOR>POSTLD.MAC.15, 30-Oct-79 11:37:18, EDIT BY MILLER
;<4.MONITOR>POSTLD.MAC.14, 30-Oct-79 10:31:48, EDIT BY MILLER
;GET SYS TIME AND DATE FROM FDB OF VERSIO.MAC
;<4.MONITOR>POSTLD.MAC.13, 20-Aug-79 02:45:20, EDIT BY GILBERT
;Re-implement BUGSTF and HIDSYM conditionals after edit 12.
;<4.MONITOR>POSTLD.MAC.12, 17-Aug-79 03:40:47, EDIT BY GILBERT
;TCO 4.2408: MAKE TYPEOUT FORMAT EASIER TO READ, ADD VARIOUS CHECKS TO
;SEE IF THE MONITOR WILL RUN, DISPLAY ALL PSECTS INCLUDING POSTCD.
;<4.MONITOR>POSTLD.MAC.11, 15-Jun-79 01:38:41, EDIT BY GILBERT
;REMOVE CODE TO GET AROUND MACRO BUG WHICH IS NOW FIXED.
;<4.MONITOR>POSTLD.MAC.10,  9-Apr-79 14:29:33, EDIT BY DBELL
;TCO 4.2227 - FIX SSEG MACRO WHICH SOMETIMES FAILED TO SAVE A PAGE.
;<4.MONITOR>POSTLD.MAC.9,  6-Mar-79 09:43:00, EDIT BY KONEN
;UPDATE COPYRIGHT FOR RELEASE 4
;<4.MONITOR>POSTLD.MAC.8, 18-Jan-79 13:35:19, EDIT BY GILBERT
;REALLY FIX BUG IF SYMBOL TABLE STARTS ON SAME PAGE THAT INCOD ENDS.
;<4.MONITOR>POSTLD.MAC.6, 15-Jan-79 07:46:33, EDIT BY GILBERT
;More TCO 4.1255:
;	Re-arrange the PSECTs.
;	Fix bug if symbol table starts in same page that INCOD ends.
;<4.MONITOR>POSTLD.MAC.5,  8-Jan-79 06:56:36, EDIT BY GILBERT
;TCO 4.2155 - Implement hidden symbol tables:
;	Make PSECT end names uniform.
;	Remove all symbol table processing code.
;	Clean up PSECT overlap typeout and teach about new PSECT order.
;<4.MONITOR>POSTLD.MAC.4, 22-Jun-78 16:25:36, EDIT BY MILLER
;ADD AN "XPUNGE"
;<1BOSACK>POSTLD.MAC.1001, 15-Jun-78 15:36:36, EDIT BY BOSACK
;<1BOSACK>POSTLD.MAC.1000,  1-Jun-78 21:06:27, EDIT BY BOSACK
;CHANGES FOR MORE PSECTS
;<4.MONITOR>POSTLD.MAC.2, 14-Jun-78 06:41:41, Edit by JBORCHEK
;ADD BUGSTF FLAG TO PUT BUGSTRINGS IN MONITOR VAS
;<3A.MONITOR>POSTLD.MAC.7,  7-Mar-78 18:54:08, EDIT BY BOSACK
;<3A.MONITOR>POSTLD.MAC.6,  7-Mar-78 18:34:40, EDIT BY BOSACK
;<3A.MONITOR>POSTLD.MAC.5,  7-Mar-78 18:33:50, EDIT BY BOSACK
;OUTPUT TYPE OF BUGXXX IN BUGXXX LISTING
;<3A.MONITOR>POSTLD.MAC.4, 23-Jan-78 20:56:36, EDIT BY BOSACK
;<3A.MONITOR>POSTLD.MAC.3, 23-Jan-78 20:36:30, EDIT BY BOSACK
;MOVE BUGSTRINGS/POINTERS TO OVERLAP SWP PAGE VARS
;THIS SOFTWARE IS FURNISHED UNDER A LICENSE AND MAY ONLY BE USED
;  OR COPIED IN ACCORDANCE WITH THE TERMS OF SUCH LICENSE.
;
;COPYRIGHT (C) 1976,1977,1978,1979,1980,1981,1982 BY DIGITAL EQUIPMENT CORPORATION, MAYNARD, MASS.

	SEARCH PROLOG
	TTITLE(POSTLD,, - POST-LOADING ONE-SHOT INIT)


EXT <NBUGP>				;NUMBER OF BUGPOINTERS


NPDL==20			;SIZE OF LOCAL PDL

DEFINE SAVSYM(MOD,SYM)<
	RADIX50 0,MOD
	RADIX50 4,SYM
>


DEFINE TSTR ($MSG)<
	HRROI A,[ASCIZ \$MSG\]
	PSOUT>

DEFINE JSERR <
	JSP 2,JSEX0>
;GET FINAL VALUE OF LOAD PC'S

DEFINE PEND(PSECT),<
    IRP PSECT,<
	.PSECT PSECT
	PSECT'Z=:.-1
	PSECT'L==:PSECT'Z_-PGSFT
	.ENDPS PSECT
    >
>

;ALLOCATE FFF AS THE LAST THING, SO IT'LL GET THE REST OF THE PAGE
;WHERE PSECT RSDAT IS DEFINED.
;THIS IS THE PATCH SPACE FOR THE RESIDENT MONITOR.

	RSI FFF2,<>,0
	RSI FFF1,<>,0
	RSI FFF,<>,400

PEND <RSCOD,INCOD,RSDAT,PPVAR,RSVAR,SYVAR,PSVAR>
PEND <JSVAR,NPVAR,NRCOD,BGSTR,BGPTR,NRVAR>


;LOAD POSTLD WHERE IT WILL GET OVERLAYED BY RUNTIME STORAGE

	.ENDPS RSCOD
	.PSECT POSTCD
;START HERE AT COMPLETION OF LOADING

SYSG0:	MOVE P,[IOWD NPDL,PDL]
	HRROI T1,P1		;#220 where to put number string
	HRRZ T2,137		;#220 get edit number
	MOVEI T3,^D8		;#220 output in octal
	NOUT			;#220 .
	 JFCL			;#220 .
	MOVEI T3,^D10		;#220 now read it back in decimal
	HRROI T1,P1		;#220 .
	NIN			;#220 .
	 JFCL			;#220 .
	MOVEM T2,OVERS		;#220 save as version to use

	SETZM T3		;ASSUME MON: IS KNOWN
	HRROI T1,[ASCIZ /MON/]
	STDEV			;SEE IF MON: IS DEFINED
	 ADDI T3,1		;NOT
	MOVX T1,GJ%OLD!GJ%SHT	;GET THE SOURCE FILE
	HRRO T2,[[ASCIZ /MON:VERSIO.MAC/]
		 [ASCIZ /VERSIO.MAC/]](T3)
	GTJFN			;GET HANDLE
	 ERJMP [HRROI T1,[ASCIZ /
%VERSIO.MAC not found. Current time and date used
/]
		PSOUT
		GTAD		;GET TIME AND DATE
		JRST SYSG00]	;AND PROCEED
	MOVEI T2,T2		;WHERE TO PUT DATE AND TIME WORD
	MOVEI T3,1		;ONE WORD IS ALL WE NEED
	RFTAD			;GET TIME AND DATE WORD
	RLJFN			;RELEASE JFN OF FILE
	 NOP
	MOVE T1,T2		;STASH WORD IN T1
SYSG00:	MOVEM T1,SYSTAD		;REMEMBER IT IN SWPMON
; Replace code bits for symbols to save, with code bits that won't
; get crunched out by cruncher, and save original bits
	CALL SWAP
; Cruch symbol table by removing symbols
; which DDT will not type out and symbols which we cannot type in.
;  Also symbols for selected programs such as POSTLD and DDT are
;  flushed since the associated code is either gone when
;  the monitor is running or it is not to be debugged in
;  the monitor context.

	MOVE Q1,.JBSYM		; Write pointer for symbols
	MOVE Q2,Q1		; Read pointer
	MOVE Q3,Q1		; And "old" read pointer
	SETZ T4,		; Initialize program table length
SYMLP:	DMOVE T1,0(Q2)		; Read a symbol
	DMOVEM T1,0(Q1)		; Write it in cruched table
	ADD Q2,BHC+2		; Advance the read pointer
	MOVE T3,T1		; Get copy of symbol and code bits
	LSH T3,-^D34		; Save only top two code bits

	SKIPE T3		;#500 Normal symbol?
	 CAIN T3,2		;#500 Half killed?
	  JRST SYMLP0		;#500 Save it

	 CAIE T3,3		;#500 Block name?
	  JRST SYMLP1		;#500 Else flush it
SYMLP0:				;#500
	ADD Q1,BHC+2		; Yes.  Save it
	SUBI T4,2		; Increment table length

SYMLP1:	CAMN T1,[RADIX50 0,EDDT]
	 MOVE Q1,Q3		; Set to overwrite this program table
	CAMN T1,[RADIX50 0,MDDT]
	 MOVE Q1,Q3
	TLNN T1,740000		; Just moved a program name?
	 JRST [CAME Q3,Q1	; Yes.  Going to keep it?
	       HRLM T4,-1(Q1)	; Yes, update length of program table
		MOVE Q3,Q1	; Save in case we need to overwrite
	       SETZ T4,		; Re-initialize length
	       JRST .+1]
	JUMPL Q2,SYMLP		; Do rest of table
	MOVE T1,Q2
	SUB T1,Q1		; Number flushed in RH
	HRLZ T1,T1		; In LH
	ADDM T1,.JBSYM		; Update symbol pointer
	HLRE T1,.JBSYM		;GET LENGTH OF SYMBOL TABLE
	MOVN T1,T1		;MAKE POSITIVE
	MOVEI T2,SYVARZ		;FIRST WORD OF RUNTIME TABLE (-1)
	ADD T2,T1		;LAST WORD
	MOVEM T2,RSTLU		;SAVE FOR PRINTOUT
	ADD T1,.JBSYM		;ADD IN BEGINNING OF TABLE
	SUBI T1,1		;CONVERT FIRST FREE TO LAST USED
	HRRZM T1,SYMLU		;REMEMBER IT
	SKIPL T1,.JBUSY		;FIRST USED IF UNDEFINED SYMBOLS
	HRRZ T1,.JBSYM		;GET FIRST USED
	HRRZM T1,SYMFU		;REMEMBER IT TOO
	SETZM FPAGES		;NO FREE PAGES YET
	CALL SWAP		; Swap back in original code bits
	HRROI T1,[ASCIZ/
/]
	PSOUT			;SKIP A LINE
	HRROI T1,TSVN		;TYPE SYSTEM NAME AND VERSION #
	PSOUT
	HRROI T1,[ASCIZ /

Monitor address space:

    Psect              Start     End  Length    Free	Limit
/]
	PSOUT

;DEFINE LOCAL MACRO FOR SPACE PRINTOUTS

DEFINE PRPSC($PSECT,$NEXT,$BEGA,$ENDA,$NEXTA,$LIMIT)<
	XLIST
	HRROI T1,[ASCIZ \
    $PSECT\]
	PSOUT%
	..N==0
IRPC <$PSECT>,<..N==..N+1>
	MOVEI T1," "
REPEAT <^D16-..N>,<PBOUT%>
IFNB <$BEGA>,<MOVE P1,$BEGA>
IFB <$BEGA>,<MOVEI P1,$PSECT>
	MOVE T2,P1
	CALL OCTOUC
IFNB <$ENDA>,<MOVE T2,$ENDA>
IFB <$ENDA>,<MOVEI T2,$PSECT'Z>
	CALL OCTOUC
	SUBM T2,P1
	EXCH T2,P1
	ADDI T2,1
	CALL OCTOUC
IFNB <$NEXTA>,<MOVE T2,$NEXTA>
IFB <$NEXTA>,<MOVEI T2,$NEXT>
	SUB T2,P1
	SUBI T2,1
	CALL OCTOUC
	HRROI T1,[ASCIZ \	\]
	PSOUT%
IFNB <$LIMIT>,<HRROI T1,[ASCIZ \$LIMIT\]
	PSOUT%>
	HRROI T1,[ASCIZ \	<= Overflow\] ;>
	SKIPGE T2
	PSOUT%
	ASH T2,-9
	ADDM T2,FPAGES
	LIST
>
;THIS CODE NEEDS SOME WORK (FREE PAGE ACCOUNTING, CASES WHERE THE UPPER
;BOUND OF A PSECT COULD BE EITHER OF TWO OTHER OVERLAPPING PSECTS) IF
;BUGSTF=0.

	PRPSC	(RSCOD,INCOD)
	PRPSC	(INCOD,RSDAT)
	PRPSC	(RSDAT,PPVAR)
	PRPSC	(PPVAR,RSVAR)
	PRPSC	(RSVAR,SYVAR)
	SKIPN HIDSYF		;HIDING SYMBOLS?
	JRST PRPSC1		;NO, DIFFERENT MESSAGE
	PRPSC	(SYVAR,PSVAR)
	JRST PRPSC2		;RE-JOIN MAIN FLOW
PRPSC1:	PRPSC	(SYVAR,<Loaded symbols>,,,SYMFU)
	PRPSC	(<Loaded symbols>,PSVAR,SYMFU,SYMLU)
PRPSC2:	PRPSC	(PSVAR,JSVAR)
	PRPSC	(JSVAR,NRVAR)
	PRPSC	(NRVAR,NRCOD)
	SKIPN BUGTP		;BUGSTRINGS IN MONITOR VAS?
	JRST PRPSC3		;NO, DIFFERENT MESSAGE
	PRPSC	(NRCOD,BGSTR)
	PRPSC	(BGSTR,BGPTR)
	PRPSC	(BGPTR,POSTCD)
	JRST PRPSC4		;RE-JOIN MAIN FLOW
PRPSC3:	PRPSC	(NRCOD,POSTCD)
PRPSC4:	PRPSC	(POSTCD,NPVAR,,[PSTEND])
	PRPSC	(NPVAR,<Section 0 end>,,,[1000000],777777)
	TSTR <
>
	PUSH P,FPAGES
	SKIPN HIDSYF		;NEED MORE INFO?
	JRST PRPSC5		;NO, SKIP THIS
	PRPSC	(<Loaded symbols >,,SYMFU,SYMLU,[NRCOD],NRCOD)
	PRPSC	(<Runtime symbols>,,[SYVARZ+1],RSTLU,[NPVAR],NPVAR)
	TSTR <

The symbols will be moved to their runtime area right after
the SYVAR psect by STG early in the monitor's initialization.
>
	; ..
PRPSC5:	SKIPE BUGTP		;NEED MORE INFO?
	JRST PRPSC6		;NO, DONE
	PRPSC	(BGSTR,BGPTR)
	PRPSC	(BGPTR,POSTCD,,,,POSTCD)
	TSTR <
>
PRPSC6:	POP P,FPAGES
	TSTR <
There are >
	MOVE T2,FPAGES
	CALL OCTOUT
	TSTR < (octal) free pages, not counting symbols.

>
	HRROI T1,[
ASCIZ \% Runtime symbols must end by 360000 in order to run on a 128K system.

\]
	MOVEI T2,360000-1	;IN ORDER TO LEAVE 20P FOR BOOT
	SUB T2,RSTLU
	SKIPGE T2
	PSOUT%
	HRROI T1,[
ASCIZ \% End of resident free pool (RESFRZ) overlaps BOOT area at 760000.

\]
	MOVEI T2,RESFRZ		;LAST 20P OF VAS RESERVED FOR BOOT
	CAIL T2,760000		;RESFRP SHOULD REALLY BE IN ITS OWN PSECT
	PSOUT%
;SET ENTRY VECTOR AND START ADDRESS

	MOVEI 1,.FHSLF
	MOVE 2,[JRST EVGO]	;MAIN START LOCATION
	HRRM 2,.JBSA
	SEVEC
	; ..


;#20 Dump important symbol values to file for listing

	CALL OSVALS		;#20 


;DUMP BUG STRINGS TO FILE, SETUP BUGTABLE IN SWPMON

BUGSR3:	MOVX T1,GJ%FOU+GJ%SHT
	HRR T1,OVERS		;#220 Use edit number for generation #
	HRROI 2,[ASCIZ /BUGSTRINGS.TXT/]
	GTJFN
	 JSERR
	PUSH P,T1		;SAVE JFN
	MOVE T2,T1		;JFN IN T2
	TSTR	<Writing sorted bug list to file >
	MOVEI T1,.PRIOU		;TO TERMINAL
	POP P,T2		;FILE DESCRIBED BY THIS JFN
	SETZ T3,		;USUAL TEXT
	JFNS			;TYPE THE FILESPEC
	MOVE T1,T2		;JFN TO T1 FOR OPENF
	MOVE 2,[7B5+1B20]
	OPENF
	 JSERR
	SETZ 3,
	HRROI 2,TSVN		;SYSTEM VERSION TEXT
	SOUT
	HRROI 2,[ASCIZ /
BUGHLT and BUGCHK names and descriptions

/]
	SOUT
;SORT THE BUG TABLE BY SIXBIT NAME

	MOVSI 7,-NBUGP
	JUMPE 7,BUGEND		;NO BUGPOINTERS LOADED?
BUGSR4:	MOVSI 5,-NBUGP(7)	;SCAN FROM HERE TO END
	HRRI 5,0(7)
	HRLOI 3,377777		;INITIAL MINIMUM
BUGSR1:	HLRZ 6,BGPTR(5)		;BUG ADDRESS
	JUMPE 6,BUGSR2		;IGNORE ZEROS
BUGSR5:	MOVE 2,1(6)		;GET NEXT WORD FROM BLOCK
	TLNN 2,770000		;FOUND THE SIXBIT NAME?
	AOJA 6,BUGSR5		;NO, LOOP BACK UNTIL FOUND
	TXC 2,1B0		;SO COMPARE WORKS ON SIXBIT NAME
	CAML 2,3		;MIN SO FAR?
	JRST BUGSR2		;NO
	MOVE 3,2		;YES, REMEMBER THIS VALUE
	MOVEI 4,0(5)		;AND LOCATION
BUGSR2:	AOBJN 5,BUGSR1
	CAMN 3,[377777,,777777]	;FOUND A MIN?
	JRST BUGD		;NO, NOTHING BUT ZEROS LEFT
	MOVE 6,BGPTR(4)		;INTERCHANGE MIN WITH TOP OF TABLE
	EXCH 6,BGPTR(7)
	MOVEM 6,BGPTR(4)
	AOBJN 7,BUGSR4		;(ALWAYS JUMP)
;PRINT STRINGS TO BUGSTRINGS.TXT

BUGD:	MOVSI 7,-NBUGP		;LOOP OVER ALL OF THE MESSAGES
BUGD1:	MOVE 6,BGPTR(7)		;TABLE ENTRY
	HLRZ 2,6		;ADDRESS
BUGD2:	MOVE 3,1(2)		;GET NEXT WORD FROM BLOCK
	TLNN 3,770000		;FOUND THE SIXBIT NAME YET?
	AOJA 2,BUGD2		;NO, LOOP UNTIL IT IS FOUND
BUGD4:	SETZ 2,			;NOW TYPE OUT NAME
	LSHC 2,6		;GET NEXT CHARACTER
	ADDI 2," "		;MAKE IT ASCII
	BOUT			;OUTPUT IT
	JUMPN 3,BUGD4		;LOOP UNTIL NAME IS FINISHED
	HLRZ 3,6		;GET ADDRESS
	HRRZ 3,(3)		;GET BUGXXX ADDRESS
	HRROI 2,[ASCIZ /	[UNK] /]
	CAIN 3,BUGHLT		;BUGHLT?
	HRROI 2,[ASCIZ /	[HLT] /]
	CAIN 3,BGCCHK		;BUGCHK
	HRROI 2,[ASCIZ /	[CHK] /]
	CAIN 3,BGCINF		;BUGINF?
	HRROI 2,[ASCIZ /	[INF] /]
	MOVEI 3,0
	SOUT			;OUTPUT DESCRIPTION
	HRROI 2,0(6)
	SETZ 3,
	SOUT			;PRINT THE STRING
	HRROI 2,[ASCIZ /
/]
	SOUT
	AOBJN 7,BUGD1
	CLOSF			;CLOSE BUGSTRINGS.TXT
	JFCL
;CREATE THE EXE FILE CONTAINING THE MONITOR

BUGEND:	MOVX A,GJ%FOU+GJ%SHT	;GET NEXT VERSION OF MONITOR FILE
	HRR A,OVERS		;#220 make generation reflect version
	HRROI B,MONSNM		;GET NAME TO SAVE AS
	GTJFN
	 JSERR
	PUSH P,A
	TSTR <
Saving monitor as >
	MOVEI A,101
	HRRZ B,0(P)
	SETZ C,
	JFNS
	MOVE A,SYMFU		;BEGINNING OF SYMBOL TABLE
	MOVEI B,INCODZ		;END OF INIT CODE
	IORI B,777		;END OF THAT PAGE
	CAMLE A,B		;SYMS ON SAME PAGE AS INCOD?
	JRST BUGEN2		;NO, PROCEED
	AOS A,B			;YES, START AT FIRST PAGE AFTER INIT CODE
	MOVEM A,SYMFU		;STORE FOR SSEG MACRO BELOW

BUGEN2:	POP P,A
	HRLI A,.FHSLF		;CONSTRUCT  FORKH,,JFN  FOR SSAVE
	MOVEI B,1(P)		;BUILD SSAVE LIST ON STACK

DEFINE SSEG($START,$END)<
	XLIST
	..NSG==..NSG+1
	HRRZ C,$END		;;GET LAST ADDRESS OF A REGION
	HRRZ D,$START		;;AND THE FIRST ADDRESS OF THE REGION
	LSH C,-PGSFT		;;GET ENDING PAGE NUMBER
	LSH D,-PGSFT		;;AND BEGINNING PAGE NUMBER
	SUB C,D			;;SEE HOW MANY PAGES BETWEEN THEM
	MOVNI C,1(C)		;;GET NEGATIVE OF NUMBER OF PAGES IN REGION
	HRL D,C			;;PUT COUNT IN LEFT HALF
	TRO D,1B18!1B20!1B22	;;SET FLAGS
	PUSH P,D		;;STORE THE WORD
	LIST
>
;USE THE ABOVE MACRO TO GENERATE AN ARGUMENT LIST ON THE STACK

	..NSG==0

	SSEG([EXP 0],[EXP RSCODZ])
	SSEG([EXP INCOD],[EXP INCODZ])
	SSEG([EXP RSDAT],[EXP RSDATZ])
	SSEG(SYMFU,SYMLU)

	SSEG([EXP NRCOD],[EXP NRCODZ])
	SKIPN BUGTP			;WANT THE BUGSTRINGS?
	 JRST SAVEND			;DONE

SAVBUG:	SSEG([EXP BGSTR],[EXP BGPTRZ])	;#501 

SAVEND:	PUSH P,[0]		;TERMINATE LIST WITH 0
	SETZ C,
	SSAVE
	SUB P,[XWD ..NSG+1,..NSG+1] ;FLUSH ARG LIST FROM STACK
	TSTR <
>				;NOTE SUCCESSFUL COMPLETION
;ALL USEFUL STUFF HAS BEEN WRITTEN, FLUSH THIS ADR SPACE

	SETO T1,
	MOVE T2,[.FHSLF,,1]	;FLUSH PAGES 1-777
	MOVE T3,[1B0+777]
	MOVE 16,[CLRPRG,,5]	;THIS CODE WILL VANISH IN THE CLEARING,
	BLT 16,16		;SO PUT THE CLEAR LOOP IN THE AC'S
	JRST 5

CLRPRG:	PHASE 5
	PMAP
	HALTF
	JRST .-1
	DEPHASE
;#20 Routine to output some important symbol values so that we
;#20 system programmers can look at the monitor with parser.

OSVALS:	MOVX T1,GJ%FOU+GJ%SHT	;#20 
	HRR T1,OVERS		;#220 Use edit number for generation #
	HRROI T2,[ASCIZ /SYSTEM-SYMBOLS.TXT/] ;#20 Output filename
	GTJFN			;#20 
	 JSERR			;#20 
	MOVE T2,[7B5+1B20]	;#20 
	OPENF			;#20 
	 JSERR			;#20 
	HRROI T2,TSVN		;#20 System version text
	SETZ T3,		;#20 
	SOUT			;#20 
	HRROI T2,[BYTE (7)11,11] ;#20 Some tabs
	SOUT			;#20 
	SETO T2,		;#20 Use current time
	ODTIM			;#20 Print it for the record
	HRROI T2,[ASCIZ /

			**********************************
			* SYSTEM'S PROGRAMMERS USE ONLY! *
			**********************************


/]				;#20 
	SOUT			;#20 Header

;#20 Now start printing symbols and their values

	MOVSI T4,-OSSYML	;#20 Iterate as necessary
OSVAL1:	HRRO T2,OSSYM(T4)	;#20 Display symbol name,
	SOUT			;#20 
	HLRZ T2,OSSYM(T4)	;#20 then numeric value
	MOVE T3,[140006,,10]	;#20  (six columns, leading spaces)
	NOUT			;#20 
	 JFCL			;#20 
	HRROI T2,[BYTE (7)15,12,12] ;#20 
	SETZ T3,		;#20 
	SOUT			;#20 
	AOBJN T4,OSVAL1		;#20  ..

	CLOSF			;#20 Close the file
	 JFCL			;#20 Ignore errors
	RET			;#20 Back to caller


DEFINE OSSYM$(SYM)<
   IRP <SYM>,<SYM,,[ASCIZ /SYM	= /]>> ;;#20 

OSSYM:	OSSYM$(<FKJOB,FKPGS,FORKX,FPC,JOBDIR,JOBPNM>) ;#20 
	OSSYM$(<PPC,SPT,UPDL>)	;#20 
   OSSYML==.-OSSYM		;#20 
;JSYS ERROR

JSEX0:	HRROI 1,[ASCIZ /
?JSYS ERROR: /]
	PSOUT
	MOVEI 1,101		;PRINT ERROR STRING ON PRIMARY OUTPUT,
	HRLOI 2,400000		; THIS FORK ,, LAST ERROR
	SETZ 3,
	ERSTR
	 JFCL
	 JFCL
	HRROI 1,[ASCIZ /
/]
	PSOUT
	HALTF

OCTOUT:	SKIPA T3,[FLD(8,NO%RDX)]	;FREE FORMAT
OCTOUC:	MOVX 3,NO%LFL+FLD(8,NO%COL)+FLD(8,NO%RDX)	;8 COLUMNS
	MOVEI T1,.PRIOU		;PRIMARY OUTPUT
	NOUT
	 JSERR
	RET

;ROUTINE TO PRESERVE FAVORITE SYMBOLS FROM THE SYMBOL CRUNCHER.
;SAVED SYMS ARE IN TABLE SYMS ASSEMBLED BELOW--THE MODULE NAME IS
;USED FIRST TO TRY TO FIND THE SYM, BUT IF THIS FAILS, A BRUTE
;FORCE SEARCH OF THE WHOLE SYMBOL TABLE IS USED.  ONLY IF THE BRUTE
;FORCE SEARCH FAILS IS AN ERROR MESSAGE OUTPUT.  

;THE SYMBOL FOUND IN THE SYM TABLE IS SWAPPED WITH THE ENTRY
;IN SYMS, AND THIS IS DONE TWICE, ONCE BEFORE THE CRUNCH AND
;ONCE AFTER, RESTORING THE ORIGINAL VERSION OF THE SYMBOL TO
;ITS PLACE IN THE FINAL SYM TAB.  THE SUBSTITUTED SYMBOL IS MARKED
;GLOBAL TO FOIL THE CRUNCHER

;AC USAGE--
;T1/SYM FROM SYM TAB
;T2/ SYM FROM SYMS
;T4/ COUNT OF REMAINING LOCATIONS TO DO
;Q1/ POINTER INTO SYM TAB
;Q2/ POINTER INTO SYMS

SWAP:	MOVEI Q2,SYMS		;pointer to SYMS table
GETMOD:	MOVE T2,0(Q2)
	CAIN T2,0		;0 marks end of SYMS
	RET
	MOVE Q1,.JBSYM		;get symbol table pointer
	HLRE T3,Q1
	MOVNS T3
	MOVE T4,T3		;save length of symbol table
	ADD Q1,T3		;point to end of symbol table
	MOVNI T3,2
NXTMOD:	ADD Q1,T3
	ADD T4,T3
	JUMPLE T4,[MOVE Q1,.JBSYM ;CAN'T FIND MODULE NAME, USE BRUTE FORCE
		HLRE T3,Q1	; SEARCH OF WHOLE SYMBOL TABLE
		MOVN T4,T3	;LENGTH OF WHOLE SYM TAB
		ADD Q1,T4	;POINTER TO BOTTOM OF SYM TAB
		JRST GETSYM]	;GO FIND THE SYMBOL IN THIS RANGE
	MOVE T1,0(Q1)
	CAMN T1,T2		;right module?
	JRST GETSYM		;yes, get the symbol
	MOVE T3,1(Q1)		;no, get length of this module
	HLRES T3
	JRST NXTMOD		;get next module name in symbol table
GETSYM:	MOVE T2,1(Q2)		;put next SYMS symbol in t2
	TLZ  T2,740000		;zero out code bits
	MOVNI T3,2
NXTSYM:	ADD Q1,T3
	ADD T4,T3
	JUMPLE T4,[HRROI T1,[ASCIZ/
%% Symbol /]
		PSOUT
		MOVE T2,1(Q2)	;symbol not found
		CALL R50ASC	;convert to ASCII
		MOVE T1,T2	;ASCII equiv of sym
		PSOUT
		HRROI T1,[ASCIZ / is not in symbol table./]
		PSOUT
		JRST NOSYM]
	MOVE T1,0(Q1)		;get a symbol
	TLZ  T1,740000		;zero out code bits
	CAME T1,T2		;right symbol?
	JRST NXTSYM		;no, get next symbol in symbol table
	MOVE T4,1(Q2)		;yes, swap symbols
	MOVE T3,0(Q1)
	MOVEM T4,0(Q1)		
	MOVEM T3,1(Q2)
NOSYM:	ADDI Q2,2		;point to next module name in SYMS
	JRST GETMOD

;;;
;;;	Accepts B - RADIX50 symbol
;;;	Returns	B - pointer to ASCIZ
;;;
R50ASC:	PUSH	P,A		; save A
	SETZM	R50STR		; clear string
	SETZM	R50STR+1	; buffer
	PUSH	P,[-1]		; save a marker
	MOVE	A,B		; symbol into A
	TLZ	A,740000	; mask out extra bits
R50AS0:	IDIVI	A,50		; divide
	PUSH	P,RADTBL(B)	; save ASCII
	JUMPN	A,R50AS0	; loop through symbol
	MOVE	A,[POINT 7,R50STR] ; point to buffer
R50AS2:	POP	P,B		; pop a byte
	JUMPL	B,R50AS4	; if done
	IDPB	B,A		; store in string
	JRST	R50AS2		; and loop
R50AS4:	MOVE	B,[POINT 7,R50STR] ; point to string
	POP	P,A		; restore A
	RET			; and done



SYMS:	SAVSYM(POSTLD,JSVARZ)
	SAVSYM(POSTLD,PSVARZ)
	SAVSYM(STG,NLINES)
	SAVSYM(STG,NUFKS)
	SAVSYM(STG,NOFN)
	SAVSYM(STG,NRESFB)
	SAVSYM(STG,PIDHDS)
	SAVSYM(STG,MAXBLK)
	SAVSYM(STG,ENQMXF)
	SAVSYM(STG,MLJFN)
	SAVSYM(STG,TRAPPC)
	SAVSYM(STG,RESQTL)
	SAVSYM(STG,SWFREL)
	SAVSYM(STG,NJOBS)
	SAVSYM(STG,SSPT)
	SAVSYM(STG,NFKS)
	SAVSYM(TTYSRV,TTDDLN)
	SAVSYM(TTYSRV,TTFLG1)
	SAVSYM(TTYSRV,TTOCT)
	SAVSYM(TTYSRV,TTICT)
	SAVSYM(TTYSRV,TTLINK)
	SAVSYM(TTYSRV,TTFLGS)
	SAVSYM(JOBDAT,JSVAR)
	SAVSYM(JOBDAT,PSVAR)
	0

;;;
;;; Translate table .RAD50 -> ASCII
;;;

RADTBL:
	0
	"0"
	"1"
	"2"
	"3"
	"4"
	"5"
	"6"

	"7"
	"8"
	"9"
	"A"
	"B"
	"C"
	"D"
	"E"

	"F"
	"G"
	"H"
	"I"
	"J"
	"K"
	"L"
	"M"

	"N"
	"O"
	"P"
	"Q"
	"R"
	"S"
	"T"
	"U"

	"V"
	"W"
	"X"
	"Y"
	"Z"
	"."
	"$"
	"%"


R50STR:	BLOCK 2		;PLACE FOR ASCII EQUIV. OF RADIX50 SYM
SYMFU:	BLOCK 1		;FIRST WORD OF SYMBOL TABLE
SYMLU:	BLOCK 1		;LAST WORD OF SYMBOL TABLE
RSTLU:	BLOCK 1		;LAST WORD OF RUNTIME SYMBOL TABLE
FPAGES:	BLOCK 1		;FREE PAGE COUNT
Overs:	Block	1		;#220	Version number for output files
PDL:	BLOCK NPDL


	TNXEND
PSTEND:	END SYSG0