perm filename HEAD2[S,AIL] blob sn#073845 filedate 1973-11-22 generic text, type T, neo UTF8
COMMENT ⊗   VALID 00009 PAGES VERSION 17-2(49)
RECORD PAGE   DESCRIPTION
 00001 00001
 00003 00002	HISTORY
 00004 00003	HISTORY
 00024 00004	DSCR EXCHOP
 00028 00005	DSCR LODBLK (TYPE,TYP1,NAME,NAME1,COUNT,COUNT1,RELOC)
 00036 00006	  MACROS FOR MANIPULATING SEMBLKS (SEE SAIL DATA DESCRIPTIONS)
 00038 00007	  MACROS FOR MANIPULATING SEMANTICS, CALLING GENERATOR ROUTINES,
 00042 00008	 Q-STACK HANDLERS
 00046 00009	THE VERY END
 00070 ENDMK
⊗;
COMMENT ⊗HISTORY
AUTHOR,REASON
021  202100000061  ⊗;


COMMENT ⊗
VERSION 17-2(49) 11-18-73 
VERSION 17-2(48) 11-18-73 BY RHT FEAT %AJ% REORGANIZE FILES: COMPILER SPECIFIC STUFF HERE

⊗;
COMMENT ⊗HISTORY
AUTHOR,REASON
021  102100000002  ⊗;


COMMENT ⊗
VERSION 17-2(47) 11-10-73 BY RHT ADD CORERR, ERRPRI, ERFLGS BITS
VERSION 17-1(46) 7-26-73 BY RHT TRY VERSION 17
VERSION 17-1(45) 7-26-73 *********************
VERSION 16-2(44) 7-9-73 BY JRL REMOVE LAST REFERENCES TO DCS SWITCH
VERSION 16-2(43) 4-23-73 BY RHT CHANGE ARGTYP TO RFITYP
VERSION 16-2(42) 2-7-73 BY RHT ADD TYPE FOR ARG LIST ITEM
VERSION 16-2(41) 1-28-73 BY JRL PUT QBIND,FBIND HERE SO STATS CAN USE
VERSION 16-2(40) 1-23-73 BY RHT MAKE NIC & UNBOUND THE SAME
VERSION 16-2(39) 1-23-73 BY JRL CHANGE CODE FOR UNBND
VERSION 16-2(38) 1-8-73 BY JRL ADD MAXLOC MAXIMUM NUMBER OF FOREACH LOCAL ITEMVARS ALLOWED
VERSION 16-2(37) 12-13-72 BY jrl BUG #KS# ADD LOADVR SWITCH
VERSION 16-2(36) 11-21-72 
VERSION 16-2(35) 11-10-72 BY HJS MODIFY QPOP TO TAKE AS AN ARGUMENT AN ADDRESS FOR THE POPPED ENTRY
VERSION 16-2(34) 10-16-72 BY JRL CHANGE INVTYP TO 31 TO ALLOW CONTEXT ARRAY ITEMS
VERSION 16-2(33) 9-15-72 BY RHT ADD USER TABLE ENTRIES FOR INTERRUPTS
VERSION 16-2(32) 8-27-72 BY RHT PUT CELL FOR STACK UNWINDER RET ADRS IN USER TABLE
VERSION 16-2(31) 8-23-72 BY JRL ADD UNBND "ITEM"
VERSION 16-2(30) 8-20-72 BY RHT MODIFY USER TABLE
VERSION 16-2(29) 8-6-72 BY RHT ADD PRILIS TO USER TABLE
VERSION 16-2(28) 8-3-72 BY JRL ADD MPBIND TO TBITS DEFS FOR MATCHING PROCEDURES
VERSION 16-2(27) 7-27-72 BY RHT MAKE MACRO FOR DECLARING PD. ENTRIES
VERSION 16-2(26) 7-20-72 BY JRL CHANGE ARRTYP VALUE
VERSION 16-2(25) 7-20-72 BY RHT ADD PROCESS ITEM (TYPE 11)
VERSION 16-2(24) 6-20-72 BY DCS BUG #HU# BETTER TTY INFORMATION
VERSION 16-2(23) 5-16-72 BY DCS INTRODUCE VERSION 16
VERSION 15-2(9-22) 5-4-72 LOTS OF THINGS
VERSION 15-2(8) 2-19-72 BY RHT THE BRAVE NEW WORLD
VERSION 15-2(7) 2-5-72 BY DCS BUG #GJ# ADD LSTON LISTING CONTROL STUFF
VERSION 15-2(6) 2-5-72 BY DCS BUG #GI# REMOVE TOPSTR DUE TO NEW `CAT'
VERSION 15-2(5) 2-1-72 BY DCS BUG #GE# INSTALL SYMB %ALLOC BLK INDICES
VERSION 15-2(4) 1-31-72 BY DCS BUG #GE# UPDATE USER TABLE, %ALLOC BITS, INDICES
VERSION 15-2(3) 1-3-72 BY DCS BUG #FX# REMOVE COM2, COM2SW COMPLETELY
VERSION 15-2(2) 12-24-71 BY DCS BUG #FF# REMOVE SAILRUN(ASSUME RUNTIM OR LIB)
VERSION 15-2(1) 12-2-71 BY DCS INSTALL VERSION NUMBER

