Google
 

Trailing-Edge - PDP-10 Archives - BB-H138B-BM - language-sources/glxmac.mac
There are 42 other files named glxmac.mac in the archive. Click here to see a list.
	UNIVER	GLXMAC  --  Parameter File For GLXLIB
	SUBTTL	/PJT/MLB/DC/PJT 3-Oct-79


;
;
;                COPYRIGHT (c) 1975,1976,1977,1978,1979
;                    DIGITAL EQUIPMENT CORPORATION
;
;     THIS SOFTWARE IS FURNISHED UNDER A LICENSE AND MAY  BE  USED
;     AND COPIED ONLY IN ACCORDANCE WITH THE TERMS OF SUCH LICENSE
;     AND WITH THE INCLUSION OF THE ABOVE COPYRIGHT NOTICE.   THIS
;     SOFTWARE  OR ANY OTHER COPIES THEREOF MAY NOT BE PROVIDED OR
;     OTHERWISE MADE AVAILABLE TO ANY OTHER PERSON.  NO  TITLE  TO
;     AND OWNERSHIP OF THE SOFTWARE IS HEREBY TRANSFERRED.
;
;     THE INFORMATION  IN  THIS  SOFTWARE  IS  SUBJECT  TO  CHANGE
;     WITHOUT  NOTICE  AND SHOULD NOT BE CONSTRUED AS A COMMITMENT
;     BY DIGITAL EQUIPMENT CORPORATION.
;
;     DIGITAL ASSUMES NO RESPONSIBILITY FOR THE USE OR RELIABILITY
;     OF  ITS  SOFTWARE  ON  EQUIPMENT  WHICH  IS  NOT SUPPLIED BY
;     DIGITAL.

	SEARCH	GALCNF			;SO WE CAN BE SYSTEM DEPENDENT
	SALL				;SUPRESS MACRO EXPANSIONS

DEFINE TOPS10 <IFN FTUUOS,>		;SETUP CONDITIONAL MACROS

DEFINE TOPS20 <IFN FTJSYS,>


TOPS10 <
    IF1,<PRINTX Building a GALAXY-10 library>
	SEARCH	UUOSYM>			;SEARCH PROPER
TOPS20 <
    IF1,<PRINTX Building a GALAXY-20 library>
	SEARCH	MONSYM>			;UNIVERSAL FOR SYSTEM SYMBOLS

IFNDEF GLXVRS,<
    IF1,<PRINTX ? Aborting... Must Compile "GLXVER+GLXMAC">
		 END>

	CHKEDT (MAC)			;CHECK OUR EDIT NUMBER

	MACEDT==0142			;EDIT NUMBER

DEFINE VRSN.(PFX),<BYTE (3)PFX'WHO (9)PFX'VER (6)PFX'MIN (18)PFX'EDT>


;THIS FILE CONTAINS SYMBOL AND MACRO DEFINITIONS WHICH ARE COMMON TO
;	ALL PROGRAMS DEVELOPED BY THE DECSYSTEM-10/20 SUBSYSTEMS
;	GROUP.  THESE PROGRAMS INCLUDE AT PRESENT:
;
;		1)ALL GALAXY COMPONENTS
;		2)TPS-20
;
;THIS FILE ALSO ACTS AS THE ADMINISTRATION MODULE FOR OTHER COMMON
;	SUBSYSTEMS MODULES AS THEY ARE DEVELOPED.

	XP FTUUOS,FTUUOS		;GLOBAL-IZE SYSTEM SWITCHES
	XP FTJSYS,FTJSYS		;GOTTEN FROM GALCNF
SUBTTL Table of contents

;               TABLE OF CONTENTS FOR GLXMAC
;
;
;                        SECTION                                   PAGE
;    1. Accumulator Definitions...................................   3
;    2. JUMPx, SKIPx Instruction OPDEFS...........................   4
;    3. ND, XP, EXT, and GLOB Macros..............................   5
;    4. CONT. LSTOF. LSTON. VRSN. Macro Definitions...............   6
;    5. PROLOG - Uniform assembly set up..........................   7
;    6. SYSPRM - Set system dependent parameters..................   8
;    7. MIN and MAX - Find minimum or maximum of vector of values.   8
;    8. LIBVEC - Library run-time system entry vector.............   9
;    9. PG2ADR,ADR2PG Macros......................................  10
;   10. Standard Constants........................................  11
;   11. Control Character Symbols.................................  12
;   12. PC WORD Flags.............................................  13
;   13. Field and Mask Macros.....................................  14
;   14. MOVX......................................................  15
;   15. CAX - COMPARE MACROS......................................  16
;   16. ADDX, SUBX, IMULX, MULX, IDIVX & DIVX MACROS..............  17
;   17. TX -- TEST MASK...........................................  18
;   18. SUBFUNCTION MACROS........................................  21
;   19. DEFSTR -- DEFINE DATA STRUCTURE...........................  22
;   20. STKVAR - STACK VARIABLE FACILITY..........................  26
;   21. TRVAR - TRANSIENT VARIABLE FACILITY.......................  27
;   22. SAVE MACRO DEFINITION.....................................  29
;   23. LOAD,STORE,INCR,DECR,ZERO.................................  31
;   24. $BGINT,$DEBRK - Interrupt context switching...............  33
;   25. $BUILD,$SET,$EOB - Build pre-formed data blocks...........  34
;   26. $CALL,$RETT,$RETF,$RETE,$RET Uniform Call/Return Mechanisms  35
;   27. $DATA and $GDATA Macros - Runtime System Data Area control  36
;   28. $FATAL, and $WARN Macro definitions.......................  37
;   29. $STOP - Cause a STOP CODE to occur........................  38
;   30. $TEXT - Interface to the T%TEXT routine...................  39
;   31. $WTO / $WTOJ / $WTOR / $ACK Macros........................  49
;   32. GALAXY system error codes.................................  50
;   33. Canonical File Information................................  51
;   34. Canonical Job Information.................................  52
;   35. Scanning and Command Module Symbols.......................  53
;   36. THE MESSAGE HEADER........................................  56
;   37. ACK - THE GALAXY 'ACK' MESSAGE............................  57
;   38. JIB - Job Information Block...............................  58
;   39. OBJ - Object Descriptor...................................  59
;   40. OBJCTS MACRO..............................................  60
;   41. FD - File Descriptor......................................  61
;   42. FOB - Parameter block passed to F%IOPN and F%OOPN.........  63
;   43. FRB - Parameter block passed to F%REN for renames.........  64
;   44. IB  - Initialization Block for GALAXY programs............  65
;   45. PIB - PID block...........................................  66
;   46. SAB - Send Argument Block passed to C%SEND................  67
;   47. MDB - Message Descriptor Block returned by C%RECV.........  68
;   48. Special system PIDS.......................................  69
;   49. System Independent IPCF Codes and Constants...............  70
;   50. Program internal parameters of interest...................  71
;   51. $HALT   -- Halt a Program without Reset...................  73
;   52. $HALT   -- Halt a Program without Reset...................  76
SUBTTL	Revision history

COMMENT \

0045	G044	Add new Routines S%TBAD and S%TBDL as well as their
		new error codes

0046		Add a new block to the MDB and the supporting code in GLXIPC.
		This new block will contain a pointer to the senders account
		string when C%RECV is called on the -20.

0047	G045	Add MSKSTR,DEFSTR MACRO Defininitions from MACSYM.
		Replaced definitions of LOAD,STORE,INCR,DECR with
		Modified definitions from MACSYM.
0050		Cleanup New Macros just added.
0051		Make INCR, DECR, and SAVE Skippable
0052		Define ADDX, SUBX, MULX, DIVX, IMULX and IDIVX
		Remove .RET from entry vector and $RET definition
0053		Add .OTIBM object type definitions
0054		Make JXo and JXF skippable
0055		Add $FATAL and $WARN definitions
0056		Add CHK.PM and AVLPAG definitions for GLXMEM
0057		Fix SAVE macro to use library co-routines
0060		Define $CALL $RETT $RETF to use indirect access
		to entry vector for non-library components
0061		Add .OTMNT object type definitions
0062		Add indexes to special PID table for Accounting, File DAEMON,
		tape labeller.
0063		Change definitions of JUMPT,JUMPF,SKIPT,SKIPF to opdefs
0064		Change definition of Call to do range check and
		conditionally do PUSHJ @ if in entry vector
0065		Change ERICA$ to ERARG$
0066		Add New $TEXT Qualifier ^R for Displaying a Job Info Block (JIB)
		and add Definitions for the JIB
0067		Add I%HOST call to entry vector
		And Define $HALT pseudo instruction for exit without reset.
0070		Make SPIDS MACRO to define special PIDS
0071		Add I%JINF Call to return Job Info on a particular Job
0072		Add S%SIXB Call to convert ASCII to SIXBIT
0073		Remove I%%WTO, Rename I%%WTI to I%%WTO (not released)
0074		Remove I%IWTO,I%WTO,I%SWTO,I%WTO.  Rename I%%WTO
		(previously I%%WTI) to I%WTO.  Leave I%SOPR in.
0075		Reorganize the IB to break out PID information into its own
		PID block.  Allows for multiple PIDs per program.
		Add C%CPID (Create a PID), C%KPID (Kill a PID), C%SPID
		(Set default sender PID).
		This edit and 0073, 0074 go together and break everyone
		who previously $BUILT IBs.
0076		Add .OTBIN and .OTXFR for archiving, file transfer
0077		Remove JX? and PJ? and ASUBR Macro definitions
		Move them temporarily to a file called GLXEXT
