Google
 

Trailing-Edge - PDP-10 Archives - BB-BT99V-BB_1990 - 10,7/galaxy/glxlib/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
;
;
;        COPYRIGHT (c) 1975,1976,1977,1978,1979,1980,1981,1982,
;			 1983,1984,1985,1986,1987,1990
;                    DIGITAL EQUIPMENT CORPORATION
;			 ALL RIGHTS RESERVED.
;
;     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

IFNDEF	GLXPURE,<GLXPURE==-1>		;DEFAULT TO HIGH SEGMENT GLXLIB

DEFINE TOPS10 <IFN FTUUOS,>		;SETUP CONDITIONAL MACROS
DEFINE TOPS20 <IFN FTJSYS,>


TOPS10 <
    IF2,<
	IFE GLXPURE,<PRINTX [Building a Galaxy-10 library]>
	IFN GLXPURE,<PRINTX [Building a Galaxy-10 OTS]>
    >
	SEARCH	UUOSYM		;GET TOPS-10 SYMBOLS
>

TOPS20 <
    IF2,<
	IFE GLXPURE,<PRINTX [Building a Galaxy-20 library]>
	IFN GLXPURE,<PRINTX [Building a Galaxy-20 OTS]>
    >
	SEARCH	MONSYM			;GET TOPS-20 SYMBOLS
>

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

	CHKEDT (MAC)			;CHECK OUR EDIT NUMBER

	MACEDT==0525			;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
	XP FTFTS,FTFTS
	XP SZ.INF,SZ.INF		;AND NAMED PID SIZE
SUBTTL Table of contents

;               TABLE OF CONTENTS FOR GLXMAC
;
;
;                        SECTION                                   PAGE
;    1. Table of contents.........................................   2
;    2. Revision history..........................................   3
;    3. Accumulator Definitions...................................   4
;    4. JUMPx, SKIPx Instruction OPDEFS...........................   5
;    5. ND, XP, EXT, and GLOB Macros..............................   6
;    6. CONT. LSTOF. LSTON. VRSN. Macro Definitions...............   7
;    7. PROLOG - Uniform assembly set up..........................   8
;    8. SYSPRM - Set system dependent parameters..................   9
;    9. MIN and MAX - Find minimum or maximum of vector of values.   9
;   10. LIBVEC - Library run-time system entry vector.............  10
;   11. PG2ADR,ADR2PG Macros......................................  11
;   12. Standard Constants........................................  12
;   13. Control Character Symbols.................................  13
;   14. PC WORD Flags.............................................  14
;   15. Field and Mask Macros.....................................  15
;   16. MOVX......................................................  16
;   17. CAX - COMPARE MACROS......................................  17
;   18. ADDX, SUBX, IMULX, MULX, IDIVX & DIVX MACROS..............  18
;   19. TX -- TEST MASK...........................................  19
;   20. SUBFUNCTION MACROS........................................  22
;   21. DEFSTR -- DEFINE DATA STRUCTURE...........................  23
;   22. STKVAR - STACK VARIABLE FACILITY..........................  27
;   23. TRVAR - TRANSIENT VARIABLE FACILITY.......................  28
;   24. SAVE MACRO DEFINITION.....................................  30
;   25. LOAD,STORE,INCR,DECR,ZERO.................................  31
;   26. $BGINT,$DEBRK - Interrupt context switching...............  33
;   27. $BUILD,$SET,$EOB - Build pre-formed data blocks...........  34
;   28. $CALL,$RETT,$RETF,$RETE,$RET Uniform Call/Return Mechanisms  35
;   29. $DATA and $GDATA Macros - Runtime System Data Area control  36
;   30. $FATAL, and $WARN Macro definitions.......................  37
;   31. $STOP - Cause a STOP CODE to occur........................  38
;   32. $TEXT - Interface to the T%TEXT routine...................  39
;   33. $TQ MACRO DEFINITION......................................  45
;   34. Error processing and messages.............................  47
;   35. ..TEXT PARSING MACRO DEFINITION...........................  48
;   36. ASCII TEXT STRING STORAGE MACRO DEFINITIONS...............  50
;   37. $WTO / $WTOJ / $WTOR / $ACK Macros........................  51
;   38. GALAXY system error codes.................................  52
;   39. Canonical File Information................................  53
;   40. Canonical Job Information.................................  54
;   41. I%TIMR  Functions and argument block......................  55
;   42. Scanning and Command Module Symbols.......................  56
;   43. THE MESSAGE HEADER........................................  59
;   44. ACK - THE GALAXY 'ACK' MESSAGE............................  60
;   45. JIB - Job Information Block...............................  61
;   46. OBJ - Object Descriptor...................................  62
;   47. OBJCTS MACRO..............................................  63
;   48. FD - File Descriptor......................................  64
;   49. FOB - Parameter block passed to F%IOPN and F%OOPN.........  66
;   50. FRB - Parameter block passed to F%REN for renames.........  67
;   51. IB  - Initialization Block for GALAXY programs............  68
;   52. PIB - PID block...........................................  69
;   53. SAB - Send Argument Block passed to C%SEND................  70
;   54. MDB - Message Descriptor Block returned by C%RECV.........  71
;   55. Special system PIDS.......................................  72
;   56. System Independent IPCF Codes and Constants...............  73
;   57. Program internal parameters of interest...................  74
;   58. $HALT   -- Halt a Program without Reset...................  75
;   59. PDB - PARSER DESCRIPTOR BLOCK DEFINITION..................  76
;   60. PDBDEF - PDBDEF MACRO DEFINITION..........................  77
;   61. PDB  --  PARSER DESCRIPTOR BLOCK..........................  78
;   62. COMMAND FUNCTION MACROS...................................  79
;   63. INITIALIZE PARSER MACRO MACROS............................  83
;   64. .$BUILD MACRO.............................................  84
;   65. PARSER MACROS FOR EACH FUNCTION...........................  85
;   66. KEYWORD TABLE MACROS......................................  91
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
0143		ADD FD TYPE CODES TO GLXMAC
0144		Add symbol definitions for IPCF sending by name
0145		Define entry to parse a number S%NUMI
0146		Define OPDEFS for $RETIF and $RETIT
0147		Define $ERRTXT macro for Parser
0150		Define entry for S%DATI and ERIDT$
0151		Add LA120 to TRMTYP macro for the -10
0152		Put in .XCREF and SUPPRESS for all MACRO created symbols
0153		MAKE ENTRY VECTOR SYMBOLS DEFINED IN GLXINI GLOBAL
0154		Change SZ.PAK (PACKET size) to PAGSIZ-1 (777 words)
0155		Modify $TEXT and ITEXT to decrease required compile
		time
0156		Define errors from S%CMND as standard error codes
0157		Fix definition of ..ASGN in PROLOG macro to work
		if GLXPURE is turned on
0160		Add defininition for JI.TLC routine to return physical
		location
0161		Fix a bug generated by edit 157. Make GLXINI get global library
		symbols by adding a : to the ..ASGN(A,ADDR),<A=ADDR> definition.
0162		Add new routines K%BUFF, K%FLSH, and K%OPEN.
0163		.REQUEST library instead of .REQUIRE for impure library
0164		Add FAL object type .OTFAL and rename .OTXFR to .OTFTS
0165		Add VT61 support for TOPS10
0166		ADD .CMFLT AND .CMTAD DEFINITIONS
0167		Add IB.DET to cause programs to detach if on FRCLIN.
0170		Delete IB.DET (GLXLIB defaults to detach)
0171		Don't declare global symbols for GLXINI during
		prolog.  This caused conflicts when loading with
		the library.  This removes edit 161.
0172		Define error code ERFIO$ for "file is offline".
0173		Remove edit 171 (Put the : back)
0174		Remove unwanted LALL [QAR 10-4899]
0175		.REQUEST REL:GLXINI

0176		Globalize FTFTS defined in GALCNF

0177		Make GLXLIB run execute-only.
		 1) Add "not-known-to-DDT" hardware mnemonics. GLXLIB needs
		    the PORTAL definition.
		 2) Remove indirection from entry vector references.
		 3) Change $BGINT so it does a $CALL instead of a JSR.

0200		Invent new IB bit 'IB.DPM' (Don't get Pid with an ipcf Message).
		This instructs GLXIPC to use our job number as a PID.

0201		Restructure GLXLIB
		 1) Rework PROLOG macro completely.
		 2) .NODDT the following symbols:
			$CALL	$RET
			$RETT	$RETF
			$RETIT	$RETIF
			JUMPT	JUMPF
			SKIPT	SKIPF
		 3) Remove CORG, DORG and VORG symbols and make code smart snough
		    to figure the stuff out. This allows the PSECT origins set
		    by LINK switches really flexible.
		 4) Define $RETE so that a PUSHJ gets generated instead of a
		    JSP. This will allow extended addressing to work someday.

0202		Invent a new IB bit (IB.NPF) to instruct the library NOT to
		set up the page fault handler. a PFH can be a real pain to
		a program that switches high segments.

0203		Expand file and I/O error codes and messages for TOPS-10.

0204		Make STKVAR and TRVAR get called with a PUSHJ instead of a JSP
		so it will work in non-zero sections.

0205		Delete second definition of FLD macro. It was incorrect anyway.

0206		Fix bug in $TEXT macros that would not allow a decimal number
		to be used as a field width (missing ^D).

0207		Add .POPJ1 to entry vector.

0210		Add two new flags to date time routines for TOPS10
		CM%FUT for future time, and CM%PST for past time
		Also add $FTAD macro to set for future time for TOPS10

0211		Comment out the MONSYM version reference until MONSYM has
		one to reference.

0212		Add a couple more LOOKUP/ENTER/RENAME error messages.

0213		Add FB.PHY to allow physical-only OPENs.
		Add 5 additional error codes from GLXSCN to the ERRORS macro.

0214		Add FRB.FL flag word to F%REN arg block

0215		Add a field in the FOBs for protection codes and physical-only
		on RENAMEs.

0216		Make $SAVE work on indexed variables

0217		Add symbols to support new file atttribute block. Remove symbols
		for protection codes added in edit 215.

220		Add CEI error for interrupt system failure

221		Add entry point I%RLIM to reset VRT and PHY core limits.
		change value of PFHORG to be 776000 (for the system PFH).

222		Add new error codes ERENF$ (Linked list entry not found) and
		ERNSL$ (No such linked list).

223		Remove references to PFHORG. Add new error codes:
			GLXIPC	ERNPI$	No pages for IPCF reception
			GLXMEM	ERNFP$	No free pages

224		Remove reference to old PFH symbols and fix problem of
		M%CLNC not getting called enough to reduce core.

225		Make two bits (CM%FUT, CM%PST) apply to the -20 as well as
		the -10.

226		Define .CHLAB ("<") and .CHRAB (">") since everyone uses them.
		Lots of symbols are golbal that shouldn't be. Localize them.

227		Remove I%RLIM since PFH won't need it.

230		Add CPU type codes.

231		Add TOPS-10 PC flag definitions.

232		Enlarge interrupt level stack

233	1371	Add CM%NSF for GLXSCN.

234	1427	Fix defs of SZ.BUF and SZ.OBF

235		Add terminal support for VT101, VT102, VT103, VT125,
		VT180, and VT185 in the TRMTYP macro. 2-Jun-83/CTK

236		Expanded the TRMTYP macro to include the address of a
		terminal initialization routine, and the escape sequences
		to set and clear keypad application modes. 24-Oct-83/NT

237		Added ERR error code IFB for indirect command files that
		are too big to fit in buffer. 28-Dec-83 /LWS

240		Make $DEFAULT macro PRINTX error message if no arg given.
		Hopefully this will prevent unwanted BDS stopcodes.
		4-Jan-84 /LWS
241		Add NDN (Null device name given) to support fix in
		GLXSCN that catches ":" device name bug. /LWS
242	10015	Add new SAB flag word and MDB priv bits.
		26-Mar-84 /DPM
450	10049	Begin version 2. Bump all version and edit numbers
		5-Jul-84 /NT
451	10050	Redefine .RETx routines to not go through entry vectors
		5-Jul-84 /NT
452	10052	Support for GLXKBD rewrite, mostly with escape tables
		interpretation for OPR SET KEYPAD command.
		5-Jul-84 /NT
