Google
 

Trailing-Edge - PDP-10 Archives - steco_19840320_1er_E35 - 30,5602/xtra.mac
There is 1 other file named xtra.mac in the archive. Click here to see a list.
	TITLE	XTRA
	SUBTTL	ASSEMBLY PARAMETERS
	SEARCH	UUOSYM
	RELOC	0

;STEVEN M. WOLFE
;DIGITAL EQUIPMENT CORP.

JOB:	27
IDEV:	.IODMP
	SIXBIT	/SWAP/
	0
IFIL:	.RBEXT
	XWD	10,1
	SIXBIT	/WEM240/
	SIXBIT	/EXE/
ODEV:	.IODMP
	SIXBIT	/DSK/
	0
OFIL:	.RBEXT
	0
	0				;DEFAULTS TO JBTNAM
	SIXBIT	/EXE/
	SUBTTL	DEFINITIONS

;ACS
	F=0				;FLAGS
	T1=1				;TEMPS
	T2=T1+1
	T3=T2+1
	T4=T3+1
	P=17				;PDL

;CHS
	II==1				;INPUT THE DUMP
	OO==2				;OUTPUT THE EXE FILE

;MISCL
	PAGMSK==17777			;THE PAGE PART OF UPMP ENTRY
	PDLSIZ==40			;SIZE OF PDL
	PAGSIZ==1000			;SIZE OF A PAGE
	SHRSEG==1B1			;THE SEGMENT IS SHAREABLE
	IFNDEF	ST%KLP,<ST%KLP==1B11>	;7.01 UUOSYM DOESN'T KNOW THIS
	IFNDEF	NSEC,<NSEC==2>		;NUMBER OF SECTIONS
	NPAG==NSEC*PAGSIZ		;NUMBER OF PAGES TOTAL

;OPDEFS
	OPDEF	PJRST[JRST]		;POPPING JRST

;FLAGS
	F.KLP==1			;KL PAGING

;KI BITS
	KI.A==1B18			;ACCESS ALLOWED
	KI.P==1B19			;PUBLIC
	KI.W==1B20			;WRITABLE
	KI.C==1B22			;CACHE

;KL BITS
	KL.A==1B2			;ACCESS ALLOWED
	KL.P==1B3			;PUBLIC
	KL.W==1B4			;WRITABLE
	KL.C==1B6			;CACHE
	KL.SM==77B17			;STORAGE MEDIA
	SUBTTL	DATA AREAS

PDL:	BLOCK	PDLSIZ			;PUSH DOWN LIST
BF:	BLOCK	PAGSIZ			;THE BUFFER
PMAP:	BLOCK	NPAG			;PAGE MAP (SAME FORMAT AS .SVFPF)
CURPAG:	BLOCK	1			;WHICH PAGE IS IN THE BUFFER
UPMP:	BLOCK	PAGSIZ			;THE JOB'S UPMP
SMAP:	BLOCK	PAGSIZ			;SECTION MAP
CURSEC:	BLOCK	1			;WHICH SECTION IS IN CORE
CMD:	IOWD	PAGSIZ,BF
	0
HIFP:	BLOCK	1			;FIRST PAGE IN HISEG
HILP:	BLOCK	1			;LAST PAGE IN HISEG
SGN:	BLOCK	1			;JBTSGN(J)
CPAG:	BLOCK	1			;PAGE NUMBER IN CORE
DPAG:	BLOCK	1			;PAGE NUMBER ON DISK
NMTB:	BLOCK	1			;POINTER TO NUMTAB
	SUBTTL	INITIALIZATION

XTRA:	JFCL				;NO CCL
	RESET				;STOP I/O
	SETZ	F,			;CLEAR FLAGS
	MOVE	P,[IOWD PDLSIZ,PDL]	;SETUP PDL
	PUSHJ	P,IONCE			;LOOKUP THE DUMP
	HRLZ	T1,JOB			;GET JBTNAM
	HRRI	T1,.GTPRG
	PUSHJ	P,GETTB
	SKIPN	OFIL+.RBNAM
	MOVEM	T1,OFIL+.RBNAM
	OPEN	OO,ODEV			;ENTER THE EXE FILE
	 HALT
	ENTER	OO,OFIL
	 HALT
	HRLZ	T1,JOB			;READ HIS UPMP
	HRRI	T1,.GTUPM
	PUSHJ	P,GETTB
	PUSHJ	P,GETPAG
	MOVE	T1,[XWD BF,UPMP]
	BLT	T1,UPMP+PAGSIZ-1
	SETZM	PMAP			;CLEAR THE PAGE MAP
	MOVE	T1,[XWD PMAP,PMAP+1]
	BLT	T1,PMAP+NPAG-1
	SETZM	CPAG			;PAGE ZERO IN CORE
	SETZM	DPAG			;PAGE ZERO ON DISK
	SETOM	CURSEC			;NO SECTION MAP YET
	PUSHJ	P,GETSGN		;GET HISEG NUMBER
