Google
 

Trailing-Edge - PDP-10 Archives - decuslib20-03 - decus/20-0078/rts/simmc2.mac
There are 2 other files named simmc2.mac in the archive. Click here to see a list.
	SEARCH	SIMMAC
	SALL
	CUNIV	SIMMC2	;[104]
;AUTHOR:	STEFAN ARNBORG
;VERSION:	 1
;PURPOSE:	PROVIDES PASS 2 GLOBAL SYMBOLS AND MACROS
;CONTENTS:	DEFINITION OF GLOBAL RUNTIME SYMBOLS,
;		PASS 2 UUO:S
;		TAG FIELD VALUES
;		GLOBAL ACCUMULATORS IN PASS 2
;		AND ALL PASS 2 FIELDS AND RECORDS
	IF1,<END>
	PRINTX	UPDATE: 19	18-Mar-77/LE
; CODE GENERATION ROUTINES
DEFINE	CGINIT=<
DEFINE	GPUSHJ(A)<
	IFNDEF	A'$,<SETZM	YLXIAC>
	L	[PUSHJ	XPDP,A]
	IFGE	<A-400K>,<GENABS
	>
	IFL	<A-400K>,<GENFIX
	>
>
DEFINE	GJRST(A)<
	SETZM	YLXIAC
	L	[JSP	A]
	IFGE	<A-400K>,<GENABS
	>
	IFL	<A-400K>,<GENFIX
	>
>
;--- OPDEF'S
IFDEF O2GWD,<OPDEF	GENDW	[PUSHJ	XPDP,O2GWD]>	;;OUTPUT DOUBLE WORD CONSTANT IN X0-X1
OPDEF	GENOP	[PUSHJ	XPDP,O2GI]	;;OUTPUT INSTRUCTION FROM YO2ADI AND YOPCOD(PREPARED BY O2AD)
OPDEF	GETAD	[PUSHJ	XPDP,O2AD]	;;PREPARE ADDRESS FIELD FOR ZQU POINTED TO BY X1
OPDEF	MEMOP	[PUSHJ	XPDP,CGMO]	;; SKIP IF XP1 POINTS TO DIRECTLY ADDRESSABLE (ZNO) OPERAND
OPDEF	IFMEMO	[PUSHJ	XPDP,CGMO1]	;;REVERSE TO MEMOP
DEFINE	CONST	<WHENNOT XP1,ZCN>
OPDEF	IMMOP	[PUSHJ	XPDP,CGIM]	;;SKIP IF XP1 POINTS TO ZCN NODE WHICH IS IMMEDIATE OPERAND
OPDEF	IFIMMO	[PUSHJ	XPDP,CGIM1]	;;REVERSE TO IMMOP
OPDEF	COMPVAL	[PUSHJ	XPDP,CGVA]
OPDEF	COMPAD	[PUSHJ	XPDP,CGAD]
OPDEF	COMPCA	[PUSHJ	XPDP,CGCA]
OPDEF	COMPCC	[PUSHJ	XPDP,CGCC]
OPDEF	COMPCO	[PUSHJ	XPDP,CGCO]
OPDEF	CLFIX	[PUSHJ	XPDP,O2CF]	;;CLEAR FIXUP FOR REUSE
OPDEF	DEFIX	[PUSHJ	XPDP,O2DF]	;;DEFINE FIXUP
OPDEF	DISPLAY	[PUSHJ	XPDP,CADS]
OPDEF	GENABS	[PUSHJ	XPDP,O2GA]	;;GENERATE ABSOLUTE INSTRUCTION
OPDEF	GENFIX	[PUSHJ	XPDP,O2GF]	;;GENERATE FIXUP TYPE INSTRUCTION
OPDEF	GENREL	[PUSHJ	XPDP,O2GR]	;;GENERATE RELOCATED INSTRUCTION
IFDEF CGRD,<
OPDEF	GENRLD	[PUSHJ	XPDP,CGRD]>	;;GENERATE WORD RELOCATED TO CODE STREAM
OPDEF	GENWRD	[PUSHJ	XPDP,O2GW]	;;GENERATE ONE-WORD CONSTANT
OPDEF	INVAL	[PUSHJ	XPDP,O2IV]	;;INPUT (18-BIT) VALUE TO X0 FROM IC1
DEFINE NEXTOP=<STEP	XP1,ZNO>
OPDEF	NEXT	[POPJ	XPDP,]
OPDEF	OP	[HRLI]			;;GET INSTR LEFT HALFWORD FROM
					;;IMMEDIATE OPERAND (IN PARENTHESES)