453	10053	Add VT2xx support.
		9-Jul-84 /NT
454	10047	Add support for EVENT queue
		13-Jul-84 /DPM
455	10058	Add new special PID index for [SYSTEM]CATALOG
		24-Jul-84 /DPM
456	10066	Add new GLXSCN flag "CM%WLD" to indicate wildcarding
		of PPNs, directories, and filespec parts is desired.
		 4-Aug-84 /DPM
457	10073	Add $SUBCM macro to allow parsing of TOPS-20 style
		sub-commands from within application tables
		13-Aug-84 /DPM

460	10079	Add new system PIDs and [SYSTEM]INFO code.
		14-Aug-84 /RCB

461	10075	Add new GLXKBD routine K%ECHO to library vector.
		15-Aug-84 /WXD

462	11011	Add fallback code for running under 7.02.
		28-Aug-84 /RCB

463	10105	Add CDO entries for S%U2DT and S%DT2U.
		12-Oct-84 /LWS

464	10121	Change FAL object name from "File Access Listener"
		to "Fal-Stream"
		14-Nov-84 /LWS

465	10122	Add error codes for network file spec parsing.
		15-Nov-84 /DPR

466	10144	Add new file attribute bits for the RDH fields.
		 5-Feb-85 /DPM

467	10165	Add $AHELP to provide additional help without suppressing
		default.
		13-Mar85 /TL

470	10167	Add VK100 to the table of known terminal types.
		19-Mar-85 /DPM

471	10168	Add object types .OTXER and .OTFCH for Xerox and microfich.
		19-Mar-85 /DPM
472	10174	Add FUNCT. module GLXFUN
		23-Mar-85 /TL
473	10201	Add RDH fields as things which may be returned by
		F%INFO.
		26-Apr-85 /NT

474	10228	Include DQS support.  Remove duplicate object type
		definitions.
		 6-Jun-85  /JAD

475	10265	Add new parse flag CM%WLA to indicate accounting-style
		wildcarding to be used when parsing PPNs.
		30-Jul-85  /DPM

476	10268	Clean up symbol tables and CREF listings by purging and
		XCREFing generated symbols and internal subroutine macros
		used by the parsing macros.
		31-Jul-85  /DPM

477	10291	Enter .RETE with a CDO macro rather than an NT.
		18-Sep-85 /NT

500	10294	Add system PID index for system MAILER.
		24-Sep-85 /ERS

501	10330	Finish edit 236, document TRMTYP macro, put the VK100 in
		alphabetical order, define the correct clear to end of line
		sequences for non-ANSI video terminals. 20-Nov-85 /NT

502	10335	Add new error code ERNHA$ (no help available).
		 4-Dec-85  /DPM

503	10402	Invent new system PID for NEBULA.
		6-May-86   /JAD

504	10405	Add support for TB%ABR in S%TBAD and S%TBDL
		10-May-86  /TL

505	10406	Add new object type for network queue controller.
		12-May-86  /DPM

510	10462	Add STOPCD macro and replace $STOP with STOPCD.
		14-Nov-86  /BAH

511	10498	Add .VERSION to PROLOG.
		12-Mar-87  /TL

512	10515	Add 2 new error codes, ERTOF$ and ERTOP$, ("timeout waiting
		for FRCLIN" and "timeout waiting for PID" resp.) for
		I%CJOB. Add definition of new CJB ("create job block")
		which is the arg used when calling I%CJOB.
		25-Jun-87  /LWS

513	10545	Add $ERDNP (Dependencies not present) error code used
		by I%CJOB.

514	10557	Remove reference to FTFLBK.
		22-Aug-87  /LWS

515	10620	Add VT330 and VT340.
		19-Apr-88  /KDO

517		Add the IB.SAV flag (for doing a SAVE. on a stopcode) to the
		IB block.
		23-May-88  /PERK

520		Fix the error recovery for the SAVE function added in edit 517.
		1-Jun-88  /PERK

521	10656	Add VT320 terminal type.
		28-Sep-88  /LWS

522	10660	Set SZ.IFN to 42 channels.  This is an artificial limit
		based on the number of streams BATCON can handle and the
		default number of extended channels the monitor will
		support.  (BATCON uses a total of 3 channels per stream.)
		See BATCON edit 5030.
		14-Oct-88 /DPM

523	10670	Clean up symbol definitions which used PHASE/DEPHASE pairs.
		Not only were some of them lacking the DEPHASE, but it makes
		it hard for people to build a useful DDT with galactic symbols.
		Fix to use .ORG pseudo-op pairs instead.
		23-Jun-89 /RCB

524	10674	Add missing file attributes, and the ability to set them from
		the IFN of another file.
		07-Aug-89 /RCB

525	10678	Remove reference to ".MCRV."; an unimplemented MACRO pseudo-op.
		16-ct-89 /DPM

\   ;End of Revision History
	SUBTTL Copyright macro

DEFINE .BCOPY,<
	XLIST
	.ORG 0
	LIST
>
DEFINE COPYRIGHT,<ASCIZ \
COPYRIGHT >
DEFINE .ECOPY,<
	XLIST
	.....X=.
	.ORG
	.ORG 0
	REPEAT .....X,<EXP 0>
	PURGE .....X
	.ORG
	LIST
>
SUBTTL	Accumulator Definitions

	;Pass FACT file accounting requirement along

	FTFACT==FTFACT		;From GALCNF

;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	Not-known-to-DDT hardware mnemonics


; These OPDEFs were taken from MACTEN
;
; JRST xx,
;
	OPDEF	PORTAL	[JRST 01,]	;CONCEALED ENTRY POINT JUMP
	OPDEF	JRSTF	[JRST 02,]	;JUMP RESTORING FLAGS
	OPDEF	HALT	[JRST 04,]	;JUMP, HALTING PROCESSOR
	OPDEF	XJRSTF	[JRST 05,]	;FLAG-PC-DOUBLEWORD JRSTF
	OPDEF	XJEN	[JRST 06,]	;FLAG-PC-DOUBLEWORD JEN
	OPDEF	XPCW	[JRST 07,]	;FLAG-PC-DOUBLEWORD XSFM+XJRSTF
	OPDEF	JEN	[JRST 12,]	;JRSTF ENABLING PI
	OPDEF	XSFM	[JRST 14,]	;SAVE FLAG-PC-DOUBLEWORD NO JUMP


; JFCL xx,
;
	OPDEF	JFOV	[JFCL 01,]	;JUMP ON FLOATING UNDER/OVERFLOW
	OPDEF	JCRY1	[JFCL 02,]	;JUMP ON CARRY-1
	OPDEF	JCRY0	[JFCL 04,]	;JUMP ON CARRY-0
	OPDEF	JCRY	[JFCL 06,]	;JUMP ON CARRY-0 OR CARRY-1
	OPDEF	JOV	[JFCL 10,]	;JUMP ON OVERFLOW


; JRST to a POPJ
;
	OPDEF	PJRST	[JUMPA 17,]	;PUSHJ/POPJ
					;THIS CUTE TRICK WILL ALLOW DDT
					;TO DISTINGUISH BETWEEN JRST AND
					;PJRST INSTRUCTIONS . . .


	DEFINE	$FALL(ADDR)<IF2,<IFN <ADDR>-.,<PRINTX ? ILLEGAL $FALL ADDR>>>
					;TO SAVE ON PJRSTS ACROSS PAGE BREAKS

; Other random OPDEFs
;
	OPDEF	XMOVEI	[SETMI]		;EXTENDED MOVEI
	OPDEF	XHLLI	[HLLI]		;NOT YET IN MACRO
	OPDEF	IFIW	[1B0]		;EXTENDED ADDRESSING HACK
		.NODDT	IFIW		;DON'T CLOBBER SETZ
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]


; Suppress DDT typeout of the above symbols
;
	.NODDT	JUMPT, JUMPF, SKIPT, SKIPF
SUBTTL	ND, XP, EXT, and GLOB Macros

;Macro to Define 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.
; Call:	PROLOG	(MODULE,OTSCOD)
;
; Where: 'MODULE' represents the module name
;	 'OTSCOD' (optional) represents a GLXLIB module mnemonic
;
%%.MOD==SIXBIT/NONAME/			;;DEFAULT MODULE NAME INCASE NULL
%%.OTS==0				;;DEFAULT OTSCOD INCASE NULL

DEFINE	PROLOG	(MODULE,OTSCOD),<

	SALL				;;FOR PRETTY LISTINGS
	LSTOF. XCREF			;;TURN OFF LISTING

	%%.GLX==%%.GLX			;;RECORD VERSION NUMBER
	GLXVRS==GLXVRS			;;...

	IFNB <MODULE>,<%%.MOD==SIXBIT/MODULE/> ;;MAKE NAME AVAILABLE
	IFNB <OTSCOD>,<%%.OTS==SIXBIT/OTSCOD/> ;;MAKE OTSCODE AVAILABLE

	GLOB	I%INIT			;;ENTRY POINT CALLED BY THE USER

	TOPS10	<			;;TOPS-10 ONLY
		SEARCH	UUOSYM		;;OPERATING SYSTEM SYMBOLS
		%%UUOS==%%UUOS		;;RECORD VERSION NUMBER
	>				;;END OF TOPS-10 CONDITIONAL

	TOPS20	<			;;TOPS-20 ONLY
		SEARCH	MONSYM		;;OPERATING SYSTEM SYMBOLS
;		%%MONS==%%MONS		;;RECORD VERSION NUMBER
	>				;;END OF TOPS-20 CONDITIONAL

	IFB <OTSCOD>,<			;;IF NOT A GLXLIB MODULE
		IFN GLXPUR,<
			.TEXT	|,REL:GLXLIB/SEARCH/REQUIRE:I%INIT/SEGMENT:LOW|
		>			;;END IFN GLXPUR
		DEFINE	$DATA (NAM,SIZ<1>),< ;;MACRO TO GENERATE DATA STORAGE
			NAM:	BLOCK	SIZ
		>			;;END OF $DATA MACRO
		DEFINE	CDO (X),<GLOB X> ;;MAKE ENTRY POINTS GLOBAL
		DEFINE	NT(X),<CDO X>	;;LIKEWISE
		LIBVEC			;;GLOBALIZE ALL ENTRY POINTS
	>				;;END OF IFB <OTSCOD> CONDITIONAL

	IFNB <OTSCOD>,<			;;IF A GLXLIB MODULE
		CHKEDT (OTSCOD)		;;CHECK GLXLIB MODULE EDIT NUMBERS

	IFDIF <OTSCOD><INI>,<		;;IF NOT GLXINI
		IFN GLXPURE,<.PSECT .HIGH.> ;;IF OTS
		IFE GLXPURE,<		;;IF LINKABLE LIBRARY
			TWOSEG	400000	;;MAKE US SHARABLE
			RELOC	0	;;DATA STORAGE STARTS HERE
			RELOC	400000	;;START LOADING THE HIGH SEGMENT
		>			;;END OF IFE GLXPURE CONDITIONAL

		DEFINE $DATA(NAM,SIZ<1>),< ;;MACRO TO GENERATE DATA STORAGE
			IFN GLXPURE,<.PSECT DATA> ;;RELOCATE TO DATA PSECT
			IFE GLXPURE,<RELOC> ;;RELOCATE TO LOW SEGMENT
			IFNDEF OTSCOD'%D,<OTSCOD'%D::! OTSCOD'%DL==:0>
			NAM:	BLOCK	SIZ
			OTSCOD'%DL==:OTSCOD'%DL+SIZ ;;COUNT WORDS
			IFN GLXPURE,<.ENDPS DATA> ;;TERMINATE PSECT REFERENCE
			IFE GLXPURE,<RELOC> ;;BACK TO THE HIGH SEG
		>			;;END OF $DATA MACRO

	IFDIF <OTSCOD><OTS>,<		;;FOR ALL BUT GLXOTS...
		DEFINE	CDO (X),<GLOB X> ;;MAKE ENTRY POINTS GLOBAL
		DEFINE	NT(X),<CDO X> ;;LIKEWISE FOR NT
		LIBVEC		;;GLOBALIZE ALL ENTRY POINTS
	>			;;END OF IFDIF <OTSCOD><OTS> CONDITIONAL

	>			;;END OF IFDIF <OTSCOD><INI> CONDITIONAL
	;;STILL IN IFNB OTSCOD

	IFIDN <OTSCOD><INI>,< ;;IF GLXINI
		DEFINE	$DATA (NAM,SIZ<1>),< ;;MACRO TO GENERATE DATA STORAGE
			NAM:	BLOCK	SIZ
		>			;;END OF $DATA MACRO
	>				;;END OF IFIDN <OTSCOD><INI> CONDITIONAL
	>;;END OF IFNB <OTSCOD>

	LSTON.				;;TURN LISTINGS ON

	GLOB	<.POPJ, .RETT, .RETF>	;;SOME POPULAR RETURNS
	OPDEF	$RET	[POPJ	P,]	;;RETURN
	OPDEF	$RETT	[PJRST	.RETT]	;;RETURN TRUE
	OPDEF	$RETF	[PJRST	.RETF]	;;RETURN FALSE
	OPDEF	$RETIT	[JUMPT	.POPJ]	;;RETURN IF TRUE
	OPDEF	$RETIF	[JUMPF	.POPJ]	;;RETURN IF FALSE
	.NODDT	$RET,$RETT,$RETF,$RETIT,$RETIF