LOOP:	PUSHJ	P,DOPAG			;DO A PAGE
	AOS	T1,CPAG			;LOOP FOR EACH PAGE
	CAIE	T1,NPAG
	JRST	LOOP
	PUSHJ	P,DODIR			;OUTPUT THE DIRECTORY
	EXIT
;ROUTINE TO PROCESS A PAGE
DOPAG:	PUSHJ	P,GETSEC		;GET THE SECTION MAP
	MOVE	T2,CPAG			;GET MAP ENTRY
	IDIVI	T2,PAGSIZ
	MOVE	T1,SMAP(T3)
	LDB	T2,[POINT 3,T1,2]	;ACCESS ALLOWED?
	CAIN	T2,1
	TLNE	T1,(KL.SM)		;AND SWAPPED IN?
	POPJ	P,			;NO
	PUSH	P,T1			;SAVE MAP ENTRY
	PUSHJ	P,GETPAG		;READ THE PAGE
	PUSHJ	P,PUTPAG		;COPY IT TO OUTPUT FILE
	MOVE	T3,SGN			;GET SHRSEG BIT
	MOVE	T2,CPAG			;IS IT IN THE HISEG?
	CAML	T2,HIFP
	CAMLE	T2,HILP
	TLZA	T3,(SHRSEG)		;NO, CAN'T BE SHARABLE
	TLO	T1,(SV%HIS)		;YES, ITS HISEG
	TLNE	T3,(SHRSEG)		;IS IT SHARABLE?
	TLO	T1,(SV%SHR)		;YES
	POP	P,T3			;GET MAP ENTRY BACK
	TLNN	T3,(KL.P)		;PUBLIC?
	TLO	T1,(SV%CON)		;NO, CONCEALED
	TLNE	T3,(KL.W)		;WRITEABLE?
	TLO	T1,(SV%WRT)		;YES
	MOVEM	T1,PMAP(T2)		;SAVE MAP ENTRY
	POPJ	P,
;ROUTINE TO LOAD THE SECTION MAP INTO CORE
GETSEC:	MOVE	T1,CPAG			;GET SECTION NUMBER
	IDIVI	T1,PAGSIZ
	CAMN	T1,CURSEC		;ALREADY IN CORE?
	POPJ	P,			;YES
	MOVEM	T1,CURSEC		;NO, IT WILL BE SOON
	TRNN	F,F.KLP			;KL PAGING?
	JRST	GTSEC1			;NO, KI
	SKIPN	T1,UPMP+540(T1)		;DOES THE SECTION EXIST?
	JRST	ZERSEC			;NO
	PUSHJ	P,GETPAG		;YES, READ IT
	MOVE	T1,[XWD BF,SMAP]	;COPY IT
	BLT	T1,SMAP+PAGSIZ-1
	POPJ	P,
GTSEC1:	JUMPE	T1,KITKL		;SECTION 0
	;PJRST	ZERSEC			;KI'S DON'T HAVE NON-0 SECTION

;ROUTINE TO ZERO THE SECTION MAP
ZERSEC:	SETZM	SMAP
	MOVE	T1,[XWD SMAP,SMAP+1]
	BLT	T1,SMAP+PAGSIZ-1
	POPJ	P,
;ROUTINE TO CONVERT A KI UPMP INTO A KL PAGE MAP
KITKL:	MOVEI	T1,PAGSIZ-1		;SET UP A LOOP
KITKL1:	MOVE	T3,T1			;GET UPMP ENTRY
	ROT	T3,-1
	MOVE	T2,UPMP(T3)
	SKIPL	T3
	MOVSS	T2
	MOVE	T3,T2			;GET PAGE NUMBER
	ANDI	T3,PAGMSK
	TRNE	T2,KI.A			;ACCESS ALLOWED
	TLO	T3,(KL.A)
	TRNE	T2,KI.P			;PUBLIC
	TLO	T3,(KL.P)
	TRNE	T2,KI.W			;WRITABLE
	TLO	T3,(KL.W)
	TRNE	T2,KI.C			;CACHE
	TLO	T3,(KL.C)
	MOVEM	T3,SMAP(T1)		;SAVE IT
	SOJGE	T1,KITKL1		;LOOP
	POPJ	P,
