Google
 

Trailing-Edge - PDP-10 Archives - BB-D480C-SB_1981 - relbuf.bli
There are 26 other files named relbuf.bli in the archive. Click here to see a list.
!THIS SOFTWARE IS FURNISHED UNDER A LICENSE AND MAY ONLY BE USED
!  OR COPIED IN ACCORDANCE WITH THE TERMS OF SUCH LICENSE.

!COPYRIGHT (C) 1974,1981 BY DIGITAL EQUIPMENT CORPORATION
!AUTHOR: S. MURPHY

MODULE RELBUF(RESERVE(0,1,2,3), SREG=#17,FREG=#16,VREG=#15,DREGS=4)=
BEGIN

GLOBAL BIND RELBUV = 6^24 + 0^18 + 30;	! Version Date: 15-Feb-74

%(

***** Begin Revision History *****

21	-----	-----	MOVE THE DECLARATIONS FOR THE STRUCTURES RELBUFF
			AND PRELBUFF TO A REQUIRE FILE.
22	-----	-----	PUT A NUMBER OF UTILITY ROUTINES USED IN MAKING
			LISTINGS THAT WERE REPEATED IN BOTH THE MODULES
			"LISTOU" AND "OUTMOD" INTO THIS MODULE
			ROUTINES ARE:  ZOUTMSG,ZOUTSYM,ZOUTOCT,RADIX50,
			ZOUDECIMAL,ZOUOFFSET
24	-----	-----	MOVE THE ROUTINE "DMPRLBLOCK" INTO THIS MODULE
25	-----	-----	MOVE THE ROUTINE "LSTRLWD" FROM LISTOU INTO THIS MODULE
26	-----	-----	SHOULD BE SHIFTING RELOCATION BITS LEFT BY (35-COUNT)
			RATHER THAN (36-COUNT)
29	-----	-----	SHOULD BE SHIFTING RELOC BITS BY (36-COUNT*2)
30	-----	-----	MAKE "DMPMAINRLBF" INTO A GLOBAL ROUTINE RATHER
			THAN LOCAL TO "ZOUTBLOCK"

***** End Revision History *****

)%

	SWITCHES NOLIST;

	REQUIRE FIRST.BLI;
	REQUIRE TABLES.BLI;
	REQUIRE REQREL.BLI;

	SWITCHES LIST;
	SWITCHES LIST;






	EXTERNAL SYMRLBF,	!BUFFER FOR REL FILE BLOCKS OF TYPE 2
				! WHICH INCLUDES BOTH SYMBOLS AND GLOBAL REQUESTS
		LOCRLBF,	!BUFFER FOR REL FILE BLOCKS OF TYPE 
				! "LOCAL REQUEST" (USED WHEN A LABEL IS
				! DEFINED FOR WHICH THERE WERE FORWARD REFS)
		MAINRLBF;	!MAIN REL FILE BUFFER - USED FOR CODE AND DATA
				! AND ALSO FOR MISC (E.G. HISEG,END, ETC)
	MAP RELBUFF SYMRLBF:LOCRLBF:MAINRLBF;


	FORWARD DMPRLBLOCK;

	EXTERNAL HILOC;		!RELATIVE LOC OF THE WD OF HISEG CODE/DATA
				! CURRENTLY BEING BUFFERED







GLOBAL ROUTINE ZOUTBLOCK(ZBLKTYPE,RELBITS)=
%(***************************************************************************
	ROUTINE TO BUFFER ONE DATA WORD THAT IS TO BE OUTPUT TO THE
	REL FILE.
	CALLED WITH THE GLOBAL "RDATWD" CONTAINING THE DATA WORD.
	CALLED WITH THE ARGS:
		ZBLKTYPE - THE REL FILE BLOCK TYPE OF THE BLOCK INTO
			WHICH THIS DATA WORD SHOULD BE PLACED
		RELBITS - THE 2 RELOCATION BITS THAT SHOULD BE ASSOCIATED
			WITH THIS DATA WORD
	WE MAINTAIN THE SEPARATE REL FILE BUFFERS:
		1."SYMRLBF" - FOR REL FILE BLOCK TYPE 2 - THIS TYPE CODE IS USED FOR
			SYMBOL DEFINITIONS AND GLOBAL REQUESTS
		2."LOCRLBF" - FOR REL FILE BLOCK TYPE 10 - THIS TYPE CODE IS USED
			FOR LOCAL REQUESTS (IE DEFINITION OF LABELS TO
			WHICH THERE WERE FORWARD REFERENCES)
		3."MAINRLBF" - FOR ALL OTHER BLOCK TYPES (PRIMARILY THIS WILL
			BE BLOCK TYPE 1 - CODE AND DATA - BUT IT WILL
			ALSO BE USED FOR OTHER MISC BLOCK TYPES)
	WHEN EITHER "SYMRLBF" OR "LOCRLBF" IS FULL, WE MUST FIRST OUTPUT
	ANYTHING IN "MAINRLBF" BEFORE OUTPUTING THE CONTENTS OF THE FULL BUFFER
	(SINCE A LOCAL OR GLOBAL FIXUP CANNOT PRECEDE THE WORD OF DATA
	IT REFERS TO)
***************************************************************************)%
BEGIN
	EXTERNAL RDATWD;
	EXTERNAL DMPMAINRLBF;
	ROUTINE BUFFOUT(BUFFER,RELBITS)=
	%(********************
		ROUTINE TO PUT THE DATA WORD CONTAINED IN THE GLOBAL
		"RDATWD" INTO THE REL FILE BUFFER INDICATED BY "BUFFER".
		"PRLOCPTR" POINTS TO THE BYTE POINTER TO BE USED TO STORE
		THE RELOCATION BITS FOR THIS DATA WORD, "RELBITS" SPECIFIES
		THE RELOCATION BITS.
		IF "BUFFER" IS FULL, THE CONTENTS OF THE MAIN REL-FILE BUFFER "MAINRLBF"
		WILL BE OUTPUT TO THE REL FILE, FOLLOWED BY THE CONTENTS OF "BUFFER".
	*************************)%
	BEGIN
		MAP PRELBUFF BUFFER;	!"BUFFER" IS A PTR TO A REL FILE BUFFER
		IF .BUFFER[RDATCNT] EQL RBLKSIZ-2	!IF BUFFER IS FULL
		THEN
		BEGIN
			DMPMAINRLBF();	!OUTPUT THE CONTENTS OF "MAINRLBF"
					! AND REINITIALIZE MAINRLBF
			DMPRLBLOCK(.BUFFER,RBLKSIZ);	!OUTPUT THE CONTENTS OF "BUFFER"

			%(**INITIALIZE "BUFFER"***)%
			BUFFER[RDATCNT]_0;
			BUFFER[RRELOCWD]_0;
		END;

		BUFFER[RDATCNT]_.BUFFER[RDATCNT]+1;
		BUFFER[RRELOCWD]_.BUFFER[RRELOCWD] OR .RELBITS^(36-.BUFFER[RDATCNT]*2);	!STORE THE RELOC BITS
		BUFFER[.BUFFER[RDATCNT],RLDATWD]_.RDATWD;	!STORE THE DATA WORD
	END;	!END OF ROUTINE "BUFFOUT"



	SELECT .ZBLKTYPE OF NSET
	RSYMBOL:
		%(***FOR A GLOBAL REQUEST OR SYMBOL DEFINITION**)%
		BUFFOUT(SYMRLBF,.RELBITS);
	RLOCAL:
		%(***FOR A LOCAL REQUEST***)%
		BUFFOUT(LOCRLBF,.RELBITS);
	OTHERWISE:
		%(***FOR CODE AND DATA, AND FOR ALL OTHER BLOCK TYPES***)%
		BEGIN
			IF (.MAINRLBF[RDATCNT] EQL RBLKSIZ-2)	!IF THE MAIN BUFFER IS FULL
			   OR
			  (.MAINRLBF[RTYPE] NEQ .ZBLKTYPE)	! OR IS BEING USED FOR SOME OTHER
							! BLOCK TYPE THAN THIS DATA WORD SHOULD GO INTO
			THEN
			BEGIN
				DMPMAINRLBF();	!OUTPUT THE CONTENTS OF MAINRLBF AND
						! REINITIALIZE IT
				MAINRLBF[RTYPE]_.ZBLKTYPE;
			END; !OF ROUTINE "DMPMAINRLBF"

			%(**THE FIRST DATA WORD OF A BLOCK OF TYPE 1 (IE CODE/DATA)
				SHOULD CONTAIN THE REL ADDRESS FOR THE 1ST WD OF CODE/DATA**)%
			IF (.ZBLKTYPE EQL RCODE) AND (.MAINRLBF[RDATCNT] EQL 0)
			THEN
			BEGIN
				MAINRLBF[1,RLDATWD]_.HILOC;
				MAINRLBF[RDATCNT]_1;
				MAINRLBF[RRELOCWD]_RELRI^34;	!RELOC BITS FOR THE ADDR ("RELOC RIGHT")
			END;

			MAINRLBF[RDATCNT]_.MAINRLBF[RDATCNT]+1;	!INCR CT OF DATA WDS
			MAINRLBF[.MAINRLBF[RDATCNT],RLDATWD]_.RDATWD;	!BUFFER THE DATA WD
			MAINRLBF[RRELOCWD]_	!PUT THE RELOC BITS FOR THIS DATA WD INTO
				.MAINRLBF[RRELOCWD] OR .RELBITS^(36-.MAINRLBF[RDATCNT]*2);	! THE RELOC WD
		END;
	TESN;
END;  !END OF "ZOUTBLOCK"

GLOBAL ROUTINE DMPMAINRLBF=
%(***************************************************************************
		ROUTINE TO OUTPUT THE CONTENTS OF THE MAIN
		REL FILE BUFFER TO THE REL FILE AND REINITIALIZE
		THE BUFFER. IF THE BUFFER IS EMPTY, DOES NOTHING
***************************************************************************)%
BEGIN
	IF .MAINRLBF[RDATCNT] EQL 0 THEN RETURN;	!IF THERE ARE NO DATA WORDS
	DMPRLBLOCK(MAINRLBF,.MAINRLBF[RDATCNT]+2);	!OUTPUT THE CONTENTS OF "MAINRLBF"

	%(***INITIALIZE THE BUFFER**)%
	MAINRLBF[RDATCNT]_0;
	MAINRLBF[RRELOCWD]_0;
END;




GLOBAL ROUTINE INIRLBUFFS=
%(***************************************************************************
	ROUTINE TO INITIALIZE ALL REL FILE BUFFERS
***************************************************************************)%
BEGIN
	%(**INIT BUFFER USED FOR SYMBOL DEFS AND GLOBAL REQS**)%
	SYMRLBF[RTYPE]_RSYMBOL;	!BLOCK TYPE CODE USED BOTH FOR
				! SYM DEFS AND GLOBAL REQS
	SYMRLBF[RDATCNT]_0;	!CT OF DATA WDS IN THIS BLOCK
	SYMRLBF[RRELOCWD]_0;	!RELOCATION BITS FOR THIS BLOCK

	%(**INIT BUFFER USED FOR LOCAL REQS**)%
	LOCRLBF[RTYPE]_RLOCAL;	!BLOCK TYPE FOR LOCAL REQUESTS
	LOCRLBF[RDATCNT]_0;
	LOCRLBF[RRELOCWD]_0;

	%(**INIT BUFFER USED FOR CODE/DATA AND FOR ALL OTHER BLOCK TYPES**)%
	MAINRLBF[RDATCNT]_0;
	MAINRLBF[RRELOCWD]_0;
END;
GLOBAL ROUTINE DMPRLBLOCK(RLBLK,WDCT)=
%(***************************************************************************
	ROUTINE TO OUTPUT A BLOCK OF REL CODE POINTED TO BY "RLBLK" TO THE RELFILE.
	WDCT IS THE NUMBER OF WORDS (INCLUDING HEADER WDS) IN THE BLOCK.
***************************************************************************)%
BEGIN
	EXTERNAL LSTOUT;	!TO LIST A CHAR
	EXTERNAL LSTRLWD;	!LIST A WD OF THE REL FILE IN THE REL-EXPANDED LISTING
	EXTERNAL RELOUT;	!ROUTINE TO WRITE A WIRD IN THE REL FILE

	STRUCTURE PVECTOR[WD]=	!STRUCTURE FOR A PTR TO A VECTOR
		(@.PVECTOR + .WD);
	MAP PVECTOR RLBLK;


	INCR I FROM 0 TO (.WDCT-1)
	DO (CHR_.RLBLK[.I]; RELOUT());

	IF .FLGREG<EXPAND> AND .FLGREG<LISTING>	!IF A LISTING OF THE REL FILE WAS REQUESTED
	THEN
	BEGIN
		CHR_#15; LSTOUT(); CHR_#12; LSTOUT();	!CR LF
		INCR I FROM 0 TO (.WDCT-1)
		DO (R2_.RLBLK[.I]; LSTRLWD());	!LIST EACH WD IN THE BLOCK
	END;
END;

GLOBAL ROUTINE LSTRLWD=
%(***************************************************************************
	ROUTINE TO LIST THE REL-FILE WORD
	IN THE GLOBAL REGISTER "R2"
***************************************************************************)%
BEGIN
	EXTERNAL LSTOUT;
		DECR J FROM 11 TO 0
		DO (	R1 _ 0; LSHC(R1,3);
			CHR _ #60[.R1]<0,0>;
			LSTOUT();
		   );
		CRLF;

END;


EXTERNAL LSTOUT;
!
!UTILITY ROUTINES USED FOR MAKING LISTINGS - THESE WERE MOVED INTO
! THIS MODULE FROM LISTOU AND OUTMOD
!
GLOBAL ROUTINE ZOUTMSG(PTR)=
BEGIN
!TO PRINT AN ASCIZ STRING
	PTR_(.PTR-1)<0,7>;
	UNTIL (CHR_SCANI(PTR)) EQL 0 DO LSTOUT();
END;
GLOBAL ROUTINE ZOUTSYM=
!R2 CONTAINS SYMBOL IN SIXBIT TO BE LISTED
DECR I FROM 5 TO 0 DO
BEGIN
	R1 _ 0; LSHC(R1,6);
	IF .R1 GTR 0
	  THEN (CHR _ .R1+#40; LSTOUT())
	  ELSE RETURN
END;
!
GLOBAL ROUTINE ZOUTOCT=	!LIST OCTAL HALF WORD OR FULL WORD
			!R2<LEFT> CONTAINS HALF WORD OCTAL VALUE
BEGIN
	REGISTER I;
	R1 _ 0; I _ 6;
	DO (LSHC(R1,3); I_ .I-1; IF .I EQL 0 THEN EXITLOOP;) WHILE .R1 EQL 0;
	DO ( CHR_#60[.R1]<0,0>; LSTOUT();
		R1 _ 0; LSHC(R1,3);
	   ) WHILE (I_.I-1) GEQ 0;
	.VREG
END; !OF ZOUTOCT
GLOBAL ROUTINE RADIX50=	!R2 CONTAINS THE SYMBOL IN SIXBIT LEFT JUSTIFIED
			!CONVERT IT TO RADIX 50
BEGIN
REGISTER R50;
MACRO SIXALPHA(X) =MOVEI(VREG,-#40,X) LEQ ("Z"-#100)$, !SIXBIT ALPHA
	SIXDIGIT(X) =MOVEI(VREG,-#20,X) LEQ 9$; !SIXBIT DIGIT
R50_0;
DO (
	R1 _ 0; LSHC(R1,6);
	IF SIXALPHA(R1) THEN R1 _ .R1 -#26
	  ELSE IF SIXDIGIT(R1) THEN R1 _ .R1 -#17
	    ELSE R1 _ #45;	!A . BY DEFAULT
	R50 _ .R50*#50; R50 _ .R50 + .R1;
   ) WHILE .R2 NEQ 0;
RETURN .R50
END;

GLOBAL ROUTINE ZOUDECIMAL=
BEGIN
!	DECIMAL OUTPUT VALUE IN R1
LOCAL Z[6];
INCR I FROM 0 TO 5 DO
	(Z[.I] _ (.R1 MOD 10);
	 R1 _ .R1/10;
	 IF .R1 EQL 0 THEN
		(DECR J FROM .I TO 0 DO (CHR _  .Z[.J] +#60; LSTOUT());
		 RETURN
		);
	)
END;
GLOBAL ROUTINE ZOUOFFSET=
BEGIN
LOCAL Z[6];
!LIST IN ASCII THE VALUE OF R1 A REGISTER
IF .R1 LSS 0 THEN CHR _ "-" ELSE CHR _ "+";
LSTOUT();
R2<LEFT> _ ABS(.R1);
ZOUTOCT();	!OCTAL OUTPUT VALUE IN R2<LEFT>
END;