>					;;END OF PROLOG MACRO
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.

; Because the entry through the entry vector is can be of relatively high
;	overhead for much used entry points (.RETx, .POPJ are good examples)
;	the user may wish to define these routines as global routines in
;	GLXINI, and therefore avoid entrance through the entry vector.
;	The NT macro allows for this. If one wishes to place any of the
;	routines in GLXINI, he should use the NT macro rather than the CDO
;	macro. The entry vector in GLXOTS will still be correctly generated
;	for older programs, but it will not be defined if GLXINI, and will
;	simply be declared global for programs which will call them.

	DEFINE LIBVEC <

	  LSTOF. XCREF

	CDO	OTSINI			;;GLXOTS INITIALIZATION
	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
	NT	.RETT
	NT	.RETF
	CDO	.RETE
	CDO	.AOS		;;USED BY INCR
	CDO	.SOS		;;USED BY DECR
	CDO	.ZERO		;;USED BY ZERO
	NT	.POPJ		;;RETURN (CPOPJ)
	CDO	.STOP		;;STOPCODE PROCESSOR
	CDO	.SAVE8		;;SAVES P1 THRU AC16
	CDO	.STKST		;;STKVAR SUPPORT CODE
	CDO	.TRSET		;;TRVAR SUPPORT CODE
	NT	.POPJ1		;;SKIP RETURN
	CDO	.UD2SC		;;Convert from UDT to number of seconds
	CDO	.SC2UD		;;Convert from seconds to UDT
	CDO	.CPUTY		;;RETURN CPU TYPE
	CDO	.DIE		;;NEW STOPCODE PROCESSOR
	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	C%PIDH
	CDO	C%SIDX
	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	FUNCT.			;;GLXFUN

	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			;;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	I%TIMR
	CDO
	CDO
	CDO	I%SOPR
	CDO	I%WTO
	CDO
	CDO	I%HOST
	CDO	I%JINF
	CDO	I%CJOB
	CDO	I%KJOB

	CDO	S%U2DT		;;GLXSCN
	CDO	S%DT2U
	CDO	S%DATI
	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	S%NUMI


	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	K%BUFF
	CDO	K%FLSH
	CDO	K%OPEN
	CDO	K%ECHO
	CDO
	CDO
	CDO
	CDO
	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

.CHLAB=="<"			;CHARACTERS WHICH DRIVE
.CHRAB==">"			;UP A WALL

.CHALT==175			;OLD ALTMODE
.CHAL2==176			;ALTERNATE OLD ALTMODE
.CHDEL==177			;DELETE
SUBTTL	 Processor definitions


%PDP6==0	;PDP-6  CP166 PROCESSOR
%KA10==1	;PDP-10 KA10 PROCESSOR
%KI10==2	;PDP-10 KI10 PROCESSOR
%KL10==3	;PDP-10 KL10 PROCESSOR
%KS10==4	;PDP-10 KS10 PROCESSOR
%XXXX==5	;PDP-10 XXXX PROCESSOR
SUBTTL	PC word flags


; TOPS-10 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


; TOPS-20 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 (%%%)<
	..CNS2 <%%%>,>

   DEFINE ..CNS2 (NEW,OLD)<
	DEFINE ..CNS (%%%)<
	  ..CNS2 <%%%>,<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)>
	$CALL	.STKST
	 ..STKN,,..STKN
	RADIX ..STKR
	DEFINE ENDSV.<.ENSV1 <ARGS>>
	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

DEFINE .ENSV1 (ARGS)<
	IRP ARGS,<
	  .ENSV2 (ARGS)>>

  DEFINE .ENSV2 (ARG)<
	.ENSV3 (ARG)>

  DEFINE .ENSV3 (ARG,SIZ)<
	DEFINE ARG<....U>>
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
	$CALL	.TRSET		;;ALLOCATE STACK SPACE, SET UP .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 A CALL-SPECIFIC CO-ROUTINE IS GENERATED
;IN A LITERAL.

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


DEFINE $SAVE(ARG)<
	.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?
		    PUSHJ P,[			;;YES -- START CO-ROUTINE
			>
		  ..PUSH(ARG,\<.NVR+1>)>>	;;PUSH IT AND BUMP COUNT

    IFE .NVR,<	;;DON'T DO AC CO-ROUTINE IF OTHER VARIABLES
	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 <.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>
	    >>

	IFN .ACM,<	;;PUSH THE AC'S IF NOT DONE BY CO-ROUTINE
	    IFE .NVR,<			;;FIRST ONE?
		PUSHJ P,[		;;YES, START CO-ROUTINE
		>

	    .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 CO-CALL AND RESTORES
		PUSHJ	P,@-.NVR(P)	;;CALL OUR CALLER
		 TRNA			;;NON-SKIP
		AOS	-1-.NVR(P)	;;PROPAGATE SKIP RETURN
	    REPEAT .NVR,<..POP(\.NVR)>	;;POP ALL THINGS STACKED
		ADJSP	P,-1		;;USELESS CALLER ADDRESS
		POPJ	P,]>		;;RETURN TO CALLER'S CALLER
> ;END OF $SAVE DEFINITION

	DEFINE ..PUSH(ARG,.NVX)<
		PUSH P,ARG
		DEFINE .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	BLISS-style call macro

;CALL STACK-STYLE (BLISS) SUBROUTINE
;THIS MACRO TAKES THE NAME OF THE SUBROUTINE AND A LIST OF ARGUMENTS.
;EACH ARGUMENT IN THE ARG LIST IS ONE OF THE FOLLOWING:
;  1. A NORMAL EFFECTIVE ADDRESS SPECIFICATION, E.G. FOO, @FIE(X)
;  2. AN IMMEDIATE ADDRESS WRITTEN AS <.,ADR> WHERE ADR IS AN EFFECTIVE
;	ADDRESS SPECIFICATION, E.G. FOO, @FIE(X).  NOTE THAT THIS
;	ADDRESS WILL BE COMPUTED BY AN XMOVEI AT THE TIME OF THE CALL
;	SO SECTION INFORMATION WILL BE BOUND AT THAT TIME.  NOTE ALSO
;	THAT THIS FORM SHOULD *NOT* BE USED FOR A LITERAL CONSTANT
;	WHERE YOU WOULD NOT WANT THE CURRENT SECTION PUT IN THE LEFT
;	HALF.  USE [CONST] INSTEAD.  YES, THE DOT HERE IS LIKE NO-DOT IN BLISS
;	AND VICE-VERSA.
;  3. A STRUCTURE REFERENCE SPECIFICATION, E.G. AAA, <BB,(X)>.  IF
;	THE LATTER FORM IS USED, THE BRACKETS ARE REQUIRED.

DEFINE BCALL. (NAME,ARGS)<
	..NA==0			;;INIT ARG COUNT
	IRP ARGS,<
	  .BCAL2 ARGS>		;;COMPILE PUSH
	PUSHJ	P,NAME		;;JUMP TO SUBR
	ADJSP	P,-..NA		;;REMOVE ARGS FROM STACK
   >

;SEPARATE PAIRED ARGS

  DEFINE .BCAL2 (ARGS)<
	.BCAL1 ARGS>

  DEFINE .BCAL1 (ARG1,ARG2)<
	  IFIDN <ARG1><.>,<
	    XMOVEI .SAC,ARG2	;;IMMEDIATE ARG
	    PUSH P,.SAC
	  >
	  IFDIF <ARG1><.>,<
	  .IFATM <ARG1>,.BLF4	;;SEE IF ARG IS ATOMIC
	  .BLF1==0		;;SET TO 1 WHEN WE ASSEMBLE SOMETHING
	  IFN .BLF4,<		;;SEE IF A STRUCTURE REF
	    .IF %'ARG1,MACRO,<	;;CHECK RELATED STRUCTURE SYMBOL
		.BLF1==1>	;;IS A STRUCTURE
	  >
	  IFNB <ARG2>,<
		.BLF1==1>	;;SECOND ARG IMPLIES STRUCTURE TOO
	  IFN .BLF1,<		;;'OR' OF ABOVE TWO CHECKS
	    LOAD .SAC,ARG1,ARG2
	    PUSH P,.SAC
	  >
	  IFE .BLF1,<		;IF WASN'T A STRUCTURE REF,
	    IFN .BLF4,<		;;IF ARG IS ATOMIC...
	     .BLF2==<<Z ARG1>&17B17>-<P>B17 ;;TRY TO GET VALUE
	      .IF .BLF2,ABSOLUTE,< ;;IF WE NOW HAVE THE VALUE
	       IFE .BLF2,<		;;SEE IF INDEXED BY P
	       .BLF1==1		;;NOTE WE DID SOMETHING
	       .BLF3==<Z ARG1>&777777
		PUSH P,.BLF3-..NA(P)>>>> ;;YES, MUST ADJUST BY PUSHES SO FAR
	  IFE .BLF1,<		;;ELSE...
		PUSH P,ARG1>>	;;PUSH ONE ARG
	  ..NA=..NA+1>

;MACRO TO SEE IF STRING IS AN ATOM, I.E. CONTAINS ONLY LEGAL SYMBOL
;CONSTITUENTS A-Z, 0-9, %, $, .
;IT IS PAINFULLY SLOW, BUT MACRO PROVIDES NO OTHER WAY
;FLAG WILL BE SET TO 1 IF STRING IS ATOM, 0 OTHERWISE

DEFINE .IFATM (S,FLG)<
	IRPC S,<
	FLG==0
	IFGE "S"-"A",<IFLE "S"-"Z",<FLG=1>> ;;SET FLG IF LETTER OK
	IFGE "S"-"0",<IFLE "S"-"9",<FLG=1>>
	IFE "S"-"%",<FLG=1>
	IFE "S"-"$",<FLG=1>
	IFE "S"-".",<FLG=1>
	IFE FLG,<STOPI>>>
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)<$CALL	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]
	.NODDT	$CALL

; $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) <
	  $CALL	.RETE			;;CALL THE ERROR ROUTINE
		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

;$RETIF is the instruction used to RETurn If True
;$RETIT	is the instruction used to RETurn If False
;	These Pseudo-ops are defined in the PROLOG macro

;		OPDEF	$RETIT	[JUMPT	.POPJ]

;		OPDEF	$RETIF	[JUMPF	.POPJ]

SUBTTL $GDATA Macro - 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.

; $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	STOPCD -- GLXLIB stopcode macro


; Macro  to  define  a  call  to the new stopcode processor in
; GLXLIB.  This macro and the supporting code in  the  library
; will  completely  supercede the existing stopcode facilities
; in GLXLIB.  The old macro and code will  remain  around  for
; the  sake  of  old programs, but it is expected that all new
; code written will use the new macro.
; 
; For  each  STOPCD  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:
; 
; 	STOPCD	(NAME,TYPE,ADDR,TEXT)
; 
; Where	NAME	A unique 3-character abbreviation
; 	TYPE	The class of stopcode; HALT, CONT, DEBUG
; 	ADDR	A continuation address
; 	TEXT	Text associated with the stopcode
; 
; For example, STOPCD (NFP,HALT,,<No free pages>) will expand to
; 
; 	S..NFP::PUSHJ	P,.DIE
; 		CAI	0,[<SIXBIT/NAME/>&<-1,,0>
; 			   EXP	%%.MOD
; 			   EXP	ADDR
; 			   EXP	[ASCIZ /TEXT/]]