OPDEF	OPZ	[HRLZI]			;;AS OP, BUT CLEAR RIGHT HALF (ADDRESS FIELD)
OPDEF	GETAC2	[PUSHJ	XPDP,CGG2]
OPDEF	GETAC3	[PUSHJ	XPDP,CGG3]
OPDEF	GETAC4	[PUSHJ	XPDP,CGG4]
OPDEF	RELAC2	[PUSHJ	XPDP,CGR2]
OPDEF	RELAC3	[PUSHJ	XPDP,CGR3]
OPDEF	RELAC4	[PUSHJ	XPDP,CGR4]
OPDEF	ACFIELD		[POINT	4,0,12]
OPDEF	INDEXFIELD	[POINT	4,0,17]	;; USED FOR CONSTRUCTING GENERATED INSTRUCTIONS
OPDEF	LONG	[PUSHJ	XPDP,CGLO]	; SKIP IF X1 POINTS TO ZNO FOR LONG (TWO AC:S) QUANT
OPDEF	IFLONG	[PUSHJ	XPDP,CGLO1]	; OPPOSITE TO LONG
>


; ROUTINE FOR OUTPUT TO ATR.TMP

DEFINE PUTATR(ACC)<
	SOSGE	YBHATR+2
	EXEC	O2ATR
	IDPB	ACC,YBHATR+1
>
	SUBTTL	SWITCH DECLARATIONS


;	COMPILER SWITCH SWITCHES
;	========================

	EXTERNAL	YSWITCH

	DSW	(YSWC,YSWITCH,35)
	DSW	(YSWD,YSWITCH,34)
	DSW	(YSWI,YSWITCH,33)
	DSW	(YSWR,YSWITCH,32)
	DSW	(YSWY,YSWITCH,31)
	DSW	(YSWA,YSWITCH,30)
	DSW	(YSWM,YSWITCH,29)
	DSW	(YSWQ,YSWITCH,28)
	DSW	(YSWW,YSWITCH,27)

;  SWITCHES FOR COMPILE
	EXTERNAL	YLINK

	DSW	(SVALUE,YLINK,0)
	DSW	(SADDRE,YLINK,1)
	DSW	(SCADDR,YLINK,2)
	DSW	(SCCOND,YLINK,3)
	DSW	(SCONDI,YLINK,4)
	DSW	(SCGSKP,YLINK,5)


; DEBUG SWITCHES
	;[247] Same definitions, dummy globals for production version
	EXTERN YCGDB,YM2DB,YO2DB

	DSW	(SCGDB1,YCGDB,1)
	DSW	(SCGDB2,YCGDB,2)
	DSW	(SCGDB3,YCGDB,3)
	DSW	(SM2DB1,YM2DB,1)
	DSW	(SM2DB3,YM2DB,2)
	DSW	(SM2DB3,YM2DB,3)
	DSW	(SO2D1,YO2DB,34)
	DSW	(SO2D2,YO2DB,33)
	DSW	(SO2D3,YO2DB,32)
	DSW	(SO2D4,YO2DB,31)
	DSW	(SCADB5,YCADB,32)
;  MASKS FOR A,M,Q AND W
;  THESE MASKS ARE USED AS OPERANDS TO THE $OPT OPERATOR IN IC1

	QSWA==1B30
	QSWM==1B29
	QSWQ==1B28
	QSWW==1B27

	
; MACROS FOR ERROR MESSAGES
;
; OPERANDS:
;	OP	EFFECTIVE ADDRESS GIVING THE LEXICAL ID OF AN IDENTIFIER OR OPERATOR
;		TO BE EDITED INTO THE MESSAGE. USUALLY ACTUAL PARAMETER IS (XCUR).
;	NO	DECIMAL MESSAGE NUMBER (THREE NUMBER SERIES FOR PASS2 WARNING, ERROR, AND FATAL MESSAGE, RESPECTIVELY)
;	MESS	TEXT TO BE DUMPED WHEN THE MACRO IS EXECUTED IN THE TEST VERSION,
;		AND A COMMENT IN THE PRODUCTION VERSION
DEFINE WARNING(NO,MESS)=<
	WARN	NO
		IFN QDEBUG,<NOP	[ASCIZ/MESS/]
>>
DEFINE ERROR1(NO,OP,MESS)=<
		IFG <^D'NO>,<
			IFL <^D'NO-20>,<
				ERRR	^D'NO,OP>
			IFGE <^D'NO-20>,<
				IFL <^D'NO-40>,<
					ERR1<^D'NO-20>,OP>
				IFGE <^D'NO-40>,<CFAIL TOO LARGE ERROR CODE IN ERROR1>
			>
		>
		IFL <^D'NO>,<CFAIL NEGATIVE ERROR CODE IN ERROR1>
		IFN QDEBUG,<NOP	[ASCIZ/MESS/]
>>
DEFINE ERROR2(NO,MESS)=<
	ERR2	^D'NO
		IFN QDEBUG,<NOP	[ASCIZ/MESS/]
>>
DEFINE FATAL(NO,MESS)=<
	FATA	^D'NO
		IFN QDEBUG,<NOP	[ASCIZ/MESS/]>