⊗;
DSCR EXCHOP
DES Exchange Semantic entries in PNT,TBITS,SBITS with those
 in PNT2,TBITS2,SBITS2 -- since "GENMOV" routines generally
 operate on the first set of ACs.
⊗
DEFINE EXCHOP	<
	EXCH	PNT,PNT2
	EXCH	TBITS,TBITS2
	EXCH	SBITS,SBITS2	>

DSCR MOVOPS
DES Copy Semantic entries from PNT,TBITS,SBITS into
 PNT2,TBITS2,SBITS2
⊗;
DEFINE MOVOPS	<
	MOVE	PNT2,PNT
	MOVE	TBITS2,TBITS
	MOVE	SBITS2,SBITS
>
DSCR LODBLK (TYPE,TYP1,NAME,NAME1,COUNT,COUNT1,RELOC)
CAL MACRO
PAR TYPE, TYP1 are the symbolic and numeric reps of
  a LOADER block type
 NAME, NAME1 are the labels to be given the block and
  its descriptor (optional, see below)
 COUNT, COUNT1 are the data count and the total count
  for the descriptor (optional, etc.)
 RELOC describes the initial relocation bits
RES if NAME1 is present, a descriptor word is put out
  to provide GBOUT with count info for entire block
 Then the Type,,count word is output, labeled NAME
 Following is the RELOC word, then a block long enough
  to hold data
SEE GBOUT, Loader blocks (ENTTAB, BINTAB, etc.)
⊗
DEFINE LODBLK (TYPE,TYP1,NAME,NAME1,COUNT,COUNT1,RELOC) <