DEFINE	STOPCD	(NAME,TYPE,ADDR,TEXT),<

.TYPE==-1				;;ASSUME UNKNOWN STOPCODE TYPE
IFIDN <TYPE><HALT>,<.TYPE==0>		;;HALT JOB
IFIDN <TYPE><CONT>,<.TYPE==1>		;;CONTINUE AFTER SNAPSHOT
IFIDN <TYPE><DEBUG>,<.TYPE==2>		;;DEBUG (ENTER DDT)

IFL .TYPE,<				;;CHECK FOR CODING ERRORS
IF2,<PRINTX ? Stopcode 'NAME is in error; see S..'NAME in CREF>
S..'NAME::JRST	4,.			;;HALT SO WILL FIND THE BAD STOPCODE
>					;;END OF IFL .TYPE CONDITIONAL

IFB <NAME>,<				;;CHECK FOR BLANK STOPCODE NAMES
IF2,<PRINTX ? Stopcode with out a name; see S.. in CREF>
S..::	JRST	4,.			;;HALT SO WILL FIND THE BAD STOPCODE
>					;;END OF IFB NAME CONDITIONAL

IFGE .TYPE,<				;;IF A KNOWN STOPCODE TYPE
S..'NAME::PUSHJ	P,.DIE			;;CALL THE STOPCODE PROCESSOR
	CAI	.TYPE,[			;;POINT TO STOPCODE ARGUMENTS
	<SIXBIT /NAME/>&777777000000	;;MNEMONIC,,0 (RH IS RESERVED)
	EXP	%%.MOD			;;MODULE NAME
	EXP	ADDR			;;SET CONTINUE ADDRESS
	EXP	[ASCIZ |TEXT|]		;;INFORMATIVE TEXT
	]				;;END OF LITERAL
>					;;END OF IFN .TYPE CONDITIONAL

	PURGE	.TYPE			;;DELETE UNNEEDED SYMBOLS
>					;;END OF STOPCD MACRO
SUBTTL	$STOP - Old stopcode macro

; The $STOP macro remaings only for compatibility with old programs
; or lazy programmers.  New programs or ambitious programmers should
; convert to the new STOPCD macro.  As an incentive, the $STOP macro
; will PRINTX a warning message when one is expanded.

DEFINE	$STOP	(CODE,STRING),<
IF1,<PRINTX % Use STOPCD macro for stopcode 'CODE instead of $STOP>
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	(ADR,STRING) <
	$CALL	T%TEXT
	LSTOF.	XCREF
	JUMP	[XWD 2,0
		 EVL (ADR)
		 ITEXT(<STRING>)]	;;Parse the string
	LSTON.>

DEFINE	EVL (A,B,C) <
	IFIDN <B'C><>,<EXP <A>>
	IFDIF <B'C><>,<
	 IFE <A+1>,<<POINT 7,'C>>
	 IFN <A+1>,<
	   IFIDN <C><>,<EXP <A,B>>
	   IFDIF <C><>,<EXP <A,B,C>>
	>>>


DEFINE	ITEXT	(STRING) <
	LSTOF.	XCREF
	..TEXT<STRING>		;;EXPAND IT
	  EXP	0		;;TERMINATE WITH A ZERO WORD
	LSTON.
> ;;End DEFINE ITEXT

; Define legal qualifers for argument types
;
;  CHR	This is the character which will invoke the function
;	when seen in a text string

;  TYPE	This is the type used in the $TQ macro to invoke the
;	function

;  ARGS	This field identifies which arguments are valid for
;	the function.  The following values may be specified:

;	0	Function accepts no arguments
;	1	Function accepts only address and field mask
;	2	Function accepts all arguments