>
DEFINE SEVER1(NO,OP,MESS)=<
		IFG <^D'NO>,<
			IFL <^D'NO-20>,<
				SEV	^D'NO,OP>
			IFGE <^D'NO-20>,<
				IFL <^D'NO-40>,<
					SEV1	<^D'NO>,OP>
				IFGE <^D'NO-40>,<CFAIL HIGH CODE NO TO SEVER1>
			>
		>
		IFL <^D'NO>,<CFAIL NEGATIVE NO TO SEVER1>
		IFN QDEBUG,<NOP	[ASCIZ/MESS/]
>>
DEFINE SEVER2(NO,MESS)=<
	SEV2	<<^D'NO>B24>
		IFN QDEBUG,<NOP [ASCIZ/MESS/]
>>
; USEFUL CONSTANTS
; FIXUP STATUS CODES
SCALAR <QA,QB,QC,QD,QE1,QF,QG>
; EXPRESSION TREE AND OPERAND STACK NODE TAG VALUES
SCALAR <QZOS,QZLI,QZCN,QZID,QZNS,QZNN>
; EXPRESSION NODE ZNNCOD VALUES
SCALAR<QCODCA,QCODAR,QCODVA,QCODAA,QCODRA>
; OPERAND CHECKING ROUTINE CODES
SCALAR	<Q,QCSAME,QCLEFT,QCHIGH,QCREAL,QCINT>
SCALAR	<Q,QRCLAS,QRBOOL,QRLAST,QRSAME>
SCALAR	<Q,Q,Q,Q,Q,Q,Q,Q,Q,Q,QARITH,QTXREF,QNREF,QNRFBO,QFTREF>
;
; REGISTERS(ACCUMULATORS) USED GLOBALLY IN PASS 2
XCUR==10
XV1==11
XV2==12
XP1==13
XP2=14
XL1=15
XL2=16
XZHE=	X7
DSW	SCERFL,YCERFL,36
EXTERN	YCERFL,YM2DB
; DEFINITIONS OF PASS 2 FIELDS
; DICTIONARY AND REDECLARATION STACK ENTRY
DF ZDCZDC,0,18,17
DF ZDCZQU,0,18,35
; BLOCK STACK ENTRIES
DF ZBSZDC,0,18,17
DF ZBSZHE,0,18,35
; FIXUP TABLE ENTRY
DF ZFXTYP,0,9,8
DF ZFXCOD,0,9,17
DF ZFXVAL,0,18,35
; OPERAND STACK AND EXPRESSION TREE NODES
DF ZNOTER,0,1,0
DF ZNOLST,0,1,1
DF ZNOTYP,0,4,5
DF ZOSLB,0,1,35
; CONSTANT OPERAND
DF ZCNTYP,0,4,11
DF ZCNVAL,1,36,35
; IDENTIFIER OPERAND
DF ZLILID,0,18,35
; SEMANTIC IDENTIFIER
DF ZIDINB,0,1,6
DF ZIDSYS,0,1,7
DF ZIDTYP,0,4,11
DF ZIDMOD,0,3,14
DF ZIDKND,0,3,17
DF ZIDZHE,0,18,35
DF ZIDZQU,1,18,35
DF ZIDZDE,1,18,17
; EXPRESSION NONTERMINAL NODE
DF ZNSTYP,0,4,11
DF ZNSMOD,0,3,14
DF ZNSKND,0,3,17
DF ZNSZNO,0,18,35
DF ZNSZQU,1,18,17
DF ZNSROR,1,1,18
DF ZNSSEF,1,1,19
DF ZNSLEV,1,4,23
DF ZNSGEN,1,12,35
; COMPILED RESULT DESCRIPTION
DF ZNNTYP,0,4,11
DF ZNNMOD,0,3,14
DF ZNNKND,0,3,17
DF ZNNZNO,0,18,35
DF ZNNZQU,1,18,35
DF ZNNCOD,1,18,17
; RELOCATION CODE BITS IN IC2 RECORD
DF ZQREL,0,3,2	; RELOC IN LEFT HALFWORD
DF ZQRER,0,3,20	; RELOC IN RIGHT HALF
; PASS 2 RECORDS
DR ZDC,1
DR ZBS,1
DR ZFX,1
DR ZNO,2
DR ZMP,4,ZDETYP,0	; THIS ONE IS DEFINED WITHOUT TAG FIELD IN MCR.MAC
DR ZCN,2,ZNOTYP,QZCN
DR ZLI,2,ZNOTYP,QZLI
DR ZOS,2,ZNOTYP,QZOS
DR ZID,2,ZNOTYP,QZID
DR ZNS,2,ZNOTYP,QZNS
DR ZNN,2,ZNOTYP,QZNN

;RECORD DISCRIMINATION MACROS

DEFINE	RECTYPE(XB,O)<
	$%REC==XB
	$%O=0
	IFNB <O>,<$%O==O>
>
DEFINE	IS(ZR)<
	IFG $%REC-17,<CFAIL ILLEGAL IS>
	LF()	ZR'%F($%REC,$%O)
	CAIE	ZR'%V
	$%REC==77
>
$%REC==77	;INITIAL VALUE
 END