;ROUTINE TO BUILD THE EXE DIRECTORY AND OUTPUT IT
DODIR:	SETZM 	BF			;CLEAR THE BUFFER
	MOVE	T1,[XWD BF,BF+1]
	BLT	T1,BF+PAGSIZ-1
	SETOM	CURPAG			;NOTHING IN CORE
	MOVE	T1,[XWD .SVDIR,1]	;HEADER WORD
	MOVEM	T1,BF
	SETZM	CPAG			;SETUP LOOP
DODIR1:	MOVE	T1,CPAG			;GET PAGE NUMBER IN CORE
	SKIPN	PMAP(T1)		;IS THERE A PAGE THERE?
	JRST	DODIR2			;NO, TRY NEXT PAGE
	JUMPE	T1,DODIR3		;ALWAYS DO FIRST ENTRY
	HRRZ	T2,BF			;GET BITS FROM PREVIOUS PAGE
	SUBI	T2,2
	MOVE	T3,BF+.SVFPF(T2)
	XOR	T3,PMAP(T1)		;SAME AS NEW BITS?
	TLNE	T3,760000
	JRST	DODIR3			;NO, HAVE TO ADD A NEW ENTRY
	LDB	T3,[POINT 13,BF+.SVPPC(T2),35];GET LAST PAGE IN CORE PLUS ONE
	LDB	T4,[POINT 9,BF+.SVPPC(T2),8]
	ADDI	T3,1(T4)
	CAME	T3,T1			;IS THAT US?
	JRST	DODIR3			;NO, HAVE TO ADD A NEW ENTRY
	LDB	T3,[POINT 13,BF+.SVFPF(T2),35];GET LAST PAGE IN FILE PLUS ONE
	ADDI	T3,1(T4)
	XOR	T3,PMAP(T1)		;IS THAT US?
	TRNN	T3,-1
	JRST	DODIR4			;YES, ADD A PAGE TO OLD ENTRY
	LDB	T3,[POINT 13,BF+.SVFPF(T2),35];NO, SEE IF BOTH ARE ZERO
	OR	T3,PMAP(T1)
	TRNN	T3,-1
	JRST	DODIR4			;BOTH ZERO, ADD A PAGE TO OLD ENTRY
;HERE TO ADD A NEW ENTRY
DODIR3:	HRRZ	T2,BF			;POINT TO FIRST FREE SLOT
	MOVE	T3,PMAP(T1)		;GET BITS AND FILE PAGE
	MOVEM	T3,BF+.SVFPF(T2)
	MOVEM	T1,BF+.SVPPC(T2)	;FILE PAGE AND ZERO COUNT
	MOVEI	T2,2			;BUMP HEADER
	ADDM	T2,BF
	JRST	DODIR2
;HERE TO ADD A PAGE TO AN EXISTING ENTRY
DODIR4:	LDB	T3,[POINT 9,BF+.SVPPC(T2),8];BUMP THE REPEAT COUNT
	ADDI	T3,1
	DPB	T3,[POINT 9,BF+.SVPPC(T2),8]
;HERE WHEN ALL PROCESSING FOR THE PAGE IS DONE
DODIR2:	AOS	T1,CPAG			;LOOP FOR EACH PAGE
	CAIE	T1,NPAG
	JRST	DODIR1
	HRRZ	T2,BF			;ADD A TRAILER ENTRY
	MOVE	T1,[XWD .SVEND,1]
	MOVEM	T1,BF(T2)
	USETO	OO,1			;OUTPUT THE DIRECTORY
	OUT	OO,CMD
	 POPJ	P,
	HALT