;  PROC	This is the name of the macro processor which will be called
;	when the qualifier is encountered.


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

	DEFINE TQUALS,<
	LSTOF.
	TQ(T,2,ASCIZ)			;;ASCIZ STRING
	TQ(O,2,OCTAL)			;;UNSIGNED OCTAL NUMBER
	TQ(D,2,DECIMAL)			;;DECIMAL NUMBER
	TQ(F,2,FILE)			;;FILE SPECIFICATION
	TQ(7,2,CSEVEN)			;;ONE RIGHT JUSTIFIED 7 BIT CHARACTER
	TQ(6,2,CSIXBIT)			;;ONE RIGHT JUSTIFIED 6 BIT, CHARACTER
	TQ(W,2,SIXBIT)			;;SIXBIT WORD
	TQ(5,2,SVNBIT)			;;ASCIZ, ONLY 1 WORD
	TQ(P,2,USER)			;;PPN OR DIRECTORY NUMBER
	TQ(U,2,DIRECTORY)			;;PPN OR USER NUMBER
	TQ(H,2,DAYTIME)			;;UDT TO BE TYPED AS DD-MON-YY HH:MM:SS
	TQ(C,2,TIME)			;;TIME FROM UDT TO BE TYPED AS HH:MM:SS
	TQ(E,2,ERROR)			;;TYPE OUT STRING FOR ERxxx$ ERROR CODE
	TQ(I,1,INDIRECT)		;;POINTER TO ITEXT (INDIRECT  TEXT) BLOCK
	TQ(M,0,CR,..TXC0(\".CHCRT))	;;TYPE ^M (CARRIAGE RETURN)
	TQ(J,0,LF,..TXC0(\".CHLFD))	;;TYPE ^J (LINE-FEED)
	TQ(L,0,FF,..TXC0(\".CHFFD))	;;TYPE ^L (FORM FEED)
	TQ(K,0,VT,..TXC0(\".CHVTB))	;;TYPE ^K (VERTICAL TAB)
	TQ(A,0,NOCRLF,..TXA(.TQCHA))	;;(APPEND) SUPPRRESS FREE CRLF
	TQ(0,0,NULL,..TXA(.TQCH0))	;;NUL CHAR INSTEAD OF CR-LF AT END
	TQ(3,0,STRING,..TXER(IQU))	;;INTERNAL STRING
	TQ(V,2,VERSION)			;;PROGRAM VERSION NUMBER
	TQ(2,0,CARET,..TXER(IQU))	;;INTERNAL UP-ARROR
	TQ(Q,2,POINTER)			;;BYTE POINTER TO ASCIZ STRING
	TQ(B,2,ROB)			;;OBJECT BLOCK
	TQ(1,2,OBJECT)			;;OBJECT TYPE
	TQ(N,2,NODE)			;;TYPE A NODE NAME/NUMBER
	TQ(R,2,JIB)			;;TYPE OUT JOB INFO BLOCK (JIB)
	LSTON.
> ;END OF TQUALS DEFINITION

;DEFINE TWO SYMBOLS OF THE FORM .TQxxx AND .TQCHx WHICH
;IDENTIFY THE VALID QUALIFIERS AND THE ARGUMENTS WHICH ARE
;VALID FOR EACH.  THE RIGHT HALF OF THE SYMBOL IS THE QUALIFIER
;INDEX AND THE LEFT HALF WILL CONTAIN A 0,1 OR 2 TO INDICATE WHICH
;ARGUMENTS ARE ALLOWED.



DEFINE	TQ(CHR,ARGS,TYP,PROC) <

  IFNB	<CHR>,<.TQCH'CHR==^D<ARGS>B17+ZZ>
  IFNB 	<PROC>,<DEFINE ..TQM'CHR<PROC>>
  IFNB	<TYP>,<.TQ'TYP==^D<ARGS>B17+ZZ>
	 ZZ==ZZ+1>

	ZZ==1			;FIRST QUALIFIER IS 1
	TQUALS			;DEFINE THE CODES

;DEFINE THE FIELDS IN THE TEXT ARGUMENT BLOCK USED FOR EACH ARG

	.TXTFL==0			;TEXT ARGUMENT FLAG WORD
	  TXT.NA==1B0			;FUNCTION HAS NO ARGUMENTS
	  TXT.FN==77B8			;TEXT FUNCTION CODE
	  TXT.AD==1B9			;ADDRESS WORD IS PRESENT
	  TXT.IM==1B10			;ADDRESS IS THE ARGUMENT (RESERVED)
	  TXT.JU==3B12			;ARGUMENT JUSTIFICATION CODE
	    .TXTJL==1			;JUSTIFY LEFT
	    .TXTJR==2			;JUSTIFY RIGHT
	    .TXTJC==3			;JUSTIFY CENTER
	  TXT.WD==377B23		;WIDTH OF FIELD
	  TXT.FC==377B35		;FILL CHARACTER

	.TXTAD==1			;TEXT ARGUMENT ADDRESS WORD
	  TXT.PT==7777B11		;POINTER PORTION OF ADDRESS
	  TXT.XA==1B12			;EXTENDED ADDRESS (RESERVED)
	  TXT.EA==37777777B35		;ADDRESS PORTION

;OBSOLETE DEFINITIONS FOR FLAG WORD

	  TXT.P==1B1			;POINTER WORD IS PRESENT (OBSOLETE)
	  TXT.S==1B2			;SPACING WORD IS PRESENT (OBSOLETE)
	  TXT.M==77B8			;MASK TO QUALIFIER PART

;OBSOLETE DEFINITIONS FOR OPTIONAL SPACING WORD

	  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
SUBTTL	$TQ MACRO DEFINITION

;THE $TQ MACRO ALLOWS TEXT ARGUMENT BLOCKS TO BE BUILD WITHOUT
;REQUIRING CHARACTER BY CHARACTER PARSING OF THE TEXT STRING

DEFINE	$TQ(TYP,ADR,WID,JUS,FIL) <

  ..TXA(.TQ'TYP,WID,JUS,FIL,ADR)	;;CALL THE WORK MACRO
      IFN ..TXEF,<			;;REPORT ANY ERRORS
	..TERR<$TQ(TYP,ADR,WID,JUS,FIL)>>

> ;END OF $TQ DEFINITION


;THE ..TXA MACRO BUILDS A STANDARD ITEXT ARGUMENT BLOCK AND
;ESTABLISHES THE DEFAULT JUSTIFICATION AND FILL IF NONE WAS
;SPECIFIED.  THIS MACRO IS CALLED BY THE $TQ MACRO AND BY THE
;TEXT PARSING MACROS WHEN AN ARGUMENT HAS BEEN ASSEMBLED

DEFINE	..TXA(TYP,WID,JUS,FIL,ADR,STR) <

	..TXEF==0			;;CLEAR THE ERROR FLAGS

IFNDEF TYP,<..TXER(UQU)>		;;QUALIFIER MUST BE DEFINED
IFDIF <WID><>,<IRPC WID,<.IFN <WID>,NUMERIC,..TXER(IWA)>>
IFNB <JUS>,<IFNDEF .TXTJ'JUS,<..TXER(IJA)>>
IFDEF  TYP,<
  IFE <TYP_-^D18>,<IFDIF <ADR'STR'WID'JUS'FIL><>,<..TXER(ANA)>>
  IFE <1-<TYP_-^D18>>,<IFDIF <WID'JUS'FIL><>,<..TXER(JNA)>>
  IFE <2-<TYP_-^D18>>,<IFIDN <ADR'STR><>,<..TXER(ADS)>>>

      IFE ..TXEF,<
	IFIDN <WID><>,<..TXWD==<..TXJU==<..TXFC==0>>>
	IFDIF <WID><>,<
	  IFE <^D<WID>>,<..TXWD==<..TXJU==<..TXFC==0>>>
	  IFN <^D<WID>>,<..TXWD==^D<WID>
	    IFNB <JUS>,<..TXJU==.TXTJ'JUS>
	    IFB  <JUS>,<..TXJU==.TXTJL
	      IFE <TYP-.TQOCT>,<..TXJU==.TXTJR>
	      IFE <TYP-.TQDEC>,<..TXJU==.TXTJR>>
	    IFB  <FIL>,<..TXFC==" ">
	    IFNB <FIL>,<..TXFC=="FIL">>>

	IFB  <ADR'STR>,<..TXPT==0>
	IFNB <ADR'STR>,<..TXPT==1>
	IFE <..TXWD+..TXPT>,<
	    EXP FLD(TYP,TXT.FN)>
	IFN <..TXWD+..TXPT>,<
	    EXP FLD(TYP,TXT.FN)+FLD(..TXJU,TXT.JU)+FLD(..TXWD,TXT.WD)+FLD(..TXFC,TXT.FC)+TXT.AD
	    PNTR(ADR,STR)>>

> ;END OF ..TXA MACRO DEFINITION
;THE PNTR MACRO ACCEPTS A STRUCTURE OR ADDRESS MASK DEFINITION
;AND CREATES A BYTE POINTER TO THEARGUMENT.
;IF THE ARGUMENT IS A FULLWORD, THE POINTER POSITION IS 0.

DEFINE	PNTR(Y,STR) <
	 IFB  <STR>,<..STR0(..PNT,,<FWMASK>,Y)>
	 IFNB <STR>,<..STR0(..PNT,,<STR>,Y)>>

   DEFINE ..PNT(AC,LOC,MSK)<
	..PST==MSK-FWMASK
	.IF0 ..PST,<
		POINT 0,LOC,35>,<
		POINTR (LOC,MSK)>>
SUBTTL	Error processing and messages

DEFINE	$TX$ERR,<
	LSTOF.
	X(UQU,Unknown qualifier)
	X(IQU,Invalid qualifier)
	X(IJA,Invalid justification argument)
	X(IWA,Invalid width argument)
	X(PEA,Premature end of argument)
	X(JNA,Justification is not allowed)
	X(ANA,Arguments are not allowed)
	X(ADS,Address must be specified)
	LSTON.
> ;End of $TX$ERR definition

;Assign a bit symbol for each error

DEFINE	X(NAM,STRING) <
	..X'NAM==1B<ZZ>
	 ZZ==ZZ+1>

	 ZZ==0
	$TX$ERR		;;EQUATE THE SYMBOLS

;DEFINE A MACRO TO DISPLAY THE COMPILE TIME DIAGNOSTIC FOR ERRORS

DEFINE ..TERR(TEXT) <
  IF1,<
    PRINTX ? Error in "TEXT"
    DEFINE X(NAM,ERR) <IFN ..X'NAM&..TXEF,<PRINTX ? ERR>>
    $TX$ERR>
> ;End ..TERR definition

;HERE WHEN AN ERROR IS DETECTED.  THIS ROUTINE REMEMBERS THE
;ERROR IN THE ERROR REGISTER ..TXF AND CAUSES RETURN TO TOP
;THE TOP LEVEL PARSING ROUTINES.

  DEFINE ..TXER(E) <
    ..TXEF==..TXEF!..X'E		;;SET THE ERROR FLAG
    ..TXF==0				;;BACK TO TOP LEVEL
    ..TXB=="^">				;;ESTABLISH BREAK

SUBTTL	..TEXT PARSING MACRO DEFINITION

DEFINE ..TEXT (C) <

    ..TXF==0				;;SET TOP PROCESSING LEVEL
    ..TXB==0				;;CLEAR THE BREAK CHARACTER
    ..TXP==0				;;CLEAR TEXT PROCESSING FLAG
    ..TXEG==<..TXEF==0>			;;CLEAR ERROR REGISTERS
    IRPC C,<				;;PARSE THE STRING
	..TXC==ASCII\C\_-35		;;GET CHARACTER VALUE
	IFN ..TXB,<IFN ..TXB-..TXC,..CNS(<C>)
		   IFE ..TXB-..TXC,..TXB==0>
	IFE ..TXB,<..TXQ(<C>,\..TXF)>>	;;CALL PROPER PROCESSOR
    ..TXC1				;;TERMINATE TEXT IF ANY
    IFN ..TXB,<IFN <..TXB-"^">,<..TXER(PEA)>>
    ..TXEF==..TXEF!..TXEG		;;GET ANY ERRORS
    IFN ..TXEF,<..TERR<C>>
> ;END OF ..TEXT


;;HERE WHEN BREAK CHARACTER IS NOT SET TO DISPATCH TO
;APPROPRIATE PROCESSOR

DEFINE ..TXQ(C,P) <..TXQ'P(<C>)>


;HERE FOR THE VERY FIRST CHARACTER AND FOR EACH CHARACTER
;FOLLOWING THE COLLECTION OF A VALID ARGUMENT

DEFINE ..TXQ0(C) <

    IFN ..TXC-"^",<..TXC0(<C>)>		;;STORE AND INIT TEXT
    IFE ..TXC-"^",<..TXF==1>>		;;UNLESS WE HAVE "^"


;;HERE TO PROCESS THE QUALIFIER

;;MAKE SURE WE HAVE A VALID QUALIFER AND DO SPECIAL CASE
;;CHECK TO ALLOW A QUOTED "^".
;;SETS THE NEXT FUNCTION TO PROCESS WIDTH IF QUALIFIER
;;ACCEPTS ANY ARGUMENTS ELSE FORCES RETURN TO TOP LEVEL.

DEFINE ..TXQ1(C) <

    IFE ..TXC-"^",<..TXC0(<C>)>	;;STORE IF SPECIAL CHARACTER
    IFN ..TXF,<			;;ELSE
	..TXF==0		;;ASSUME TOP LEVEL
	IFDEF .TQCH'C,<		;;IF QUALIFIER IS VALID
	    IFDEF ..TQM'C,..TQM'C ;;EXECUTE MACRO IF DEFINED
	    IFN <.TQCH'C_-^D18>,<..TXF==2>>>
    IFE ..TXF-2,<..TXC1(<C>)	;;CLOSE CURRENT TEXT STRING
	..ICNS			;;CLEAR ACCUMULATED TEXT
	..CNS<..TXA(.TQCH'C,>>	;;SET STRING TO CALL ..TXA MACRO
    ..TXEG==..TXEG!..TXEF>	;;REMEMBER ANY ERRORS

;HERE TO PROCESS WIDTH

;THIS MACRO APPENDS ALL NUMERIC CHARACTERS TO THE STRING WHICH
;IS BEING ACCUMULATED.  WHEN THE FIRST NON NUMERIC IS ENCOUNTERED
;THE JUSTIFICATION PROCESSOR IS CALLED.

DEFINE ..TXQ2(C) <
    ..TXF==3				;;ASSUME JUSTIFICATION
    IFGE ..TXC-"0",IFLE ..TXC-"9",<..TXF==2>;;UNLESS ARGUMENT IS NUMERIC
    IFE ..TXF-2,<..CNS(C)>		;;APPEND NUMERIC ARGUMENT
    IFE ..TXF-3,<..CNS<,>		;;ELSE CLOSE WIDTH
		 ..TXQ3(C)>>		;;AND PROCESS JUSTIFICATION


;HERE TO PROCESS JUSTIFICATION

;STORE JUSTIFICATION ARGUMENT AND SETUP TO PROCESS FILL CHARACTER
;OR PROCESS FIRST ADDRESS DELIMITER

DEFINE	..TXQ3(C) <
    ..TXF==4				;;ASSUME NEXT ARG IS FILL
    IFE ..TXC-"/",<..TXF==5>		;;UNLESS FIRST SLASH
    IFE ..TXC-"[",<..TXF==5>		;;OR ADDRESS DELIMITER
    IFE ..TXF-4,<..CNS<C,>>		;;STORE JUSTIFICATION ARG
    IFE ..TXF-5,<..CNS<,,>		;;OR CLOSE JUSTIF AND FILL
		 ..TXQ5(C)>>		;;AND PROCESS DELIMITER


;HERE TO PROCESS FILL CHARACTER

;IF CHARACTER IS NOT ADDRESS DELIMITER WE STORE IT AS THE FILL
;CHARACTER AND SETUP TO PROCESS A SLASH.  IF THE ARGUMENT IS
;A DELIMITER WE CLOSE THE FILL CHARACTER ARGUMENT AND PROCESS
;IT.

DEFINE ..TXQ4(C) <
    ..TXF==4				;;ASSUME WE HAVE FILL CHARACTER
    IFE ..TXC-"/",..TXF==5		;;UNLESS IT IS ADDRESS
    IFE ..TXC-"[",..TXF==5		;;DELIMITER
    IFE ..TXF-5,<..CNS<,>		;;ELSE CLOSE FILL ARGUMENT
		 ..TXQ5<C>>		;;AND PROCESS DELIMITER
    IFE ..TXF-4,<..CNS<C,>		;;STORE FILL CHARACTER
		 ..TXF==5>>		;;SET TO PROCESS DELIMITER


;HERE TO PROCESS FIRST ADDRESS DELIMITER

;HERE WE SET OUR NEXT FUNCTION TO PROCESS FINAL DELIMITER

DEFINE ..TXQ5(C) <
    ..TXF==6				;;SET NEXT FUNCTION
    IFE ..TXC-"/",..TXB=="/"		;;SET FINAL BREAK CHARACTER
    IFE ..TXC-"[",..TXB=="]"
    IFE ..TXB-"]",..CNS<[>		;;STORE START OF LITERAL
    IFE ..TXB,..TXF==5>			;;IGNORE ANY JUNK


;HERE TO PROCSS FINAL DELIMITER AND BUILD AN ARGUMENT BLOCK

DEFINE ..TXQ6(C) <
    ..TXF==0			;;BACK TO TOP LEVEL
    IFE ..TXC-"]",..CNS<]>	;;STORE END OF LITERAL
    ..CNS<)>			;;TERMINATE ARGUMENT LIST
    ..GCNS			;;DO THE ..TXA MACRO
    ..TXEG==..TXEG!..TXEF>	;;REMEMBER ANY ERRORS


SUBTTL	ASCII TEXT STRING STORAGE MACRO DEFINITIONS

;HERE TO STORE A CHARACTER IN AN ASCII STRING.  A CHECK IS MADE
;TO ENSURE THAT WE ARE PROCESSING ASCII TEXT.

DEFINE ..TXC0(C) <
    IFE ..TXP,<			;;INITIALIZE TEXT PARSING
	..ICNS			;;CLEAR ACCUMULATED STRING
	..CNS<ASCIZ\>		;;START ASCIZ LITERAL
	..TXP==1>		;;REMEMBER WE ARE DOING TEXT
    ..CNS<C>			;;APPEND THE CHARACTER
    ..TXF==0			;;BACK TO TOP LEVEL
    ..TXB=="^">			;;SET TOP LEVEL BREAK


;HERE TO TERMINATE TEXT PROCESSING AND BUILD TEXT ARGUMENT

DEFINE ..TXC1(C) <

    IFN ..TXP,<			;;IGNORE IF NOT DOING TEXT
	..CNS<\>		;;CLOSE ASCIZ LITERAL
	EXP <FLD(.TQCHT,TXT.FN)+[..GCNS]>>;;BUILD THE ARGUMENT
    ..TXP==0>			;;CLEAR TEXT PROCESSING FLAG

	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 TIEIR 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 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,<Receivers quota full>
	ERR	SQF,<Senders quota full>
	ERR	NRE,<No remembered entry>
	ERR	TBF,<Table is full>
	ERR	EIT,<Table entry already exists>
	ERR	ITE,<Invalid table entry>
	ERR	QEF,<Quota exceeded or disk full>
	ERR	ARG,<Invalid argument specified>
	ERR	IFN,<Invalid function specified>
	ERR	IJN,<Invalid job number specified>
	ERR	RAD,<Invalid radix specified>
	ERR	NUM,<Invalid numeric argument>
	ERR	IDT,<Invalid date field specified>
	ERR	ITF,<Invalid time field specified>
	ERR	DOR,<Date/time out of range>
	ERR	DTM,<Value missing in date/time>
	ERR	MDD,<Missing day in date/time>
	ERR	DFZ,<Field zero in date/time>
	ERR	MDS,<Mnemonic date/time switch not implemented>
	ERR	DFL,<Field too large in date/time>
	ERR	ILR,<Illegal year format in date/time>
	ERR	NND,<Negative number in date/time>
	ERR	NPF,<Not known whether past or future in date/time>
	ERR	RDP,<Relative date parse required>
	ERR	NSW,<Switch does not begin with slash>
	ERR	NOM,<Unrecognized switch or keyword>
	ERR	NUL,<Null switch or keyword given>
	ERR	INW,<Invalid guide word>
	ERR	NC,<Not confirmed>
	ERR	ICN,<Invalid character in number>
	ERR	NQS,<Invalid quoted string - does not begin with quote>
	ERR	AMB,<Ambiguous switch or keyword>
	ERR	NMT,<Does not match token>
	ERR	CMA,<Comma not given>
	ERR	NNC,<Node name may not exceed 6 characters>
	ERR	INT,<Node terminator "::" must be specified>
	ERR	NSN,<Unknown node name>
	ERR	IPS,<Invalid path specification>
	ERR	IUS,<Invalid user specification>
	ERR	DGS,<Device name may not exceed 6 characters>
	ERR	DNE,<Unknown device>
	ERR	DIO,<Device can not do input or output>
	ERR	BDF,<Invalid date/time format>
	ERR	ABS,<Field too long for internal buffer>
	ERR	TMT,<Command too long for internal buffer>
	ERR	BDS,<Invalid default string>
	ERR	BTF,<Invalid table format>
	ERR	TME,<Date/time must be in the future>
	ERR	TMN,<No timer entry has expired>
	ERR	TMA,<Timer entry already exists>
	ERR	DVT,<Device terminator ":" must be specified>
	ERR	NCI,<Argument block may not be in the ACs>
	ERR	TLU,<Terminal location is unknown>
	ERR	FIO,<File is offline>
	ERR	FBM,<File being modified>
	ERR	WLK,<Write-locked device>
	ERR	CSD,<Cannot supersede a directory>
	ERR	CDD,<Cannot delete a non-empty directory>
	ERR	SNF,<Sub-file directory not found>
	ERR	ESL,<Search list is empty>
	ERR	LVL,<SFD level nested deeper than the maximum allowed>
	ERR	CCW,<Cannot create/write on any structure in search list>
	ERR	FCU,<Cannot update file>
	ERR	ENQ,<File has outstanding Enqueue lockes set>
	ERR	SWS,<Software write-lock on structure>
	ERR	DER,<Hardware device error>
	ERR	DTE,<Hard data error>
	ERR	BKT,<Block too large>
	ERR	IPP,<Non-existant UFD>
	ERR	TRN,<RIB or transmission error>
	ERR	ILC,<Illegal character in date/time>
	ERR	NFT,<Date/time must be in the future>
	ERR	NPS,<Date/time must be in the past>
	ERR	UDM,<Unrecognized month in date/time>
	ERR	UDN,<Unrecognized name in date/time>
	ERR	IFA,<Illegal file attribute>
	ERR	FAI,<File attribute inconsistancy>
	ERR	CEI,<Can't enable/disable interrupt system>
	ERR	ENF,<Linked list entry not found>
	ERR	NSL,<No such linked list>
	ERR	NFP,<No free pages>
	ERR	NPI,<No free pages for IPCF reception>
	ERR	IFB,<Indirect file too big for internal buffer>	;;[237]
	ERR	NDN,<Null device name given>		;;[241]
	ERR	PWA,<PID went away>
	ERR	CGP,<Can't get a PID>
	ERR	IND,<Invalid node name>
	ERR	IAC,<Invalid access string>
	ERR	IDV,<Invalid device name>
	ERR	INA,<Invalid file name>
	ERR	IEX,<Invalid file extension>
	ERR	IGN,<Invalid generation number>
	ERR	IDR,<Invalid directory name or PPN>
	ERR	NHA,<No help available>
	ERR	TOF,<Timeout waiting for FRCLIN>
	ERR	TOP,<Timeout waiting for PID>
	ERR	DNP,<Dependencies not present>
>  ;END DEFINE ERRORS

;GENERATE THE ERROR SYMBOLS

	ER%%%==1			;DON'T USE ERROR CODE 0
DEFINE ERR(A,B),<
	IF1,<IFDEF ER'A'$,PRINTX ?Duplicate error code A>
	ER'A'$==ER%%%
	ER%%%==ER%%%+1
>  ;END DEFINE ERR

	ERRORS

	ERUJI$==ERIFN$			;***Temporary***
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)
	X	ACT		;;ACCOUNT STRING
	X	CRY		;;ENCRYPTION CODE
	X	DTY		;;DATA TYPE
	X	DTO		;;DATA OTS TYPE
	X	DCC		;;DATA CARRIAGE CONTROL
	X	BSZ		;;LOCAL DATA BYTE SIZE
	X	FSZ		;;PHYSICAL DATA FRAME SIZE
	X	HSZ		;;FIXED-HEADER SIZE (VARIABLE-LEN RECORDS)
	X	RFM		;;RECORD FORMAT
	X	RFO		;;RECORD FORMAT ORGANIZATION
	X	RSZ		;;RECORD SIZE
	X	BLS		;;BLOCK SIZE (BYTES)
	X	FFB		;;FIRST FREE BYTE WITHIN LAST BLOCK
	X	ACW		;;APPLICATION-SPECIFIC FIELD
	X	RMS		;;RMS-10 FORMATTED FILE
	X	MCY		;;MACY11 FORMATTED FILE
	X	CTG		;;CONTIGUOUS ALLOCATION
	X	NSB		;;RECORDS DO NO SPAN PHYSICAL BLOCKS
	X	ACD		;;ACCESS DATE
	X	MTA		;;TAPE LABEL
	X	STS		;;FILE STATUS BITS
	X	IDT		;;BACKUP INCREMENTAL DATE/TIME
	X	PCA		;;PRIVILEGED CUSTOMER-SETTABLE WORD
	X	TIM		;;PHYSICAL CREATION DATE/TIME
	X	LAD		;;LAST ACCOUNTING DATE
	X	EXP		;;EXPIRATION DATE (UDT)

	  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>,<-1,,GJBLOC> ;;JOB LOCATION INFORMATION
	X RTM,.JIRT,<-1,,GJBRTM>	;;JOB RUNTIME IN MILLISECS
	X TLC,<-1,,GJBTLC>,<-1,,GJBTLC>	;;JOBS TERMINAL LOCATION
	  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	I%TIMR	Functions and argument block


.TIFNC==0		;HEADER WORD FOR EACH TIMER ENTRY
  TI.FRK==777777B17	;FORK HANDLE (TOPS20 RESERVED)
  TI.FNC==777777B35	;TIMER FUNCTION CODE
    .TIMRT==0		;RESERVED FOR RUNTIME
    .TIMEL==1		;ADD A REQUEST TO OCCUR AFTER N MILLISECONDS
    .TIMDT==2		;ADD A REQUEST TO OCCUR AT THE SPECIFIED UDT
    .TIMDD==3		;REMOVE PENDING REQUESTS AT THE UDT
    .TIMBF==4		;REMOVE PENDING REQUESTS BEFORE THE UDT
    .TIMAL==5		;REMOVE ALL PENDING REQUESTS
.TITIM==1		;ELAPSED TIME OR UDT AT WHICH EVENT IS TO OCCUR
.TIPSI==2		;PSI WORD (RESERVED)
.TIMPC==3		;USER SUPPLIED PC FOR TIMER
.TIDAT==4		;START OF USER SUPPLIED DATA

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.

;**;[236] Added three new fields to the TRMTYP macro to include
;**;[236]  a per terminal initialization routine, and escape sequences
;**;[236]  to set and clear the keypad mode and clear to end of line./NT
DEFINE	TRMTYP,<
	LSTOF.
 X(33,TTY33,33,.RETT,,,)			;;MODEL 33
 X(35,TTY35,35,.RETT,,,)			;;MODEL 35
TOPS20<
 X(37,TTY37,37,.RETT,,,)			;;MODEL 37
 X(EXECUPORT,EXEC,EXE,.RETT,,,)			;;TI EXECUPORT
>;;END TOPS20
TOPS10<
 X(LA120,LA120,L12,.RETT,,,)			;;LA120
>;;END TOPS10
 X(LA36,LA36,L36,.RETT,,,)			;;LA36
 X(VK100,VK100,K10,SETTLC,<.CHESC,"[","K">,<.CHESC,"=">,<.CHESC,.CHRAB>)
 X(VT05,VT05,V05,.RETT,<37,177,177,177>,,)	;;VT05
 X(VT100,VT100,100,SETTLC,<.CHESC,"[","K">,<.CHESC,"=">,<.CHESC,.CHRAB>) ;;VT100
;;**;[235]ADD 6 LINES AFTER VT100 ENTRY 2-Jun-83/CTK
TOPS10<	X(VT101,VT101,101,SETTLC,<.CHESC,"[","K">,<.CHESC,"=">,<.CHESC,.CHRAB>)> ;;[235] VT101
 X(VT102,VT102,102,SETTLC,<.CHESC,"[","K">,<.CHESC,"=">,<.CHESC,.CHRAB>) ;;[235] VT102
TOPS10<	X(VT103,VT103,103,SETTLC,<.CHESC,"[","K">,<.CHESC,"=">,<.CHESC,.CHRAB>)> ;;[235] VT103
 X(VT125,VT125,125,SETTLC,<.CHESC,"[","K">,<.CHESC,"=">,<.CHESC,.CHRAB>) ;;[235] VT125
TOPS10<	X(VT180,VT180,180,SETTLC,<.CHESC,"[","K">,<.CHESC,"=">,<.CHESC,.CHRAB>)> ;;[235] VT180
TOPS10<	X(VT185,VT185,185,SETTLC,<.CHESC,"[","K">,<.CHESC,"=">,<.CHESC,.CHRAB>)> ;;[235] VT185
 X(VT220,VT220,220,SETTLC,<.CHESC,"[","K">,<.CHESC,"=">,<.CHESC,.CHRAB>) ;;VT220
 X(VT240,VT240,240,SETTLC,<.CHESC,"[","K">,<.CHESC,"=">,<.CHESC,.CHRAB>) ;;VT240
 X(VT320,VT320,320,SETTLC,<.CHESC,"[","K">,<.CHESC,"=">,<.CHESC,.CHRAB>) ;;VT320
 X(VT330,VT330,330,SETTLC,<.CHESC,"[","K">,<.CHESC,"=">,<.CHESC,.CHRAB>) ;;VT330
 X(VT340,VT340,340,SETTLC,<.CHESC,"[","K">,<.CHESC,"=">,<.CHESC,.CHRAB>) ;;VT340
 X(VT50,VT50,V50,SETTLC,<.CHESC,"K">,<.CHESC,"=">,<.CHESC,.CHRAB>) ;;VT50
 X(VT52,VT52,V52,SETTLC,<.CHESC,"K">,<.CHESC,"=">,<.CHESC,.CHRAB>) ;;VT52
TOPS10<	X(VT61,VT61,V61,SETTLC,<.CHESC,"K">,<.CHESC,"=">,<.CHESC,.CHRAB>)> ;;VT61
	LSTON.

>;END DEFINE TRMTYP

;The general form of the X macro (which must be redefined just before invoking
;TRMTYP) is:
;X(PARNAM,SIXNAM,SUF,INITER,EOLSEQ,SETKEY,SETNUM)
;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
;	INITER	Is the address of a routine to initialize the terminal
;	EOLSEQ	is a sequence of bytes which will clear to end of line
;	SETKEY	is a sequence of bytes to set alternate keypad mode
;	SETNUM	is a sequence of bytes to set numeric keypad mode

;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,INITER,EOLSEQ,SETKEY,SETNUM),<
.TI'SUF==..Z
..Z==..Z+1>
	..Z==0
	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,INITER,EOLSEQ,SETKEY,SETNUM),<
.TT'SUF==..Z
..Z==..Z+1
>;END DEFINE X
	..Z==0			;Start at 0
	TRMTYP			;Do 'em all!
	PURGE	..Z
>;END TOPS10
; The following data structures are defined to support the keypad mode
;	in GLXKBD's TEXTI routine.

TOPS10 <
	.ORG	0
.ESENT:!BLOCK	1			;One word/entry
	  ES.FLG==777600,,0		;11 bits for flags
	    EF.IST==1B0			;Address points to input string
	    EF.OST==1B1			;   "       "    " output   "
	    EF.TBL==1B2			;Address points to another table
	    EF.LST==1B3			;Address is a command list table
	  ES.SIZ==177,,0		;Size of the bytes
	  ES.STR==0,,777777		;The rest is address of string
ESTSIZ:!
	.ORG

; The format for the command list table is:
; word 0 :	Lenght of table including this word
; word 1 - n :	Commands as per above

>;;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==15			;FLOATING POINT (RSVD)
	.CMDEV==16			;DEVICE NAME
	.CMTXT==17			;TEXT
	.CMTAD==20			;DATE-TIME
	.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%NSF==1B12				;SUFFIX MAY BE OMITTED IF DESIRED
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
>;;Pause in TOPS10 definition -- The next 2 symbols will apply for TOPS20 also

CM%FUT==1B3				;Time is in future
CM%PST==1B4				;Time is in past

; Resume TOPS10 conditional.
TOPS10	<

CM%WLD==1B5				;DO WILDCARDING
CM%WLA==1B6				;DO ACCOUNTING-STYLE WILDCARDING
					;[10,#] AND [10,%]

;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 ADD/DELETE FLAGS - IN S1 WITH TABLE HEADER ADDRESS

	TB%ABR==1B0			;ABBREVIATIONS PRESENT IN KEYWORD TABLE

; 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                  !
;	!=======================================================!

	.ORG	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
	.ORG
SUBTTL	General message format

;The following is a description of the typical messages sent in
;GALAXY.

;	!=======================================================!
;	\                                                       \
;	\                  THE MESSAGE HEADER                   \
;	\                                                       \
;	!-------------------------------------------------------!
;	!                       FLAG WORD                       !
;	!-------------------------------------------------------!
;	!                  ARGUMENT COUNT WORD                  !
;	!=======================================================!
;


;			ARGUMENT DATA BLOCKS


;
;	!=======================================================!
;	!  LENGTH OF THE ARGUMENT   !     TYPE OF ARGUMENT      !
;	!-------------------------------------------------------!
;	\                                                       \
;	\                     ARGUMENT DATA                     \
;	\                                                       \
;	!=======================================================!

	.ORG MSHSIZ
.OFLAG:! BLOCK	1			;FLAG WORD FOR MESSAGE
.OARGC:! BLOCK	1			;ARGUMENT COUNT WORD
.OHDRS:!				;SIZE OF THE HEADER

	.ORG

;DESCRIPTION OF THE ARGUMENT BLOCK

	.ORG 0
ARG.HD:! BLOCK	1			;ARGUMENT HEADER WORD
	AR.LEN==-1,,0			;LENGTH OF THE BLOCK
	AR.TYP==0,,-1			;TYPE OF BLOCK
ARG.DA:! BLOCK	1			;START OF DATA AREA
ARG.SZ:!				;MINIMUM SIZE OF THE BLOCK

	.ORG

;General data types for all messages

.OROBJ==100				;OBJECT BLOCK
.ORTYP==101				;OBJECT TYPE FIELD
.ORJBN==102				;JOBNAME TYPE FIELD
.ORSEQ==103				;SEQUENCE NUMBER FIELD
.ORREA==104				;REASON TYPE FIELD
.ORDSP==105				;OPR DISPLAY ARGUMENT
.ORREQ==106				;REQUEST NUMBER FIELD
.ORNOD==107				;NODE BLOCK FOR QUASAR VALIDATION
.ORD60==110				;DN60 BLOCK OF DATA
.ORTIM==111				;TIME BLOCK (UDT)
.ORJNU==112				;JOB NUMBER FIELD

;The following function types are currently used as argument types

;.CMNOD			FOR NODE NAME TYPE
;.CMTXT			FOR TEXT ASCIZ DATA
;.CMIFI			FOR INPUT FILE SPEC
;.CMUSR			FOR USER ID INFORMATION
;.CMDEV			FOR DEVICE DESIGNATOR
	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)                !
;	!                                                       !
;	!=======================================================!


	.ORG 	0

JIB.JN:! BLOCK	1			;JOB NAME IN SIXBIT
JIB.SQ:! BLOCK	1			;SEQUENCE NUMBER FIELD
	JB.SEQ==777700,,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
	.ORG
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                  !
;	!=======================================================!


		.ORG	0

OBJ.TY:! BLOCK	1			;OBJECT TYPE CODE WORD
					; (DEFINED IN OBJCTS MACRO)
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

		.ORG
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	.OTTRM,Terminal
	X	.OTJOB,Job
	X	.OTOPR,Operator
	X	.OTIBM,<IBM Remote>
	X	.OTMNT,<Device>
	X	.OTFTS,<File Transfer>
	X	.OTBIN,<Card Reader Interpreter>
	X	.OTRET,<File Retrieval>
	X	.OTNOT,<Retrieval Notification>
	X	.OTDBM,<DBMS System>
	X	.OTFAL,<FAL-Stream>
	X	.OTEVT,<Event>
	X	.OTFCH,<Microfiche>
	X	.OTXER,<Xerox>
	X	.OTNQC,<NQC-Stream>
> ;END OF OBJCTS DEFINITION

	ZZ==0
DEFINE	X	(NAM,TXT),<NAM==<ZZ==ZZ+1>>
	OBJCTS
	.OTMAX==ZZ
	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.


	.ORG	0

.FDLEN:! BLOCK	1			;LENGTH WORD
	FD.LEN==-1,,0			;MASK TO LENGTH FIELD
	FD.TYP==0,,-1			;TYPE OF FD
	   .FDNAT==0			;NATIVE FILE DESCRIPTOR
	   .FDLOC==1			;ASCIZ LOCAL FILE DESRIPTOR
	   .FDNET==2			;ASCIZ REMOTE FILE DESCRIPTOR
	   .FDFRN==3			;ASCIZ FORIEGN FILE DESCRIPTOR
					;  (NON-DECNET)

.FDFIL:!				;FIRST WORD OF FILESPECIFICATION

	.ORG

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              !
;	!                                                       !
;	!=======================================================!

	.ORG	.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

	.ORG

>  ;END OF TOPS10

					;CONTINUED ON FOLLOWING PAGE
TOPS20 <		;FILE DESCRIPTOR FOR TOPS20 (FD.TYP==.FDNAT)

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

	.ORG	.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

	.ORG

>  ;END OF TOPS20


;		FILE DESCRIPTOR FOR LOCAL FILE (FD.TYP==.FDLOC)

;	!=======================================================!
;	/                                                       /
;	/   THE FILE DESCRIPTOR FOR THE LOCAL FILESPEC MAY BE   /
;	/   AN ASCIZ STRING IN A FORM ACCEPTABLE TO THE LOCAL   /
;	/   SYSTEM						/
;	/   DEV:[PPN]FILE.EXT OR DEV:[DIRECTORY]FILE.EXT.GEN	/
;	/                                                       /
;	!=======================================================!



;		FILE DESCRIPTOR FOR REMOTE DECNET NODE (FD.TYP==.FDNET)

;	!=======================================================!
;	/                                                       /
;	/   THE FILE DESCRIPTOR FOR A DECNET FILESPEC IS AN	/
;	/   ASCIZ STRING OF THE FORM NODE::DEV:[PPN]FILE.EXT	/
;	/   OR NODE::DEV:[DIRECTORY]FILE.EXT.GEN		/
;	/                                                       /
;	!=======================================================!

	.ORG	.FDFIL

.FDNST:! BLOCK	1		;ASCIZ STRING FOR GTJFN/OPENF SEQUENCE
FDNSIZ==^D300/^D5		;RESERVE ROOM FOR 300 CHARACTERS

	.ORG

;		FILE DESCRIPTOR FOR A FORIEGN NODE (FD.TYP==.FDFRN)

;	!=======================================================!
;	/                                                       /
;	/   THE FILE DESCRIPTOR FOR A FORIEGN NODE IS AN ASCIZ	/
;	/   STRING OF THE FORM:					/
;	/   NODE::REMOTE-FILESPEC OR NODE::"REMOTE-FILESPEC"	/
;	/                                                       /
;	!=======================================================!

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)          !
;	!=======================================================!

		.ORG	0

FOB.FD:! BLOCK	1			;POINTER TO FD AREA
FOB.CW:! BLOCK	1			;CONTROL WORD
	   FB.PHY==1B27			;PHYSICAL OPEN
	   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			;USER ID FOR "IN BEHALF" OPERATIONS
FOB.CD:! BLOCK	1			;CONNECTED DIRECTORY (TOPS-20)
FOB.AB:! BLOCK	1			;FILE ATTRIBUTE BLOCK ADDRESS

FOB.SZ:!				;SIZE OF AN FOB

		.ORG


; File attribute definitions
;
FI.IMM==1B0		;ARGUMENT IS AN IMMEDIATE VALUE
FI.IFN==1B1		;ARGUMENT VALUE IS FROM ANOTHER FILE (GIVEN BY IFN)
FI.LEN==777B17		;LENGTH (IN WORDS) OF ATTRIBUTE
FI.ATR==777777B35	;FILE ATTRIBUTE MASK
   .FIPRO==1		   ;PROTECTION CODE
   .FIACT==2		   ;ACCOUNT STRING
   .FISPL==3		   ;SPOOLED FILE NAME
   .FICRY==4		   ;ENCRYPTION CODE
   .FIDTY==5		   ;DATA TYPE
   .FIDTO==6		   ;DATA "OTS" TYPE
   .FIDCC==7		   ;DATA CARRIAGE CONTROL
   .FIBSZ==10		   ;LOCAL DATA BYTE SIZE
   .FIFSZ==11		   ;PHYSICAL DATA FRAME SIZE
   .FIHSZ==12		   ;FIXED-HEADER SIZE (FOR VARIABLE-LENGTH RECORDS)
   .FIRFM==13		   ;RECORD FORMAT
   .FIRFO==14		   ;RECORD FORMAT ORGANIZATION
   .FIRSZ==15		   ;RECORD SIZE
   .FIBLS==16		   ;BLOCK SIZE (BYTES)
   .FIFFB==17		   ;FIRST FREE BYTE WITHIN LAST BLOCK
   .FIACW==20		   ;APPLICATION-SPECIFIC FIELD
   .FIRMS==21		   ;RMS-10 FORMATTED FILE
   .FIMCY==22		   ;MACY11 FORMATTED FILE
   .FICTG==23		   ;CONTIGUOUS ALLOCATION
   .FINSB==24		   ;RECORDS DO NOT SPAN PHYSICAL BLOCKS
   .FICRE==25		   ;CREATION DATE/TIME (UDT)
   .FIACD==26		   ;ACCESS DATE
   .FIMOD==27		   ;I/O MODE OF FILE
   .FIVER==30		   ;VERSION OF FILE IN STANDARD FORMAT
   .FIUSW==31		   ;USER-SETTABLE WORD
   .FIMTA==32		   ;TAPE LABEL
   .FISTS==33		   ;FILE STATUS BITS
   .FIIDT==34		   ;BACKUP DATE/TIME
   .FIPCA==35		   ;PRIVILEGED CUSTOMER-SETTABLE WORD
   .FITIM==36		   ;PHYSICAL CREATION DATE/TIME
   .FILAD==37		   ;LAST ACCOUNTING DATE
   .FIEXP==40		   ;EXPIRATION DATE (UDT)
   .FIAUT==41		   ;FILE AUTHOR
   .FIMAX==.FIAUT	   ;HIGHEST LEGAL ATTRIBUTE TYPE
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)!
;	!-------------------------------------------------------!
;	! 		    FLAG BITS				!
;	!=======================================================!


			.ORG 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			;USER ID FOR IN BEHALF
FRB.CD:! BLOCK	1			;CONNECTED DIRECTORY (TOPS20)
FRB.FL:! BLOCK	1			;RENAME FLAG BITS
   FR.NFO==1B0				   ;NEW FILE ONLY
   FR.PHY==1B1				   ;PHYSICAL RENAME
FRB.AB:! BLOCK	1			;FILE ATTRIBUTE BLOCK ADDRESS

FRB.SZ:!				;SIZE OF AN FRB

			.ORG
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!DET!           program-wide flags              !
;	!-------------------------------------------------------!
;	!       Base of program's interrupt vector(s)           !
;	!-------------------------------------------------------!
;	!       PID block address                               !
;	!-------------------------------------------------------!
;	!       $TEXT error exit routine                        !
;	!=======================================================!

		.ORG	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.DPM==1B2			; USE JOB NUMBER FOR A PID
	IB.NPF==1B3			; DON'T SETUP PFH
	IB.SAV==1B4			; DO A SAVE. UUO ON A STOPCODE
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

		.ORG
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)     !
;	!=======================================================!

	.ORG	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
	.ORG
SUBTTL	SAB - Send Argument Block passed to C%SEND

;This block describes the IPCF message being sent


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

	.ORG 0


SAB.PD:!	BLOCK	1		;PID TO SEND MESSAGE TO
					; OR ADDRS OF NAME STRING
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.NAM==1B1			;SET IF SAB.PD CONTAINS THE ADRS OF
					;A STRING (NAME OF PROCESS TO SEND TO)
	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.MZ:!				;MIMIUM LENGTH OF SAB
SAB.FL:!	BLOCK	1		;FLAG WORD
	SF.PRV==1B29			;SENDER WISHES TO INVOKE PRIVILEGES
	SF.ECD==77B35			;ERROR CODE TO SET ON SENDS
SAB.SZ:!				;LENGTH OF THE SAB

	.ORG
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                   !
;	!=======================================================!

	.ORG	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.PIP==1B3			;PROCESS HAS IPCF PRIV.
	MD.POK==1B4			;PROCESS HAS POKE PRIV.
	MD.PLG==1B5			;PROCESS IS LOGGED IN
	MD.PXO==1B6			;PROCESS IS EXECUTE-ONLY
	MD.PJB==777B35			;JOB NUMBER OF SENDER
	MD.PJH==0,,-1			;JCH 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

.ORG
SUBTTL	CJB - Create Job Block used in call to I%CJOB

;This block describes the format of the block pass to I%CJOB for
;starting up a (usually) Galactic component.
;
;	!=======================================================!
;	!                 SIXBIT PROGRAM NAME                   !
;	!-------------------------------------------------------!
;	!  TIME TO WAIT (SECONDS)   !    SPECIAL PID INDEX      !
;	!-------------------------------------------------------!
;	!           FLAGS           !               ! QSR ! STC !
;	!-------------------------------------------------------!
;	!		UP TO %CJSTC WORDS OF TEXT		!
;				    .	    
;				    .	    
;	!                     STRING POINTERS                   !
;	!=======================================================!

	%CJSTC==4			;MAX NUMBER OF TEXT STRINGS

	.ORG	0
CJB.NM:!	BLOCK	1		;PROGRAM NAME IN SIXBIT
CJB.TP:!	BLOCK	1		;CONTAINS WAIT TIME AND PID INDEX
	CJ.TIM==-1,,0			;SECONDS TO WAIT (0 TO +262143)
	CJ.SPI==0,,-1			;SPECIAL PID INDEX
CJB.FL:!	BLOCK	1		;FLAGS AND OTHER ERRATA
	CJ.DEP==7B2			;CURRENT DEPENDENCY FIELD WIDTH
	  CJ.ANF==1B0			;ANF NETWORK REQUIRED
	  CJ.DCN==1B1			;DECNET REQUIRED
	  CJ.D60==1B2			;DN60 CODE REQUIRED
	CJ.STC==17B35			;COUNT OF TEXT STRING POINTERS
	CJ.QSR==7B31			;RESERVED FOR QUASAR USE
CJB.ST:!	BLOCK	%CJSTC		;POINTERS TO ASCIZ TEXT STRINGS
CJB.SZ:!				;SIZE OF CJB
	.ORG
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,OPERATOR)
.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,,ACCOUNTING DAEMON)
.SPID	(SP.TLP,.IPCPT,,TAPE LABELLER)
.SPID	(SP.TOL,.IPCPC,,TAPE AVR)	;;Tape Auto-Vol-Recognizer
.SPID	(SP.DOL,.IPCPD,,DISK AVR)	;;Disk Auto-Vol-Recognizer
.SPID	(SP.FIL,.IPCPF,,FILE DAEMON)
.SPID	(SP.CAT,.IPCPV,,CATALOG DAEMON)
.SPID	(SP.ERL,.IPCPL,,ERROR LOGGER)
.SPID	(SP.TGH,.IPCPE,,TGHA)
.SPID	(SP.NCP,.IPCNM,,DECNET CONTROLLER)
.SPID	(SP.MAI,.IPCPX,,MAILER)
.SPID	(SP.GFR,.IPCPG,,GOPHER)
>;;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	;;DEFINE INDEX
	IFG	CANNAM-MX.PID,<MX.PID==CANNAM>	;;KEEP TRACK OF MAXIMUM
>;END DEFINE .SPID
	MX.PID==0			;Start with 0 as the max
	SPIDS				;Generate the special PIDS
	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,^D52,^D30	;NUMBER OF FILES OPEN SIMULTANEOUSLY
	SYSPRM	SZ.BUF,200,1000		;SIZE OF BUFFER AREA
	SYSPRM	SZ.OBF,200,1000		;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,PAGSIZ-1		;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.ADR==1B34		;PAGE IS ADDRESSABLE (I.E. EXISTS)
	  PT.INI==1B33		;PART OF INITIAL IMAGE (I.E. CODE, ETC.)
; PARAMETERS USED BY:	GLXOTS & GLXINI

	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,^D50	;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 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==777777B17		   ;OFFSET FOR PDB LENGTH
   PB.FDB==777777B35		   ;OFFSET FOR FDB LENGTH

	.ORG	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%PMT:! BLOCK	1			;SUB-COMMAND PROMPT STRING ADDR
PB%SIZ:! 				;SIZE OF MAXIMUM PDB DATA


	.ORG
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),<.XCREF	.%TYPE,	.$TYP
			DEFINE .$TYP <ARG>
			.%TYPE==1>

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

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

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

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