; Create LOADER OUTPUT BLOCK of type TYPE (really the
;  integer TYP1.  Name it NAME.  Give it a data count
;  of COUNT.  If there is a NAME1, create a descriptor
;  for GBOUT of the form [(COUNT1 or COUNT+2),,NAME].
;  Issue a reloc word of (RELOC or 0).
;  Put out a COUNT-word block for holding the data

IFNB (NAME1) <


;DESCRIPTOR FOR GBOUT ROUTINE
↑↑NAME1:
IFNB (COUNT1) <
	XWD	COUNT1,NAME;>	XWD   COUNT+2,NAME
>

;LOADER BLOCK HEADER
↑↑NAME: XWD	TYP1,COUNT

;RELOCATION BITS
IFNB (RELOC) <
	RELOC;>			0

;DATA WORDS
	BLOCK	COUNT
>;LODBLK
;  MACROS FOR MANIPULATING SEMBLKS (SEE SAIL DATA DESCRIPTIONS)

DSCR GETBLK (X)
CAL MACRO
PAR X is address (optional)
RES into LPSA (and X) is put address of new Semblk (zeroed)
SID LPSA, X changed -- probably TEMP too
SEE BLKGET, the routine it calls, and main SAIL data descriptions
⊗
DEFINE GETBLK ( X ) <
	PUSHJ	P,BLKGET
	IFDIF <X><>,<HRRM	LPSA,X>>

DSCR FREBLK (X)
CAL MACRO
PAR X (optional) is address of Semblk (LPSA is default)
RES Semblk is released to free Semblk list
SID TEMP, LPSA changed
SEE BLKFRE, the routine used, and main SAIL data descriptions
⊗
DEFINE FREBLK ( X ) <
	IFIDN <><X>,<PUSH P,LPSA;>  PUSH P,X
	PUSHJ	P,BLKFRE
	>

;	TAKE CDR OF A LINKED LIST, GOING ALONG LINK Y. GO TO Z
;		IF LIST IS EXHAUSTED.
DEFINE RIGHT (X,Y,Z ) <
	IFDIF <X><>,<MOVE LPSA,X>
	HRRZ	LPSA,Y(LPSA)
	IFDIF <Z><>,<JUMPE	LPSA,Z>>

;	SAME FOR MOVING LEFT ALONG A LINK.
DEFINE LEFT (X,Y,Z) <
	IFDIF <><X>,<MOVE LPSA,X>
	HLRZ	LPSA,Y(LPSA)
	IFDIF <><Z>,<JUMPE LPSA,Z>>
;  MACROS FOR MANIPULATING SEMANTICS, CALLING GENERATOR ROUTINES,
;  GENERATING CALLS ON RUNTIME ROUTINES ON BEHALF OF COMPILED CODE, ETC.

; PICK UP SEMANTICS WORDS FOR A PARSER TEMPORARY.
DEFINE GETSEM (X) <
	MOVE	PNT,GENLEF+X
	PUSHJ	P,GETAD	>

; SAME, BUT PUT SEMANTICS IN TBITS2,SBITS2
DEFINE GETSM2 (X) <
	MOVE	PNT2,GENLEF+X
	PUSHJ	P,GETAD2 >


DSCR GENMOV (Z,X,Y)
DES MACRO TO FACILITATE CALLING GENERATOR SUBROUTINES.
PAR Z IS ROUTINE NAME.
 X IS FLAGS (OPTIONAL)
 Y IS TYPE (INTEGER,,,) TO BE PASSED IN REGISTER B.
RES Calls routine after setting up AC's.
⊗;
DEFINE	GENMOV (Z,X,Y) <
	IFDIF <X><>,<HRRI FF,X>
	IFDIF <Y><>,<HRRI B,Y>
	PUSHJ	P,Z>



DSCR XCALL (X)
CAL MACRO
DES Facilitates calling runtine functions.
PAR X is the "NAME" of such a function, all of which
 are named in the beginning of the file "GEN"
RES a call (PUSHJ) to the routine is generated and fixed up
SID AC A is clobbered.
SEE XCALLQ
⊗;
DEFINE	XCALL	' (X)	<
	MOVEI	A,LIBTAB+R'X	;FIXUP LOCATION.
	PUSHJ	P,XCALLQ
	>

DSCR LPCALL (X,Y,Z)
CAL MACRO
DES Facilitates EMITting calls to LEAP interpreter
 functions. 
PAR X is function "NAME" (list is located at beginning of file "LEAP")
 Y (optional) displacement from X.
 Z tells what kind of call it is.  If non-null, we use the
  index computed by STCHK (Q.V.) to add to X, otherwise
  just the type bits computed by STCHK.
SEE LEAPC1, LEAPC2, STCHK
⊗;
DEFINE LPCALL ' (X,Y,Z) <
	MOVEI	A,L'X		;ROUTINE NAME.
	IFDIF <Y><>,<ADD A,Y>
	IFIDN <Z><>,<PUSHJ P,LEAPC1;> PUSHJ P,LEAPC2
	>

DSCR XPREP
CAL MACRO
DES Make sure AC 1 is free (I.E. erase the ACKTAB entry for it --
 so that a call on a runtime routine which returns a result
 in AC 1 can now be EMITted.
SEE STORZ
⊗;
DEFINE XPREP	<
	PUSHJ	P,[
		HRRI	D,1
		JRST	STORZ]
	>


DSCR EMIT (INSTR)
CAL MACRO
DES Facilitates calling the EMITTER for us.
PAR INSTR is the instruction and "DIRECTIVE" bits to the
 EMITTER.
⊗;
DEFINE	EMIT	(INSTR) <
	MOVE	A,[INSTR]
	PUSHJ	P,EMITER	;CALL EMITER
>

; Q-STACK HANDLERS

DSCR QPUSH (X,Y)
CAL MACRO
DES calls the generalized stack routine BPUSH.
PAR X (optional) is name of stack to be used.
 Y (optional) is data word to be pushed (AC A).
SID A, LPSA, TEMP changed
SEE BPUSH
⊗
DEFINE	QPUSH (X,Y)	<
	IFDIF <X><>,<MOVEI LPSA,X>
	IFDIF <Y><>,<MOVE A,Y>
	PUSHJ	P,BPUSH		>

DSCR QPOP
CAL MACRO
DES Facilitates calls on generalized stack routine BPOP
PAR X is name of the stack to be used (optional).. otherwise
 pointer in LPSA.
 Y (optional) is where the popped entry is to be returned.
RES Popped entry is returned in AC A and Y (optional).
SEE BPOP
⊗;
DEFINE	QPOP (X,Y)	<
	IFDIF <X><>,<MOVEI LPSA,X>
	PUSHJ 	P,BPOP
	IFDIF <Y><>,<MOVEM A,Y>	>

DSCR QLOOK
CAL MACRO
DES Allows one to get hold of the top element in the Qstack X
PAR X is the name of the stack to be used
RES the pointer to the top element in the stack is returned in AC A.
⊗
DEFINE  QLOOK (X)	<	
	HLRZ	A,X		>

DSCR QTAKE (X)
CAL MACRO
DES facilitates "taking" things out of one of the generalized
 QSTACKS (uses routine QTAK).
PAR X is name of Qstack to be used.
 AC B must have a QPUSH/QPOP-like pointer to the element requested.
RES Popped result returned in register A.
 **** SKIPS IF SUCCESSFUL ****
SEE QTAK
⊗;
DEFINE	QTAKE	(X)	<
	IFDIF <X><>,<MOVEI LPSA,X>
	PUSHJ	P,QTAK		>

DSCR QBACK 
CAL MACRO
PAR In AC B must be a QSTACK descriptor
RES B's descriptor is "popped" by one, word put in AC A.
 No storage is released
 **** SKIPS IF SUCCESSFUL ****
DES See BBACK routine in TOTAL for details of operation, AC usage, etc.
SEE BBACK
⊗

DEFINE QBACK <
	PUSHJ	P,BBACK
>


DSCR QFLUSH (X) 
CAL MACRO
PAR Qstack descriptor address
RES All storage is released for the stack, and the descriptor
 address is zeroed.
DES Used when QBACK and QTAKE operations have left blocks around.
 There should always be one actual PDP-type cell which points
 to the top (is only used in QPUSH and QPOPs).  This should be
 pointed at to flush the stack.
SEE BFLUSH
⊗

DEFINE QFLUSH (X) <
IFDIF <><X> <
	MOVEI	LPSA,X
>
	PUSHJ	P,BFLUSH
>

DSCR QBEGIN (X)
CAL MACRO
PAR X → A QPDP, LOADED TO LPSA IF PRESENT
RES B contains QPDP for QTAKEing first word, 0 if no stack
SEE BBEG
⊗
DEFINE QBEGIN (X)<
IFDIF <><X> <
	MOVEI	LPSA,X
>
	PUSHJ	P,BBEG
>
;THE VERY END

SUBTTL	SAIL ASSEMBLY SPECIFICATIONS