;ROUTINE TO GET HISEG NUMBER ETC
GETSGN:	HRLZ	T1,JOB			;GET ENTRY IN JBTSGN
	HRRI	T1,.GTSGN
	PUSHJ	P,GETTB
	MOVEM	T1,SGN
	SETOM	HIFP			;ASSUME NO HISEG
	SETOM	HILP
	TRNN	T1,-1			;A REAL HISEG?
	POPJ	P,			;NO
	HRLZS	T1			;GET HISEG ORIGIN
	HRRI	T1,.GTUPM
	PUSHJ	P,GETTB
	LSH	T1,-33
	MOVEM	T1,HIFP
	HRLZ	T1,SGN			;LAST PAGE IN HISEG
	HRRI	T1,.GTADR
	PUSHJ	P,GETTB
	LSH	T1,-33
	ADD	T1,HIFP
	MOVEM	T1,HILP
	POPJ	P,
;ROUTINE TO OUTPUT THE BUFFER
;T1 RETURNS THE PAGE ON DISK THE BUFFER WENT TO
PUTPAG:	PUSHJ	P,ZBFP			;IS THE BUFFER ZERO?
	 AOSA	T1,DPAG			;NO, BUMP PAGE NUMBER
	SETZ	T1,			;YES, PAGE 0
	JUMPE	T1,CPOPJ		;RETURN IF ZERO
	PUSH	P,T1			;SAVE PAGE NUMBER
	LSH	T1,2			;CONVERT PAGE TO BLOCK
	USETO	OO,1(T1)		;OUTPUT THE PAGE
	OUT	OO,CMD
	 JRST	TPOPJ
	HALT

;PREDICATE IF THE BUFFER IS EMPTY
;SKIP IF EMPTY
ZBFP:	MOVEI	T1,PAGSIZ-1		;SETUP LOOP
ZBFP1:	SKIPE	BF(T1)			;ZERO?
	POPJ	P,			;NO, FAIL IMMEDIATELY
	SOJGE	T1,ZBFP1		;YES, KEEP LOOKING
CPOPJ1:	AOSA	(P)			;SKIP RETURN
TPOPJ:	POP	P,T1
CPOPJ:	POPJ	P,
;ROUTINE TO GET THE CONTENTS OF A WORD
;T1 PASSES THE ADDR
;T1 RETURNS THE CONTENTS
GETWRD:	IDIVI	T1,PAGSIZ		;GET PAGE AND OFFSET
	PUSH	P,T2			;SAVE OFFSET
	PUSHJ	P,GETPAG		;GET THE PAGE IN CORE
	POP	P,T2			;RESTORE THE WORD
	MOVE	T1,BF(T2)		;GET THE CONTENTS
	POPJ	P,

;ROUTINE TO LOAD A PAGE INTO CORE
;T1 PASSES THE PAGE NUMBER
GETPAG:	ANDI	T1,PAGMSK		;GET RID OF NOISE BITS
	CAMN	T1,CURPAG		;ALREADY IN CORE?
	POPJ	P,			;YES
	MOVEM	T1,CURPAG		;NO, IT WILL BE SOON
	LSH	T1,2			;CONVERT TO BLOCK NUMBER
	USETI	II,5(T1)		;READ IT
	IN	II,CMD
	 POPJ	P,
	HALT

;ROUTINE TO DO A GETTAB
;T1 PASSES ARG
;T1 RETURNS RESULT
GETTB:	PUSH	P,T1			;SAVE ARG
	HRRZS	T1			;GET TABLE NUMBER
	ADD	T1,NMTB			;INDEX INTO NUMTAB
	PUSHJ	P,GETWRD		;GET CONTENTS OF NUMTAB
	POP	P,T2			;GET ARG BACK
	HLRZS	T2			;ISOLATE THE OFFEST
	ADD	T1,T2			;INDEX INTO TABLE
	TLZ	T1,-1			;GET RID OF NOISE BITS
	PJRST	GETWRD			;GET CONTENTS

;ROUTINE TO INITIALIZE THE INPUT FILE
IONCE:	OPEN	II,IDEV
	 HALT
	LOOKUP	II,IFIL
	 HALT
	SETOM	CURPAG			;NO PAGE IN CORE YET
	MOVEI	T1,410			;FIND POINTER TO NUMTAB
	PUSHJ	P,GETWRD
	MOVEM	T1,NMTB
	MOVE	T1,[XWD .GTSLF,.GTSLF]	;CHECK IT
	PUSHJ	P,GETTB
	TLZ	T1,-1
	CAME	T1,NMTB
	HALT
	MOVE	T1,[%CNST2]		;FIND OUT IF KL PAGING
	PUSHJ	P,GETTB
	TLNE	T1,(ST%KLP)
	TRO	F,F.KLP
	POPJ	P,

	END	XTRA