DEFINE	$SBCM	(ARG),<.XCREF	.%SBCM,	.$SBCM
	IFDIF	<ARG><>,<DEFINE	.$SBCM	<EXP	<ARG>>>
	.%SBCM==1
> ;;END $SBCM

DEFINE $DEFAULT (ARG),<
	IFDIF <ARG> <>,<.XCREF	.%DEFM,	.$DEFM
DEFINE .$DEFM <POINT 7,[ASCIZ\ARG\]>
			.%DEFM==1>
	IFIDN <ARG> <>,<
IF1 <
PRINTX %Null argument in $DEFAULT macro>>>

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

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

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

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

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

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

DEFINE $ERRTXT (ARG),<.XCREF	.%ERTN,	.$ERTN
			DEFINE .$ERTN <[MOVEI S2,[ASCIZ\ARG\]
				      $RETF]>
			.%ERTN==1>


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

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

;INITIALIZE ALL THE INNER MACROS
;

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

DEFINE .$RESET <
	.XCREF
	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
	DEFINE	.$SBCM	<0>
	.%SBCM==0
	.CREF
>;END OF .$RESET


	SUBTTL	.$BUILD MACRO

;REDEFINE PDB.XX

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

	.XCREF	%FDBL,	%PDBL,	%PDB,	%FLAG

	.XCREF	.%TYPE,	.%FLGS,	.%DATA,	.%HLPM,	.%DEFM,	.%LST
	.XCREF	.$TYP,	.$FLGS,	.$DATA,	.$HLPM,	.$DEFM,	.$LST

	.XCREF	.%BREA,	.%NXT,	.%ERTN,	.%RTN,	.%DEFR,	.%SBCM
	.XCREF	.$BREA,	.$NXT,	.$ERTN,	.$RTN,	.$DEFR,	.$SBCM

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

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

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

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