0100		Change $SET to use DEFSTR and MSKSTR structure definitions
0101		CHANGE JOB IN WTO MACROS TO BE JBN. THUS WE WON'T
		CONFLICT WITH WT.JOB (WE'LL BE WT.JBN INSTEAD)
0102		Change op-code names for WTO blocks from WT.xxx to WO.xxx
0103		Change defstr and mskstr to allow them to accept arguments
		as GETLIM and STOLIM do.
0104		Change FLD to look exactly like INSVL.
0105		Bump edit by 1 to take up slack in GLXWTO removal
0106		Remove extra CRLF from definition of $TEXT, ITEXT,
		$WARN, $FATAL, $STOP

		Added Module name printout to $WARN, $FATAL

		Defaulted %%.MOD to NONAME before PROLOG macro

0107		Add C%MAXP to get maximum packet small packet size
0110		RESTORE IB.PRG IN THE IB TO CONTAIN THE PROGRAM NAME
0111		Extend DEFSTR and MSKSTR definitions to allow index
		specification within LOCN field.
0112		Made C%PIDJ entry point to get Pid Job number
0113		Remove name from $FATAL and $WARN
0114		Define .BGINT in Prolog so Library can use $BGINT
0115		Change $FATAL to use stop code processor
		Change $WARN to expand name (again)
		Change Proglog to define %%.OTS for library component
		tests.
		Change Prolog to use GLOB instead of IF2 for vector
		expansion.
		Change $CALL and $BGINT to define themselves properly
		Change $BGINT, $RETT, $RETF and $RETE to define properly
0116		Changed SAVE macro to $SAVE
0117		Change LOAD, STORE, INCR and DECR to skip structure
		stuff if called without a possible structure
0120		Changed Prolog to define Library entry points
		as Macros to allow the Call/return mechanisms
		to become simple OPDEFS
		Changed $CALL, $RETT, $RETF to simple OPDEFS
		Changed PROLOG to equate entry vector symbols
		for GLXINI
0121		Change SZ.OBF and SZ.BUF values for new GLXFIL
0123		Add Support to WTO macros for new Object Type Block
0124		Add new Object type for DBMS queues (.OTDBM)
0125		Install the TRMTYP macro 'for all' terminal types
0126		Change $ACK macro to always turn on WT.SJI
0127		Change DCT.MN from 2 to 1.
0130		-10, Change TRMTYP for VT05 erase EOL sequence to be
		37,177,177,177. (It somehow was 377,177,.. no good!)
0131		Add L%APOS to the entry vector.
0132		Change the text description of .OTMNT to from 'Tape-disk
		mount' TO 'Device'
0133		Move the PFH into the library on the -10
		Redefine $DATA and $GDATA to use PSECTs
		Remove pointers from entry vector to PAGTBL.
		No longer needed since PFH is in library
		Introduce the GLXPURE assembly switch
0134		Make .REQUEST REL:GLXINI so people can find it
0135		Remove edit 134. It seems to be a bad idea
0136		Add code for .MSFLG in the WTO macros
0137		Change PROLOG to define %%.GLX for the module instead of in
		GLXINI
0140		Add .NULIO for -10 definitions
0141		Add -10 symbold for .CMTAD
0142		Add PARUNV macros to GLXMAC
\   ;End of Revision History
SUBTTL	Accumulator Definitions

;THE FOLLOWING ACCUMULATOR DEFINITIONS ARE STANDARD THROUGHOUT THE
;	SUB-SYSTEMS GROUP AND MAY NOT BE CHANGED.  THE ACCUMULATORS DEFINED ARE:

	TF==0			;TRUE/FALSE REGISTER, NEVER REFERENCED DIRECTLY
				; USED BY $RETx AND JUMPT,JUMPF, SKIPT,SKIPF
	.SAC==0			;SCRATCH AC USED BY SOME NONE SKIPPABLE
				;MACROS AND SOME MACRO CALLS TO GLXCOM
				;.SAC MAY NOT BE CHANGED ON EXIT FROM A
				;CO-ROUTINE SO THAT ANY ROUTINE MAY PASS
				;A TRUE FALSE VALUE BACK TO IT'S CALLER.

	S1==1			;S1 & S2 ARE ARGUMENTS TO ROUTINES
	S2==2			;AND ARE OTHERWISE SCRATCH

	T1==3			;T1 - T4 ARE TEMPORARY REGS
	T2==4
	T3==5
	T4==6

	P1==7			;P1 - P4 ARE PRESERVED REGS
	P2==10
	P3==11
	P4==12
	.A13==13		;.A13 THRU .A16 NOT USED BY LIBRARY
	.A14==14
	.A15==15
	.A16==16

	.FP==16			;FRAME POINTER USED BY TRVAR AND ASUBR
				;MAY NOT BE CHANGED WITHIN THE SCOPE OF
				;A ROUTINE USING TRVAR OR ASUBR
				;HOWEVER -- IT IS PRESERVED OUTSIDE THE
				;SCOPE OF THESE ROUTINES

	P==17			;PUSHDOWN POINTER

;THERE ARE CO-ROUTINES DEFINED IN GLXCOM TO SAVE AND AUTOMATICALLY
;	RESTORE THE "T" AND "P" THAT ARE INVOKED BY THE SAVE MACRO
;	CALLED AS FOLLOWS:

;	$SAVE <P1,P2,P3,P4>	;TO SAVE P1-P4
;	$SAVE <T1,T2,T3,T4>	;TO SAVE T1-T4
;	$SAVE <P1>		;TO SAVE P1
;	$SAVE <P1,P2,P3>		;TO SAVE P1-P3
;	$SAVE <T1,T2>		;TO SAVE T1-T2
;	$SAVE <TF,S1>		;TO SAVE TF AND S1 FOR RETURN TO CALLER
;				;AC'S ARE AUTOMATICALLY RESTORED ON RETURN

;AC'S 13,14,15 & 16 ARE AVAILABLE TO THE COMPONENT AND MAY BE USED
;	TO ANY END WITH THE NOTEABLE EXCEPTION:

;			* * * *  N O T E  * * * *

;	AC16 IS USED AS A FRAME POINTER FOR TRVAR AND ASUBR DYNAMIC
;	VARIABLE ALLOCATION.  IT MAY NOT BE REFERENCED WITHIN THE
;	RANGE OF THE TRVAR OR ASUBR, HOWEVER IT IS PRESERVED ON RETURN
;	TO THE CALLER.

;REFER TO GLXLIB.MEM FOR A FULL DESCRIPTION OF MACROS AND AC USAGE
SUBTTL	JUMPx, SKIPx Instruction OPDEFS

;All subroutines which follow GALAXY conventions return a "success/failure"
; value in the register TF.  This is done by returning via one of 
; the return instructions, $RETE, $RETT  or $RETF (See next page).
;The value of TRUE or FALSE which a routine returns can be tested with one
;of the following instructions, which alter program flow according to
; the value currently in TF.

; Jump to location specified if TF contains TRUE

	OPDEF	JUMPT [JUMPN]

; Jump to location specified if TF contains FALSE

	OPDEF	JUMPF [JUMPE]

; Skip the next instruction if TF contains TRUE

	OPDEF	SKIPT [SKIPN]

; Skip the next instruction if TF contains FALSE

	OPDEF 	SKIPF [SKIPE]

; PJRST instruction OPDEF

	OPDEF	PJRST [JRST]
SUBTTL	ND, XP, EXT, and GLOB Macros

;Macro to Define a Symbol if not already defined
;	ND  SYMBOL,VALUE

DEFINE	ND(SYM,VAL),<IF2,<IFDEF SYM,<SYM==SYM>> IFNDEF SYM,<SYM==VAL>>


;Macro to Define a Symbol and force it INTERN
;	XP  SYMBOL,VAL,PRINT

;		Where PRINT is any Non-blank to allow printing from DDT

DEFINE	XP(SYM,VAL,PRINT),<IFB <PRINT>,<SYM==:VAL> IFNB <PRINT>,<SYM=:VAL>>

;Macro to EXTERN a Symbol if not defined in this routine
;	EXT SYMBOL

DEFINE	EXT(SYMBOL),<IRP SYMBOL,<
	IF2,<IFNDEF SYMBOL,<EXTERN SYMBOL>>>>


;Macro to EXTERN or INTERN a Symbol
;	GLOB SYMBOL

DEFINE	GLOB(SYMBOL),<IRP SYMBOL,<
	IF2,<IFDEF SYMBOL,<.IFN SYMBOL,EXTERN,<INTERN SYMBOL>>
	     IFNDEF SYMBOL,<EXTERN SYMBOL>
	     SUPPRES SYMBOL>>>
SUBTTL	CONT. LSTOF. LSTON. VRSN. Macro Definitions

;Macro to force page overflow with appropriate comments

DEFINE	CONT.(NAME)<LALL
PAGE; (NAME Continued on next page)
SALL; (NAME Continued from previous page)>


;Macros to turn on and off listings with nesting and level control
;	LSTOF.			;TURNS OFF LISTINGS ONLY
;	LSTOF. XCREF		;TURNS OFF LISTINGS AND CREF
;	LSTON.			;RESTORES LISTINGS AND CREF AT TOP LEVEL
;IF LSTIN. IS DEFINED AS .MINFI THEN ALL LISTINGS ARE ON

DEFINE	LSTOF.(FOO),<
	IFNDEF LSTIN.,LSTIN.==0		;;INITIALIZE LEVEL COUNTER
IFE LSTIN.,<
	IFIDN <XCREF><FOO>,<.XCREF>	;;CONDITIONALLY SUPPRESS CREF
		   XLIST>		;;TURN OFF LISTINGS
	LSTIN.==LSTIN.+1>		;;BUMP LIST LEVEL

DEFINE	LSTON.,<
	IFG LSTIN.,LSTIN.==LSTIN.-1	;;DECR LIST LEVEL
	IFLE LSTIN.,<.CREF		;;RESUME CREFS
		      LIST>>		;;RESUME LISTS

;Macro to Generate Standard Version Word
;Assumes PFXWHO, PFXVER, PFXMIN, PFXEDT are defined.
;	VRSN. (PFX)

DEFINE VRSN.(PFX),<BYTE (3)PFX'WHO (9)PFX'VER (6)PFX'MIN (18)PFX'EDT>
SUBTTL PROLOG - Uniform assembly set up

;The PROLOG macro is used to uniformly search all the right UNV files
;	and setup the listing format and STOP CODE controls.

; The call is :		PROLOG(xxxxxx,OTSCOD)
;	where the 'xxxxxx' represents the module name,
;	and OTSCOD (optional) indicates that this module is part
;	of the GALAXY object time system.  If present, this code
;	should be the module name with the "GLX" taken off, for instance
;	PROLOG(GLXIPC,IPC) would be the prolog for module "GLXIPC".

	%%.MOD==SIXBIT/NONAME/		;DEFAULT MODULE NAME BEFORE
					; PROGRAM DOES PROLOG
	%%.OTS==0			;DEFAULT OTS CODE TO NULL

;The GLXPURE switch enables the library to be built as either a sharable
; high segment or as a linkable library.
; In the case of the high segment, the entry vector is established,
; and all library data space is allocated in the the DATA .PSECT
; In the case of the linkable library, no entry vector is generated,
; and data space is allocated in-line.
;
;For user programs, the GLXPURE switch controls whether references to
; library routines will be through the entry vector (for the high segment case)
; or simple external references (for linking the library)

	IFNDEF GLXPURE,<GLXPURE==-1>	;Default to high segment assembly
;	IFNDEF GLXPURE,<GLXPURE==0>	;Or ... default to impure


	DEFINE 	PROLOG(MODULE,OTSCOD)<
	  SALL
	  LSTOF. XCREF
	  TOPS20 <SEARCH MONSYM>	;;LOAD O.S. SYMBOLS
	  TOPS10 <SEARCH UUOSYM>	;; FOR PROPER OPERATING SYSTEM
	  IFB <OTSCOD>,<
			GLOB <I%INIT>
			%%.GLX==:%%.GLX	;;DEFINE THE VERSION IN THE MODULE
					;;FOR NON-LIBRARY COMPONENTS
			DEFINE $DATA(NAM,SIZ<1>)<
			  NAM:	BLOCK	SIZ
			>
			IFN GLXPURE,<.REQUEST GLXINI ;;GETSEG GLXLIB
					DEFINE ..ASGN(A,ADR)<DEFINE A<@^O'ADR>>
				>;;END IFN GLXPURE
			IFE GLXPURE,<.REQUIRE GLXLIB ;;LINK IN LIBRARY
					DEFINE ..ASGN(A,ADDR) <GLOB(A)>
				>;;END IFE GLXPURE
			>;;END IFB <OTSCOD>
	  IFNB <OTSCOD>,<
			CHKEDT(OTSCOD)	;;CHECK MODULE EDIT LEVEL
			IFIDN <OTSCOD><OTS>,<EXTERN .RETT,.RETF>
			IFDIF <OTSCOD><INI>,<
			IFN GLXPURE,< .PSECT	.HIGH.>;;BUILD A HIGH SEGMENT
			IFE GLXPURE,<;;IF WE'RE GOING TO BE LINKED IN...
			DEFINE $DATA(NAM,SIZ<1>)<
			  IFNDEF	OTSCOD'%D,<OTSCOD'%D::!	OTSCOD'%DL==:0>
			  NAM:	BLOCK	SIZ
			  IF1,<OTSCOD'%DL==:OTSCOD'%DL+SIZ>;;Count the length of the data space
			>;;END DEFINE $DATA
			>;;END IFE GLXPURE
			GLOB <IIB>	;;GLOBALIZE IIB for $WARN
			DEFINE ..ASGN(A,ADDR) <GLOB(A)>
			>;;END IFDIF <OTSCOD><INI>
			IFIDN <OTSCOD><INI>,<
			DEFINE ..ASGN(A,ADDR) <A=ADDR>
			>
			>
	IFNB <MODULE>,<%%.MOD==SIXBIT/MODULE/> ;;MAKE NAME AVAILABLE
	IFNB <OTSCOD>,<%%.OTS==SIXBIT/OTSCOD/> ;;MAKE OTSCODE AVAILABLE
	ZZ==VORG
	DEFINE CDO (A) <IFNB <A>,<..ASGN(A,\ZZ)>
			ZZ==ZZ+1>
	LIBVEC
	OPDEF $RETT [PJRST .RETT]	;;Pick up proper .RETT/.RETF
	OPDEF $RETF [PJRST .RETF]
	LSTON.				;;TURN LISTINGS BACK ON
> ;END OF PROLOG DEFINITION
SUBTTL	SYSPRM - Set system dependent parameters

;THE SYSPRM MACRO IS USED TO DEFINE A SYMBOL WHOSE VALUE IS DIFFERENT
;	DEPENDING ON THE OPERATING SYSTEM WHICH THE PROGRAM IS
;	BEING ASSEMBLED FOR.
;
;	THE CALL IS:
;
;	  SYSPRM   'SUBSYSTEM-NAME' , 'TOPS10 VALUE' , 'TOPS20 VALUE'


DEFINE	SYSPRM(SYMBOL,UUOS,JSYS),<
	IFNB <UUOS>,<TOPS10<SYMBOL==UUOS>>
	IFNB <JSYS>,<TOPS20<SYMBOL==JSYS>>
>  ;END DEFINE SYSPRM




SUBTTL	MIN and MAX - Find minimum or maximum of vector of values

;THE MIN AND MAX MACROS FIND THE MIN OR MAX OF THE ITEMS IN THE FIRST
;	ARGUMENT LIST.  THE SYMBOL NAMED BY THE SECOND ARGUMENT WILL BE
;	DEFINED AS THE MIN OR MAX OF THE LIST.  IF THE SECOND ARGUMENT
;	IS MISSING, "MINSIZ" OR "MAXSIZ" IS DEFINED.

DEFINE	MAX(A,B),<
	IFB <B>,<MAXSIZ==0
		IRP A,<IFG <A-MAXSIZ>,<MAXSIZ==A>>>
	IFNB <B>,<B==0
		IRP A,<IFG <A-B>,<B==A>>>
>  ;END OF DEFINE MAX

DEFINE	MIN(A,B),<
	IFB <B>,<MINSIZ==377777,,777777
		IRP A,<IFG <MINSIZ-A>,<MINSIZ==A>>>
	IFNB <B>,<B==377777,,777777
		IRP A,<IFG <B-A>,<B==A>>>
>  ;END OF DEFINE MIN
SUBTTL LIBVEC - Library run-time system entry vector

; Each entry in this macro represents a routine or variable that must
; be made available to the OTS itself or to programs using the OTS.

; For OTS programs, each entry is declared EXTERNAL if it does not appear
; in the module itself.  For non-OTS code, the symbols are defined as offsets
; in the Library Dispatch vector as absolute symbols.  This vector
; lives in GLXOTS

; Each modules entry points are grouped together. In order to allow for
;	the addition of new routines for each module, there are blank places
;	held open.  When a new routine is added, remove one of the blank
;	occurrences of "CDO".  This will keep the vector straight and allow
;	the running of older programs without their re-compilation.

	DEFINE LIBVEC <

	  LSTOF. XCREF

	CDO	     			;;GLXCOM
	CDO	.ZPAGA
	CDO	.ZPAGN
	CDO	.ZCHNK
	CDO	.SAVE1
	CDO	.SAVE2
	CDO	.SAVE3
	CDO	.SAVE4
	CDO	.SAVET
	CDO	.SV13
	CDO	.SV14
	CDO	.SV15
	CDO	.SV16
	CDO	.RETT
	CDO	.RETF
	CDO	.RETE
	CDO	.AOS		;;USED BY INCR
	CDO	.SOS		;;USED BY DECR
	CDO	.ZERO		;;USED BY ZERO
	CDO	.POPJ
	CDO	.STOP
	CDO	.SAVE8		;;SAVES P1 THRU AC16
	CDO	.STKST		;;STKVAR SUPPORT CODE
	CDO	.TRSET		;;TRVAR SUPPORT CODE
	CDO			;;OLD ASUBR SUPPORT CODE (REMOVED)
	CDO	.POPJ		;;OLD .RET (TO BE REMOVED)
	CDO
	CDO
	CDO
	CDO
	CDO

	CDO				;;GLXIPC
	CDO	C%RPRM
	CDO	C%INTR
	CDO	C%SEND
	CDO	C%RECV
	CDO	C%BRCV
	CDO	C%REL
	CDO	C%CPID
	CDO	C%KPID
	CDO	C%SPID
	CDO	C%MAXP
	CDO	C%PIDJ
	CDO
	CDO
	CDO
	CDO
	CDO

	CDO	      			;;GLXFIL
	CDO	F%IOPN
	CDO	F%AOPN
	CDO	F%OOPN
	CDO	F%IBYT
	CDO	F%OBYT
	CDO	F%IBUF
	CDO	F%OBUF
	CDO	F%REL
	CDO	F%DREL
	CDO	F%RREL
	CDO	F%REW
	CDO	F%POS
	CDO	F%CHKP
	CDO	F%INFO
	CDO	F%FD
	CDO	F%REN
	CDO	F%DEL
	CDO	F%FCHN
	CDO
	CDO
	CDO
	CDO
	CDO
	CDO
	CDO
	CDO
	CDO

	CDO	      			;;GLXMEM
	CDO	M%ACQP
	CDO	M%RELP
	CDO	M%IPSN
	CDO	M%NXPG
	CDO	M%IPRC
	CDO	M%IPRM
	CDO	M%AQNP
	CDO	M%RLNP
	CDO	M%CLNC
	CDO	M%FPGS
	CDO	M%GMEM
	CDO	M%RMEM
	CDO
	CDO
	CDO
	CDO
	CDO
	CDO
	CDO	M%GPAG
	CDO	M%RPAG
	CDO
	CDO
	CDO
	CDO
	CDO
	CDO
	CDO
	CDO

	CDO	      			;;GLXTXT
	CDO	T%TEXT
	CDO	T%TTY
	CDO
	CDO
	CDO
	CDO
	CDO
	CDO
	CDO
	CDO
	CDO
	CDO

	CDO	      			;;GLXLNK
	CDO	L%CLST
	CDO	L%DLST
	CDO	L%CENT
	CDO	L%CBFR
	CDO	L%DENT
	CDO	L%NEXT
	CDO	L%FIRS
	CDO	L%LAST
	CDO	L%PREV
	CDO	L%PREM
	CDO	L%CURR
	CDO	L%RENT
	CDO	L%SIZE
	CDO	L%APOS
	CDO
	CDO
	CDO
	CDO
	CDO
	CDO
	CDO
	CDO

	CDO	I%INI1			;;GLXINT
	CDO	I%NOW
	CDO	I%EXIT
	CDO	I%ION
	CDO	I%IOFF
	CDO	I%SLP
	CDO	I%INT1
	CDO	I%INT2
	CDO	I%INT3
	CDO
	CDO
	CDO
	CDO	I%SOPR
	CDO	I%WTO
	CDO
	CDO	I%HOST
	CDO	I%JINF
	CDO
	CDO

	CDO				;;GLXSCN
	CDO
	CDO
	CDO	S%SIXB
	CDO	S%CMND
	CDO	S%TBLK
	CDO	S%SCMP
	CDO	S%ERR
	CDO	S%INTR
	CDO	S%EXIT
	CDO	S%TBAD
	CDO	S%TBDL
	CDO
	

	CDO	K%RCOC			;;GLXKBD
	CDO	K%WCOC
	CDO	K%SUET
	CDO	K%STYP
	CDO	K%TXTI
	CDO	K%SOUT
	CDO	K%BOUT
	CDO	K%BIN
	CDO	K%BACK
	CDO	K%TPOS
	CDO
	CDO
	CDO
	CDO
	  LSTON.
  > ;END OF LIBVEC DEFINITION
SUBTTL	PG2ADR,ADR2PG Macros

DEFINE	PG2ADR(AC),<LSH AC,^D9>

DEFINE	ADR2PG(AC),<LSH AC,-^D9>
SUBTTL	Standard Constants

.INFIN==:377777,,777777		;PLUS INFINITY
.MINFI==:1B0			;MINUS INFINITY
LHMASK==:777777B17		;LEFT HALF
RHMASK==:777777			;RIGHT HALF
FWMASK==:-1			;FULL WORD


; BYTE POINTER PARTS

	BP.POS==77B5			;POSITION (BITS TO THE RIGHT)
	BP.SIZ==77B11			;SIZE OF BYTE
	BP.ADR==Z -1			;ADDRESS PORTION


; DEFINE UNIVERSAL TRUE AND FALSE CONSTANTS

	FALSE==0
	TRUE=-1

; MEMORY CONSTANTS

	PAGSIZ==^D512			;SIZE OF ONE PAGE
	MEMSIZ==^D512			;PAGES IN THE ADDRESS SPACE

; DEBUGGING CONSTANTS

	SYSPRM	DDTADR,.JBDDT,770000	;LOCATION CONTAINING START OF DDT
	SYSPRM	DEBUGW,.JBOPS,135	;SPECIAL "DEBUGGING" WORD
SUBTTL	Control Character Symbols

.CHNUL==:000			;NULL
.CHCNA==:001
.CHCNB==:002
.CHCNC==:003
.CHCND==:004
.CHCNE==:005
.CHCNF==:006
.CHBEL==:007			;BELL
.CHBSP==:010			;BACKSPACE
.CHTAB==:011			;TAB
.CHLFD==:012			;LINE-FEED
.CHVTB==:013			;VERTICAL TAB
.CHFFD==:014			;FORM FEED
.CHCRT==:015			;CARRIAGE RETURN
.CHCNN==:016
.CHCNO==:017
.CHCNP==:020
.CHCNQ==:021
.CHCNR==:022
.CHCNS==:023
.CHCNT==:024
.CHCNU==:025
.CHCNV==:026
.CHCNW==:027
.CHCNX==:030
.CHCNY==:031
.CHCNZ==:032
.CHESC==:033			;ESCAPE
.CHCBS==:034			;CONTROL BACK SLASH
.CHCRB==:035			;CONTROL RIGHT BRACKET
.CHCCF==:036			;CONTROL CIRCONFLEX
.CHCUN==:037			;CONTROL UNDERLINE

.CHALT==:175			;OLD ALTMODE
.CHAL2==:176			;ALTERNATE OLD ALTMODE
.CHDEL==:177			;DELETE
SUBTTL	PC WORD Flags

;PC FLAGS

PC%OVF==:1B0			;OVERFLOW
PC%CY0==:1B1			;CARRY 0
PC%CY1==:1B2			;CARRY 1
PC%FOV==:1B3			;FLOATING OVERFLOW
PC%BIS==:1B4			;BYTE INCREMENT SUPPRESSION
PC%USR==:1B5			;USER MODE
PC%UIO==:1B6			;USER IOT MODE
PC%LIP==:1B7			;LAST INSTRUCTION PUBLIC
PC%AFI==:1B8			;ADDRESS FAILURE INHIBIT
PC%ATN==:3B10			;APR TRAP NUMBER
PC%FUF==:1B11			;FLOATING UNDERFLOW
PC%NDV==:1B12			;NO DIVIDE
SUBTTL	Field and Mask Macros

;STANDARD MACROS

;MACROS TO HANDLE FIELD MASKS

;COMPUTE LENGTH OF MASK, I.E. LENGTH OF LEFTMOST STRING OF ONES
;REMEMBER THAT ^L DOES 'JFFO', I.E. HAS VALUE OF FIRST ONE BIT IN WORD

;COMPUTE WIDTH OF MASK, I.E. LENGTH OF LEFTMOST STRING OF ONES

DEFINE WID(MASK)<<^L<-<<MASK>_<^L<MASK>>>-1>>>

;COMPUTE POSITION OF MASK, I.E. BIT POSITION OF RIGHTMOST ONE IN MASK

DEFINE POS(MASK)<<^L<<MASK>&<-<MASK>>>>>

;CONSTRUCT BYTE POINTER TO MASK

DEFINE POINTR(LOC,MASK)<<POINT WID(MASK),LOC,POS(MASK)>>

;PUT RIGHT-JUSTIFIED VALUE INTO FIELD SPECIFIED BY MASK

DEFINE	FLD(VALUE,MASK),<<<<VALUE>B<POS(<MASK>)>>&<MASK>>>

;MAKE VALUE BE RIGHT JUSTIFIED IN WORD.

DEFINE .RTJST(VAL,MSK)<<VAL>B<^D70-POS(MSK)>>

;CONSTRUCT MASK FROM BIT AA TO BIT BB. I.E. MASKB 0,8 = 777B8

DEFINE MASKB (AA,BB)<1B<<AA>-1>-1B<BB>>

;MODULE - GIVES REMAINDER OF DEND DIVIDED BY DSOR

DEFINE MOD. (DEND,DSOR)<<DEND-<DEND/DSOR>*DSOR>>

;OLD STYLE MACTEN TYPE CALLS

;MACRO TO BUILD A MASK "WID" BITS WIDE, WITH ITS RIGHTMOST BIT
;	IN THE BIT POSITION "POS".
DEFINE MASK.(WID,POS),<<<<1_<WID>>-1>B<POS>>>


;INVSL. POSITIONS VALUE IN MASK TO BE REPLACED BY FLD(VALUE,MASK)
DEFINE	INSVL.(VALUE,MASK),<<<<VALUE>B<POS(<MASK>)>>&<MASK>>>
SUBTTL MOVX

;MOVX - LOAD AC WITH CONSTANT

DEFINE MOVX (AC,MSK)<
   ..MX1==MSK			;;EVAL EXPRESSION IF ANY
IFDEF .PSECT,<
   .IFN ..MX1,ABSOLUTE,<
	MOVE AC,[MSK]>
   .IF ..MX1,ABSOLUTE,<
	..MX2==0		;;FLAG SAYS HAVEN'T DONE IT YET
	IFE <..MX1>B53,<
	  ..MX2==1
	  MOVEI AC,..MX1>	;;LH 0, DO AS RH
	IFE ..MX2,<		;;IF HAVEN'T DONE IT YET,
	IFE <..MX1>B17,<
	  ..MX2==1
	  MOVSI AC,(..MX1)>>	;;RH 0, DO AS LH
	IFE ..MX2,<		;;IF HAVEN'T DONE IT YET,
	IFE <<..MX1>B53-^O777777>,<
	  ..MX2==1
	  HRROI AC,<..MX1>>>	;;LH -1
	IFE ..MX2,<		;;IF HAVEN'T DONE IT YET,
	IFE <<..MX1>B17-^O777777B17>,<
	  ..MX2==1
	  HRLOI AC,(..MX1-^O777777)>> ;;RH -1
	IFE ..MX2,<		;;IF STILL HAVEN'T DONE IT,
	  MOVE AC,[..MX1]>	;;GIVE UP AND USE LITERAL
	>>

IFNDEF .PSECT,<
	..MX2==0		;;FLAG SAYS HAVEN'T DONE IT YET
	IFE <..MX1>B53,<
	  ..MX2==1
	  MOVEI AC,..MX1>	;;LH 0, DO AS RH
	IFE ..MX2,<		;;IF HAVEN'T DONE IT YET,
	IFE <..MX1>B17,<
	  ..MX2==1
	  MOVSI AC,(..MX1)>>	;;RH 0, DO AS LH
	IFE ..MX2,<		;;IF HAVEN'T DONE IT YET,
	IFE <<..MX1>B53-^O777777>,<
	  ..MX2==1
	  HRROI AC,<..MX1>>>	;;LH -1
	IFE ..MX2,<		;;IF HAVEN'T DONE IT YET,
	IFE <<..MX1>B17-^O777777B17>,<
	  ..MX2==1
	  HRLOI AC,(..MX1-^O777777)>> ;;RH -1
	IFE ..MX2,<		;;IF STILL HAVEN'T DONE IT,
	  MOVE AC,[..MX1]>	;;GIVE UP AND USE LITERAL
>
	PURGE ..MX1,..MX2>
SUBTTL CAX - COMPARE MACROS

;CREATE THE CAX MACRO DEFINITIONS

DEFINE	..DOCX (T)<
	IRP T,<
	  DEFINE CAX'T (AC,MSK)<
	    ..CX(T,AC,MSK)>>>

	..DOCX (<,L,LE,E,G,GE,N,A>)  ;DO 8 DEFINITIONS
	PURGE ..DOCX

DEFINE	..CX(T,AC,MSK)<
	  ..CX1==MSK
	IFDEF .PSECT,<
 	.IFN ..CX1,ABSOLUTE,<
	      CAM'T AC,[MSK]>
	.IF ..CX1,ABSOLUTE,<	;;MASK IS TESTABLE
		..CX2==0	;;MARK NOT DONE
	  IFE <..CX1&^O777777B17>,<
		..CX2==1	;;LH 0 CAN DO CAI
	    CAI'T AC,MSK>
	  IFE ..CX2,<		;;MUST USE CAM
	    CAM'T AC,[MSK]>
	PURGE ..CX1,..CX2>>
	IFNDEF .PSECT,<
		..CX2==0	;;MARK NOT DONE
	  IFE <..CX1&^O777777B17>,<
		..CX2==1	;;LH 0 CAN USE CAI
	    CAI'T AC,MSK>
	  IFE ..CX2,<		;;MUST USE CAM
	    CAM'T AC,[MSK]>
	PURGE ..CX1,..CX2>>
SUBTTL	ADDX, SUBX, IMULX, MULX, IDIVX & DIVX MACROS

;ALL MACROS JUST CALL ..AS OR ..OP WHICH DO ALL THE WORK
DEFINE	 ADDX(AC,VAL) <..AS(AC,VAL,ADD,SUB)>
DEFINE	 SUBX(AC,VAL) <..AS(AC,VAL,SUB,ADD)>
DEFINE	IMULX(AC,VAL) <..OP(AC,VAL,IMUL)>
DEFINE	 MULX(AC,VAL) <..OP(AC,VAL,MUL)>
DEFINE	IDIVX(AC,VAL) <..OP(AC,VAL,IDIV)>
DEFINE	 DIVX(AC,VAL) <..OP(AC,VAL,DIV)>

DEFINE	..AS(AC,VAL,OPR,ALT)<
	   ..AS1==-<VAL>	;;GET COMPLIMENT OF VALUE
	IFDEF .PSECT,<
	.IFN ..AS1,ABSOLUTE,<
	     OPR AC,[-..AS1]>	;;MUST USE LITERAL
	.IF ..AS1,ABSOLUTE,<
		..AS2==0	;;MARK NOT DONE
	  IFE <..AS1&^O777777B17>,<
		..AS2==1	;;CAN USE ALTERNATE IMMEDIATE
	    ALT'I AC,..AS1>
	  IFE ..AS2,<
	    ..OP(AC,VAL,OPR)>	;;MUST DO IMMEDIATE OR LITERAL
	PURGE ..AS1,..AS2>>
	IFNDEF .PSECT,<
		..AS2==0	;;MARK NOT DONE
	  IFE <..AS1&^O777777B17>,<
		..AS2==1	;;CAN DO ALTERNATE IMMEDIATE
	    ALT'I AC,..AS1>
	  IFE ..AS2,<		;;MUST DO IMMEDIATE OR LITERAL
	    ..OP(AC,VAL,OPR)>
	PURGE ..AS1,..AS2>>

DEFINE	..OP(AC,VAL,OPR)<
	  ..OP1==VAL
	IFDEF .PSECT,<
 	.IFN ..OP1,ABSOLUTE,<
	      OPR AC,[..OP1]>
	.IF ..OP1,ABSOLUTE,<	;;MASK IS TESTABLE
		..OP2==0	;;MARK NOT DONE
	  IFE <..OP1&^O777777B17>,<
		..OP2==1	;;LH 0 CAN DO IMMEDIATE
	    OPR'I AC,..OP1>
	  IFE ..OP2,<		;;MUST USE LITERAL
	    OPR AC,[..OP1]>
	PURGE ..OP1,..OP2>>
	IFNDEF .PSECT,<
		..OP2==0	;;MARK NOT DONE
	  IFE <..OP1&^O777777B17>,<
		..OP2==1	;;LH 0 CAN USE IMMEDIATE
	    OPR'I AC,..OP1>
	  IFE ..OP2,<		;;MUST USE LITERAL
	    OPR AC,[..OP1]>
	PURGE ..OP1,..OP2>>
SUBTTL TX -- TEST MASK

;CREATE THE TX MACRO DEFINITIONS

;THIS DOUBLE IRP CAUSES ALL COMBINATIONS OF MODIFICATION AND TESTING
;TO BE DEFINED

DEFINE ..DOTX (M,T)<
	IRP M,<
	IRP T,<
	  DEFINE TX'M'T (AC,MSK)<
		..TX(M'T,AC,<MSK>)>>>>

	..DOTX (<N,O,Z,C>,<,E,N,A>) ;DO ALL DEFINITIONS
	PURGE ..DOTX

;..TX
;ALL TX MACROS JUST CALL ..TX WHICH DOES ALL THE WORK

DEFINE ..TX(MT,AC,MSK)<
   ..TX1==MSK			;;EVAL EXPRESSION IF ANY
IFDEF .PSECT,<
   .IFN ..TX1,ABSOLUTE,<
	TD'MT AC,[MSK]>
   .IF ..TX1,ABSOLUTE,<		;;MASK MUST BE TESTABLE
	..TX2==0		;;FLAG SAYS HAVEN'T DONE IT YET
	IFE <..TX1&^O777777B17>,<
	  ..TX2==1		;;LH 0, DO AS RH
	  TR'MT AC,..TX1>
	IFE ..TX2,<		;;IF HAVEN'T DONE IT YET,
	IFE <..TX1&^O777777>,<
	  ..TX2==1		;;RH 0, DO AS LH
	  TL'MT AC,(..TX1)>>
	IFE ..TX2,<		;;IF HAVEN'T DONE IT YET,
	  IFE <<..TX1>B53-^O777777>,< ;;IF LH ALL ONES, 
	    ..TX3 (MT,AC)>>	;;TRY Z,O,C SPECIAL CASES
	IFE ..TX2,<		;;IF STILL HAVEN'T DONE IT,
	  TD'MT AC,[..TX1]>	;;MUST GIVE UP AND USE LITERAL
	PURGE ..TX1,..TX2>>
IFNDEF .PSECT,<
	..TX2==0		;;FLAG SAYS HAVEN'T DONE IT YET
	IFE <..TX1&^O777777B17>,<
	  ..TX2==1		;;LH 0, DO AS RH
	  TR'MT AC,..TX1>
	IFE ..TX2,<		;;IF HAVEN'T DONE IT YET,
	IFE <..TX1&^O777777>,<
	  ..TX2==1		;;RH 0, DO AS LH
	  TL'MT AC,(..TX1)>>
	IFE ..TX2,<		;;IF HAVEN'T DONE IT YET,
	  IFE <<..TX1>B53-^O777777>,< ;;IF LH ALL ONES, 
	    ..TX3 (MT,AC)>>	;;TRY Z,O,C SPECIAL CASES
	IFE ..TX2,<		;;IF STILL HAVEN'T DONE IT,
	  TD'MT AC,[..TX1]>	;;MUST GIVE UP AND USE LITERAL
	PURGE ..TX1,..TX2>>
;SPECIAL CASE FOR LH ALL ONES

DEFINE ..TX3 (MT,AC)<
	IFIDN <MT><Z>,<		;;IF ZEROING WANTED
	  ..TX2==1
	  ANDI AC,^-..TX1>	;;CAN DO IT WITH ANDI
	IFIDN <MT><O>,<		;;IF SET TO ONES WANTED
	  ..TX2==1
	  ORCMI AC,^-..TX1>	;;CAN DO IT WITH IORCM
	IFIDN <MT><C>,<		;;IF COMPLEMENT WANTED
	  ..TX2==1
	  EQVI AC,^-..TX1>>	;;CAN DO IT WITH EQV
;VARIENT MNEMONICS FOR TX DEFINITIONS

DEFINE IORX (AC,MSK)<
	TXO AC,<MSK>>

DEFINE ANDX (AC,MSK)<
	TXZ AC,<^-<MSK>>>

DEFINE XORX (AC,MSK)<
	TXC AC,<MSK>>
SUBTTL SUBFUNCTION MACROS

;.IF0 CONDITION, ACTION IF CONDITION 0, ACTION OTHERWISE

DEFINE .IF0 (COND,THEN,ELSE)<
	..IFT==COND		;;GET LOCAL VALUE FOR CONDITION
	IFE ..IFT,<
	THEN
	..IFT==0>		;;RESTORE IN CASE CHANGED BY NESTED .IF0
	IFN ..IFT,<
	ELSE>>

;CASE (NUMBER,<FIRST,SECOND,...,NTH>)

DEFINE .CASE (NUM,LIST)<
	..CSN==NUM
	..CSC==0
	IRP LIST,<
	IFE ..CSN-..CSC,<
	  STOPI
	  ..CAS1 (LIST)>
	..CSC==..CSC+1>>

DEFINE ..CAS1 (LIST)<
	LIST>

;TEST FOR FULL WORD, RH, LH, OR ARBITRARY BYTE

DEFINE ..TSIZ (SYM,MSK)<
	SYM==3			;;ASSUME BYTE UNLESS...
	IFE <MSK>+1,<SYM=0>	;;FULL WORD IF MASK IS -1
	IFE <MSK>-^O777777,<SYM==1> ;;RH IF MASK IS 777777
	IFE <MSK>-^O777777B17,<SYM==2>> ;;LH IF MAST IS 777777,,0

;TEST FOR LOC BEING AN AC -- SET SYM TO 1 IF AC, 0 IF NOT AC

DEFINE ..TSAC (SYM,LOC)<
	IFNDEF .PSECT,<
	SYM==0			;;ASSUME NOT AC UNLESS...
	..TSA1==<Z LOC>		;;LOOK AT LOC
	  IFE ..TSA1&^O777777777760,<SYM==1> ;;AC IF VALUE IS 0-17
	>
	IFDEF .PSECT,<
	SYM==0			;;ASSUME NOT AC UNLESS...
	..TSA1==<Z LOC>		;;LOOK AT LOC
	.IF ..TSA1,ABSOLUTE,<	;;SEE IF WE CAN TEST VALUE
	  IFE ..TSA1&^O777777777760,<SYM==1>> ;;AC IF VALUE IS 0-17
	PURGE ..TSA1>>

;FUNCTION TO TEST FOR MASK CONTAINING EXACTLY ONE BIT. RETURNS
;1 IFF LEFTMOST BIT AND RIGHTMOST BIT ARE SAME

DEFINE ..ONEB (SYM,MSK)<
	SYM==<<<-<MSK>>&<MSK>>&<1B<^L<MSK>>>>>
SUBTTL DEFSTR -- DEFINE DATA STRUCTURE

;DEFINE DATA STRUCTURE
; NAM - NAME OF STRUCTURE AS USED IN CODE
; LOCN - ADDRESS OF DATA
; POS - POSITION OF DATA WITHIN WORD (RIGHTMOST BIT NUMBER)
; SIZ - SIZE OF DATA (IN BITS) WITHIN WORD

DEFINE DEFSTR (NAM,LOCN,POS,SIZ)<
	NAM==<-1B<POS>+1B<POS-SIZ>> ;;ASSIGN SYMBOL TO HOLD MASK
	IF1,<IFDEF %'NAM,<PRINTX ?NAM ALREADY DEFINED>>
	DEFINE %'NAM (OP,AC,Y,MSK)<	;;DEFINE MACRO TO HOLD LOCATION
	IFDIF <Y><>,<
	OP (<AC>,LOCN'+'Y,MSK)>	
	IFIDN <Y><>,<
	OP (<AC>,LOCN''Y,MSK)>>>	

;ALTERNATE FORM OF DEFSTR -- TAKES MASK INSTEAD OF POS,SIZ

DEFINE MSKSTR (NAM,LOCN,MASK)<
	NAM==MASK		;;ASSIGN SYMBOL TO HOLD MASK
	IF1,<IFDEF %'NAM,<PRINTX ?NAM ALREADY DEFINED>>
	DEFINE %'NAM (OP,AC,Y,MSK)<	;;DEFINE MACRO TO HOLD LOCATION
	IFDIF <Y><>,<
	OP (<AC>,LOCN'+'Y,MSK)>	
	IFIDN <Y><>,<
	OP (<AC>,LOCN''Y,MSK)>>>	

;..STR0 - PROCESS INSTANCE OF STRUCTURE USAGE, SINGLE STRUCTURE CASE.

DEFINE ..STR0 (OP,AC,STR,Y)<
	IFNDEF STR,<PRINTX STR IS NOT DEFINED
	  OP (<AC>,Y,FWMASK)>	;;RESERVE A WORD, ASSUME WORD MASK
	IFDEF STR,<
	IFNDEF %'STR,<
	  OP (<AC>,Y,STR)>	;;ASSUME NO OTHER LOCN
	IFDEF %'STR,<
	  %'STR (OP,<AC>,Y,STR)>>> ;;DO IT
;..STR1, ..STR2, ..STR3, AND ..STR4 ARE INTERNAL MACROS FOR PROCESSING
;INSTANCES OF STRUCTURE USAGE.

DEFINE ..STR1 (OP,AC,STR,Y,CLL)<
	..NS==0			;;INIT COUNT OF STR'S
	IRP STR,<..NS=..NS+1>	;;COUNT STR'S
	IFE ..NS,<PRINTX ?EMPTY STRUCTURE LIST, OP>
	IFE ..NS-1,<		;;THE ONE CASE, CAN DO FAST
	  ..STR0 (OP,<AC>,<STR>,Y)>
	IFG ..NS-1,<		;;MORE THAN ONE, DO GENERAL CASE
	..ICNS			;;INIT REMOTE MACRO
	..CNS (<CLL (OP,<AC>,,>) ;;CONS ON CALL AND FIRST ARGS
	IRP STR,<		;;DO ALL NAMES IN LIST
	  IFNDEF STR,<PRINTX STR NOT DEFINED>
	  IFDEF STR,<
	  IFNDEF %'STR,<
	  ..CNS (<,STR,Y>)>	;;ASSUME NO OTHER LOCN
	  IFDEF %'STR,<
	  %'STR (..STR2,,Y,STR)> ;;STR MACRO WILL GIVE LOCN TO ..STR2
	  ..CNS (<)>)		;;CLOSE ARG LIST
	  ..GCNS		;;DO THIS AND PREVIOUS NAME
	  ..ICNS		;;REINIT CONS
	  ..CNS (<CLL (OP,<AC>>) ;;PUT ON FIRST ARGS
	  IFNDEF %'STR,<
	  ..CNS (<,STR,Y>)>	;;ASSUME NO OTHER LOCN
	  IFDEF %'STR,<
	  %'STR (..STR2,,Y,STR)>>> ;;PUT ON THIS ARG, END IRP
	..CNS (<,,)>)		;;CLOSE ARG LIST
	..GCNS>>		;;DO LAST CALL
;..STR2 -- CALLED BY ABOVE TO APPEND STRUCTURE NAME AND LOC TO ARG LIST

DEFINE ..STR2 (AA,LOC,STR)<
	..CNS (<,STR,LOC>)>	;;CONS ON NEXT ARG PAIR

;..STR3 -- CHECK FOR ALL STRUCTURES IN SAME REGISTER

DEFINE ..STR3 (OP,AC,S1,L1,S2,L2)<
	IFDIF <L1><L2>,<
	  IFNB <L1>,<
	    OP (<AC>,L1,..MSK)	;;DO ACCUMULATED STUFF
	    IFNB <L2>,<PRINTX S1 AND S2 ARE IN DIFFERENT WORDS>>
	  ..MSK==0>		;;INIT MASK
	IFNB <L2>,<
	  ..MSK=..MSK!<S2>>>

;..STR4 -- COMPARE SUCCESSIVE ITEMS, DO SEPARATE OPERATION IF
;DIFFERENT WORDS ENCOUNTERED

DEFINE ..STR4 (OP,AC,S1,L1,S2,L2)<
	IFDIF <L1><L2>,<	;;IF THIS DIFFERENT FROM PREVIOUS
	  IFNB <L1>,<
	    OP (<AC>,L1,..MSK)>	;;DO PREVIOUS
	  ..MSK==0>		;;REINIT MASK
	IFNB <L2>,<
	  ..MSK=..MSK!<S2>>>	;;ACCUMULATE MASK

;..STR5 - SAME AS ..STR4 EXCEPT GIVES EXTRA ARG IF MORE STUFF TO
;FOLLOW.

DEFINE ..STR5 (OP,AC,S1,L1,S2,L2)<
	IFDIF <L1><L2>,<	;;IF THIS DIFFERENT FROM PREVIOUS,
	  IFNB <L1>,<
	    IFNB <L2>,<		;;IF MORE TO COME,
		OP'1 (AC,L1,..MSK)> ;;DO VERSION 1
	    IFB <L2>,<		;;IF NO MORE,
		OP'2 (AC,L1,..MSK)>> ;;DO VERSION 2
	  ..MSK==0>		;;REINIT MASK
	IFNB <L2>,<
	  ..MSK=..MSK!<S2>>>	;;ACCUMULATE MASK
;'REMOTE' MACROS USED TO BUILD UP ARG LIST

;INITIALIZE CONS -- DEFINES CONS

DEFINE ..ICNS <
   DEFINE ..CNS (ARG)<
	..CNS2 <ARG>,>

   DEFINE ..CNS2 (NEW,OLD)<
	DEFINE ..CNS (ARG)<
	  ..CNS2 <ARG>,<OLD'NEW>>>
   >

;GET CONS -- EXECUTE STRING ACCUMULATED

DEFINE ..GCNS <
   DEFINE ..CNS2 (NEW,OLD)<
	  OLD>			;;MAKE ..CNS2 DO THE STUFF
	..CNS ()>		;;GET ..CNS2 CALLED WITH THE STUFF
SUBTTL STKVAR - STACK VARIABLE FACILITY

;MACRO FOR ALLOCATING VARIABLES ON THE STACK. ITS ARGUMENT IS
;A LIST OF ITEMS.  EACH ITEM MAY BE:
; 1. A SINGLE VARIABLE WHICH WILL BE ALLOCATED ONE WORD
; 2. A VARIABLE AND SIZE PARAMETER WRITTEN AS <VAR,SIZ>.  THE
;	VARIABLE WILL BE ALLOCATED THE SPECIFIED NUMBER OF WORDS.
;RETURN FROM A SUBROUTINE USING THIS FACILITY MUST BE VIA
;RET OR RETSKP.  A DUMMY RETURN WHICH FIXES UP THE STACK IS PUT ON
;THE STACK AT THE POINT THE STKVAR IS ENCOUNTERED.
;WITHIN THE RANGE OF A STKVAR, PUSH/POP CANNOT BE USED AS THEY WILL
;CAUSE THE VARIABLES (WHICH ARE DEFINED AS RELATIVE STACK LOCATIONS)
;TO REFERENCE THE WRONG PLACE.
;TYPICAL USE:   STKVAR <AA,BB,<QQ,5>,ZZ>


DEFINE STKVAR (ARGS)<
	..STKR==10		;;REMEMBER RADIX
	RADIX 8
	..STKN==0
	IRP ARGS,<
	  .STKV1 (ARGS)>
	JSP .SAC,.STKST
	 ..STKN,,..STKN
	RADIX ..STKR
	PURGE ..STKN,..STKR,..STKQ
   >

;INTERMEDIATE MACRO TO PEAL OFF ANGLEBRACKETS IF ANY

DEFINE .STKV1 (ARG)<
	.STKV2 (ARG)>

;INTERMEDIATE MACRO TO CALCULATE OFFSET AND COUNT VARIABLES

DEFINE .STKV2 (VAR,SIZ)<
	IFB <SIZ>,<..STKN==..STKN+1>
	IFNB <SIZ>,<..STKN==..STKN+SIZ>
	..STKQ==..STKN+1
	.STKV3 (VAR,\..STKQ)>

;INNERMOST MACRO TO DEFINE VARIABLE

DEFINE .STKV3 (VAR,LOC)<
   IFDEF VAR,<.IF VAR,SYMBOL,<PRINTX STKVAR VAR ALREADY DEFINED>>
	DEFINE VAR<-^O'LOC(P)>
	$'VAR==<Z VAR>>		;SYMBOL FOR DDT
SUBTTL TRVAR - TRANSIENT VARIABLE FACILITY

;TRANSIENT (STACK) VARIABLE FACILITY - EQUIVALENT TO STKVAR
;EXCEPT ALLOWS VARIABLES TO BE USED WITHIN LOWER LEVEL ROUTINES
;AND AFTER OTHER THINGS HAVE BEEN PUSHED ON STACK.
;N.B. USES .FP AS FRAME POINTER - MUST NOT BE CHANGED WHILE
;VARIABLES IN USE.


DEFINE TRVAR (VARS)<
	..TRR==10		;;REMEMBER CURRENT RADIX
	RADIX 8
	..NV==1			;;INIT COUNT OF STACK WORDS
	IRP VARS,<
	  .TRV1 (VARS)>		;;PROCESS LIST
	JSP .SAC,.TRSET		;;ALLOCATE STACK SPACE, SETUP .FP
	 ..NV-1,,..NV-1
	RADIX ..TRR		;;RESTORE RADIX
	PURGE ..TRR,..NV>	;;CLEAN UP

DEFINE .TRV1 (VAR)<
	.TRV2 (VAR)>		;;PEEL OFF ANGLEBRACKETS IF ANY

DEFINE .TRV2 (NAM,SIZ)<
	.TRV3 (NAM,\..NV)	;;DEFINE VARIABLE
	IFB <SIZ>,<..NV=..NV+1>
	IFNB <SIZ>,<..NV=..NV+SIZ>>

DEFINE .TRV3 (NAM,LOC)<
   IFDEF NAM,<.IF NAM,SYMBOL,<PRINTX TRVAR NAM ALREADY DEFINED>>
	DEFINE NAM<^O'LOC(.FP)>
	$'NAM==<Z NAM>>		;;SYMBOL FOR DDT
;AC VARIABLE FACILITY

.FPAC==P1			;FIRST PRESERVED AC
.NPAC==10			;NUMBER OF PRESERVED AC'S

DEFINE ACVAR (LIST)<
	..NAC==0		;;INIT NUMBER OF ACS USED
	IRP LIST,<
	  .ACV1 (LIST)>		;;PROCESS ITEMS
	.ACV3 (\..NAC)>		;;SAVE ACS USED

DEFINE .ACV1 (ITEM)<
	.ACV2 (ITEM)>		;;PEEL OFF ANGLEBRACKETS IF ANY

DEFINE .ACV2 (NAM,SIZ)<
	NAM=.FPAC+..NAC		;;DEFINE VARIABLE
	IFB <SIZ>,<..NAC=..NAC+1>
	IFNB <SIZ>,<..NAC=..NAC+SIZ>>

DEFINE .ACV3 (N)<
	IFG N-.NPAC,<PRINTX ?TOO MANY ACS USED>
	IFLE N-4,<
	  $CALL .SAVE'N>	;;SAVE ACTUAL NUMBER USED
	IFG N-4,<
	  $CALL .SAVE8>>	;;SAVE ALL
SUBTTL	SAVE MACRO DEFINITION

;VARIABLE SAVE FACILITY -- ACCEPTS A LIST OF ARGUMENTS
;	$SAVE <LIST-OF-VARIABLES>
;AUTOMATICALLY RESTORES ALL NAMED VARIABLES ON RETURN FROM ROUTINE
;  SUPPORTS +1 OR +2 RETURNS

;IF AN APPROPRIATE CO-ROUTINE IS DEFINED IN GLXCOM FOR THE DESIRED
;AC'S IT IS USED, OTHERWISE OPEN PUSHES AND A DUMMY RESTORE ROUTINE
;ARE GENERATED.

;IF THE SAME SET OF VARIABLES IS SAVED MORE THAN ONCE IN A PROGRAM,
;THE RESTORE ROUTINE GENERATED IN THE LITERALS IS SHARED BETWEEN THE
;TWO SAVES.

DEFINE SAVE (ARG) <PRINTX % Replacing SAVE with $SAVE
		   $SAVE <ARG>>


DEFINE $SAVE(ARG,%L1)<
	.NVR==0			;;INITILIZE VARIABLE COUNT
	.ACM==0			;;INITIALIZE AC MASK

	IRP ARG,<		;;BUILD AC MASK AND PUSH OTHER VARIABLES
		..TSAC(.ACB,ARG)		;;IS IT AN AC?
		IFN .ACB,<.ACM==.ACM!1B<ARG>>	;;YES -- BUILD MASK
		IFE .ACB,<			;;NO -- PUSH IT
		IFE .NVR,<			;;FIRST VARIABLE?
		    CAIA			;;YES -- DO SKIP CODE
		    LSTOF.
		    JRST %L1>
		  ..PUSH(ARG,\<.NVR+1>)>>	;;PUSH IT AND BUMP COUNT

	IFN .ACM,<	;;CHECK FOR PROPER AC CO-ROUTINE
	    IFE <.ACM-17B<T4>>,<.ACM==0
				$CALL .SAVET>
	    IFE <.ACM-377B<.A16>>,<.ACM==0
				$CALL .SAVE8>
	    IFE <.ACM-17B<P4>>,<.ACM==0
				$CALL .SAVE4>
	    IFE <.ACM-7B<P3>>,<.ACM==0
				$CALL .SAVE3>
	    IFE .NVR,<	;;DON'T DO CO-ROUTINE IF OTHER VARIABLES
	    IFE <.ACM-3B<P2>>,<.ACM==0
				$CALL .SAVE2>
	    IFE <.ACM-1B<P1>>,<.ACM==0
				$CALL .SAVE1>
	    IFE <.ACM-1B<.A13>>,<.ACM==0
				$CALL .SV13>
	    IFE <.ACM-1B<.A14>>,<.ACM==0
				$CALL .SV14>
	    IFE <.ACM-1B<.A15>>,<.ACM==0
				$CALL .SV15>
	    IFE <.ACM-1B<.A16>>,<.ACM==0
				$CALL .SV16>
	    >>

;;SAVE IS CONITINUED ON NEXT PAGE
;;SAVE MACRO CONTINUED FROM PREVIOUS PAGE

	IFN .ACM,<	;;PUSH THE AC'S IF NOT DONE BY CO-ROUTINE
	    IFE .NVR,<			;;FIRST ONE?
		CAIA			;;YES -- DO SKIP CODE
		LSTOF.
		JRST %L1>

	    .ACB==0			;;START AT AC0
	REPEAT ^D16,<			;;LOOP THRU ALL 16
	    IFN <.ACM&1B<.ACB>>,<	;;WAS IT GIVEN?
		..PUSH(\.ACB,\<.NVR+1>)>;;YES -- PUSH IT
		.ACB==.ACB+1>>		;;STEP TO NEXT

	IFN .NVR,<	;;BUILD DUMMY ROUTINE TO RESTORE ALL PUSHES
	    PUSH P,[[CAIA		;;HERE FOR NON SKIP RETURN
		     AOS -.NVR(P)	;;HANDLE SKIP RETURN
	    REPEAT .NVR,<..POP(\.NVR)>	;;POP ALL THINGS STACKED
		     POPJ P,0]]>	;;RETURN TO CALLER
	LSTON.
%L1:	SUPPRESS %L1>

	DEFINE ..PUSH(ARG,.NVX)<
		PUSH P,ARG
		.NV'.NVX==ARG
		.NVR==.NVR+1>

	DEFINE ..POP(.NVX)<
		POP P,.NV'.NVX
		PURGE .NV'.NVX
		.NVR==.NVR-1>
SUBTTL	LOAD,STORE,INCR,DECR,ZERO

DEFINE LOAD (AC,Y,STR)<
	IFNB <STR>,<..STR0 (..LDB,AC,STR,Y)>
	IFB  <STR>,<MOVE AC,Y>>		;;DEFAULT TO FULL WORD MOVE

   DEFINE ..LDB (AC,LOC,MSK)<
	..TSIZ (..PST,MSK)
	.CASE ..PST,<<
		MOVE AC,LOC>,<
		HRRZ AC,LOC>,<
		HLRZ AC,LOC>,<
		LDB AC,[POINTR (LOC,MSK)]>>>

DEFINE STORE (AC,Y,STR)<
	IFNB <STR>,<..STR0 (..DPB,AC,STR,Y)>
	IFB  <STR>,<MOVEM AC,Y>>	;;DEFAULT FULL WORD MOVE

   DEFINE ..DPB (AC,LOC,MSK)<
	..TSIZ (..PST,MSK)
	.CASE ..PST,<<
		MOVEM AC,LOC>,<
		HRRM AC,LOC>,<
		HRLM AC,LOC>,<
		DPB AC,[POINTR (LOC,MSK)]>>>

DEFINE INCR (Y,STR)<
	IFNB <STR>,<..STR0 (.INCR0,,<STR>,Y)>
	IFB  <STR>,<AOS Y>>		;;DEFAULT FULL WORD INCR

   DEFINE .INCR0 (AC,LOC,MSK)<
	..PST==MSK-FWMASK
	.IF0 ..PST,<
		AOS LOC>,<	;;FULL WORD, CAN USE AOS
		$CALL .AOS	;;MUST USE SUPPORT CODE
		LSTOF.
		JUMP [POINTR(LOC,MSK)]
		LSTON.>>

DEFINE DECR (Y,STR)<
	IFNB <STR>,<..STR0 (.DECR0,,<STR>,Y)>
	IFB  <STR>,<SOS Y>>		;;DEFAULT FULL WORD DECR

   DEFINE .DECR0 (AC,LOC,MSK)<
	..PST==MSK-FWMASK
	.IF0 ..PST,<
		SOS LOC>,<	;;FULL WORD, CAN USE SOS
		$CALL .SOS	;;MUST USE SUPPORT CODE
		LSTOF.
		JUMP [POINTR(LOC,MSK)]
		LSTON.>>
DEFINE ZERO (Y,STR)<
	IFNB <STR>,<..STR1 (..TQZ,,<STR>,Y,..STR4)>
	IFB  <STR>,<SETZM Y>>		;;DEFAULT FULL WORD ZERO

   DEFINE ..TQZ (AC,LOC,MSK)<
	..TSIZ (..PST,MSK)	;;SET ..PST TO CASE NUMBER
	.CASE ..PST,<<
		SETZM LOC>,<	;;FULL WORD
		HLLZS LOC>,<	;;RH
		HRRZS LOC>,<	;;LH
	  ..TSAC (..ACT,LOC)	;;SEE IF LOC IS AC
	  .IF0 ..ACT,<
		$CALL .ZERO	;;NO -- MUST USE SUPPORT CODE
		LSTOF.
		JUMP [POINTR(LOC,MSK)]
		LSTON.>,<
		..TX (Z,LOC,MSK)>>>>
SUBTTL $BGINT,$DEBRK - Interrupt context switching

;At the beginning of each interrupt level routine, the first instruction
; is a $BGINT, with the address field indicating which priority level
; this interrupt is on.  When the interrupt is over, the $DEBRK instruction
; is used, which resumes non-interrupt level context and dismisses the
; interrupt.  Interrupt context gives all ACs and a new Stack for use.

;Establish interrupt level context

	DEFINE $BGINT(LVL)<
	  IFG LVL-INT.LV,<PRINTX ?Level LVL interrupts not supported>
	  .BGINT.(\LVL) >	;;END OF $BGINT DEFINITION

	DEFINE .BGINT.(A)<JSR I%INT'A>



;Return to normal (non-interrupt) level

	DEFINE $DEBRK<
	  $RET				;WILL INVOKE RIGHT ROUTINE
	> ;END OF $DEBRK DEFINITION
SUBTTL $BUILD,$SET,$EOB - Build pre-formed data blocks

;Many components have a need to build simple and complex blocks which
;	contain pre-formatted data, such as FOBs,IBs and other blocks
;	which are made up of several words, each containing from 1 to several
;	fields.  Since data structures change, these blocks should not be
;	just created using EXP or whatever.  These macros will take values
;	and install them in the right field and word of a structure.

; Start off a structure, argument is the size of the structure.

	DEFINE $BUILD(SIZE)<
	  IFDEF ..BSIZ,<PRINTX ?Missing $EOB after a $BUILD>
	  ..BSIZ==0			;;START COUNTER
	  ..BLOC==.			;;REMEMBER OUR STARTING ADDRESS
	  REPEAT SIZE,<			;;FOR EACH WORD IN THE BLOCK
		BLD0.(\..BSIZ,0)	;;ZERO OUT IT'S ACCUMULATOR
		..BSIZ==..BSIZ+1>	;;AND STEP TO NEXT
	>;END OF $BUILD DEFINITION

; For each value installed somewhere in the structure, set it into the block
; 	Arguments are word offset,field in word (optional) and value to set.

	DEFINE $SET(OFFSET,STR,VALUE),<
	  IFNDEF ..BSIZ,<PRINTX ?$SET without previous $BUILD>
	  IFNB <STR>,<..STR0 (..SET,<VALUE>,STR,OFFSET)>
	  IFB  <STR>,<..STR0 (..SET,<VALUE>,FWMASK,OFFSET)>
	> ; END OF $SET DEFINITION

	DEFINE ..SET (VALUE,LOC,MSK) <
	  IFGE <<<LOC>&777777>-..BSIZ>,<
		PRINTX ?WORD offset greater than $BUILD size parameter>
	  SET0. (\<LOC>,MSK,<VALUE>)
	> ;END ..SET DEFINITION

; After all values are declared, the block must be closed to do its actual
;	creation.

	DEFINE $EOB,<
	  IFNDEF ..BSIZ,<PRINTX ?$EOB without previous $BUILD>
	  IFN <.-..BLOC>,<PRINTX ?Address change between $BUILD and $EOB>
	  LSTOF.			;;DON'T SHOW THE BLOCK
	  ..T==0
	  REPEAT ..BSIZ,<
	    BLD0.(\..T,1)		;;STORE EACH WORD
	    ..T==..T+1 >
	  PURGE ..BSIZ,..T,..BLOC	;;REMOVE SYMBOLS
	  LSTON.
	>; END OF $EOB DEFINITION

	DEFINE BLD0.(N,WHAT),<
	  IFE WHAT,<..T'N==0>
	  IFN WHAT,<EXP ..T'N
		    PURGE ..T'N>
	> ;END OF BLD0. DEFINITION

	DEFINE SET0.(LOC,MSK,VALUE),<
	IFN <<..T'LOC>&MSK>,<PRINTX ?Initial field not zero in $SET>
	  ..TVAL==<VALUE>
	  ..TMSK==<MSK>
	  ..T'LOC==..T'LOC!<FLD(..TVAL,..TMSK)>
	  PURGE ..TVAL,..TMSK
	>;END OF SET0. DEFINITION
SUBTTL	$CALL,$RETT,$RETF,$RETE,$RET Uniform Call/Return Mechanisms

;	All routines which follow GALAXY Conventions should call
;  library routines and internal routines which return TRUE/FALSE
;  values with the $CALL Macro.  This provides a uniform calling
;  mechanism.

; 	All routines which follow GALAXY conventions should return
;  via one of the return instructions. These instructions set the contents
;  of the true/false register, TF and then return via POPJ P,.

;	If a routine wishes to merely pass on the value of the TF register
;  it should return using a $RET


	OPDEF	$CALL	[PUSHJ P,0]

; $RETE is the instruction used to return FALSE from a routine and also
; set a specific error code in the first status register, S1.  The argument
; provided to the instruction is a 3 letter GLXLIB canonical error code.
; The effect of the $RETE instruction is to place the value of the
; GLXLIB error code into S1, place FALSE into TF and return via POPJ.

	DEFINE $RETE (COD) <
	  JSP	TF,.RETE		;;GO TO SUPPORT COD
		LSTOF.
	  JUMP	ER'COD'$
		LSTON.>			;;END OF $RETE DEFINITION


;$RETT is the instruction used to place a value of TRUE into the TF register
;  and return from the routine.  This instruction is used when a routine 
;  wishes to indicate to its caller that it is returning successfully.

;	$RETT is defined during the PROLOG macro


;		OPDEF	$RETT PJRST .RETT]


;$RETF is the instruction used to place a value of FALSE into the TF register
;  and return from the routine.  This instruction is used when a routine
;  wishes to indicate to its caller that is returning unsuccessfully.

;	$RETF is defined during the PROLOG macro

;		OPDEF	$RETF [PJRST .RETF]


;$RET is the instruction used to return the last value of TF to the caller

	OPDEF	$RET	[POPJ P,]	;;RETURN CURRENT VALUE OF TF
SUBTTL $DATA and $GDATA Macros - Runtime System Data Area control

;This macro is used to define impure storage areas.  The actual
;areas are created at run-time by the memory manager.  The first argument
; is the name of the word(s) to be allocated. This name may be referenced
; as any other labelled location.  The second argument is the number of
; words to allocate.  If omitted, this defaults to 1.

;In order to facilitate debugging of new library routines, the $DATA and
;	$GDATA macros produce BLOCK pseudo-op type locations when used
;	in a module whose PROLOG indicates it is not part of the library.
; 	This means that a new library module may be loaded with a test program
;	as a non-library piece of code while it is being debugged.

	DEFINE $DATA(NAM,SIZ<1>)<
		.PSECT	DATA
	NAM:	BLOCK	SIZ
		.ENDPS
	> ;END OF $DATA DEFINITION


; $GDATA is exactly like $DATA, except that the location defined
;	is GLOBAL, that is, available to other programs.

	DEFINE $GDATA(NAM,SIZ<1>)<
	  INTERN NAM
	  $DATA(NAM,<SIZ>)
	> ;END OF $GDATA DEFINITION
SUBTTL	$FATAL, and $WARN Macro definitions

;$FATAL is provided as a short form STOP code.  It should
;be used when it is impossible to proceed because
;the program doesn't have proper priviledges or can't find a required
;file -- or any other occassion where the full stopcode information
;is irrelevant or misleading


;CALL	$FATAL <any valid $TEXT string argument>
;

DEFINE $FATAL (STRING) <
	$CALL	.STOP
	LSTOF.
	JUMP	[XWD 0,[ITEXT (<STRING>)]
		 EXP %%.MOD]
	LSTON. > ;END OF $FATAL DEFINITION

;$WARN May be used when it is desired to issue a warning on the
;users terminal.

;CALL	$WARN <any valid $TEXT string argument>
;
DEFINE	$WARN (STRING) <
IFE %%.OTS,<DEFINE $WARN (MSG) <
		$TEXT (T%TTY,<% ^W6/[%%.MOD]/ MSG>)>>
IFN %%.OTS,<DEFINE $WARN (MSG) <
		$TEXT (T%TTY,<% ^W6/IIB+IB.PRG/ ^W/[%%.MOD]/ MSG>)>>
	$WARN <STRING>> ;END OF $WARN DEFINITION
SUBTTL	$STOP - Cause a STOP CODE to occur

; The $STOP macro generates a call to the .STOP routine in GLXCOM,
;	which processes the information imbedded in the $STOP parameter
;	area.  Modules using the $STOP macro should begin with a PROLOG
;	to set up the module name symbol %%.MOD or should define this
;	symbol separately.


;For each $STOP there is a unique label made, using the 3 letter
;	code provided.  The label is 'S..xxx' where the xxx is the 3 letter
;	code.  This label is declared global, to insure unique STOP
;	CODE names.

;The macro call is:
;	$STOP(CODE,STRING)

;WHERE	CODE = A UNIQUE 3 CHARACTER INDICATION OF THE STOP CODE
;  AND
;STRING IS AN EXPANDED STRING ASSOCIATED WITH THE ERROR CONDITION
; I.E.:	$STOP(NFP,No free pages)
;	WILL EXPAND TO:   PUSHJ	P,.STOP
;			  JUMP	 [XWD 'NFP',[ITEXT (No free pages)]
;				  EXP %%.MOD ]



DEFINE	$STOP(CODE,STRING),<
S..'CODE::!	$CALL .STOP
		LSTOF.
		JUMP [XWD ''CODE'',[ITEXT (<STRING>)]
			EXP %%.MOD]
		LSTON.	> ;END OF $STOP DEFINITION
SUBTTL $TEXT - Interface to the T%TEXT routine

; The $TEXT macro is used to do all formatted ASCII output involving
;	strings and/or variables.  The macro takes two arguments.
;	The first argument is the address of a routine to call when T%TEXT
;	actually has a single right justified 7 bit ASCII character to output
;	from its arguments.  The specified routine will be called with the
;	character in S1 and should return TRUE or FALSE in S1.  A value of
;	FALSE will cause a STOP CODE to occur.
;	If the first argument is null, i.e. left blank, then a default
;	routine will be called, specified at initialization.
;	If the first argument is <-1,,ADDR>, it is a IDPB style byte pointer
;	for GLXTXT to store bytes into.

;	The second argument is a text string containing characters to output
;	and imbedded argument specifiers for substitutable parameters to be
;	merged with constant data. 

;	If no specifier precedes a string in the second argument, it is
;	assumed to be straight string data to be passed to the output routine
;	directly.  On the other hand, substitutable parameters are described
;	by:	^<QUALIFIER>[OPT. SPACING]/<ADDRESS-OF-VARIABLE>[OPTIONAL <,MASK>]/
;	Where the qualifier is one of the recognized single letter argument
;	types (See next page), and the address and optional mask are two 
;	36 bit quantities, such as might be passed to LOAD/STORE. These 
;	addresses can contain indexing and/or indirection ,may point to
;	the accumulators or the stack.

;	Each $TEXT instruction normally ends in a "free" carriage return
;	line feed sequence. That is, each $TEXT instruction produces one
;	line of output.  However, through use of the qualifiers 0,A,M,J,K and L,
;	output can be formatted to produce multiple lines via a single $TEXT
;	or one line via multiple $TEXTS. ^0 gives a null (0) terminator in place of CRLF.

; NOTE:	The $TEXT macro is a pseudo-instruction, and as such, it may be skipped
;	over to avoid its execution. Also, all accumulators are guaranteed
;	preserved .

;	Example:
;	   $TEXT(PUTCHR,<This is your PPN: ^P/MYPPN/ for today.>)
;		1. Prints (using the routine PUTCHR for output) the string,
;		    "This is your PPN: "
;		2. Prints the contents of location MYPPN as a TOPS-10 PPN.
;		3. Prints the string " for today."
;		4. Prints a <CRLF> to produce the end of the line.
;	Example:
;	   $TEXT(<-1,,LINBUF>,<File ^D/FB%STS(P1),FBS%FN/ is named ^F/@S1/^A>)
;		1. Prints the string "File ", depositing chars into the user buffer LINBUF
;		2. Prints the "loaded" contents of FB%STS(P1),FBS%FN as
;		    a decimal number
;		3. Prints the string " is named "
;		4. Prints the contents of the FD pointed to by AC S1 as
;		    a file specification.
;		5. Does not produce a <CRLF> sequence, since the ^A qualifier
;		    specifies that we supress it.
;	Optionally, any output field may be right or left justified or
;	centered.  The information used to do this appears between the
;	qualifier symbol and the slash which starts the address of the
;	field to be output.  The justification information consists of
;	three parts, two of which are optional.  The first piece of the
;	justification information is the width of the field. This is given
;	in Radix 10. and can be any number greater than zero.  The second
;	piece is a one letter code telling the Text processor which type
;	of justification to use. This can be "L" for left justification,
;	"R" for right justification or "C" for centering.  If this field
;	is omitted, the default is right justification for numeric items
;	(I.E. ^O and ^D), and left justification for all other types.
;	The third, optional, part is a single character which will be the
;	character used to do any padding necessary for the justification.
;	If the character is given, the justification code must be given also.
;	If the padding character is omitted, it defaults to blanks.

;	Example:
;	  $TEXT(PUTCHR,<^D10L*/S1/  ^F30/@FILSPC/  ^T40C/FOO(S2)>)
;		1. Prints the decimal number in S1, in a field of 10. characters.
;		   The number will be left justified, the remainder of the
;		   field will be filled with the character "*".
;		2. After printing one space, the file specification pointed
;		   to by location FILSPC will be printed in a 30 character
;		   field.  The justification defaults to left justification,
;		   and the fill character is a space.
;		3. After printing another space, the ASCIZ string starting
;		   at location FOO(S2) will be printed in a 40 character
;		   field. The resulting output will be centered in the field
;		   and filled with blanks as necessary.
;
;	NOTE: If output overflows a field, then no justification is done.
;
; The actual $TEXT macro

DEFINE $TEXT(ROUTINE,STRING,%L1)<

	$CALL	T%TEXT		;;CALL THE OUTPUT ROUTINE
	LSTOF.	XCREF			;;DONT LIST THIS MESS
	JRST	%L1			;;SKIP OVER THE ARGUMENTS
	..CN..==0
	..KN..==0
	  EFLG==1
	IRP ROUTINE,<..CN..==..CN..+1>
	IFE <..CN..>,<SETZ 0,		;;NO PARM,,DEFAULT TO IB ROUTINE.
		      EFLG==0>		;;SET TO SHOW PARM OK.
	IFE <..CN..-1>,<MOVEI 0,ROUTINE	;;1 PARM,,USE THIS AS $TEXT OUT ROUT.
		      EFLG==0>		;;SET TO SHOW PARM OK.
	IFE <..CN..-3>,<IRP ROUTINE,<	;;FIND THE 3RD PARM.
			..KN..==..KN..+1
			IFE <..KN..-..CN..>,<
			    EFLG==0	;;SET TO SHOW PARM OK.
			    HRROI 0,ROUTINE >>>
	IFN <EFLG>,<IF1,<
		    PRINTX ?Invalid syntax in $TEXT parameter ROUTINE.
		    PRINTX > 
		    HALT . >		;;STOP HERE WHEN EXEC.
	FTEXT.(<STRING>)		;;PARSE THE STRING
	IFN EFLG,<ETEXT.($TEXT,<STRING>)> ;;IF ANY ERRORS, DESCRIBE THEM
%L1:					;;PLACE LABEL
	SUPPRESS %L1			;;DON'T CONFUSE DDT OR ME
	LSTON.	> ;END OF $TEXT DEFINITION
; Define legal qualifers for argument types
;
; The first argument is the qualifier, the second is a flag telling
; the macro that this qualifer takes no arguments.

; Remember to add new qualifiers to the end, in order to keep older
; programs working.

	DEFINE TQUALS,<
	LSTOF.
	X(T,TXT.A)			;;ASCIZ STRING
	X(O,TXT.A)			;;UNSIGNED OCTAL NUMBER
	X(D,TXT.A)			;;DECIMAL NUMBER
	X(F,TXT.A)			;;FILE SPECIFICATION
	X(7,TXT.A)			;;ONE RIGHT JUSTIFIED 7 BIT CHARACTER
	X(6,TXT.A)			;;ONE RIGHT JUSTIFIED 6 BIT CHARACTER
	X(W,TXT.A)			;;SIXBIT WORD
	X(5,TXT.A)			;;ASCIZ, ONLY 1 WORD
	X(P,TXT.A)			;;PPN OR DIRECTORY NUMBER
	X(U,TXT.A)			;;PPN OR USER NUMBER
	X(H,TXT.A)			;;UDT TO BE TYPED AS DD-MON-YY HH:MM:SS
	X(C,TXT.A)			;;TIME FROM UDT TO BE TYPED AS HH:MM:SS
	X(E,TXT.A)			;;TYPE OUT STRING FOR ERxxx$ ERROR CODE
	X(I,TXT.A)			;;POINTER TO ITEXT (INDIRECT  TEXT) BLOCK
	X(M,TXT.NA)			;;TYPE ^M (CARRIAGE RETURN)
	X(J,TXT.NA)			;;TYPE ^J (LINE-FEED)
	X(L,TXT.NA)			;;TYPE ^L (FORM FEED)
	X(K,TXT.NA)			;;TYPE ^K (VERTICAL TAB)
	X(A,TXT.NA)			;;(APPEND) SUPPRESS FREE CARRIAGE RET.-LINE FEED
	X(0,TXT.NA)			;;NULL CHAR INSTEAD OF CR-LF AT END
	X(3,TXT.A)			;;INTERNAL STRING (DO NOT USE AS QUALIFIER)
	X(V,TXT.A)			;;PROGRAM VERSION NUMBER
	X(2,TXT.NA)			;;INTERNAL UP-ARROW (DO NOT USE AS QUALIFIER)
	X(Q,TXT.A)			;;BYTE POINTER TO ASCIZ STRING
	X(B,TXT.A)			;;OBJECT BLOCK
	X(1,TXT.A)			;;OBJECT TYPE
	X(N,TXT.A)			;;TYPE A NODE NAME/NUMBER
	X(R,TXT.A)			;;TYPE OUT JOB INFO BLOCK (JIB)
	LSTON.
> ;END OF TQUALS DEFINITION

	DEFINE	X(A,ARG)<TXTF.'A==<ZZ>B8+ARG
			ZZ==ZZ+1>

	TXT.A==0B0			;FLAG THAT SAYS TAKES ARGUMENTS
	TXT.NA==1B0			;FLAG THAT SAYS DOESNT TAKE ARGS
	TXT.P==1B1			;FLAG THAT SAYS TWO WORD BLOCK NEEDED
	TXT.S==1B2			;FLAG THAT SAYS WANTS SPACING
	  TXT.SC==177B6			;MASK TO GET CHARACTER FOR SPACING
	  TXT.SS==3B17			;MASK TO GET SIDE FOR SPACING
	    TXT.SL==1			;CODE TO SPACE LEFT
	    TXT.SR==2			;CODE TO SPACE RIGHT
	    TXT.SM==3			;CODE TO SPACE MIDDLE (CENTER)
	  TXT.SP==777777		;MASK TO GET POSITIONS FOR SPACING
	TXT.M==77B8			;MASK TO QUALIFIER PART

; CREATE THE TXTF SYMBOLS
	ZZ==1
	TQUALS
;  Definitions of Macros used by $TEXT

; CLEAR THE TEXT GATHERING MECHANISM

	DEFINE CTEXT.	<
	DEFINE XTEXT.(OPCODE,NEW)<
	OPCODE	<<NEW>>>>

; ADD TEXT OR DEFINE IT

	DEFINE	ATEXT.(OLD)<
	DEFINE	XTEXT.(OPCODE,NEW)<
	OPCODE	<OLD,<NEW>>>>

; MACRO TO STRIP OFF ONE PAIR OF BRACKETS

	DEFINE	TEXT.(A),<TXT1. (A)>


; MACRO TO CREATE THE TWO WORD BLOCK NEEDED FOR LOAD/STORE PAIRS

	DEFINE PTEXT.(A,B)<
	   OPC A
	   POINTR(0,B)
	> ;END OF PTEXT. DEFINITION


;; CONTINUED ON NEXT PAGE
; DUMP ACCUMULATED TEXT INTO WHERE ITS GOING TO BE USED

	DEFINE DTEXT.(TYPE)<
	IFN TFLG,<
DEFINE TXT1.(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,ZZ,A1,B1,C1,D1,E1)<
TYPE+[ASCIZ\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'ZZ'A1'B1'C1'D1'E1\]
>>
IFE TFLG,<
DEFINE TXT1.(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,ZZ,A1,B1,C1,D1,E1)<
	IFE ZFLG,<
	OPDEF OPC [TYPE]
OPC 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'ZZ'A1'B1'C1'D1'E1
	>
	IFN ZFLG,<
	OPDEF OPC [ZFLG+TYPE]
PTEXT.(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'ZZ'A1'B1'C1'D1'E1)
	>
>>

IFE TYPE&TXT.NA,<
	  .CREF
	XTEXT. TEXT.
	  .XCREF
		>
IFN TYPE&TXT.NA,<
	EXP TYPE
		>

IFN TYPE&TXT.S,<
	IFE SCHAR,<SCHAR==" ">
	IFE SSIDE,< IFE TXTF.D-<TYPE&TXT.M>,< SSIDE==TXT.SR>>
	IFE SSIDE,< IFE TXTF.O-<TYPE&TXT.M>,< SSIDE==TXT.SR>>
	IFE SSIDE,< SSIDE==TXT.SL>
	EXP <<INSVL.(SCHAR,TXT.SC)>+<INSVL.(SSIDE,TXT.SS)>+<INSVL.(SWIDTH,TXT.SP)>>
	SSIDE==0
	SWIDTH==0
	SCHAR==0
>
	CTEXT.
	TFLG==0
	ZFLG==0
	PURGE OPC
	> ;END OF DTEXT. DEFINITION
;  DO ERROR PROCESSING IF AN ERROR IS DETECTED DURING ASSEMBLY

	DEFINE ETEXT.(NAME,STRING)<
IF1,<
	IFN EFLG&1,<PRINTX ?Uknown qualifier in NAME call of STRING
		     PRINTX
>
	IFN EFLG&2,<PRINTX ?Bad spacing specification in NAME call of STRING
		     PRINTX
>
	IFN EFLG&4,<PRINTX ?Premature end of text in NAME call of STRING
		     PRINTX
>
	IFN EFLG&10,<PRINTX ?Bad address in NAME call of STRING
		     PRINTX
>
	IFN EFLG&20,<PRINTX ?Variable address too long in NAME call of STRING
		     PRINTX
>
	IFN EFLG&40,<PRINTX ?Spacing on I qualifier in NAME call of STRING
		     PRINTX
>
> ;END OF IF1
> ;END OF ETEXT. DEFINITION



; ALLOW A T%TEXT ARGUMENT BLOCK TO BE BUILT OUTSIDE OF THE $TEXT
;  CALL. THIS IS USED FOR THE "I" QUALIFIER, WHERE THE ADDRESS
;  SPECIFIED IS THAT OF A T%TEXT ARGUMENT BLOCK, BUILT BY THIS MACRO.
; THIS ALLOWS MORE COMPLEX STRINGS THAN ^T TYPE STRINGS TO BE INCLUDED
; IN $TEXT INSTRUCTIONS.

; THE SINGLE ARGUMENT IS A $TEXT TYPE STRING, ENCLOSED IN A <> PAIR.

	DEFINE	ITEXT(STRING)<
	LSTOF. XCREF			;;TURN OFF LISTINGS
	FTEXT.(<STRING>)		;;PARSE THE ARGUMENT STRING
	IFN EFLG,< ETEXT.(ITEXT,<STRING>)> ;IF ERROR, DESCRIBE IT
	EXP	0			;;STORE NULL WORD AS TERMINATOR
	LSTON.	> ;END OF ITEXT DEFINITION
; THE ACTUAL PARSE MACRO USED TO BREAK UP THE STRING
;	NOTE: THE MACRO IS MADE AS SMALL AS POSSIBLE TO CONSERVE SPACE AND
;	      MAKE IT FASTER.

DEFINE FTEXT.($A),<
	TFLG==0	;;NOT ACCUMULATING TEXT
	AFLG==0	;;NOT ACCUMULATING ARGUMENT ADDRESS
	SFLG==0	;;NOT LOOKING FOR QUALIFIER
	IFLG==0	;;CLEAR SLASH/INGORE FLAG
	ZFLG==0	;;CLEAR TWO PART ADDRESS FLAG
	EFLG==0
	SCHAR==0;;CLEAR CHARACTER
	SWIDTH==0;;AND SPACING
	SSIDE==0;;AND THE SIDE TO SPACE ON
	CTEXT.

IRPC $A,<	;;MAIN LOOP, REPEAT FOR EACH CHARACTER
    IFN SFLG,<	;;IS QUALIFER EXPECTED?
	FTEX1.(<$A>)	;;YES, CALL QUALIFER PARSER
>		;;END OF IFN SFLG
IFE SFLG+AFLG+IFLG,<	;;IF NO QUALIFER,OR ADDRESS OR IGNORING	
IFIDN <$A>,<^>,<	;;LOOK FOR QUALIFIER
IFN TFLG,<DTEXT.(TXTF.3)>;;FOUND IT, DUMP ANY TEXT SO FAR
SFLG==1	;;AND LOOK FOR QUALIFER NEXT TIME
>	;;END OF IFIDN FOR CARET
IFE SFLG,<	;;UNLESS JUST FOUND QUALIFIER,
IFE ^D29-TFLG,<;;CHECK FOR TEXT OVERFLOW
DTEXT.(TXTF.3);;SO WE DONT LOSE IT
>	;;END OF IFE
TFLG==TFLG+1	;;COUNT ADDED CHARACTER
XTEXT. ATEXT.,<$A>	;;ADD THE CHARACTER
>	;;END OF IFE SFLG
>	;;END OF IFE SFLG+AFLG+IFLG
IFE SFLG+IFLG+TFLG,<	;;IF NOT QUAL. NEXT, IGNORE OR DOING TEXT
FTEX2.(<$A>)	;;PROCESS ADDRESS BUILDING
>	;;END OF IFE SFLG+IFLG+TFLG
IFN IFLG,<;;IGNORE FLAG LIT, SEE WHY
FTEX3.(<$A>)	;;IN SLASH PROCESSOR
>	;;END OF IFN IFLG
>;;END OF IRPC
IFN TFLG,<DTEXT.(TXTF.3)>;;AT THE END, DUMP ANY LEFT OVER TEXT
IFN AFLG+SFLG+IFLG,<EFLG==EFLG!4>;;MAKE SURE WE WERE NOT LEFT HANGING
	> ;END FTEXT. DEFINTION
; THESE "SUBROUTINE" MACROS ARE USED TO PROCESS INFREQUENT OCCURENCES
;	IN THE STRING PASSED TO THE FTEXT. MACRO.  PUTTING THEM HERE,
;	RATHER THAN IN THE MAIN FTEXT. MACRO MAKES ASSEMBLY FASTER.

DEFINE FTEX1.($A)<			;;PROCESS QUALIFIER SYMBOL
        SFLG==0				;;CLEAR QUALIFER EXPECTED
	STYP==0				;;CLEAR QUALIFER
	IFIDN <$A><^>,<STYP==TXTF.2>	;;FAKE THE ^^ QUALIFER TO BE 2
	IFE STYP,<IFDEF TXTF.'$A,<STYP==TXTF.'$A>>;;IF LEGAL SET TYPE
	IFE STYP,<EFLG==EFLG!1>		;;ELSE SET "ILLEGAL QUALIFER"
	IFN STYP&TXT.NA,<		;;IF THIS QUALIFER HAS NO ARGUMENTS
	     DTEXT.(STYP)		;;THEN DUMP THE QUALIFER NUMBER AND FLAGS NOW
	     IFLG==3			;;AND SET TO IGNORE REST OF PASS
			>	 	;;END OF IFN STYP&TXT.NA
	IFE STYP&TXT.NA,<		;;IF THERE IS AN ARGUMENT,
	    IFLG==1			;;IGNORE THIS PASS, GET SLASH NEXT TIME
	    AFLG==1			;;AND START ACCUMULATING ADDRESS OF ARG
	    SWIDTH==0			;;CLEAR SPACING WIDTH
			>	 	;;END OF IFE STYP&TXT.NA
	ZFLG==0				;;IN ANY CASE, CLEAR 2-PART ADDR FLAG
 >;END OF FTEX1. DEFINITION



DEFINE FTEX2.($A)<			;;PROCESS ARG ADDRESS
	IFIDN <$A></>,<			;;ARE WE AT END?
	    AFLG==0			;;YES, SO CLEAR ACCUMULATING ADDRESS FLAG
	    IFLG==3			;;IGNORE THE SLASH
	    DTEXT.(STYP)		;;AND DUMP THE WHOLE ^X/FOO/ THING
		  >          		;;END OF IFIDN
	IFN AFLG,<			;;OTHER WISE, JUST ACCUMULATE ADDRESS
	    XTEXT. ATEXT.,<$A>
	    AFLG==AFLG+1		;;TRACK LETTERS IN ADDRESS
	    IFE AFLG-^D31,<EFLG==EFLG!20> ;;IF TOO LONG, COMPLAIN
	    IFIDN <$A><,>,<		;;DO WE HAVE A COMMA? (2 PART ADDR)
		IFN ZFLG,<EFLG==EFLG!10> ;;DONT ALLOW TWICE
		ZFLG==TXT.P
			  >		;;END OF IFIDN ,COMMA
		  >			;;END OF IFN AFLG
 > ;END OF FTEX2. DEFINTION


DEFINE FTEX3.($A)<			;;PROCESS SPECIAL SLASH REQUEST

	IFE IFLG-3, <			;;VALUE OF 3 SAYS JUST TURN IT OFF
	    IFLG==0			;; GIVES A WAY TO FLUSH THE PASS
		    >			;;END IFE IFLG-3
	IFE IFLG-2,<			;;VALUE=2 MEANS 
	    IFLG==0			;;TURN IT OFF
	    IFDIF<$A></>,<FTEX4.(<$A>)>	;;CHECK FOR SLASH, IF NOT THERE CHECK IT
		  >			;;END OF IFE IFLG-2
	IFE IFLG-1,<			;;VALUE=2 MEANS, IGNORE THIS PASS BUT
	    IFLG==2			;;ON NEXT, CHECK FOR SLASH
		  >	 		;;END OF IFE IFLG-2
 >;END OF FTEX3. DEFINITION

DEFINE FTEX4.($A)<			;;PROCESS SPACING SPECIFICATIONS
    EFLG==EFLG!2			;;ASSUME AN ERROR
     IFE SSIDE,<			;;IF HAVE NOT SEEN SIDE YET,
    IFLE "0"-"$A",<			;;IF NUMERIC
	IFGE "9"-"$A",<SWIDTH==SWIDTH*^D10+^D'$A ;;ACCUMULATE SPACING
		   IFE STYP-TXTF.I<EFLG==EFLG!40> ;;DON'T ALLOW ON INDIRECT
		   STYP==STYP!TXT.S	;;INDICATE SPACING WANTED
		   EFLG==EFLG&<^-2>	;;CLEAR ERROR FLAG
		 >			;;END OF IFGE 9
		  >			;;END OF IGLE 0
	>				;;END OF IFE SSIDE
    IFIDN <$A><R>,< 			;;IF ITS AN R,
	   IFN SWIDTH,<			;;AND WE HAVE SEEN A WIDTH
		SSIDE==TXT.SR		;;SET TO THE RIGHT
		EFLG==EFLG&<^-2>	;;CLEAR ERROR FLAG
		       >		;;END OF IFN SWIDTH
		    >			;;END OF IFIDN R
    IFIDN <$A><L>,< 			;;IF ITS AN L,
	   IFN SWIDTH,<			;;AND WE HAVE SEEN A WIDTH
		SSIDE==TXT.SL		;;SET TO THE LEFT
		EFLG==EFLG&<^-2>	;;CLEAR ERROR FLAG
		       >		;;END OF IFN SWIDTH
		    >			;;END OF IFIDN L
    IFIDN <$A><C>,< 			;;IF ITS AN C,
	   IFN SWIDTH,<			;;AND WE HAVE SEEN A WIDTH
		SSIDE==TXT.SM		;;SET TO THE MIDDLE
		EFLG==EFLG&<^-2>	;;CLEAR ERROR FLAG
		       >		;;END OF IFN SWIDTH
		    >			;;END OF IFIDN C
    IFN SWIDTH, <			;;IF WE HAVE A WIDTH,
	IFN SSIDE,<			;;AND A SIDE,
	 IFN EFLG&2,<			;;AND NOTHING THIS PASS,
	   IFE SCHAR,< SCHAR=="$A"	;;BUT NOT A CHAR, SET IT UP NOW
			EFLG==EFLG&<^-2>;;CLEAR ERROR
		     >			;;END OF IFE SCHAR
		  >			;;END OF IFN EFLG
		  >			;;END OF IFN SSIDE
		 >			;;END OF IFN SWIDTH
    IFE EFLG&2,< IFLG==2>		;;IF NO ERRORS, STILL LOOK FOR SLASH
  > ;END OF FTEX4. DEFINITION
	SUBTTL $WTO / $WTOJ / $WTOR / $ACK Macros

	COMMENT /
		 THE CALLING FORMAT IS:

		$WTO  (<Type line>,<Text line>,OBJ Blk address,Optional args)

		$WTOJ (<Type line>,<Text line>,OBJ Blk address,Optional args)

		$WTOR (<Type line>,<Text line>,OBJ Blk address,ACK code addr,Optional args)

		$ACK  (<Type line>,<Text line>,OBJ Blk address,ACK code addr,Optional args)

		$LOG  (<Type line>,<Text line>,OBJ Blk address,Optional args)

		$KWTOR	(ACK Code Addr,Optional args)	;KILL A WTOR REQUEST

		ANY OR ALL OF THE PARAMETERS AND THEIR COMBINATIONS ARE
		ACCEPTABLE AS INPUT.
		THE TYPE-LINE OR TEXT-LINE ARE STRUCTURED
		THE SAME AS $TEXT CODE. ALL POSSIBLE COMBINATIONS OF
		$TEXT AND ITEXT CODES ARE ACCEPTABLE.

		The 'optional args' consist of
		<arg1,arg2,...,argn> where each of the arg'i is
		of the form: $WTxxx(y), where xxx is one of the
		valid suffixes from the ALLWTO macro, and y is
		the address of a block, or a flag bit, or some
		ITEXT, depending on the meaning of xxx

		/

;First, define the 'for all WTO parameters' macro
;The code types are as follows:
;0 -	Takes an address
;1 -	Takes an 'OR-able' flag word
;2 -	Takes an ITEXT
;(It turns out that 0 and 1 are today indistinguishable during assembly)
DEFINE ALLWTO,<
	.EAWTO(MTY,0)
	.EAWTO(TYP,2)
	.EAWTO(TXT,2)
	.EAWTO(OBJ,0)
	.EAWTO(ACK,0)
	.EAWTO(FLG,1)
	.EAWTO(NOD,0)
	.EAWTO(JBN,0)
	.EAWTO(ACD,0)
	.EAWTO(OCD,0)
	.EAWTO(MFL,1)
>;End define ALLWTO

;Then define the individual setting macros
	DEFINE .EAWTO(SUFFIX,CODE),<
	DEFINE	$WT'SUFFIX'	(ARG),<
		IFB	<ARG>,<.WF'SUFFIX'==0
			IFN <CODE-2>,<.$W'SUFFIX'==0>>
		IFNB	<ARG>,<.WF'SUFFIX'==-1
			IFN <CODE-2>,<.$W'SUFFIX'==.$W'SUFFIX'!<ARG>>
			IFE <CODE-2>,<DEFINE .$W'SUFFIX',<<WO.'SUFFIX'>B8+[ITEXT (<ARG>)]>>
		>;;End IFNB
>;;End of define $WTSUFFIX
>;End define .EAWTO
	ALLWTO				;Define the $WTxxx macros

;Then define the 'RESET' macro
	DEFINE	$WTRST<
	DEFINE	.EAWTO(SUFFIX),<$WT'SUFFIX'	<>>
	ALLWTO				;;Reset all the $WTxxx macros
>;End define $WTRST

;Generate the op-codes for the argument block
	DEFINE	.EAWTO(SUFFIX),<
	.OPCD==.OPCD+1
	WO.'SUFFIX'==.OPCD
>;End define .EAWTO
	.OPCD==0			;Initialize the op-code counter
	WO.MIN==.OPCD+1			;Anticipate the minimum opcode
	ALLWTO				;Generate the opcodes
	WO.MAX==.OPCD			;Define the largest, too
	PURGE	.OPCD			;Flush this sym

;And define the Action routine to generate the in-line blocks
DEFINE	$WTBLD<
	IFE	<.WFMTY>,<PRINTX ?No message type in $WTBLD>
DEFINE .EAWTO(SUFFIX,ARGCOD),<
IFN .WF'SUFFIX',<
	IFE	<ARGCOD-0>,<<WO.'SUFFIX'>B8+ .$W'SUFFIX'>
	IFE	<ARGCOD-1>,<<WO.'SUFFIX'>B8+ [EXP .$W'SUFFIX']>
	IFE	<ARGCOD-2>,<.$W'SUFFIX'>
>;;END IFN .WFSUFFIX
>;;End define .EAWTO
	ALLWTO				;;Build each arg block, if neccessary
	EXP	0			;;Finish the arg list
>;End define $WTBLD

;Now define the most commonly used forms of these macros
	DEFINE	$WTO(TYPE,TEXT,OBJADR,ARGS),<.WTOX.(.OMWTO,<TYPE>,<TEXT>,<OBJADR>,,<ARGS>)>

	DEFINE	$WTOR(TYPE,TEXT,OBJADR,ACKADR,ARGS),<.WTOX.(.OMWTR,<TYPE>,<TEXT>,<OBJADR>,<ACKADR>,<ARGS>)>

	DEFINE	$ACK(TYPE,TEXT,OBJADR,ACKADR,ARGS),<.WTOX.(.OMACK,<TYPE>,<TEXT>,<OBJADR>,<ACKADR>,<$WTFLG(WT.SJI),ARGS>)>

	DEFINE	$WTOJ(TYPE,TEXT,OBJADR,ARGS),<.WTOX.(.OMWTO,<TYPE>,<TEXT>,<OBJADR>,,<$WTFLG(WT.JOB),ARGS>)>

	DEFINE	$LOG(TYPE,TEXT,OBJADR,ARGS),<.WTOX.(.OMLOG,<TYPE>,<TEXT>,<OBJADR>,,<ARGS>)>

	DEFINE	$KWTOR(ACKADR,ARGS),<.WTOX.(.OMWTR,,,,<ACKADR>,<$WTFLG(WT.KIL),ARGS>)>

	DEFINE	.WTOX.(TYP,HDR,TXT,OBJ,ACK,ARG,%LLN),<
		$CALL	I%WTO		;;INIT THE MSG BLKS AND LETERRIP.
		LSTOF.			;;TURN OFF THE LISTING.
		JRST	%LLN		;;MAKE THE MACRO SKIP-ABLE.
		$WTRST			;;Reset the WTO macros
	IFNB <TYP>,<$WTMTY (<TYP>)>	;;Put in the message type
	IFNB <HDR>,<$WTTYP (<HDR>)>	;;Add the 'type' line of text
	IFNB <TXT>,<$WTTXT (<TXT>)>	;;Add the 'text' line of text
	IFNB <OBJ>,<$WTOBJ (<OBJ>)>	;;And the object block address
	IFNB <ACK>,<$WTACK (<ACK>)>	;;And the ack code
		IRP ARG,<ARG>		;;And do all the extra stuff
		$WTBLD			;;Then put in the blocks
	%LLN:	LSTON.  >		;;RESUME LISTINGS
SUBTTL GALAXY system error codes

DEFINE ERRORS,<
	ERR	EOF,<End Of File>
	ERR	IFP,<Illegal file position>
	ERR	FDE,<File Data Error>
	ERR	FND,<File is not on disk>
	ERR	NSD,<No such device>
	ERR	FCF,<File checkpoint failed>
	ERR	SLE,<A System Limit Was Exceeded>
	ERR	IFS,<Illegal File Specification>
	ERR	FNF,<File Not Found>
	ERR	PRT,<Protection Violation>
	ERR	DNA,<Device Was Not Available>
	ERR	NCE,<No "current" entry in list>
	ERR	NMA,<No IPCF message is available>
	ERR	FDS,<Files are on different structures>
	ERR	FAE,<File already exists>
	ERR	USE,<Unexpected System Error>
	ERR	NSP,<No Such Pid>
	ERR	BOL,<Beginning of list reached>
	ERR	EOL,<End of list reached>
	ERR	RQF,<Receiver's quota full>
	ERR	SQF,<Sender's quota full>
	ERR	NRE,<No Remembered Entry>
	ERR	TBF,<The Command Table is full>
	ERR	EIT,<Entry already exists in the table>
	ERR	ITE,<Invalid Table Entry>
	ERR	QEF,<Quota Exceeded or Disk Full>
	ERR	ARG,<Invalid Argument>
	ERR	UJI,<Invalid I%JINF Function>
	ERR	IJN,<Invalid Job Number Specified for I%JINF>
>  ;END DEFINE ERRORS

;GENERATE THE ERROR SYMBOLS

	ER%%%==1			;DON'T USE ERROR CODE 0
DEFINE ERR(A,B),<
	ER'A'$==ER%%%
	ER%%%==ER%%%+1
>  ;END DEFINE ERR

	ERRORS
SUBTTL Canonical File Information

;In order to bring the number of feature test switches needed to the
;absolute minimum, the GLXFIL (file handler) module makes information
;about open files available through the F%INFO routine call.  The
;particular piece of information desired is designated by providing
;a canonical descriptor for that piece of information.

;These FI.xxx symbols, defined here, are the F%INFO descriptors

DEFINE CFI<
	
	  LSTOF.

	X CRE	;;UDT FORMAT CREATION DATE/TIME OF FILE
	X GEN	;;VERSION/GENERATION NUMBER OF FILE
	X PRT	;;PROTECTION OF THE FILE
	X CLS	;;CLASS OF FILE (TOPS-20) ONLY
	X AUT	;;AUTHOR OF THE FILE
	X USW	;;USER SETTABLE WORD
	X SPL	;;SPOOL WORD (TOPS-10) 
	X SIZ   ;;SIZE OF FILE, IN BYTES
	X MOD	;;DATA MODE
	X CHN	;;FILE CHANNEL # (CHN OR JFN)

	  LSTON.

> ;END OF CFI DEFINITION

;CREATE THE SYMBOLS

	FI.%%%==0

	DEFINE X(A)<
	FI.'A==FI.%%%
	FI.%%%==FI.%%%+1
	>

	CFI
SUBTTL Canonical Job Information

;In order to bring the number of feature test switches needed to the
;absolute minimum, GLXINT (Initialization) module makes information
;about jobs available through the I%JINF routine call. The
;particular piece of information desired is designated by providing
;a canonical descriptor for that piece of information.

;These JI.XXX symbols, defined here, are the I%JINF descriptors

DEFINE JBTAB<
	
	  LSTOF.

	X JNO,.JIJNO,<-1,,GJBJNO>	;;JOB NUMBER
	X TNO,.JITNO,<-1,,GJBTTY>	;;TERMINAL NUMBER
	X USR,.JIUNO,.GTPPN		;;LOGGED IN DIRECTORY NUMBER
	X CDN,.JIDNO,<-1,,GJBPTH>	;;CONNECTED DIRECTORY NUMBER
	X PRG,.JIPNM,.GTPRG		;;SIXBIT PROGRAM NAME
	X CJN,.JICPJ,<-1,,GJBCJB>	;;CONTROLLING JOB NUMBER (IF CONTROLLED BY PTY)
	X BAT,.JIBCH,.GTOBI		;;BATCH DATA WORD..STREAM # AND WTO DATA
	X JLT,.JISTM,.GTJLT		;;JOB LOGGED IN TIME
	X LOC,<-1,,GJBLOC>,.GTLOC	;;JOB LOCATION INFORMATION
	X RTM,.JIRT,<-1,,GJBRTM>	;;JOB RUNTIME IN MILLISECS

	  LSTON.

> ;END OF CJI DEFINITION

;CREATE THE SYMBOLS

	.ZZ==1
	JI.MIN==.ZZ		;smallest accepted value

	DEFINE X(A,B,C)<
	JI.'A==.ZZ
	.ZZ==.ZZ+1
	>

	JBTAB
	JI.MAX==.ZZ-1		;LARGEST ACCEPTED VALUE
SUBTTL Scanning and Command Module Symbols

;Define the major macro to expand X(y,z,...) for each terminal type
;Note well:  the items in the TRMTYP macro MUST be in Alphabetical order
;	so that TRMTYP can be used to build parse tables.

DEFINE	TRMTYP,<
LSTOF.
X(33,TTY33,33,)				;;MODEL 33
X(35,TTY35,35,)				;;MODEL 35
TOPS20<
X(37,TTY37,37,)				;;MODEL 37
X(EXECUPORT,EXEC,EXE,)			;;TI EXECUPORT
>
X(LA36,LA36,L36,)			;;LA36
X(VT05,VT05,V05,<37,177,177,177>)	;;VT05
X(VT100,VT100,100,<.CHESC,"[","K">)	;;VT100
X(VT50,VT50,V50,<.CHESC,"J">)		;;VT50
X(VT52,VT52,V52,<.CHESC,"J">)		;;VT52
LSTON.
>;END DEFINE TRMTYP

;The general form of the X macro (which must be redefined just before invoking
;TRMTYP) is:
;X(PARNAM,SIXNAM,SUF,EOLSEQ)
;Where,
;	PARNAM	is the parseable name
;	SIXNAM	is the (TOPS-10) SIXBIT name for TRMOP. .TOTRM
;	SUF	is a 3-char suffix for .TTsuf and .TIsuf
;	EOLSEQ	is a sequence of bytes which will clear to end of line

;Note:
;	.TTsuf is the code to be passed to K%STYP
;		This value need not be the same on the -10 and the -20,
;		but today, they are.
;	.TIsuf is a number between 0 and .TIMAX (inclusive) which may
;		be used to $BUILD and $SETup dispatch tables

;Now, define the .TIsuf symbols which are indicies into tables
;which contain 1 entry for each type of terminal
DEFINE X(PARNAM,SIXNAM,SUF,EOLSEQ),<
.TI'SUF==..Z
..Z==..Z+1>
	..Z==0
	LALL
	TRMTYP			;Do 'em all!
	.TIMAX==..Z-1		;Set the max (must $BUILD (.TIMAX+1) still!)
	PURGE	..Z

TOPS10<
;Define the .TTsuf symbols, since they're not in UUOSYM
DEFINE X(PARNAM,SIXNAM,SUF,EOLSEQ),<
.TT'SUF==..Z
..Z==..Z+1
>;END DEFINE X
	..Z==0			;Start at 0
	TRMTYP			;Do 'em all!
	PURGE	..Z
>;END TOPS10

; The following TOPS-20 symbols are defined when building a TOPS-10 library
;	so that the emulation routines provided for scanning and command
;	parsing can use the same symbols on both systems.

TOPS10 <				;ALREADY DEFINED ON THE -20

; RDTTY flags and argument offsets

	.RDCWB==0			;COUNT OF WORDS FOLLOWING
	.RDFLG==1			;FLAG BITS
	  RD%BRK==1B0			;  BREAK ON ^Z OR ESC
	  RD%TOP==1B1			;  BREAK ON TOPS-10 BREAK SET
	  RD%PUN==1B2			;  BREAK ON PUNCTUATION
	  RD%BEL==1B3			;  BREAK ON EOL
	  RD%CRF==1B4			;  EAT CARRIAGE RETURNS
	  RD%RND==1B5			;  RETURN IF EDITED TO BEGINNING
	  RD%JFN==1B6			;  IFN RATHER THAN STRING PTR
	  RD%RIE==1B7			;  NON-BLOCKING, I.E. RETURN IF EMPTY
	  RD%BBG==1B8			;  PTR TO DEST BUFFER IS IN .RDBFP
	  RD%RAI==1B10			;  CONVERT LOWER TO UPPER CASE
	  RD%SUI==1B11			;  SUPRESS ^U (RUBOUT LINE) HANDLING

	  RD%BTM==1B12			;  INPUT ENDED ON A BREAK
	  RD%BFE==1B13			;  USER DELETED TO BEGINNING
	  RD%BLR==1B14			;  BACKUP LIMIT REACHED

	  RD%NEC==1B35			;  NO ECHO ON ANYTHING (TOPS-10)

	.RDIOJ==2			;INPUT AND OUTPUT IFNS OR STRING POINTER
	.RDDBP==3			;DESTINATION BYTE POINTER
	.RDDBC==4			;NUMBER OF BYTES LEFT AFTER POINTER
	.RDBFP==5			;BEGINNING BYTE POINTER
	.RDRTY==6			;RE-TYPE PROMPT POINTER
	.RDBRK==7			;LOCATION OF 4 WORD BREAK SET TABLE
	.RDBKL==10			;REAL (ARBITRARY) BACKUP LIMIT

;; STILL UNDER TOPS10 CONDITIONAL
; COMMAND SCANNING (S%CMND) INTERFACE

;FORMAT OF COMND STATE BLOCK:

	.CMFLG==:0			;USER FLAGS,,REPARSE DISPATCH ADDRESS
	.CMIOJ==:1			;INJFN,,OUTJFN
	.CMRTY==:2			;^R BUFFER POINTER
	.CMBFP==:3			;PTR TO TOP OF BUFFER
	.CMPTR==:4			;PTR TO NEXT INPUT TO BE PARSED
	.CMCNT==:5			;COUNT OF SPACE LEFT IN BUFFER AFTER PTR
	.CMINC==:6			;COUNT OF CHARACTERS FOLLOWING PTR
	.CMABP==:7			;ATOM BUFFER POINTER
	.CMABC==:10			;ATOM BUFFER SIZE
	.CMGJB==:11			;ADR OF GTJFN ARG BLOCK
	 CM%GJB==:777777		;ADR OF GTJFN ARG BLOCK

;FUNCTION DESCRIPTOR BLOCK

	.CMFNP==:0			;FUNCTION AND POINTER
	   CM%FNC==:777B8		;FUNCTION CODE
	   CM%FFL==:377B17		;FUNCTION-SPECIFIC FLAGS
	   CM%LST==:777777		;LIST POINTER
	.CMDAT==:1			;DATA FOR FUNCTION
	.CMHLP==:2			;HELP TEXT POINTER
	.CMDEF==:3			;DEFAULT STRING POINTER
	.CMBRK==4			;BREAK SET FOR CM%BRK

; FUNCTION CODES
;Note: The following function code symbols must agree with analogous
;definitions found in MONSYM.

	.CMKEY==0			;KEYWORD
	.CMNUM==1			;NUMBER
	.CMNOI==2			;NOISE WORD
	.CMSWI==3			;SWITCH
	.CMIFI==4			;INPUT FILE
	.CMOFI==5			;OUTPUT FILE
	.CMFIL==6			;GENERAL FILESPEC
	.CMFLD==7			;ARBITRARY FIELD
	.CMCFM==10			;CONFIRM
	.CMDIR==11			;DIRECTORY NAME (PPN)
	.CMUSR==12			;USER NAME (PPN)
	.CMCMA==13			;COMMA
	.CMINI==14			;INITIALIZE COMMAND
					;.CMFLT IS NOT PROVIDED
	.CMDEV==16			;DEVICE NAME
	.CMTXT==17			;TEXT
					;.CMTAD IS NOT PROVIDED
	.CMQST==21			;QUOTED STRING
	.CMUQS==22			;UNQUOTED STRING
	.CMTOK==23			;TOKEN
	.CMNUX==24			;NUMBER DELIMITED BY NON-DIGIT
	.CMACT==25			;ACCOUNT
	.CMNOD==26			;NODE
>  ;END TOPS10

	  .RDSIZ==.RDBKL+1		;SIZE OF ARGUMENT BLOCK
TOPS10 <
	;Null JFN

;FLAGS

CM%ESC==:1B0				;ESC SEEN
CM%NOP==:1B1				;NO PARSE
CM%EOC==:1B2				;END OF COMMAND SEEN
CM%RPT==:1B3				;REPEAT PARSE NEEDED
CM%SWT==:1B4				;SWITCH TERMINATED WITH ":"
CM%PFE==:1B5				;PREVIOUS FIELD ENDED WITH ESC
CM%RAI==:1B6				;RAISE INPUT
CM%XIF==:1B7				;NO INDIRECT FILES
CM%WKF==:1B8				;WAKEUP AFTER EACH FIELD
;REMOVE CM%NJF 9/21/79 MLB
CM%BRK==:1B13				;INDICATES .CMBRK HAS DATA
CM%PO==:1B14				;PARSE ONLY FLAG
CM%HPP==:1B15				;HELP PTR PRESENT
CM%DPP==:1B16				;DEFAULT PTR PRESENT
CM%SDH==:1B17				;SUPPRESS DEFAULT HELP MESSAGE

;FLAGS FOR CMSWI FUNCTION

CM%VRQ==:1B0				;VALUE REQUIRED


;FLAGS FOR TIME AND DATE

CM%IDA==1B0				;INPUT DATE
CM%ITM==1B1				;INPUT TIME
CM%NCI==1B2				;NO CONVERT TO INTERNAL

;FLAGS IN KEYWORD TABLE (FIRST WORD OF STRING IF B0-6 = 0)

CM%INV==:1B35				;INVISIBLE
CM%NOR==:1B34				;NO-RECOGNIZE (PLACE HOLDER)
CM%ABR==:1B33				;ABBREVIATION
CM%FW==:1B7				;FLAG WORD (ALWAYS SET)


; STRING COMPARE (S%SCMP) FLAGS

	SC%LSS==1B0			;TEST STRING LESS THAN BASE STRING
	SC%SUB==1B1			;TEST STRING SUBSET OF BASE STRING
	SC%GTR==1B2			;TEST STRING GREATER THAN BASE STRING
					;(IF NONE, EXACT MATCH IS RESULT)

; TABLE LOOK UP (S%TBLK) FLAGS

	TL%NOM==1B0			;NO MATCH
	TL%AMB==1B1			;AMBIGUOUS
	TL%ABR==1B2			;UNIQUE ABBREVIATION
	TL%EXM==1B3			;EXACT MATCH

 > ;END TOPS10
CM%INT==:1B9				;INTERRUPT RET. (10 AND 20..GALAXY DEFINED)
; COMMAND REPLY
	CR.FLG==0			;OFFSET TO FLAG WORD
	CR.RES==1			;OFFSET TO RESULT WORD
	CR.PDB==2			;GIVEN PDB,,USED PDB
	CR.COD==3			;CODE TYPE OF PROCESSED FIELD
	  CR.SIZ==CR.COD+1		;SIZE OF COMMAND REPLY BLOCK

;COMMAND ERROR BUFFER SIZE
	ERRBSZ==20			;SETUP 20 WORDS FOR NOW
SUBTTL	THE MESSAGE HEADER

;Among GALAXY programs, there is a common message header format
;	so that communication and error checking is easier.  There are
;	also some common function codes (currently only TEXT) which are
;	defined across program lines.   The specific data (if any) associated
;	with each message type follows the standard header. Note also
;	that MESSAGE LENGTH includes the header itself.

;	!=======================================================!
;	!      Message Length       !       Message Type        !
;	!-------------------------------------------------------!
;	!ACK!NOM!FAT!WRN!MOR!       !       Sixbit Suffix       !
;	!-------------------------------------------------------!
;	!                 Acknowledgement code                  !
;	!=======================================================!

	PHASE	0

.MSTYP:!	BLOCK	1
	MS.CNT==-1,,0			;MESSAGE LENGTH
	MS.TYP==0,,-1			;MESSAGE TYPE
	  MT.OFF==700000		;OFFSET TO THE COMMON CODES
	  MT.TXT==700000		;TEXT MESSAGE
.MSFLG:!BLOCK	1			;FLAGS WORD
	MF.ACK==1B0			;ACKNOWLEDGEMENT REQUESTED
	MF.NOM==1B1			;NO MESSAGE, JUST AN ACK
	MF.FAT==1B2			;FATAL MESSAGE
	MF.WRN==1B3			;WARNING MESSAGE
	MF.MOR==1B4			;MORE MESSAGE FOLLOWS
	MF.SUF==777777			;SUFFIX FOR TEXT MESSAGE
.MSCOD:!BLOCK	1			;USER SUPPLIED CODE USED FOR ACK'ING
MSHSIZ:!				;LENGTH OF MESSAGE
.MSDAT:!BLOCK	0			;START OF MESSAGE CONTENTS
	DEPHASE
	SUBTTL	ACK - THE GALAXY 'ACK' MESSAGE

;	!=======================================================!
;	\							\
;	\		THE MESSAGE HEADER			\
;	\							\
;	!-------------------------------------------------------!
;	!		FLAG WORD (.OFLAG)			!
;	!-------------------------------------------------------!
;	!		ARGUMENT COUNT (.OARGC)			!
;	!-------------------------------------------------------!
;
;		THE MESSAGE BODY BLOCK
;
;	!-------------------------------------------------------!
;	!	BLOCK LENGTH	!	.CMTXT			!
;	!-------------------------------------------------------!
;	\							\
;	\		ASCIZ TEXT MESSAGE			\
;	\							\
;	!-------------------------------------------------------!
;
;		THE MESSAGE HEADER BLOCK
;
;	!-------------------------------------------------------!
;	!	BLOCK LENGTH	!	.ORDSP			!
;	!-------------------------------------------------------!
;	\							\
;	\		ASCIZ MESSAGE HEADER			\
;	\							\
;	!-------------------------------------------------------!


;	NOTE:::: * * * * * N O T E   W E L L * * * * *
;
;	THE 'ACK' CODE THAT WAS SUPPLIED BY THE USER IN THE ORIGIONAL
;		REQUEST WILL BE RETURNED IN .MSCOD
;
;
;	THE MESSAGE TYPE MAY BE MT.TXT (OLD MSG TYPE) OR 
;		.OMTXT OR .OMACS (NEW ACK MESSAGE TYPE(S))
;
;
;	THE .ORDSP BLOCK WILL ONLY BE FOUND IN A .OMACS MESSAGE
;
;
;	THE .MSCOD FIELD MAY HAVE BITS MF.NOM, MF.FAT, MF.WRN,
;		MF.MOR LIT.
;	THE .MSCOD FIELD MAY ALSO HAVE MF.SUF FILLED IN.
SUBTTL	JIB - Job Information Block

;The foJob Information Block contains  the GALAXY Information to describe
;a job to the system. This block will be used to pass this information
;between all Galaxy Components.

;	!=======================================================!
;	!                   JOBNAME IN SIXBIT                   !
;	!-------------------------------------------------------!
;	!  SEQUENCE NUMBER OF JOB   !   QUASAR DEFINED FIELDS   !
;	!-------------------------------------------------------!
;	!           USER NUMBER ON -20 OR PPN ON -10            !
;	!-------------------------------------------------------!
;	!              REQUEST IDENTIFIER FOR JOB               !
;	!=======================================================!
;	
;	
;	
;	!=======================================================!
;	!                                                       !
;	!               USER NAME (TOPS-10 ONLY)                !
;	!                                                       !
;	!=======================================================!


	PHASE 	0

JIB.JN:! BLOCK	1			;JOB NAME IN SIXBIT
JIB.SQ:! BLOCK	1			;SEQUENCE NUMBER FIELD
	JB.SEQ==-1,,0			;SEQUENCE NUMBER (QUASAR RESTRICTION)
JIB.US:! BLOCK	1			;USER NUMBER OR PPN
JIB.ID:! BLOCK	1			;REQUEST IDENTIFIER NUMBER

TOPS10<
JIB.NM:! BLOCK	2			;USER NAME 2 SIXBIT WORDS (TOPS-10 ONLY)
>;END TOPS10
JIBSIZ:!				;SIZE OF THE JOB INFO BLOCK
SUBTTL	OBJ - Object Descriptor

; Various programs must use a device/object designator which fully
; describes a an entity as to its type,unit number and node.  The canonical
; object descriptor is used for this purpose


;	The object/device designator:

;	!=======================================================!
;	!              Object type descriptor code              !
;	!-------------------------------------------------------!
;	!   Low Bound unit number   !  High Bound unit number   !
;	!-------------------------------------------------------!
;	!                  Node name in SIXBIT                  !
;	!=======================================================!


		PHASE	0

OBJ.TY:!	BLOCK	1		;OBJECT TYPE CODE WORD
	.OTRDR==1			;TYPE	READER
	.OTNCU==2			;TYPE	NETWORK CONTROLLER
	.OTLPT==3			;TYPE	PRINTER
	.OTBAT==4			;TYPE	BATCH CONTROLLER
	.OTCDP==5			;TYPE	CARD PUNCH
	.OTPTP==6			;TYPE	PAPER TAPE PUNCH
	.OTPLT==7			;TYPE	PLOTTER
	.OTTRM==10			;TYPE	TERMINAL
	.OTJOB==11			;TYPE	JOB (T/S)
	.OTOPR==12			;TYPE	OPERATOR
	.OTIBM==13			;TYPE	IBM
	.OTMNT==14			;TYPE	MOUNT
	.OTXFR==15			;TYPE	FILE TRANSFER
	.OTBIN==16			;TYPE	CARD INTERPRETER PROGRAM
	.OTRET==17			;TYPE	FILE RETRIEVAL
	.OTNOT==20			;TYPE	RETRIEVAL NOTIFICATION
	.OTDBM==21			;TYPE	DBMS
	.OTMAX==.OTDBM			;SET THE LARGEST ONE DEFINED
OBJ.UN:! BLOCK	1			;UNIT NUMBER WORD
	OU.HRG==-1,,0			;MASK FOR HIGH RANGE OF UNIT
	OU.LRG==0,,-1			;MASK FOR LOW RANGE OF UNIT
					;HRG=0 MEANS ONLY ONE ITEM
					;HRG=-1MEANS UP TO HIGHEST EXISTING
OBJ.ND:!	BLOCK	1		;NODE NAME, KEPT IN SIXBIT
OBJ.SZ:!				;SIZE OF THE OBJECT DESIGNATOR

		DEPHASE
SUBTTL	OBJCTS MACRO

;THIS MACRO ASSOCIATES ALL LEGAL OBJECT CODES (SEE OBJECT DESCRIPTOR
; DEFINITION) WITH A TEXT STRING FOR THE OBJECT TYPE


	DEFINE OBJCTS,<

	X	.OTRDR,Reader
	X	.OTNCU,Network-Controller
	X	.OTLPT,Printer
	X	.OTBAT,Batch-Stream
	X	.OTCDP,Card-Punch
	X	.OTPTP,Papertape
	X	.OTPLT,Plotter
	X	.OTJOB,Job
	X	.OTTRM,Terminal
	X	.OTOPR,Operator
	X	.OTIBM,<IBM Remote>
	X	.OTMNT,<Device>
	X	.OTXFR,<File Transfer>
	X	.OTBIN,<Card Reader Interpreter>
	X	.OTRET,<File Retrieval>
	X	.OTNOT,<Retrieval Notification>
	X	.OTDBM,<DBMS System>
> ;END OF OBJCTS DEFINITION
	SUBTTL	FD - File Descriptor

; The FD (File Descriptor) is the data structure used to pass a system
;	dependent file description to subroutines or as part of a larger
;	message or data structure.


	PHASE	0

.FDLEN:! BLOCK	1			;LENGTH WORD
	FD.LEN==-1,,0			;MASK TO LENGTH FIELD
.FDFIL:!				;FIRST WORD OF FILESPECIFICATION

	DEPHASE

TOPS10 <	;FILE DESCRIPTOR FOR TOPS10

;	!=======================================================!
;	!		   LENGTH OF THE FD			!
;	!-------------------------------------------------------!
;	!             STRUCTURE CONTAINING THE FILE             !
;	!-------------------------------------------------------!
;	!                       FILE NAME                       !
;	!-------------------------------------------------------!
;	!                       EXTENSION                       !
;	!-------------------------------------------------------!
;	!                        [P,PN]                         !
;	!=======================================================!
;	!                                                       !
;	!                 SFD PATH FOR THE FILE                 !
;	!               THESE WORDS ARE OPTIONAL                !
;	!             AND CAN BE OF LENGTH  0 TO 5              !
;	!                                                       !
;	!=======================================================!

	PHASE	.FDFIL

.FDSTR:! BLOCK	1		;STRUCTURE CONTAINING THE FILE
.FDNAM:! BLOCK	1		;THE FILE NAME
.FDEXT:! BLOCK	1		;THE EXTENSION
.FDPPN:! BLOCK	1		;THE OWNER OF THE FILE
FDMSIZ:!			;MINUMUM SIZE OF A FILE DESCRIPTOR

.FDPAT:! BLOCK	5		;PATH (OPTIONAL AND FROM 0 TO 5 WORDS)
FDXSIZ:!			;MAXIMUM FD AREA SIZE

	DEPHASE

>  ;END OF TOPS10

					;CONTINUED ON FOLLOWING PAGE
TOPS20 <		;FILE DESCRIPTOR FOR TOPS20

;	!=======================================================!
;	/                                                       /
;	/                                                       /
;	/   THE FILE DESCRIPTOR ON TOPS20 IS AN ASCIZ STRING    /
;	/      OF VARIABLE LENGTH AND READY TO BE GTJFN'ED      /
;	/                                                       /
;	/                                                       /
;	!=======================================================!

	PHASE	.FDFIL

.FDSTG:! BLOCK	1		;ASCIZ STRING FOR GTJFN/OPENF SEQUENCE
FDMSIZ:!			;MINIMUM SIZE OF A FILE DESCRIPTOR
FDXSIZ==^D300/^D5		;RESERVE ROOM FOR 300 CHARACTERS

	DEPHASE

>  ;END OF TOPS20
SUBTTL FOB - Parameter block passed to F%IOPN and F%OOPN

; THE FOLLOWING IS A DESCRIPTION OF THE BLOCK USED AS A PARAMETER
; PASSING AREA TO THE TWO FILE OPEN ROUTINES IN GLXFIL.

;	!=======================================================!
;	!      ADDRESS OF FD TO USE FOR FILE SPECIFICATION      !
;	!-------------------------------------------------------!
;	!				      !LSN!NFO!BYTE SIZE!
;	!-------------------------------------------------------!
;	!       FIRST HALF OF USER ID FOR "IN BEHALF OF"        !
;	!-------------------------------------------------------!
;	!          CONNECTED  DIRECTORY (TOPS-20 ONLY)          !
;	!=======================================================!

		PHASE	0

FOB.FD:! BLOCK	1			;POINTER TO FD AREA
FOB.CW:! BLOCK	1			;CONTROL WORD
	   FB.LSN==1B28			;LINE SEQUENCE NUMBERS APPEAR (IGNORE)
	   FB.NFO==1B29			;NEW FILE ONLY (NON-SUPERSEDING)
	   FB.BSZ==77B35		;BYTE SIZE OF THE FILE

FOB.MZ:!				;MINIMUM SIZE OF A FOB

FOB.US:! BLOCK	1			;(OPTIONAL) USER ID FOR "IN BEHALF" OPERATIONS
FOB.CD:! BLOCK	1			;(OPTIONAL) CONNECTED DIRECTORY (TOPS20)

FOB.SZ:!				;SIZE OF AN FOB

		DEPHASE
SUBTTL FRB - Parameter block passed to F%REN for renames

; THE FOLLOWING BLOCK IS SET UP BY THE CALLER OF F%REN IN GLXFIL.
; THE BLOCK PROVIDES THE SOURCE AND DESTINATION OF THE RENAME, AS
; WELL AS NEEDED PROTECTION INFORMATION.

;	!=======================================================!
;	!     POINTER TO FD DESCRIBING SOURCE OF THE RENAME     !
;	!-------------------------------------------------------!
;	!  POINTER TO FD DESCRIBING DESTINATION OF THE RENAME   !
;	!-------------------------------------------------------!
;	!           USER ID FOR AN "IN BEHALF" RENAME           !
;	!-------------------------------------------------------!
;	!CONNECTED DIRECTORY FOR AN "IN BEHALF" RENAME (TOPS-20)!
;	!=======================================================!


			PHASE 0

FRB.SF:! BLOCK	1			;POINTER TO FD OF SOURCE FILE
FRB.DF:! BLOCK	1			;POINTER TO FD OF DESTINATION FILE

FRB.MZ:!				;MINIMUM SIZE OF AN FRB

FRB.US:! BLOCK	1			;(OPTIONAL) USER ID FOR IN BEHALF
FRB.CD:! BLOCK	1			;(OPTIONAL) CONNECTED DIRECTORY (TOPS20)

FRB.SZ:!				;SIZE OF AN FRB

			DEPHASE
SUBTTL IB  - Initialization Block for GALAXY programs

;All programs which make use of the GALAXY library or runtime system
;	must go through an initialization call to insure that the
;	modules are in a determinant state, and also to set up the
;	profile that this program wants.  This initialization is
;	carried out using a communications area, the Initialization
;	Block, from which parameters are read and information filled in.
;	
;	The initialization call to I%INIT is made with S1 containing the
;	size of the IB and S2 containing its address.

;	Initialization Block (IB):

;	!=======================================================!
;	!    Address of output routine for defaulted $TEXTs     !
;	!-------------------------------------------------------!
;	!OCT!STP!               program-wide flags              !
;	!-------------------------------------------------------!
;	!       Base of program's interrupt vector(s)           !
;	!-------------------------------------------------------!
;	!       PID block address                               !
;	!-------------------------------------------------------!
;	!       $TEXT error exit routine                        !
;	!=======================================================!

		PHASE	0

IB.OUT:!	BLOCK	1		;ADDRESS OF ROUTINE TO CALL FROM 
					;OUTPUT ROUTINE IF $TEXT SPECIFIES NONE
IB.FLG:!	BLOCK	1		;Program-wide flag word
	IT.OCT==1B0			;  OPEN COMMAND TERMINAL
	IP.STP==1B1			;SEND STOPCODES TO ORION AS WTO IF SET
IB.INT:!	BLOCK	1		;BASE OF INTERRUPT VECTOR(S)
IB.PIB:!	BLOCK	1		;Address of PID block
IB.ERR:!	BLOCK	1		;USER $TEXT ERROR EXIT ROUTINE ADDRESS.
IB.PRG:!	BLOCK	1		;PROGRAM NAME 

IB.SZ:!					;SIZE OF THE IB

		DEPHASE
SUBTTL	PIB - PID block

;This block describes the PID that the program wishes to become, and
;other assorted flavors of IPCF parameters.  It is a parameter
;for the C%CPID, C%KIPD, C%SPID calls, and is aimed at by the IB.

;	!=======================================================!
;	!      Length               !                           !
;	!-------------------------------------------------------!
;	!                PID (filled by GLXLIB)                 !
;	!-------------------------------------------------------!
;	!PSI!JWP!RSE!SPI!CFV!SPB!                               !
;	!-------------------------------------------------------!
;	!      System index         !             !Chan or offst!
;	!-------------------------------------------------------!
;	!      Max # of PIDs        ! Send quota  !Receive quota!
;	!-------------------------------------------------------!
;	!               Pointer to INFO NAME (optional)         !
;	!-------------------------------------------------------!
;	!             Pointer to ACCOUNT string (optional)      !
;	!-------------------------------------------------------!
;	!             Pointer to LOCATION string (optional)     !
;	!=======================================================!

	PHASE	0
PB.HDR:!	BLOCK	1		;The PID block header word
	PB.LEN==LHMASK			;Length of this block
PB.PID:!	BLOCK	1		;The PID assigned (filled by GLXLIB)
PB.FLG:!	BLOCK	1		;Flags
	IP.PSI==1B0			;Connect this PID to the PSI system
	IP.JWP==1B1			;Get a job-wide PID (good till logout)
	IP.RSE==1B2			;Return to caller if send fails
	IP.SPF==1B3			;Special PID Flag (caller wants to
					;  be a system PID)
	IP.SPB==1B5			;SET IF CALLER IS PRIVELEGED AND WISHES
					;   TO SEE IF SENDER SET IP.CFP
PB.INT:!	BLOCK	1		;Interrupt channel or offset
	IP.SPI==LHMASK			;Special PID index
	IP.CHN==77			;Channel
PB.SYS:!	BLOCK	1		;Special index, quotas
	IP.MNP==LHMASK			;Max # PIDs for this job
	IP.SQT==777B26			;Send Quota
	IP.RQT==777B35			;Receive Quota
	IP.BQT==IP.SQT!IP.RQT		;Both Quotas
PB.MNS:!				;Minimum size of a PIB
PB.NAM:!	BLOCK	1		;Pointer to Name string
PB.ACT:!	BLOCK	1		;Pointer to Account string
PB.LOC:!	BLOCK	1		;Pointer to Location string
PB.MXS:!				;Maximum size of PIB
	DEPHASE
SUBTTL	SAB - Send Argument Block passed to C%SEND

;This block describes the IPCF message being sent


;	!=======================================================!
;	!                    DESTINATION PID                    !
;	!-------------------------------------------------------!
;	!                   LENGTH OF MESSAGE                   !
;	!-------------------------------------------------------!
;	!                  ADDRESS OF MESSAGE                   !
;	!-------------------------------------------------------!
;	!FLG!                SYSTEM PID INDEX                   !
;	!-------------------------------------------------------!
;	!           0 or PID Block address to send for          !
;	!=======================================================!

	PHASE 0


SAB.PD:!	BLOCK	1		;PID TO SEND MESSAGE TO
SAB.LN:!	BLOCK	1		;LENGTH OF MESSAGE TO SEND
					; THIS FIELD DEFINES IF THE MESSAGE IS 
					; TO BE SENT AS A PAGE OR A PACKET
					; A LENGTH OF EXACTLY 1000 WILL
					; CAUSE A PAGE-MODE SEND OF THE
					; THE PAGE POINTED TO BY SAB.MS
					; OTHERWISE THE MESSAGE WILL BE
					; SENT AS A PACKET IF POSSIBLE OR
					; COPIED TO A NEW PAGE IF NECESSARY
SAB.MS:!	BLOCK	1		;STARTING ADDRESS OF MESSAGE
					; IF SAB.LN CONTAINS 1000, AN ERROR
					; WILL OCCUR IF THIS IS NOT THE
					; FIRST ADDRESS OF A PAGE

SAB.SI:!	BLOCK	1		;INFORMATION ON SPECIAL SYSTEM PID
	SI.FLG==1B0			;SET IF SI.IDX IS TO BE USED
	SI.IDX==0,,-1			;SENDER'S INDEX IN SYSTEM PID TABLE
					;NOTE, SETTING SP.FLG AND FILLING IN A
					;VALID INDEX IS SUFFICIENT TO IDENTIFY
					;THE DESTINATION OF A SEND. IN THIS CASE,
					;THE DESTINATION PID NEED NOT BE FILLED IN

SAB.PB:!	BLOCK	1		;0, or address of PIB describing PID
					;for which send is to be done

SAB.SZ:!				;LENGTH OF THE SAB

	DEPHASE
SUBTTL	MDB - Message Descriptor Block returned by C%RECV

;This block describes the IPCF message received by C%RECV or C%BRCV

;	!=======================================================!
;	!                         FLAGS                         !
;	!-------------------------------------------------------!
;	!                     SENDER'S PID                      !
;	!-------------------------------------------------------!
;	!                    RECEIVER'S PID                     !
;	!-------------------------------------------------------!
;	!     LENGTH OF MESSAGE     !    ADDRESS OF MESSAGE     !
;	!-------------------------------------------------------!
;	!             SENDER'S LOGGED-IN DIRECTORY              !
;	!-------------------------------------------------------!
;	!                  SENDER'S PRIVILEGES                  !
;	!-------------------------------------------------------!
;	!             SENDER'S CONNECTED DIRECTORY              !
;	!-------------------------------------------------------!
;	!FLG!                SYSTEM PID INDEX                   !
;	!=======================================================!

	PHASE	0

MDB.FG:!	BLOCK	1		;MESSAGE FLAGS (SEE UUOSYM.MAC)
MDB.SP:!	BLOCK	1		;SENDER'S PID
MDB.RP:!	BLOCK	1		;RECEIVER'S PID
MDB.MS:!	BLOCK	1		;MESSAGE INFORMATION
	MD.CNT==-1,,0			;WORD COUNT OF MESSAGE
	MD.ADR==0,,-1			;ADDRESS OF MESSAGE
MDB.SD:!	BLOCK	1		;SENDER'S LOGGED IN DIRECTORY
MDB.PV:!	BLOCK	1		;SENDER'S PRIVILEGES
	MD.PWH==1B0			;PROCESS HAS WHEEL PRIVILEGES
	MD.POP==1B1			;PROCESS HAS OPERATOR PRIV.
	MD.PMT==1B2			;PROCESS HAS MAINTENANCE PRIV.
	MD.PJB==0,,-1			;JOB NUMBER OF SENDER
MDB.CD:!	BLOCK	1		;SENDER'S CONNECTED DIRECTORY
MDB.SI:!	BLOCK	1		;SENDER'S SPECIAL SYSTEM PID TABLE INFO
	SI.FLG==1B0			;SET IF SI.IDX IS TO BE USED
	SI.IDX==0,,-1			;SENDER'S INDEX IN SYSTEM PID TABLE

MDB.SZ:!				;MDB LENGTH

DEPHASE
SUBTTL Special system PIDS

;For convenience, we define a macro which can generate code or data
;for all system PIDS which are of interest to the GALAXY library.
;Anyone interested in generating data or code for all special PIDS should
;define the .SPID macro, and invoke SPIDS
;The .SPID MACRO will take 4 params, a canonical index name, TOPS10 value,
;TOPS20 value, SIXBIT name of debugging component

DEFINE SPIDS,<
.SPID	(SP.QSR,.IPCPQ,.SPQSR,QUASAR)	;;QUASAR
.SPID	(SP.OPR,.IPCPO,.SPOPR,ORION)	;;ORION
.SPID	(SP.INF,.IPCPI,.SPINF,INFO)	;;INFO
.SPID	(SP.MDA,.IPCPM,.SPMDA,MDA)	;;Mountable device allocator
TOPS10<
.SPID	(SP.IPC,.IPCPS,,IPCC)		;;IPC Controller
.SPID	(SP.ACT,.IPCPA,,ACTDAE)		;;Accouting DAEMON
.SPID	(SP.TLP,.IPCPT,,TAPLAB)		;;Tape labelling process
.SPID	(SP.TOL,.IPCPC,,TAPAVR)		;;Tape Auto-Vol-Recognizer
.SPID	(SP.DOL,.IPCPD,,DSKAVR)		;;Disk Auto-Vol-Recognizer
.SPID	(SP.FIL,.IPCPF,,FILDAE)		;;File DAEMON
>;;End TOPS10
>;End DEFINE SPIDS
SUBTTL System Independent IPCF Codes and Constants

;The constants and codes presented here are used to prevent
;too many feature test switches in the various modules.  When the two
;operating systems present two different codes for the same error
;situation, or two different indices for the same type of entry in a table,
;we can use SYSPRM to make up a canonical code for use by the GALAXY system.
;This makes for more readable code and lessens the  chance of error.

;IPCF error messages

	SYSPRM	IPE.SQ,IPCRS%,IPCFX6	;SENDER'S QUOTA EXHAUSTED
	SYSPRM	IPE.RQ,IPCRR%,IPCFX7	;RECEIVER'S QUOTA EXHAUSTED
	SYSPRM	IPE.SF,IPCRY%,IPCFX8	;SYSTEM FREE SPACE EXHAUSTED
	SYSPRM	IPE.DU,IPCDU%,IPCFX4	;DESTINATION PID IS UNKNOWN
	SYSPRM	IPE.DD,IPCDD%,IPCFX5	;DESTINAION PID IS DISABLED
	SYSPRM	IPE.WM,IPCPR%,IPCF16	;RECEPTION IN THE WRONG MODE
	SYSPRM	IPE.NR,IPCUP%,777777	;NO ROOM IN CORE (TOPS-10 ONLY)
	SYSPRM	IPE.NM,IPCNP%,IPCFX2	;NO MESSAGE IS AVAILABLE

;IPCF codes

	SYSPRM	IP.CFV,IP.CFV,IP%CFV	;PAGE MODE BIT
	SYSPRM	IP.CFC,IP.CFC,IP%CFC	;FROM SYSTEM INFO OR IPCC
	SYSPRM	IP.CFE,IP.CFE,IP%CFE	;ERROR INDICATOR'S IN DESCRIPTOR
	SYSPRM	IP.CFM,IP.CFM,IP%CFM	;A RETURNED MESSAGE
	SYSPRM	IP.CFP,IP.CFP,IP%CFP	;PRIVILEGED SEND
	SYSPRM	IP.TTL,IP.CFT,IP%TTL	;TRUNCATE IF TOO LONG
	SYSPRM	IP.CFB,IP.CFB,IP%CFB	;DO NOT BLOCK ON RECEIVE
	SYSPRM	IP.CFS,IP.CFS,IP%CFS	;INDIRECT SENDERS PID
	SYSPRM	IP.CFR,IP.CFR,IP%CFR	;INDIRECT RECIEVERS PID

;Special System PID table indices

DEFINE .SPID(CANNAM,T10IDX,T20IDX,SYMBOL),<
	SYSPRM	CANNAM,T10IDX,T20IDX
>;END DEFINE .SPID
	SPIDS				;Generate the special PIDS

DEFINE .SPID(CANNAM,T10IDX,T20IDX,SYMBOL),<
	IFG	CANNAM-MX.PID,<MX.PID==CANNAM>
>;END DEFINE .SPID
	MX.PID==0			;Start with 0 as the max
	SPIDS				;Find the maximum
	MX.PID==MX.PID			;Publish the maximum
SUBTTL Program internal parameters of interest

; IN ORDER THAT CALLERS OF GLXLIB PROGRAMS CAN MAKE THE MOST EFFICIENT
;    USE OF THEM, SEVERAL PARAMETERS WHICH ARE REALLY INTERNAL TO THE
;    SEPARATE COMPONENTS ARE DECLARED HERE, SO THAT THEY ARE ACCESSIBLE.
;
; VALUES DECLARED HERE ARE "READ-ONLY" AND SHOULD NOT BE CHANGED
;    WITHOUT CONSULTING THE LISTING OF THE ACTUAL GLXLIB COMPONENT.

; PARAMETERS USED BY:	GLXFIL

	SYSPRM	SZ.IFN,^D30,^D30	;NUMBER OF FILES OPEN SIMULTANEOUSLY
	SYSPRM	SZ.BUF,406,400		;SIZE OF BUFFER AREA
	SYSPRM	SZ.OBF,200,400		;MAXIMUM WORDS XFERRED ON F%?BUF CALL
	SYSPRM	.PRIIN,377776,.PRIIN	;PRIMARY INPUT JFN
	SYSPRM	.PRIOU,377777,.PRIOU	;PRIMARY OUTPUT JFN
	SYSPRM	.NULIO,377775,.NULIO	;NULL I/O JFN

; PARAMETERS USED BY:	GLXIPC

	ND	SZ.PAK,^D50		;MAXIMUM SIZE OF A SHORT PACKET
	ND	SZ.PID,MX.PID+1		;MAXIMUM NUMBER OF SYSTEM PIDS
	ND	RT.SLP,^D3		;TIME TO SLEEP (SECS) BETWEEN RETRIES
	ND	RT.SFL,^D5		;RETRIES ON A SEND FAILURE
	ND	RT.SCL,^D60		;RETRIES ON A SYSTEM-COMPONENT TIME-OUT

; PARAMETERS USED BY:	GLXMEM

	ND	DDCNT,5			;PAGES ADDED TO FREE POOL BEFORE
					;DUMPING DICTIONARY
	ND	DCT.MN,1		;MINIMUM SIZE OF ENTRIES IN DICTIONARY
	ND	DCT.MX,^D50		;MAXIMUM SIZE OF ENTRY IN DICT
	ND	IPCPAD,1		;MINIMUM NUMBER OF PAGES THAT MUST BE FREE
					;BEFORE M%NXPG WILL RETURN ONE
	ND	CNK.PM,^D24	;CHUNK MANAGERS PAGE COUNT BEFORE CLEANUP
	ND	PAGAVL,^D10	;MAX PAGES IN MEM MANAGER BEFORE CLEANUP

	PT.FLG==777		;FLAG FIELD OF PAGE TABLE ENTRY
	  PT.USE==1B35		;INDICATES PAGE IS IN USE
	  PT.WRK==1B34		;PAGE IS IN WORKING SET (I.E. IN CORE)
	  PT.ADR==1B33		;PAGE IS ADDRESSABLE (I.E. EXISTS)
	  PT.INI==1B32		;PART OF INITIAL IMAGE (I.E. CODE, ETC.)
	  PT.SWP==1B31		;SWAPPABLE ON A TIMER TRAP (SYMBOLS ETC)
; PARAMETERS USED BY:	GLXOTS & GLXINI

	ND	DORG,600000	;ADDRESS TO BUILD DATA PAGES AT
	ND	CORG,400000	;ADDRESS TO START OTS AT
	ND	VORG,400010	;ADDRESS OTS DISPATCH VECTOR STARTS AT
	DEFINE CDO (X)<ZZ==ZZ+1> ;COUNT ENTRIES IN DISPATCH VECTOR
	ZZ==VORG
	LIBVEC			;COMPUTE LAST ENTRY ADDRESS
	ND	VMAX,ZZ		;ADDRESS OTS DISPATCH VECTOR ENDS AT
	TOPS10 <	OTSNAM==SIXBIT /GLXLIB/>	;LIBRARY NAME
	TOPS20 < DEFINE OTSNAM,< [ASCIZ \GLXLIB.EXE\]>>

; PARAMETERS USED BY:	GLXINT

	INT.MX==3		;INTERRUPT LEVELS TO INCLUDE
	SYSPRM	INT.LV,1,3	;MAXIMUM NUMBER OF ACTIVE INTERRUPT LEVELS
	ND	IPL.SZ,^D30	;INTERRUPT STACK DEPTH
	SUBTTL	$HALT	-- Halt a Program without Reset

	SYSPRM	$HALT,<EXIT 1,>,<HALTF>	;EXIT WITHOUT RESET
	SUBTTL PDB - PARSER DESCRIPTOR BLOCK DEFINITION

; THE PARSER DESCRIPTOR BLOCK (PDB) IS THE BASIC DATA STRUCTURE USED TO 
;CONTROL THE ACTION OF THE PARSER ROUTINE. THE PDB CONSISTS OF THE STANDARD 
;FUNCTION DESCRIPTOR BLOCK (FDB) AS USED BY THE COMND JSYS, PLUS FOUR 
;ADDITIONAL WORDS USED BY THE PARSER ROUTINE TO CONTROL THE PARSE. THE PDBDEF
;MACRO IS USED TO BUILD A PDB AND ALLOWS THE PROGRAMMER TO SPECIFY ALL OF
;THE FIELD PARAMETERS. IN ADDITION, THERE ARE A NUMBER OF MNEMONIC MACROS
;WHICH ALLOW THE USER TO BUILD FUNCTION SPECIFIC PDBS' AND PROVIDE A COMMON
;SUBSET OF THE PARAMETER FIELDS. THE PDBS' ARE LINKED THROUGH A NEXT PDB 
;CHAIN FIELD, AND AN ALTERNATE PDB CHAIN FIELD TO FORM A TREE LIKE STRUCTURE
;WHICH DEFINES THE COMMAND SYNTAX. THE PARSE ROUTINE, WHEN PASSED THE ADDRESS
;OF THE ROOT OF THE TREE, THEN PARSES ONE COMPLETE COMMAND AND RETURNS CONTROL
;TO THE CALLER. THERE IS A PROVISION FOR THE USER TO SPECIFY EXIT ROUTINES
;WITHIN EACH PDB WHICH WILL BE CALLED AT CRITICAL POINTS AS THE PARSE
;PROGRESSES.
;
; THE FORMAT OF THE PARSER DESCRIPTOR BLOCK IS SHOWN BELOW:
;
;
;
;	!=======================================================!
;	!  FUNCTION   !  FUNCTION   ! ADDRESS OF NEXT FUNCTION  !
;	!    CODE     !    FLAGS    !     DESCRIPTOR BLOCK      !
;	!-------------------------------------------------------!
;	!              DATA FOR SPECIFIC FUNCTION               !
;	!-------------------------------------------------------!
;	!            POINTER TO HELP TEXT FOR FIELD             !
;	!-------------------------------------------------------!
;	!          POINTER TO DEFAULT STRING FOR FIELD          !
;	+-------------------------------------------------------+
;	!          SPECIAL ACTION ROUTINE FOR THIS PDB          !
;	!-------------------------------------------------------!
;	!              PDB DEFAULT FILLING ROUTINE              !
;	!-------------------------------------------------------!
;	!                     ERROR ROUTINE                     !
;	!-------------------------------------------------------!
;	!             CHAIN POINTER TO LINKED PDB'S             !
;	!=======================================================!
	SUBTTL PDBDEF - PDBDEF MACRO DEFINITION


; THE FORM OF THE PDBDEF MACRO CALL IS:

;PDBDEF (TYP,FLGS,DATA,HLPM,DEFM,LST,NXT,ERRTN,RTN,DEFR)

; ARGUMENTS TO THE PDBDEF MACRO ARE:
;
;
;	TYP	TYPE OF FDB, IE. .CMKEY
;	FLGS	FUNCTION SPECIFIC FLAGS
;	DATA	FUNCTION SPECIFIC DATA
;	HLPM	BYTE POINTER FOR HELP TEXT
;	DEFM	POINTER TO DEFAULT
;	LST	POINTER TO ALTERNATE FDB
;	NXT	PTR TO NEXT FDB (OPTIONAL FOR TYPE .CMKEY OR .CMSWI)
;	ERRTN	ROUTINE IF AN ERROR IS GOTTEN POINTING TO THIS PDB
;	RTN	SPECIAL ACTION ROUTINE FOR THIS PDB
;	DEFR	SPECIAL ROUTINE TO FILL IN DEFAULTS FOR THIS PDB


	DEFINE	FLD(VAL,MSK)<<VAL>B<POS(MSK)>>


DEFINE PDBDEF(TYP,FLGS,DATA,HLPM,DEFM,LST,NXT,ERRTN,RTN,DEFR),<

	..XX==<FLD(TYP,CM%FNC)>+FLGS+<Z LST> ;;DEFINE .CMFNP WORD OF COMND FDB

   IFNB <HLPM>,<..XX=..XX!CM%HPP> ;;IF HELP TEXT, INCLUDE FLAG BIT
   IFNB <DEFM>,<..XX=..XX!CM%DPP> ;;IF DEFAULT TEXT, INCLUDE FLAG BIT

	EXP ..XX		;;ASSEMBLE THE .CMFNP WORD

   IFNB <DATA>,<EXP DATA>
   IFB <DATA>,<EXP 0>

   IFNB <HLPM>,<POINT 7,[ASCIZ \HLPM\]>
   IFB <HLPM>,<0>

   IFNB <DEFM>,<POINT 7,[ASCIZ \DEFM\]>
   IFB <DEFM>,<0>

;;THE REST OF THE DEFINITION IS NOT USED BY THE JSYS BUT ONLY BY THE PARSER

   IFB <RTN>,<0>
   IFNB <RTN>,<EXP RTN>

   IFB <DEFR>,<0>
   IFNB <DEFR>,<EXP DEFR>

   IFB <ERRTN>,<0>
   IFNB <ERRTN>,<EXP ERRTN>

   IFB <NXT>,<0>
   IFNB <NXT>,<EXP NXT>

>;END OF DEFINITION OF PDBDEF MACRO
	SUBTTL	PDB  --  PARSER DESCRIPTOR BLOCK

	;THIS BLOCK DEFINES THE OFFSETS AFTER THE FDB FOR THE PDB
	;RELATED ROUTINES.
	
	PB%HDR==0		;HEADER FOR THE BLOCK
	 PB.PDB==-1,,0		;OFFSET FOR PDB LENGTH
	 PB.FDB==0,,-1		;OFFSET FOR FDB LENGTH

	PHASE	0

PB%NXT:! BLOCK	1			;NEXT PDB TO USE
PB%RTN:! BLOCK	1			;ACTION ROUTINE FOR THE PARSER
PB%ERR:! BLOCK	1			;ERROR ROUTINE
PB%DEF:! BLOCK	1			;DEFAILT FILLING ROUTINE
PB%SIZ:! 				;SIZE OF MAXIMUM PDB DATA


	DEPHASE
IFN	FTUUOS,< .CMBRK==.CMDEF+1>	;DEFINE THE BREAK FIELD
IFN	FTUUOS,< CM%BRK==1B13>	;BREAK BIT FOR THE -10

PDB.SZ==.CMBRK+PB%SIZ

	COMMENT \

PDB.FD:!	BLOCK	.CMDEF+1 ;ALLOCATE SPACE FOR AN FDB
PDB.RT:!	BLOCK	1	;SPECIAL ACTION ROUTINE ADDRESS
PDB.DF:!	BLOCK	1	;DEFAULT FILLING ROUTINE ADDRESS
PDB.ER:!	BLOCK	1	;ERROR MESSAGE ROUTINE ADDRESS
PDB.NX:!	BLOCK	1	;ADDRESS OF PDB TO USE NEXT
PDB.SZ:!			;SIZE OF A PDB

	DEPHASE

	\;END OF COMMENT
	SUBTTL COMMAND FUNCTION MACROS

; THE FOLLOWING FUNCTION SPECIFIC MACROS ARE PROVIDED FOR THE PURPOSE OF
;DEFINING THE PDB COMMAND TREE. THE MACROS AND THEIR SYNTAX IS SHOWN BELOW:

; Where upper case identifies keywords which must be coded as shown
;and lower case identifies variable information which must be provided
;by the programmer, e.g., a symbol which represents the address of a
;block.

; The variable parameters are as follows -

; "next__pdb_address" is the address of the next parser data block to use
;in the parse

; "table__address" is the address of keyword table in TBLUK format

; "radix" is the radix in which the number will be input, in octal

; "help__text" is a string to be output on a ?

; "noise__text" is string representing the noise phrase

; "keyword__list" is an optional list of keywords representing additional
;functions

; where the general form of a keyword parameter is

; 	KEYWORD (argument)

; the entire list of keywords must be enclosed by angle brackets "<", ">"
;and the keyword elements are separated blanks or a comma


;	the valid keywords are
;
;	$DEFAULT (default__string)
;
;	$PDEFAULT (default__address)
;
;	$ALTERNATE (alternate__pdb)
;
;	$NEXT (next__pdb__address)
;
;	$ERROR (error__routine)
;
;	$ERRPDB (next_pdb)
;
;	$ACTION (special__action__routine)
;
;	$PREFILL (default__filling__routine)
;	EXAMPLE:

;	$KEY (NOIPDB,KYTBL1,<$ACTION(CHKIT)>)
;
;;	$KEY (next__pdb__address,table__address,keyword__list)
;
;;	$KEYDSP (table__address,keyword__list)
;
;;	$NUMBER (next__pdb__address,radix,help__text,keyword__list)
;
;;	$DIGIT (next__pdb__address,radix,help__text,keyword__list)
;
;;	$NOISE (next__pdb__address,noise__text,keyword__list)
;
;;	$SWITCH (next__pdb__address,table__address,keyword__list)
;
;;	$IFILE (next__pdb__address,help__text,keyword__list)
;
;;	$OFILE (next__pdb__address,help__text,keyword__list)
;
;;	$FIELD (next__pdb__address,help__text,keyword__list)
;
;;	$CRLF (,keyword__list)
;
;;	$DIR (next__pdb__address,keyword__list)
;
;;	$USER (next__pdb__address,keyword__list)
;
;;	$COMMA (next__pdb__address,keyword__list)
;
;;	$INIT (next__pdb__address,keyword__list)
;
;;	$FLOAT (next__pdb__address,help__text,keyword__list)
;
;;	$DEV (next__pdb__address,keyword__list)
;
;;	$CTEXT (next__pdb__address,help__text,keyword__list)
;
;;	$DATE (next__pdb__address,keyword__list)
;
;;	$TIME (next__pdb__address,keyword__list)
;
;;	$TAD (next__pdb__address,keyword__list)
;
;;	$QUOTE (next__pdb__address,help__text,keyword__list)
;
;;	$TOKEN (next__pdb__address,token__character,keyword__list)
;
;;	$NODNM (next__pdb__address,help__text,keyword__list)
;
;;	$ACCOUNT (next__pdb__address,help__text,keyword__list)
;
;;	$UQSTR (next__pdb__address,BRKSET,help__text,keyword__list)

; THE FOLLOWING SUPPORT MACROS ARE DEFINED TO ALLOW THE USER TO DEFINE THE
;KEYWORD AND SWITCH TABLES USED BY THE KEYWORD AND SWITCH PDB'S:

;
;;	DSPTAB (next__pdb__address,user__code,keyword__entry,[flags])
;
;;	KEYTAB (user__code,keyword__entry)
;
;;	$STAB
;
;;	$ETAB
;
DEFINE $TYPE (ARG),<DEFINE .$TYP <ARG>
			.%TYPE==1>

DEFINE $FLAGS (ARG),<DEFINE .$FLGS <ARG>
			.%FLGS==1>

DEFINE $PDATA (ARG),<DEFINE .$DATA <ARG>
			.%DATA==1>

DEFINE $HELP (ARG),<
	IFDIF <ARG> <>,<
DEFINE .$HLPM <POINT 7,[ASCIZ\ARG\]>
			.%HLPM==1>>

DEFINE $DEFAULT (ARG),<DEFINE .$DEFM <POINT 7,[ASCIZ\ARG\]>
			.%DEFM==1>

DEFINE $PDEFAULT (ARG),<DEFINE .$DEFM <POINT 7,<ARG>>
			.%DEFM==1>

DEFINE $ALTERNATE (ARG),<DEFINE .$LST <ARG+1>
			.%LST==1>

DEFINE $NEXT (ARG),<DEFINE .$NXT <ARG>
			.%NXT==1>

DEFINE $ERROR (ARG),<DEFINE .$ERTN <ARG>
			.%ERTN==1>

DEFINE $BREAK (ARG),<DEFINE .$BREA <ARG>
			.%BREA==1>

DEFINE $ERRPDB (ARG),<DEFINE .$ERTN <1B0+ARG+1>
			.%ERTN==1>

DEFINE $ACTION (ARG),<DEFINE .$RTN <ARG>
			.%RTN==1>

DEFINE $PREFILL (ARG),<DEFINE .$DEFR <ARG>
			.%DEFR==1>
	SUBTTL	INITIALIZE PARSER MACRO MACROS

;INITIALIZE ALL THE INNER MACROS
;

	$TYPE (0)
	$FLAGS (0)
	$HELP (<>)
	$DEFAULT (0)
	$ALTERNATE (0)
	$NEXT (0)
	$ERROR (0)
	$BREAK (0)
	$ACTION (0)
	$PREFILL (0)
	DEFINE	NEXT(FOO),<TEMFDB##>
	;***REMOVE THIS DEFINITION
	C.SWIT==1B0
	DEFINE	SHRSWT,<C.SWIT+PDBCPY##>

DEFINE .$RESET <
	SALL
	XLIST
	DEFINE .$TYP <0>
	.%TYPE==0
	DEFINE .$FLGS <0>
	.%FLGS==0
	DEFINE .$DATA <0>
	.%DATA==0
	DEFINE .$HLPM <>
	.%HLPM==0
	DEFINE .$DEFM <0>
	.%DEFM==0
	DEFINE .$LST <0>
	.%LST==0
	DEFINE .$BREA <0>
	.%BREA==0
	DEFINE .$NXT <0>
	.%NXT==0
	DEFINE .$ERTN <0>
	.%ERTN==0
	DEFINE .$RTN <0>
	.%RTN==0
	DEFINE .$DEFR <0>
	.%DEFR==0>;END OF .$RESET
	SUBTTL	.$BUILD MACRO

;REDEFINE PDB.XX

DEFINE .$BUILD (%FDBL,%PDBL,%PDB,%FLAG) <			;;BUILD A PDB

	%FLAG==<FLD(.$TYP,CM%FNC)>!.$FLGS!<.$LST> ;;DEFINE .CMFNP WORD OF FDB

	IFN <.%BREA>,<%FLAG==%FLAG!CM%BRK> ;; IF BREAK SET IS PROVIDED

	IFN <.%HLPM>,<%FLAG==%FLAG!CM%HPP!CM%SDH> ;;IF HELP TEXT, INCLUDE FLAG 
						;;BIT AND SUPPRESS HELP

	IFN <.%DEFM>,<%FLAG==%FLAG!CM%DPP> ;;IF DEFAULT, INCLUDE FLAG BIT

%PDB:	XWD	%PDBL,%FDBL			;; LENGTH OF PDB,LENGTH OF FDB

	EXP %FLAG				;;ASSEMBLE WORD .CMFNP OF FDB

	EXP .$DATA			;;ASSEMBLE WORD .CMDAT OF FDB

IFN <.%HLPM!.%DEFM!.%BREA>,<
		EXP	.$HLPM>		;;ASSEMBLE WORD .CMHLP OF FDB


IFN <.%DEFM!.%BREA>,<
		EXP	.$DEFM>		;;ASSEMBLE WORD .CMDEF OF FDB


IFN <.%BREA>,<	EXP	.$BREA>		;;ASSEMBLE WORD .CMBRK FOR THE FDB

	%FDBL==.-%PDB			;LENGTH OF THE FDB

IFN <.%NXT!.%DEFR!.%RTN!.%ERTN>,< EXP .$NXT >	;;ASSEMBLE WORD PDB.NX OF PDB

IFN <.%DEFR!.%RTN!.%ERTN>,<EXP .$RTN >	;;GENERTAT ACTION ROUTINE

IFN <.%DEFR!.%ERTN>,<	EXP	.$ERTN>	;;GENERATE THE ERROR ROUTINE

IFN <.%DEFR>,<		EXP	.$DEFR>	;;GENERATE DEFAULT FILLING ROUTINE


	%PDBL==.-%PDB			;;LENGTH OF THE WHOLE BLOCK

	IF2<	PURGE %FDBL,%PDBL,%PDB,%FLAG>
	LIST>;END .$BUILD
	SUBTTL	PARSER MACROS FOR EACH FUNCTION

DEFINE $KEYDSP (TABLE,ARGLST) <
	.$RESET
	$TYPE (.CMKEY)
	$PDATA (TABLE)
	$NEXT (0)
	IRP ARGLST,<ARGLST>
	.$BUILD>


DEFINE $KEY (NXT,TABLE,ARGLST) <
	.$RESET
	$TYPE (.CMKEY)
	$PDATA (TABLE)
	$NEXT (NXT)
	IRP ARGLST,<ARGLST>
	.$BUILD>



DEFINE $NUMBER (NXT,RADIX,HELP,ARGLST) <
	.$RESET
	$TYPE (.CMNUM)
	$PDATA (RADIX)
	$HELP (<>)
	$NEXT (NXT)
IFIDN <HELP> <>,< IRP ARGLST,<ARGLST>
			.$BUILD>
IFDIF <HELP> <>,<
	$HELP (HELP)
	IRP ARGLST,<ARGLST>
	.$BUILD>>

DEFINE $DIGIT (NXT,RADIX,HELP,ARGLST) <
	.$RESET
	$TYPE (.CMNUX)
	$PDATA (RADIX)
	$HELP (<>)
	$NEXT (NXT)
IFIDN <HELP> <>,< IRP ARGLST,<ARGLST>
			.$BUILD>
IFDIF <HELP> <>,<
	$HELP (HELP)
	IRP ARGLST,<ARGLST>
	.$BUILD>>
DEFINE $NOISE (NXT,TEXT,ARGLST) <
	.$RESET
	$TYPE (.CMNOI)
	$PDATA (<POINT 7,[ASCIZ\TEXT\]>)
	$NEXT (NXT)
	IRP ARGLST,<ARGLST>
	.$BUILD>


DEFINE $SWITCH (NXT,TABLE,ARGLST) <
	.$RESET
	$TYPE (.CMSWI)
	$PDATA (TABLE)
	$NEXT (NXT)
	IRP ARGLST,<ARGLST>
	.$BUILD>

DEFINE $SWIDSP (TABLE,ARGLST) <
	.$RESET
	$TYPE (.CMSWI)
	$PDATA (TABLE)
	$NEXT (0)
	IRP ARGLST,<ARGLST>
	.$BUILD>


DEFINE $IFILE (NXT,HELP,ARGLST) <
	.$RESET
	$TYPE (.CMIFI)
	$HELP (<>)
	$NEXT (NXT)
IFIDN <HELP> <>,< IRP ARGLST,<ARGLST>
			.$BUILD>
IFDIF <HELP> <>,<
	$HELP (HELP)
	IRP ARGLST,<ARGLST>
	.$BUILD>>

DEFINE $OFILE (NXT,HELP,ARGLST) <
	.$RESET
	$TYPE (.CMOFI)
	$NEXT (NXT)
	$HELP (<>)
IFIDN <HELP> <>,< IRP ARGLST,<ARGLST>
			.$BUILD>
IFDIF <HELP> <>,<
	$HELP (HELP)
	IRP ARGLST,<ARGLST>
	.$BUILD>>
DEFINE $FILE (NXT,HELP,ARGLST) <
	.$RESET
	$TYPE (.CMFIL)
	$HELP (<>)
	$NEXT (NXT)
IFIDN <HELP> <>,< IRP ARGLST,<ARGLST>
			.$BUILD>
IFDIF <HELP> <>,<
	$HELP (HELP)
	IRP ARGLST,<ARGLST>
	.$BUILD>>

DEFINE $FIELD (NXT,HELP,ARGLST) <
	.$RESET
	$TYPE (.CMFLD)
	$NEXT (NXT)
	$HELP (<>)
IFIDN <HELP> <>,< IRP ARGLST,<ARGLST>
			.$BUILD>
IFDIF <HELP> <>,<
	$HELP (HELP)
	IRP ARGLST,<ARGLST>
	.$BUILD>>

DEFINE $CRLF (ARGLST),<
	.$RESET
	$TYPE (.CMCFM)
	IRP ARGLST,<ARGLST>
	.$BUILD>


DEFINE $DIR (NXT,ARGLST) <
	.$RESET
	$TYPE (.CMDIR)
	$NEXT (NXT)
	IRP ARGLST,<ARGLST>
	.$BUILD>


DEFINE $USER (NXT,ARGLST) <
	.$RESET
	$TYPE (.CMUSR)
	$NEXT (NXT)
	IRP ARGLST,<ARGLST>
	.$BUILD>


DEFINE $COMMA (NXT,ARGLST) <
	.$RESET
	$TYPE (.CMCMA)
	$NEXT (NXT)
	IRP ARGLST,<ARGLST>
	.$BUILD>
DEFINE $INIT (NXT,ARGLST) <
	.$RESET
	$NEXT (NXT)
	$TYPE (.CMINI)
	IRP ARGLST,<ARGLST>
	.$BUILD>

DEFINE $FLOAT (NXT,HELP,ARGLST) <
	.$RESET
	$TYPE (.CMFLT)
	$HELP (<>)
	$NEXT (NXT)
IFIDN <HELP> <>,< IRP ARGLST,<ARGLST>
			.$BUILD>
IFDIF <HELP> <>,<
	$HELP (HELP)
	IRP ARGLST,<ARGLST>
	.$BUILD>>


DEFINE $DEV (NXT,ARGLST) <
	.$RESET
	$TYPE (.CMDEV)
	$NEXT (NXT)
	IRP ARGLST,<ARGLST>
	.$BUILD>


DEFINE $CTEXT (NXT,HELP,ARGLST) <
	.$RESET
	$TYPE (.CMTXT)
	$HELP (<>)
	$NEXT (NXT)
IFIDN <HELP> <>,< IRP ARGLST,<ARGLST>
			.$BUILD>
IFDIF <HELP> <>,<
	$HELP (HELP)
	IRP ARGLST,<ARGLST>
	.$BUILD>>

DEFINE $DATE (NXT,ARGLST) <
	.$RESET
	$TYPE (.CMTAD)
	$PDATA (CM%IDA)
	$NEXT (NXT)
	IRP ARGLST,<ARGLST>
	.$BUILD>


DEFINE $TIME (NXT,ARGLST) <
	.$RESET
	$TYPE (.CMTAD)
	$PDATA (CM%ITM)
	$NEXT (NXT)
	IRP ARGLST,<ARGLST>
	.$BUILD>
DEFINE $TAD (NXT,ARGLST) <
	.$RESET
	$TYPE (.CMTAD)
	$PDATA (<CM%IDA!CM%ITM>)
	$NEXT (NXT)
	IRP ARGLST,<ARGLST>
	.$BUILD>


DEFINE $QUOTE (NXT,HELP,ARGLST) <
	.$RESET
	$TYPE (.CMQST)
	$HELP (<>)
	$NEXT (NXT)
IFIDN <HELP> <>,< IRP ARGLST,<ARGLST>
			.$BUILD>
IFDIF <HELP> <>,<
	$HELP (HELP)
	IRP ARGLST,<ARGLST>
	.$BUILD>>

DEFINE $UQSTR (NXT,BRKSET,HELP,ARGLST) <
	.$RESET
	$TYPE (.CMUQS)
	$HELP (<>)
	$NEXT (NXT)
	$PDATA (BRKSET)
IFIDN <HELP> <>,< IRP ARGLST,<ARGLST>
			.$BUILD>
IFDIF <HELP> <>,<
	$HELP (HELP)
	IRP ARGLST,<ARGLST>
	.$BUILD>>

DEFINE $NODNM (NXT,HELP,ARGLST) <
	.$RESET
	$TYPE (.CMNOD)
	$HELP (<>)
	$NEXT (NXT)
IFIDN <HELP> <>,< IRP ARGLST,<ARGLST>
			.$BUILD>
IFDIF <HELP> <>,<
	$HELP (HELP)
;	$FLAGS (CM%PO)
	IRP ARGLST,<ARGLST>
	.$BUILD>>
DEFINE $ACCOUNT (NXT,HELP,ARGLST) <
	.$RESET
	$TYPE (.CMACT)
	$HELP (<>)
	$NEXT (NXT)
IFIDN <HELP> <>,< IRP ARGLST,<ARGLST>
			.$BUILD>
IFDIF <HELP> <>,<
	$HELP (HELP)
	IRP ARGLST,<ARGLST>
	.$BUILD>>

DEFINE $TOKEN (NXT,CHAR,ARGLST) <
	.$RESET
	$TYPE (.CMTOK)
	$PDATA (<POINT 7,[ASCIZ\CHAR\]>)
	$NEXT (NXT)
	IRP ARGLST,<ARGLST>
	.$BUILD>
	SUBTTL KEYWORD TABLE MACROS

;DSPTAB - MACRO TO BUILD A DISPATCH TABLE ENTRY
;	USED IN CONJUNCTION WITH $KEYDSP MACRO

DEFINE DSPTAB (NXT,CODE,KEY,FLAGS),<
	IFB <FLAGS>,<
	XWD	[ASCIZ\KEY\],[XWD CODE,NXT]>
	IFNB <FLAGS>,<
	XWD	[EXP CM%FW!FLAGS
		ASCIZ\KEY\],[XWD CODE,NXT]>
>	;END OF DSPTAB MACRO

;KEYTAB - MACRO TO BUILD A KEYWORD OR SWITCH TABLE ENTRY
;	USED IN CONJUNCTION WITH $KEY OR $SWITCH MACRO

DEFINE KEYTAB (CODE,KEY,FLAGS),<
	IFB <FLAGS>,<
	XWD	[ASCIZ\KEY\],CODE>
	IFNB <FLAGS>,<
	XWD	[EXP CM%FW!FLAGS
		ASCIZ\KEY\],CODE>
>	;END OF KEYTAB MACRO

;$STAB/$ETAB - MACROS TO DELINEATE START AND END OF KEYWORD TABLE
;	USED IN CONJUNCTION WITH DSPTAB AND KEYTAB MACROS

DEFINE $STAB (%X,%Y) <
	%X==.
	XWD %Y-1,%Y-1
	DEFINE $ETAB <
		%Y==.-%X>>
	END
; PARAMETERS USED BY:	GLXOTS & GLXINI

	ND	DORG,600000	;ADDRESS TO BUILD DATA PAGES AT
	ND	CORG,400000	;ADDRESS TO START OTS AT
	ND	VORG,400010	;ADDRESS OTS DISPATCH VECTOR STARTS AT
	DEFINE CDO (X)<ZZ==ZZ+1> ;COUNT ENTRIES IN DISPATCH VECTOR
	ZZ==VORG
	LIBVEC			;COMPUTE LAST ENTRY ADDRESS
	ND	VMAX,ZZ		;ADDRESS OTS DISPATCH VECTOR ENDS AT
	TOPS10 <	OTSNAM==SIXBIT /GLXLIB/>	;LIBRARY NAME
	TOPS20 < DEFINE OTSNAM,< [ASCIZ \GLXLIB.EXE\]>>

; PARAMETERS USED BY:	GLXINT

	INT.MX==3		;INTERRUPT LEVELS TO INCLUDE
	SYSPRM	INT.LV,1,3	;MAXIMUM NUMBER OF ACTIVE INTERRUPT LEVELS
	ND	IPL.SZ,^D30	;INTERRUPT STACK DEPTH
	SUBTTL	$HALT	-- Halt a Program without Reset

	SYSPRM	$HALT,<EXIT 1,>,<HALTF>	;EXIT WITHOUT RESET


	END