%PDB:!	<INSVL.(%PDBL,PB.PDB)>!<INSVL.(%FDBL,PB.FDB)> ;PDB, FDB
	EXP	%FLAG			;;WORD .CMFNP OF THE FDB
	EXP	.$DATA			;;WORD .CMDAT OF THE FDB
IFN <.%HLPM!.%DEFM!.%BREA>,<
	EXP	.$HLPM>			;;WORD .CMHLP OF THE FDB
IFN <.%DEFM!.%BREA>,<
	EXP	.$DEFM>			;;WORD .CMDEF OF THE FDB
IFN <.%BREA>,<
	EXP	.$BREA>			;;WORD .CMBRK OF THE FDB

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

IFN <.%NXT!.%DEFR!.%RTN!.%ERTN!.%SBCM>,<
	EXP	.$NXT >			;;WORD PDB.NX OF THE PDB
IFN <.%DEFR!.%RTN!.%ERTN!.%SBCM>,<
	EXP	.$RTN >			;;GENERATE ACTION ROUTINE
IFN <.%DEFR!.%ERTN!.%SBCM>,<
	EXP	.$ERTN>			;;GENERATE THE ERROR ROUTINE
IFN <.%DEFR!.%SBCM>,<
	EXP	.$DEFR>			;;GENERATE DEFAULT FILLING ROUTINE
IFN <.%SBCM>,<
	EXP	.$SBCM>			;;GENERATE SUB-COMMAND PROMPT

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

IF2,<
	PURGE	.%TYPE,	.%FLGS,	.%DATA,	.%HLPM,	.%DEFM,	.%LST
	PURGE	.$TYP,	.$FLGS,	.$DATA,	.$HLPM,	.$DEFM,	.$LST

	PURGE	.%BREA,	.%NXT,	.%ERTN,	.%RTN,	.%DEFR,	.%SBCM
	PURGE	.$BREA,	.$NXT,	.$ERTN,	.$RTN,	.$DEFR,	.$SBCM

	PURGE	%FDBL,	%PDBL,	%PDB,	%FLAG
> ;;END IF2
	LIST>;END .$BUILD

	SUBTTL	PARSER MACROS FOR EACH FUNCTION

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


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



DEFINE $NUMBER (NXT,RADIX,HELP,ARGLST) <
	.XCREF	.$RESET, .$BUILD
	.$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) <
	.XCREF	.$RESET, .$BUILD
	.$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) <
	.XCREF	.$RESET, .$BUILD
	.$RESET
	$TYPE (.CMNOI)
	$PDATA (<POINT 7,[ASCIZ\TEXT\]>)
	$NEXT (NXT)
	IRP ARGLST,<ARGLST>
	.$BUILD>


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

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


DEFINE $IFILE (NXT,HELP,ARGLST) <
	.XCREF	.$RESET, .$BUILD
	.$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) <
	.XCREF	.$RESET, .$BUILD
	.$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) <
	.XCREF	.$RESET, .$BUILD
	.$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) <
	.XCREF	.$RESET, .$BUILD
	.$RESET
	$TYPE (.CMFLD)
	$NEXT (NXT)
	$HELP (<>)
IFIDN <HELP> <>,< IRP ARGLST,<ARGLST>
			.$BUILD>
IFDIF <HELP> <>,<
	$HELP (HELP)
	IRP ARGLST,<ARGLST>
	.$BUILD>>

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


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


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


DEFINE $COMMA (NXT,ARGLST) <
	.XCREF	.$RESET, .$BUILD
	.$RESET
	$TYPE (.CMCMA)
	$NEXT (NXT)
	IRP ARGLST,<ARGLST>
	.$BUILD>
DEFINE	$SUBCM	(NXT,PROMPT,ARGLST) <
	.XCREF	.$RESET, .$BUILD
	.$RESET
	$NEXT	(NXT)
	$TYPE	(.CMINI)
	$SBCM	(PROMPT)
	IRP ARGLST,<ARGLST>
	.$BUILD>

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

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


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


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

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


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

TOPS10<
DEFINE $FTAD (NXT,ARGLST) <
	.XCREF	.$RESET, .$BUILD
	.$RESET
	$TYPE (.CMTAD)
	$PDATA (<CM%IDA!CM%ITM!CM%FUT>)
	$NEXT (NXT)
	IRP ARGLST,<ARGLST>
	.$BUILD>
> ; End of TOPS10


DEFINE $QUOTE (NXT,HELP,ARGLST) <
	.XCREF	.$RESET, .$BUILD
	.$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) <
	.XCREF	.$RESET, .$BUILD
	.$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) <
	.XCREF	.$RESET, .$BUILD
	.$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) <
	.XCREF	.$RESET, .$BUILD
	.$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) <
	.XCREF	.$RESET, .$BUILD
	.$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) <
	.XCREF	%X,	%Y
	%X==.
	XWD %Y-1,%Y-1
	DEFINE $ETAB <.XCREF	%X,	%Y
		%Y==.-%X>>
	END