	.TITLE	Error Analyzer.
;	Author:	T. R. Wyant
;	Date:	Unknown (1984 sometime)
;	Modified:
;	Remarks:
;		This module contains two error message analyzers
;		and formatters, invoked as follows:
;
;		INTEGER*2 ERRORF	! Size of error message.
;
;		CALL ERRORS(LUN,USRTXT,USRPRM,ERS,...)
;		ISIZ = ERRORF(IBUF,USRTXT,USRPRM,ERS,...)
;
;		ERRORS actually formats and writes an error message
;		on the LUN specified. ERRORF formats the error
;		message in buffer IBUF, and returns the size as
;		the value of the function.
;
;		The arguments are:
;
;		LUN	- The LUN to write the error message on.
;		IBUF	- The buffer to build the error message in.
;		USRTXT	- Optional user text. It consists of optional
;				control text, a carriage control byte,
;				and a control string suitable for
;				$EDMSG. The following characters will
;				perform control functions if they appear
;				at the start of the text string:
;				% - Omit task name and time stamp;
;				. - Omit period at end of message;
;				P - Use next character for end-of-mes-
;					sage punctuation;
;				The first character not in the above set
;				is taken as carriage control. In ad-
;				dition to the usual "+", " ", "0", "1",
;				and "$", you can use "@" to specify no
;				carriage control whatsoever.
;		USRPRM	- Optional data to go woth USRTXT. See the
;				SYSLIB subroutines manual for what goes
;				here.
;		ERS	- One or more parameters describing the error.
;				The first parameter is a RAD-50 string
;				describing the type of error. The rest
;				depend on the first as follows:
;
;				First	Next
;				-----	--------------------------------
;				DSW	Directive status word.
;				FCS	Synonym for IO.
;				FIL	Synonym for RMS if RMS support
;					    was selected - else synonym
;					    for IO.
;				IO	I/O status block (2 word array).
;				NET	Status block from high-level
;					    language DECnet call.
;				NFA	Status block from high-level
;					    language remote file access.
;				RMS	STS code from RMS. STV (if any)
;					    is passed in next argument.
;
;		The output message looks like:
;
;		Taskname - Date - User Message
;			Error Type
;			Error Detail
;			More detail (if appropriate).



	.ENABL	LC
	.MCALL	GTIM$S,GTSK$S,QIOW$S

NETWRK	= 0	; Define to get network messages.
;;; NFAMSG	= 0	; Define to get Network File Access errors.
NETMSG	= 0	; Define to get high-level DECnet errors.
;;; RMSMSG	= 0	; Define to get RMS errors.

	.IIF DF NFAMSG,	NETWRK = 0
	.IIF DF NETMSG, NETWRK = 0

	.IF DF NETWRK
	.LIBRARY /LB:[1,1]NETLIB/
	.MCALL	NSSYM$
	NSSYM$
	.ENDC	; DF NETWRK

	.IF DF RMSMSG
	.LIBRARY /LB:[1,1]RMSMAC/
	.MCALL	$RMSTAT
	$RMSTAT	DFIN$L
	.ENDC	; DF RMSMSG

	.MACRO	ERRLST	NAME,OPT,TEXT,FMT=D,SYN
ERRFLG	= 0
ERRSYM	=:  1	; Include symbolic with error message (1=yes).
ERRCUR	=:  2	; Continue analyzing current error (1=yes).
ERRBYT	=:  4	; Byte argument (1=yes).
ERRALN	=: 10	; Perform alignment (1=yes).
ERRODD	=: 20	; Align on odd boundary (1=yes).
ERRSYN	=: 40	; Synonym entry (1=yes).
ERRMAC	=: 100	; Data Access Protocol macrocode error
ERRMIC	=: 200	; Data Access Protocol microcode error
ERROPT	=: 400	; This field is optional (ie- error analysis terminates
		;     without issuing "xxx not passed" if missing).

	.IRP	O,<OPT>
	.IIF IDN <O>,<SYMB>,	ERRFLG = ERRFLG!ERRSYM
	.IIF IDN <O>,<CURR>,	ERRFLG = ERRFLG!ERRCUR
	.IIF IDN <O>,<BYTE>,	ERRFLG = ERRFLG!ERRBYT
	.IIF IDN <O>,<EVEN>,	ERRFLG = ERRFLG!ERRALN
	.IIF IDN <O>,<ODD>,	ERRFLG = ERRFLG!ERRALN!ERRODD
	.IIF IDN <O>,<MACCOD>,	ERRFLG = ERRFLG!ERRMAC
	.IIF IDN <O>,<MICCOD>,	ERRFLG = ERRFLG!ERRMIC
	.IIF IDN <O>,<OPTIONAL>, ERRFLG = ERRFLG!ERROPT
	.ENDM
	.IIF NE ERRFLG&ERRMAC	ERRFLG = <ERRFLG!ERRALN>&^C<ERRBYT>
	.IIF NE ERRFLG&ERRMIC	ERRFLG = <ERRFLG!ERRALN!ERRCUR>&^C<ERRBYT>
	.IIF EQ ERRFLG&ERRBYT	ERRFLG = <ERRFLG!ERRALN>&^C<ERRODD>
	.IIF NB <SYN>,		ERRFLG = ERRFLG!ERRSYN
	.SAVE


	.IF B <SYN>

	.PSECT	ERRTXT	RO,D,LCL,REL,CON
ERRDOT	= .
	.ASCIZ	\,%N%9S'TEXT code not available.\
	.MACRO	ERREXX
	.SAVE
	.PSECT	ERRTXT	RO,D,LCL,REL,CON
ERRDOT	= .
	.ASCIZ	\,%N%9SUnrecognized TEXT code %FMT'.\
	.RESTORE
	.ENDM	ERREXX

	.IFTF	; B <SYN>

	.PSECT	ERRTBL	RO,D,LCL,REL,CON
	.IRP	N,<NAME>
N:
	.ENDR

	.IFT	; B <SYN>

	.WORD	ERRFLG,ERRDOT

	.IFF	; B <SYN>

	.WORD	ERRFLG,SYN

	.ENDC	; B <SYN>


	.RESTORE
	.ENDM





	.MACRO	ERROR	ADDR,CODE,TEXT,NEXT=0
	.SAVE

	.IF NB <TEXT>
	.PSECT	ERRTXT	RO,D,LCL,REL,CON
	.IIF NB <ADDR>	ADDR:
ERRDOT	= .
	.ASCII	\,%N%9S\
	.IIF NE ERRFLG&1,	.ASCII	\CODE - \

	.ASCIZ	\TEXT%I\

	.IFTF	; NB <TEXT>
	.PSECT	ERRTBL	RO,D,LCL,REL,CON
	.IFT	; NB <TEXT>
	.WORD	ERRDOT,CODE
	.IFF	; NB <TEXT>
	.WORD	ADDR,CODE
	.ENDC	; NB <TEXT>

	.WORD	NEXT

	.RESTORE
	.ENDM

	.MACRO	ERREND	CHAIN
	.SAVE
	.PSECT	ERRTBL	RO,D,LCL,REL,CON
	.IF B <CHAIN>
	ERREXX
	.WORD	0,MESSAG,ERRDOT
	.IFF	; B <CHAIN>
	.WORD	0,CHAINR,CHAIN
	.ENDC	; B <CHAIN>
	.RESTORE
	.ENDM	ERREND



	ERRLST	ERRTBL,,<error type>,R

	ERROR	DSWMSG,<^RDSW>,<Directive error>,DSW
	ERROR	IOMSG,<^RIO>,<I/O error>,IO
	ERROR	FCSMSG,<^RFCS>,<FCS error>,IO
	ERROR	FORMSG,<^RFOR>,<FORTRAN OTS error>,FORT
	ERROR	DSWMSG,-1,,DSW
	ERROR	FCSMSG,0,,IO

	.IF DF NETMSG
	ERROR	,<^RNET>,<DECnet error>,NETERR
	.ENDC	; DF NETMSG

	.IF DF NFAMSG
	ERROR	,<^RNFA>,<DECnet remote file access error>,NFAERR
	.ENDC	; DF NFAMSG

	.IF DF RMSMSG
	ERROR	,<^RFIL>,<File access error>,RMSERR
	ERROR	,<^RRMS>,<RMS file access error>,RMSERR
	.IFF	; DF RMSMSG
	ERROR	,<^RFIL>,<File access error>,IO
	.ENDC	; DF RMSMSG

	ERREND


	ERRLST	FORT,<SYMB,EVEN>,<FORTRAN OTS error>

	ERROR	,1.,<Invalid error call>
	ERROR	,2.,<Task initialization failure>
	ERROR	,3.,<Odd address trap (SST0)>
	ERROR	,4.,<Segment fault (SST1)>
	ERROR	,5.,<T-bit or BPT trap (SST2)>
	ERROR	,6.,<IOT trap (SST3)>
	ERROR	,7.,<Reserved instruction trap (SST4)>
	ERROR	,8.,<Non-RSX EMT trap (SST5)>
	ERROR	,9.,<TRAP instruction trap (SST6)>
	ERROR	,10.,<PDP-11/40 FIS trap (SST7)>
	ERROR	,11.,<FPP hardware fault>
	ERROR	,12.,<FPP illegal opcode trap>
	ERROR	,13.,<FPP illegal variable trap>
	ERROR	,14.,<FPP maintenance trap>
	ERROR	,20.,<REWIND error>
	ERROR	,21.,<Duplicate file specifications>
	ERROR	,22.,<Input record too long>
	ERROR	,23.,<Backspace error>
	ERROR	,24.,<End-of-file during read>,FILOPT
	ERROR	,25.,<Record number outside range>
	ERROR	,26.,<Access mode not specified>
	ERROR	,27.,<More than one record in I/O statement>
	ERROR	,28.,<Close error>
	ERROR	,29.,<No such file>
	ERROR	,30.,<Open failure>,FILOPT
	ERROR	,31.,<Mixed file access modes>
	ERROR	,32.,<Invalid logical unit number>
	ERROR	,33.,<ENDFILE error>
	ERROR	,34.,<Unit already open>
	ERROR	,35.,<Segmented record format error>
	ERROR	,36.,<Attempt to access non-existent record>
	ERROR	,37.,<Inconsistent record length>
	ERROR	,38.,<Error during write>,FILOPT
	ERROR	,39.,<Error during read>,FILOPT
	ERROR	,40.,<Recursive I/O operation>
	ERROR	,41.,<No buffer room>
	ERROR	,42.,<No such device>
	ERROR	,43.,<File name specification error>
	ERROR	,44.,<Inconsistent record type>
	ERROR	,45.,<Keyword value error in OPEN statement>
	ERROR	,46.,<Inconsistent OPEN/CLOSE parameters>
	ERROR	,47.,<Write to read-only file>
	ERROR	,48.,<Unsupported I/O operation>
	ERROR	,49.,<Invalid key specification>
	ERROR	,50.,<Inconsistent key change or duplicate key value>
	ERROR	,51.,<Inconsistent file organization>
	ERROR	,52.,<Specified record locked>
	ERROR	,53.,<No current record>
	ERROR	,54.,<REWRITE error>
	ERROR	,55.,<DELETE error>
	ERROR	,56.,<UNLOCK error>
	ERROR	,57.,<FIND error>
	ERROR	,59.,<List-directed I/O syntax error>
	ERROR	,60.,<Infinite format loop>
	ERROR	,61.,<Format/variable-type mismatch>
	ERROR	,62.,<Syntax error in format>
	ERROR	,63.,<Output conversion error>
	ERROR	,64.,<Input conversion error>
	ERROR	,65.,<Format too big for 'FMTBUF'>
	ERROR	,66.,<Output statement overflows record>
	ERROR	,67.,<Record too small for I/O list>
	ERROR	,68.,<Variable format expression value error>

	ERREND

	ERRLST	DSWOPT,<SYMB,BYTE,EVEN,OPTIONAL>,SYN=DSW
	ERRLST	DSWSYN,<SYMB,BYTE,EVEN,CURR>,SYN=DSW
	ERRLST	DSW,<SYMB,BYTE,EVEN>,<directive error>

	ERROR	ISCLR,IS.CLR,<Event flag was clear>
	ERROR	ISSUC,IS.SUC,<Operation complete, Success>
	ERROR	ISSET,IS.SET,<Event flag was set>
	ERROR	IEUPN,IE.UPN,<Insufficient dynamic storage>
	ERROR	IEINS,IE.INS,<Specified task not installed>
	ERROR	IEPTS,IE.PTS,<Partition too small for task>
	ERROR	IEUNS,IE.UNS,<Insufficient dynamic storage for send>
	ERROR	IEULN,IE.ULN,<Unassigned LUN>
	ERROR	IEHWR,IE.HWR,<Device driver not resident>
	ERROR	IEACT,IE.ACT,<Task not active>
	ERROR	IEITS,IE.ITS,<Directive inconsistent with task state>
	ERROR	IEFIX,IE.FIX,<Task already fixed/unfixed>
	ERROR	IECKP,IE.CKP,<Issuing task not checkpointable>
	ERROR	IETCH,IE.TCH,<Task is checkpointable>
	ERROR	IERBS,IE.RBS,<Receive buffer is too small>
	ERROR	IEPRI,IE.PRI,<Privilege violation>
	ERROR	IERSU,IE.RSU,<Resource in use>
	ERROR	IENSW,IE.NSW,<No swap space available>
	ERROR	IEILV,IE.ILV,<Illegal vector specified>
	ERROR	IEITN,IE.ITN,<Invalid table number>
	ERROR	IELNF,IE.LNF,<Logical name not found>
	ERROR	IEAST,IE.AST,<Directive issued/not issued from AST>
	ERROR	IEMAP,IE.MAP,<Illegal mapping specified>
	ERROR	IEIOP,IE.IOP,<Window has I/O in progress>
	ERROR	IEALG,IE.ALG,<Alignment error>
	ERROR	IEWOV,IE.WOV,<Address window allocation overflow>
	ERROR	IENVR,IE.NVR,<Invalid region ID>
	ERROR	IENVW,IE.NVW,<Invalid address window ID>
	ERROR	IEITP,IE.ITP,<Invalid TI parameter>
	ERROR	IEIBS,IE.IBS,<Invalid SEND buffer size (greater than 255.)>
	ERROR	IELNL,IE.LNL,<LUN locked in use>
	ERROR	IEIUI,IE.IUI,<Invalid UIC>
	ERROR	IEIDU,IE.IDU,<Invalid device or unit>
	ERROR	IEITI,IE.ITI,<Invalid time parameters>
	ERROR	IEPNS,IE.PNS,<Partition/region not in system>
	ERROR	IEIPR,IE.IPR,<Invalid priority (greater than 250.)>
	ERROR	IEILU,IE.ILU,<Invalid LUN>
	ERROR	IEIEF,IE.IEF,<Invalid event flag number (greater than 64.)>
	ERROR	IEADP,IE.ADP,<Part of DPB out of user's space>
	ERROR	IESDP,IE.SDP,<DIC or DPB size invalid>

	ERREND

	.IIF NDF RMSMSG, ERRLST	FILOPT,<SYMB,BYTE,EVEN,OPTIONAL>,SYN=IO
	ERRLST	IOOPT,<SYMB,BYTE,EVEN,OPTIONAL>,SYN=IO
	ERRLST	IO,<SYMB,BYTE,EVEN>,<I/O error>

	ERROR	IEBAD,IE.BAD,<Bad parameters>
	ERROR	IEIFC,IE.IFC,<Illegal function code>
	ERROR	IEDNR,IE.DNR,<Device not ready>
	ERROR	IEVER,IE.VER,<Parity error on device>
	ERROR	IEONP,IE.ONP,<Hardware option not present>
	ERROR	IESPC,IE.SPC,<Illegal user buffer>
	ERROR	IEDNA,IE.DNA,<Device not attached>
	ERROR	IEDAA,IE.DAA,<Device already attached>
	ERROR	IEDUN,IE.DUN,<Device not attachable>
	ERROR	IEEOF,IE.EOF,<End-of-file detected>
	ERROR	IEEOV,IE.EOV,<End-of-volume detected>
	ERROR	IEWLK,IE.WLK,<Write attempted to locked unit>
	ERROR	IEDAO,IE.DAO,<Data overrun>
	ERROR	IESRE,IE.SRE,<Send/receive failure>
	ERROR	IEABO,IE.ABO,<Request terminated>
	ERROR	IEPRI,IE.PRI	; <Privilege violation>
	ERROR	IERSU,IE.RSU	; <Sharable resource in use>
	ERROR	IEOVR,IE.OVR,<Illegal overlay request>
	ERROR	IEBYT,IE.BYT,<Odd byte count (or virtual address)>
	ERROR	IEBLK,IE.BLK,<Logical Block Number too large>
	ERROR	IEMOD,IE.MOD,<Invalid UDC module number>
	ERROR	IECON,IE.CON,<UDC connect error>
	ERROR	IENOD,IE.NOD,<System dynamic memory>
	ERROR	IEDFU,IE.DFU,<Device full>
	ERROR	IEIFU,IE.IFU,<Index file full>
	ERROR	IENSF,IE.NSF,<No such file>
	ERROR	IELCK,IE.LCK,<Locked from read/write access>
	ERROR	IEHFU,IE.HFU,<File header full>
	ERROR	IEWAC,IE.WAC,<Accessed for write>
	ERROR	IECKS,IE.CKS,<File header checksum error>
	ERROR	IEWAT,IE.WAT,<Attribute control list format error>
	ERROR	IERER,IE.RER,<File processor device read error>
	ERROR	IEWER,IE.WER,<File processor device write error>
	ERROR	IEALN,IE.ALN,<File already accessed on LUN>
	ERROR	IESNC,IE.SNC,<File ID, file number check>
	ERROR	IESQC,IE.SQC,<File ID, sequence number check>
	ERROR	IENLN,IE.NLN,<No file accessed on LUN>
	ERROR	IECLO,IE.CLO,<File was not properly closed>
	ERROR	IENBF,IE.NBF,<No buffer space available for file>
	ERROR	IERBG,IE.RBG,<Illegal record size>
	ERROR	IENBK,IE.NBK,<File exceeds space allocated, no blocks>
	ERROR	IEILL,IE.ILL,<Illegal operation on file descriptor block>
	ERROR	IEBTP,IE.BTP,<Bad record type>
	ERROR	IERAC,IE.RAC,<Illegal record access bits set>
	ERROR	IERAT,IE.RAT,<Illegal record attribute bits set>
	ERROR	IERCN,IE.RCN,<Illegal record number - too large>
	ERROR	IEICE,IE.ICE,<Internal consistency error>
	ERROR	IE2DV,IE.2DV,<Rename - two different devices>
	ERROR	IEFEX,IE.FEX,<Rename - new file name already in use>
	ERROR	IEBDR,IE.BDR,<Bad directory file>
	ERROR	IERNM,IE.RNM,<Cannot rename old file system>
	ERROR	IEBDI,IE.BDI,<Bad directory syntax>
	ERROR	IEFOP,IE.FOP,<File already open>
	ERROR	IEBNM,IE.BNM,<Bad file name>
	ERROR	IEBDV,IE.BDV,<Bad device name>
	ERROR	IEBBE,IE.BBE,<Bad block on device>
	ERROR	IEDUP,IE.DUP,<Enter - duplicate entry in directory>
	ERROR	IESTK,IE.STK,<Not enough stack space (FCS or FCP)>
	ERROR	IEFHE,IE.FHE,<Fatal hardware error on device>
	ERROR	IENFI,IE.NFI,<File ID was not specified>
	ERROR	IEISQ,IE.ISQ,<Illegal sequential operation>
	ERROR	IEEOT,IE.EOT,<End-of-tape detected>
	ERROR	IEBVR,IE.BVR,<Bad version number>
	ERROR	IEBHD,IE.BHD,<Bad file header>
	ERROR	IEOFL,IE.OFL,<Device off line>
	ERROR	IEBCC,IE.BCC,<Block check, CRC, or framing error>
	ERROR	IEONL,IE.ONL,<Device on line>
	ERROR	IENNN,IE.NNN,<No such node>
	ERROR	IENFW,IE.NFW,<Path lost to partner>
	ERROR	IEBLB,IE.BLB,<Bad logical buffer>
	ERROR	IENDR,IE.NDR,<No dynamic space available>
	ERROR	IEURJ,IE.URJ,<Connection rejected by user>
	ERROR	IENRJ,IE.NRJ,<Connection rejected by DECnet>,NETREJ
	ERROR	IEEXP,IE.EXP,<File expiration date not reached>
	ERROR	IEBTF,IE.BTF,<Bad tape format>
	ERROR	IENNC,IE.NNC,<Not ANSI "D" format byte count>
	ERROR	IENDA,IE.NDA,<No data available>
	ERROR	IENLK,IE.NLK,<Task not linked to specified ICS/ICR interrupts>
	ERROR	IENST,IE.NST,<Specified task not installed for ICS/ICR>
	ERROR	IEFLN,IE.FLN,<ICS/ICR off-line when off-line request issued>
	ERROR	IEIES,IE.IES,<Invalid escape sequence>
	ERROR	IEPES,IE.PES,<Partial escape sequence>
	ERROR	IEALC,IE.ALC,<Allocation failure>
	ERROR	IEULK,IE.ULK,<Unlock error>
	ERROR	IEWCK,IE.WCK,<Write check failure>
	ERROR	IENTR,IE.NTR,<Task not triggered>
	ERROR	IEREJ,IE.REJ,<Transfer rejected by receiving CPU>
	ERROR	IEFLG,IE.FLG,<Event flag already specified>
	ERROR	IEDSQ,IE.DSQ,<Disk quota exceeded>
	ERROR	IEIQU,IE.IQU,<Inconsistent qualifier usage>
	ERROR	IERES,IE.RES,<Circuit reset during operation>
	ERROR	IETML,IE.TML,<Too many links to task>
	ERROR	IENNT,IE.NNT,<Not a network task>
	ERROR	IETMO,IE.TMO,<Time-out on request>
	ERROR	IECNR,IE.CNR,<Connection rejected>
	ERROR	IEUKN,IE.UKN,<Unknown name>
	ERROR	IESZE,IE.SZE,<Unable to size device>
	ERROR	IEMII,IE.MII,<Media inserted incorrectly>
	ERROR	IESPI,IE.SPI,<Spindown ignored>

	ERREND



	.IF DF NETMSG

	ERRLST	NETERR,<BYTE,EVEN>,<DECnet error>

	ERROR	,-1,<Required system resources not available>
	ERROR	,-2,<No logical link established on LUN>
	ERROR	,-3,<Link disconnected with request outstanding>
	ERROR	,-4,<Receive buffer too small - data truncated>
	ERROR	,-5,<Incorrect argument>
	ERROR	,-6,<No data in user's network data queue>
	ERROR	,-7,<Connect rejected by network>,NETREJ
	ERROR	,-8.,<Logical link already established on LUN>
	ERROR	,-9.,<Issuing task not part of net (OPNNET not issued)>
	ERROR	,-10.,<User attempting to access network for second time>
	ERROR	,-11.,<Interrupt attempted before last one completed>
	ERROR	,-12.,<Connect rejected by user>
	ERROR	,-13.,<Buffer outside user's task, or not word aligned>
	ERROR	,-14.,<GNDNT[W] attempted before last one completed>
	ERROR	,-20.,<RUNNC[W] - Not enough dynamic memory on remote node>
	ERROR	,-21.,<RUNNC[W] or ABONC[W] - Task not installed on remote node>
	ERROR	,-22.,<RUNNC[W] with invalid time parameter>
	ERROR	,-23.,<RUNNC[W] or ABONC[W] - Task already active/not active>
	ERROR	,-24.,<RUNNC[W] or ABONC[W] - Privilege violation>
	ERROR	,-25.,<ABONC[W] - Task marked for abort>
	ERROR	,-26.,<RUNNC[W] - Invalid UIC>
	ERROR	,-40.,<Directive error>,DSWSYN

	ERREND	CHAIN=IO

	.ENDC	; DF NETMSG


	ERRLST	NETSYM,<SYMB,CURR,BYTE,ODD>,SYN=NETREJ
	ERRLST	NETREJ,<SYMB,CURR,BYTE,EVEN>,<DECnet reject reason>

	.IF DF NETWRK

	ERROR	,NE$RES,<Insufficient DECnet resources>
	ERROR	,NE$NOD,<Unrecognized node name>
	ERROR	,NE$NSR,<Remote node shutting down>
	ERROR	,NE$UOB,<Object unknown at remote node>
	ERROR	,NE$FMT,<Invalid object name format>
	ERROR	,NE$MLB,<Object too busy>
	ERROR	,NE$ABM,<Aborted by network management>
	ERROR	,NE$NNF,<Invalid node name format>
	ERROR	,NE$NSL,<Local node shutting down>
	ERROR	,NE$ACC,<Access control rejected>
	ERROR	,NE$ABO,<No response from object>
	ERROR	,NE$COM,<Node unreachable>

	.ENDC	; DF NETWRK

	ERREND	; <DECnet reject reason>


	.IF DF NFAMSG

	ERRLST	NFAERR,<BYTE,EVEN>,<DECnet remote file access error>

	ERROR	,-1,<Channel already active>
	ERROR	,-2,<Channel not active>
	ERROR	,-3,<Data Access Protocol error>,DAPMAC
	ERROR	,-4,<Network Services Protocol error>,NSPERR
	ERROR	,-5,<Invalid attributes>
	ERROR	,-6,<Data overrun>
	ERROR	,-7,<Tasks out of sync>
	ERROR	,-8.,<Invalid LUN>
	ERROR	,-9.,<Buffer allocation error>
	ERROR	,-10.,<Directive error>,DSWSYN
	ERROR	,-11.,<Illegal request>

	ERREND



	ERRLST	NSPERR,<BYTE,EVEN>,<Network Services Protocol error>

	ERROR	,-1,<Required system resources not available>
	ERROR	,-2,<No logical link established on LUN>
	ERROR	,-3,<Link disconnected with request outstanding>
	ERROR	,-4,<Receive buffer too small - data truncated>
	ERROR	,-5,<Incorrect argument>
	ERROR	,-6,<No data in user's network data queue>
	ERROR	,-7,<Connect rejected by network>,NETSYM
	ERROR	,-8.,<Logical link already established on LUN>
	ERROR	,-9.,<Issuing task not part of net (OPNNET not issued)>
	ERROR	,-10.,<User attempting to access network for second time>
	ERROR	,-11.,<Interrupt attempted before last one completed>
	ERROR	,-12.,<Connect rejected by user>
	ERROR	,-13.,<Buffer outside user's task, or not word aligned>
	ERROR	,-14.,<GNDNT[W] attempted before last one completed>

	ERREND



	ERRLST	DAPMAC,<CURR,MACCOD>,<DAP macrocode>

	ERROR	,2,<Unsupported DAP request>
	ERROR	,4,<File open error>,FILMIC
	ERROR	,5,<Data transfer error>,FILMIC
	ERROR	,6,<Data transfer warning>,FILMIC
	ERROR	,7,<File close error>,FILMIC
	ERROR	,10,<Message format error>
	ERROR	,11,<Invalid message>
	ERROR	,12,<DAP message out of sync>

	ERREND


	ERRLST	FILMIC,<MICCOD>,<File access microcode>

	ERROR	,1,<ER$ABO - Operation aborted>
	ERROR	,2,<ER$ACC - F11ACP could not access file>
	ERROR	,3,<ER$ACT - File activity precludes operation>
	ERROR	,4,<ER$AID - Bad area ID>
	ERROR	,5,<ER$ALN - Alignment options error>
	ERROR	,6,<ER$ALQ - Allocation quantity too large>
	ERROR	,7,<ER$ANI - Not ANSI D format>
	ERROR	,10,<ER$AOP - Allocation options error>
	ERROR	,11,<ER$AST - Invalid operation at AST level>
	ERROR	,12,<ER$ATR - Attribute read error>
	ERROR	,13,<ER$ATW - Attribute write error>

	ERROR	,132,<ER$RER - File read error>

	ERROR	IEHWR,244	; <IE.HWR - Handler not in system>
	ERROR	IEFHE,245	; <IE.FHE - Fatal hardware error on device>
	ERROR	IEEOF,246	; <IE.EOF - End-of-file detected>
	ERROR	IEONP,247	; <IE.ONP - Hardware option not present>
	ERROR	IEDNA,250	; <IE.DNA - Device not attached>
	ERROR	IEDAA,251	; <IE.DAA - Device already attached>
	ERROR	IEDUN,252	; <IE.DUN - Device not attachable>
	ERROR	IERSU,253	; <IE.RSU - Sharable resource in use>
	ERROR	IEOVR,254	; <IE.OVR - Illegal overlay request>
	ERROR	IEBCC,255	; <IE.BCC - Block check, CRC, or framing error>
	ERROR	IENOD,256	; <IE.NOD - System dynamic memory>
	ERROR	IEIFU,257	; <IE.IFU - Index file full>
	ERROR	IEHFU,260	; <IE.HFU - File header full>
	ERROR	IEWAC,261	; <IE.WAC - Accessed for write>
	ERROR	IECKS,262	; <IE.CKS - File header checksum error>
	ERROR	IEWAT,263	; <IE.WAT - Attribute control list format error>
	ERROR	IEALN,264	; <IE.ALN - File already accessed on LUN>
	ERROR	IEBTF,265	; <IE.BTF - Bad tape format>
	ERROR	IEILL,266	; <IE.ILL - Illegal operation on file descriptor block>
	ERROR	IE2DV,267	; <IE.2DV - Rename - two different devices>
	ERROR	IEFEX,270	; <IE.FEX - Rename - new file name already in use>
	ERROR	IERNM,271	; <IE.RNM - Cannot rename old file system>
	ERROR	IEFOP,272	; <IE.FOP - File already open>
	ERROR	IEVER,273	; <IE.VER - Parity error on device>
	ERROR	IEEOV,274	; <IE.EOV - End-of-volume detected>
	ERROR	IEDAO,275	; <IE.DAO - Data overrun>
	ERROR	IEBBE,276	; <IE.BBE - Bad block on device>
	ERROR	IEEOT,277	; <IE.EOT - End-of-tape detected>
	ERROR	IENBF,300	; <IE.NBF - No buffer space available for file>
	ERROR	IENBK,301	; <IE.NBK - File exceeds space allocated, no blocks>
	ERROR	IENST,302	; <IE.NST - Specified task not installed for ICS/ICR>
	ERROR	IEULK,303	; <IE.ULK - Unlock error>
	ERROR	IENLN,304	; <IE.NLN - No file accessed on LUN>
	ERROR	IESRE,305	; <IE.SRE - Send/receive failure>

;	ERROR	IEBAD,	; <IE.BAD - Bad parameters>
;	ERROR	IEIFC,	; <IE.IFC - Illegal function code>
;	ERROR	IEDNR,	; <IE.DNR - Device not ready>
;	ERROR	IESPC,	; <IE.SPC - Illegal user buffer>
;	ERROR	IEWLK,	; <IE.WLK - Write attempted to locked unit>
;	ERROR	IEABO,	; <IE.ABO - Request terminated>
;	ERROR	IEPRI,	; <IE.PRI - Privilege violation>
;	ERROR	IEBYT,	; <IE.BYT - Odd byte count (or virtual address)>
;	ERROR	IEBLK,	; <IE.BLK - Logical Block Number too large>
;	ERROR	IEMOD,	; <IE.MOD - Invalid UDC module number>
;	ERROR	IECON,	; <IE.CON - UDC connect error>
;	ERROR	IEDFU,	; <IE.DFU - Device full>
;	ERROR	IENSF,	; <IE.NSF - No such file>
;	ERROR	IELCK,	; <IE.LCK - Locked from read/write access>
;	ERROR	IERER,	; <IE.RER - File processor device read error>
;	ERROR	IEWER,	; <IE.WER - File processor device write error>
;	ERROR	IESNC,	; <IE.SNC - File ID, file number check>
;	ERROR	IESQC,	; <IE.SQC - File ID, sequence number check>
;	ERROR	IECLO,	; <IE.CLO - File was not properly closed>
;	ERROR	IERBG,	; <IE.RBG - Illegal record size>
;	ERROR	IEBTP,	; <IE.BTP - Bad record type>
;	ERROR	IERAC,	; <IE.RAC - Illegal record access bits set>
;	ERROR	IERAT,	; <IE.RAT - Illegal record attribute bits set>
;	ERROR	IERCN,	; <IE.RCN - Illegal record number - too large>
;	ERROR	IEICE,	; <IE.ICE - Internal consistency error>
;	ERROR	IEBDR,	; <IE.BDR - Bad directory file>
;	ERROR	IEBDI,	; <IE.BDI - Bad directory syntax>
;	ERROR	IEBNM,	; <IE.BNM - Bad file name>
;	ERROR	IEBDV,	; <IE.BDV - Bad device name>
;	ERROR	IEDUP,	; <IE.DUP - Enter - duplicate entry in directory>
;	ERROR	IESTK,	; <IE.STK - Not enough stack space (FCS or FCP)>
;	ERROR	IENFI,	; <IE.NFI - File ID was not specified>
;	ERROR	IEISQ,	; <IE.ISQ - Illegal sequential operation>
;	ERROR	IEBVR,	; <IE.BVR - Bad version number>
;	ERROR	IEBHD,	; <IE.BHD - Bad file header>
;	ERROR	IEOFL,	; <IE.OFL - Device off line>
;	ERROR	IEONL,	; <IE.ONL - Device on line>
;	ERROR	IENNN,	; <IE.NNN - No such node>
;	ERROR	IENFW,	; <IE.NFW - Path lost to partner>
;	ERROR	IEBLB,	; <IE.BLB - Bad logical buffer>
;	ERROR	IENDR,	; <IE.NDR - No dynamic space available>
;	ERROR	IEURJ,	; <IE.URJ - Connection rejected by user>
;	ERROR	IENRJ,	; <IE.NRJ - Connection rejected by DECnet>,NETREJ
;	ERROR	IENNC,	; <IE.NNC - Not ANSI "D" format byte count>
;	ERROR	IENDA,	; <IE.NDA - No data available>
;	ERROR	IENLK,	; <IE.NLK - Task not linked to specified ICS/ICR interrupts>
;	ERROR	IEAST,	; <IE.AST - No AST specified in connect> ; same as above
;	ERROR	IEFLN,	; <IE.FLN - ICS/ICR off-line when off-line request issued>
;	ERROR	IEIES,	; <IE.IES - Invalid escape sequence>
;	ERROR	IEPES,	; <IE.PES - Partial escape sequence>
;	ERROR	IEALC,	; <IE.ALC - Allocation failure>
;	ERROR	IEWCK,	; <IE.WCK - Write check failure>
;	ERROR	IEIQU,	; <IE.IQU - Inconsistent qualifier usage>
;	ERROR	IERES,	; <IE.RES - Circuit reset during operation>
;	ERROR	IETML,	; <IE.TML - Too many links to task>
;	ERROR	IENNT,	; <IE.NNT - Not a network task>
;	ERROR	IECNR,	; <IE.CNR - Connection rejected>
;	ERROR	IEUKN,	; <IE.UKN - Unknown name>

	ERREND

	.ENDC	; DF NFAMSG


	.IF DF RMSMSG

	ERRLST	FILOPT,<SYMB,BYTE,EVEN,OPTIONAL>,SYN=RMSERR
	ERRLST	RMSERR,<SYMB,EVEN>,<RMS error>

	ERROR	,SU$SUC,<Operation succeeded>
	ERROR	,SU$DUP,<Inserted record has duplicate key>
	ERROR	,SU$IDX,<Error updating index>
	ERROR	,ER$ACC,<File access error>,IOOPT
	ERROR	,ER$ACT,<Activity precludes operation>
	ERROR	,ER$AID,<Bad value in AID field>
	ERROR	,ER$ALN,<Bad mask in ALN field>
	ERROR	,ER$ALQ,<Bad value in ALQ field>
	ERROR	,ER$ANI,<Bad ANSI-format magtape file>
	ERROR	,ER$AOP,<Bad mask in AOP field>
	ERROR	,ER$ATR,<Error reading attributes>,IOOPT
	ERROR	,ER$ATW,<Error writing attributes>,IOOPT
	ERROR	,ER$BKS,<Bad value in BKS field>
	ERROR	,ER$BKZ,<Bad value in BKZ field>
	ERROR	,ER$BOF,<Beginning-of-file found>
	ERROR	,ER$BPA,<Bad address in BPA field>
	ERROR	,ER$BPS,<Bad address in BPS field>
	ERROR	,ER$CCR,<RAB already in use>
	ERROR	,ER$CHG,<Illegal record key change>
	ERROR	,ER$CHK,<Bad bucket header>
	ERROR	,ER$CLS,<File processor CLOSE error>,IOOPT
	ERROR	,ER$COD,<Bad value in COD field>
	ERROR	,ER$CRE,<File processor CREATE error>,IOOPT
	ERROR	,ER$CUR,<Undefined current-record context>
	ERROR	,ER$DAN,<Bad value in DAN field>
	ERROR	,ER$DEL,<Record with given RFA has been deleted>
	ERROR	,ER$DEV,<Bad device specification>
	ERROR	,ER$DFW,<File processor deferred WRITE error>,IOOPT
	ERROR	,ER$DIR,<Bad directory specification>
	ERROR	,ER$DME,<Pool exhausted>
	ERROR	,ER$DNA,<Bad address in DNA field>
	ERROR	,ER$DNF,<No such directory>
	ERROR	,ER$DNR,<Device not ready>
	ERROR	,ER$DPE,<Device positioning error>
	ERROR	,ER$DTP,<Bad code in DTP field>
	ERROR	,ER$DUP,<Duplicate key not allowed>
	ERROR	,ER$ENT,<File processor directory ENTER error>,IOOPT
	ERROR	,ER$ENV,<Feature not in selected RMS environment>
	ERROR	,ER$EOF,<End-of-file reached>
	ERROR	,ER$ESA,<Bad address in ESA field>
	ERROR	,ER$ESL,<Bad value in ESL field>
	ERROR	,ER$ESS,<ESS field value too small>
	ERROR	,ER$EXP,<File expiration date not yet reached>
	ERROR	,ER$EXT,<File processor EXTEND error>,IOOPT
	ERROR	,ER$FAC,<FAC field forbids operation>
	ERROR	,ER$FAL,<Operation not supported by remote node>
	ERROR	,ER$FEX,<File already exists>
	ERROR	,ER$FID,<Bad value in FID field>
	ERROR	,ER$FLG,<Bad mask in FLG field>
	ERROR	,ER$FLK,<File locked by another task>
	ERROR	,ER$FNA,<Bad address in FNA field>
	ERROR	,ER$FND,<File processor FIND error>,IOOPT
	ERROR	,ER$FNF,<File not found>
	ERROR	,ER$FNM,<Bad file name>
	ERROR	,ER$FOP,<Bad mask in FOP field>
	ERROR	,ER$FUL,<Device or file full>
	ERROR	,ER$IAN,<Bad value in IAN field>
	ERROR	,ER$IDX,<Index not initialized>
	ERROR	,ER$IFI,<Bad value in IFI field>
	ERROR	,ER$IMX,<Too many XABs of the same type>
	ERROR	,ER$IOP,<Illegal operation for file>
	ERROR	,ER$IRC,<Illegal record found in sequential file>
	ERROR	,ER$ISI,<Bad value in ISI field>
	ERROR	,ER$KBF,<Bad address in KBF field>
	ERROR	,ER$KEY,<Bad key>
	ERROR	,ER$KRF,<Bad value in KRF field>
	ERROR	,ER$KSZ,<Bad value in KSZ field>
	ERROR	,ER$LAN,<Bad value in LAN field>
	ERROR	,ER$LBL,<Bad magtape label>
	ERROR	,ER$LBY,<Logical channel busy>
	ERROR	,ER$LCH,<Bad value in LCH field>
	ERROR	,ER$LEX,<Extension not needed>
	ERROR	,ER$LOC,<Bad value in LOC field>
	ERROR	,ER$MEM,<Memory address rollover>
	ERROR	,ER$MKD,<File processor DELETE error>,IOOPT
	ERROR	,ER$MRN,<Bad value in MRN field, or bad record number>
	ERROR	,ER$MRS,<Bad value in MRS field>
	ERROR	,ER$NAE,<Unmappable network access error>
	ERROR	,ER$NAM,<Bad address in NAM field>
	ERROR	,ER$NEF,<Context not end-of-file>
	ERROR	,ER$NET,<Network link lost>
	ERROR	,ER$NMF,<No more matching files>
	ERROR	,ER$NOD,<Bad node name>
	ERROR	,ER$NPK,<No primary key for indexed file>
	ERROR	,ER$ORD,<Ordering of XABs illegal>
	ERROR	,ER$ORG,<Bad mask in ORG field>
	ERROR	,ER$PLG,<Error reading file prologue>
	ERROR	,ER$PLV,<File prolog version level unsupported>
	ERROR	,ER$POS,<Bad value in POS field>
	ERROR	,ER$PRM,<Bad file date read>
	ERROR	,ER$PRV,<Privilege violation>
	ERROR	,ER$RAC,<Bad mask in RAC field>
	ERROR	,ER$RAT,<Bad mask in RAT field>
	ERROR	,ER$RBF,<Bad address in RBF field>
	ERROR	,ER$RER,<File processor READ error>,IOOPT
	ERROR	,ER$REX,<Record already exists>
	ERROR	,ER$RFA,<Bad value in RFA field>
	ERROR	,ER$RFM,<Bad code in RFM field>
	ERROR	,ER$RLK,<Record locked>
	ERROR	,ER$RMV,<File processor directory REMOVE error>,IOOPT
	ERROR	,ER$RNF,<No such record>,RMSERR
	ERROR	,ER$RNL,<Record not locked>
	ERROR	,ER$ROP,<Bad mask in ROP field>
	ERROR	,ER$RPL,<File processor prologue READ error>,IOOPT
	ERROR	,ER$RRV,<Bad internal pointer>
	ERROR	,ER$RSL,<Bad value in RSL field>
	ERROR	,ER$RSS,<Bad value in RSS field>
	ERROR	,ER$RST,<Bad address in RSA field>
	ERROR	,ER$RSZ,<Bad value in RSZ field>
	ERROR	,ER$RTB,<Record too big for user buffer>
	ERROR	,ER$RVU,<Internal pointer corrupted>
	ERROR	,ER$SEQ,<Sequential insertion records not in order>
	ERROR	,ER$SHR,<Bad mask in SHR field>
	ERROR	,ER$SIZ,<Bad value in SIZ field>
	ERROR	,ER$SUP,<Operation not supported over network>
	ERROR	,ER$SYS,<System error>,DSWOPT
	ERROR	,ER$TRE,<Index error>
	ERROR	,ER$TYP,<Bad file type>
	ERROR	,ER$UBF,<Bad address in UBF field>
	ERROR	,ER$UIN,<Field value rejected by FAL>
	ERROR	,ER$USZ,<Bad value in USZ field>
	ERROR	,ER$VER,<Bad file version number>
	ERROR	,ER$WCD,<Illegal wildcard in merged string>
	ERROR	,ER$WER,<File processor WRITE error>,IOOPT
	ERROR	,ER$WLK,<Device write-locked>
	ERROR	,ER$WPL,<File processor prologue WRITE error>,IOOPT
	ERROR	,ER$XAB,<Bad address in XAB field>
	ERROR	,ER$XTR,<Extraneous data in file specification>

	ERREND

	.ENDC	; DF RMSMSG



	.PSECT	PURTXT	RO,D,LCL,REL,CON
	.NLIST	BEX
GBLMSG:	.ASCIZ	\%2R - %Y %3Z - \
	.EVEN
	.LIST	BEX

	.PSECT	IMPDAT	RW,D,LCL,REL,CON

PUNCT:	.BLKW	1		; End punctuation.
ERRBAD:	.BLKW	1		; Addr. of front of error message buffer
ERRADR:	.BLKW	1		; Addr. of error code.
ERRLUN:	.BLKW	1		; LUN for output.
ERRBLD:	.BLKW	20.		; Error parameters block.
ERRBUF:	.BLKW	128.		; Error message buffer.
ERRBFA:	.BLKW	1		; Address in error message buffer.

	.ASECT
.=0
NARG:	.BLKW	1		; Number of arguments.
LUN:	.BLKW	1		; Address of LUN.
USRTXT:	.BLKW	1		; User text.
USRPRM:	.BLKW	1		; Params with user text.
ERS:	.BLKW	1		; Start of error params.

	.PSECT	PURCOD	RO,I,LCL,REL,CON

	.ENABL	LSB		; For alternate entry.

ERRORF::MOV	LUN(R5),ERRBAD	; Get the user's buffer address.
	CLR	ERRLUN		; No error LUN.
	BR	10$		; Join common code.
ERRORS::MOV	#ERRBUF,ERRBAD	; Save error message address.
	MOV	@LUN(R5),ERRLUN	; Save LUN number.
10$:	CALL	$SAVAL		; Save registers to work with.

	MOV	ERRBAD,R0	; Get the buffer address.
	MOV	#'.,PUNCT	; Set up default punctuation.
	CLR	R2		; Use R2 as option flag.
	MOV	USRTXT(R5),R4	; Get the user text.
	CMP	R4,#-1		; Was it passed?
	BNE	20$		; If so, use it.
	CLR	R4		; If not, zero is easier to check.
	MOVB	#40,(R0)+	; Also, default to single-space.
	BR	100$		; Skip all the user junk.
20$:	CLR	R1		; Get the next
	BISB	(R4)+,R1	;    character.
	CMPB	R1,#'%		; Is it the magic percent?
	BEQ	30$		; If so, handle.
	CMPB	R1,#'.		; Is it the magic dot?
	BEQ	40$		; If so, handle.
	CMPB	R1,#'P		; Is it the magic "P"?
	BEQ	50$		; If so, handle.
	CMPB	R1,#'@		; Is it the "@" (proxy for null)?
	BNE	100$		; If not, it's normal form control.
	CLR	R1		; If so, put in an honest-to-God null.
	BR	100$		; Go process time and date.
30$:	BIS	#100000,R2	; Flag no standard header.
	BR	20$		; Go get the next character.
40$:	CLR	PUNCT		; No punctuation.
	BR	20$		; Go get the next character.
50$:	MOVB	(R4)+,PUNCT	; Next char. is desired punct.
	BR	20$		; Go get the next character.

100$:	MOVB	R1,(R0)+	; Save the carriage control.
	TST	R2		; Want the standard header?
	BLT	110$		; If not, don't bother.
	MOV	#ERRBLD,R2	; Point to parameter block.
	GTSK$S	R2		; Get our task name.
	GTIM$S	#ERRBLD+4	; Get the current time.
	MOV	#GBLMSG,R1	; Get the format for it.
	CALL	$EDMSG		; Format it all.

110$:	MOV	R4,R1		; Get the user's data.
	BEQ	120$		; If there ain't none, fergit it.
	MOV	USRPRM(R5),R2	; Get the data block address.
	CALL	$EDMSG		; Format the data.

120$:	MOV	R0,ERRBFA	; Save our current location.
	CLR	R4		; Get the number of
	BISB	NARG(R5),R4	;    arguments.
	MOV	#ERRBLD,R3	; Point to error data block.
	MOV	#ERRTBL,R2	; Point to the error analysis table.
	ADD	#ERS,R5		; Point to the first error arg.
	SUB	#ERS/2-1,R4	; Find the number of error arguments.
	BGT	NXTARG		; If we have some, analyze them.
	JMP	WRITE		; If not, just write what we have.

	.DSABL	LSB		; End of shared code.

NXTARG:	MOV	ERRADR,R0	; Assume reprocessing previous entry.
	BIT	#ERRCUR,(R2)	; Want to get another arg?
	BNE	10$		; If not, proceed with the current one.
	DEC	R4		; All out of them?
	BLT	MESSAO		; If so, log the missing data.
	MOV	(R5)+,R0	; Get the address of the data.
	CMP	R0,#-1		; Is it null?
	BEQ	MESSAO		; If so, log missing data.
10$:	BIT	#ERRALN,(R2)	; Need to word align the address?
	BEQ	20$		; If not, proceed.
	CLR	-(SP)		; If so, assume word align.
	BIT	#ERRODD,(R2)	; Want odd alignment?
	BEQ	15$		; If not, go align.
	INC	(SP)		; If so, set it up, and
	DEC	R0		;    knock off the odd bit.
15$:	INC	R0		; Align to next
	BIC	#1,R0		;    even address.
	ADD	(SP)+,R0	; Go to next odd if needed.
20$:	MOV	R0,R1		; Copy the address.
	BIT	#ERRBYT,(R2)	; Is this a byte argument?
	BNE	30$		; If so, go get it.
	MOV	(R1)+,R0	; Get the word argument.
	BIT	#ERRMAC!ERRMIC,(R2)	; Is it a DAP error?
	BEQ	40$		; If not, fine.
	MOV	#170000,-(SP)	; Assume microcode.
	BIT	#ERRMIC,(R2)	; Is it a microcode?
	BNE	25$		; If so, handle it.
	TST	-(R1)		; Back up the error addr.
	ASH	#-12.,R0	; Put code in low byte.
	MOV	#^C17,(SP)	; Mask for macrocode.
25$:	BIC	(SP)+,R0	; Clear unwanted bits.	
	BR	40$		; Go on about our business.
30$:	MOVB	(R1)+,R0	; Get the byte argument.
	MOVB	R0,R0		; Sign-extend the code.
40$:	MOV	R1,ERRADR	; Save the address of this arg.
	BIT	#ERRSYN,(R2)	; Is this a synonym entry?
	BEQ	PROCES		; If not, go process it.
	TST	(R2)+		; If so, point to synonym address,
				;    and fall thru to chaining code.

CHAINR:	MOV	(R2),R2		; Get new table address.

PROCES:	ADD	#4,R2		; Skip initial data.
10$:	MOV	(R2)+,R1	; Get prospective text address.
	BEQ	50$		; If none, at end.
	CMP	(R2)+,R0	; Is this the error?
	BEQ	40$		; If so, use it.
	TST	(R2)+		; If not, skip data,
	BR	10$		;   and try again.
40$:	MOV	R1,(R3)+	; Save the message.
	MOV	(R2)+,R2	; Got more chain?
	BNE	NXTARG		; If so, run it.
	BR	WRITE		; If not, quit.
50$:	JMP	@(R2)+		; Go process appropriately

MESSAO:	BIT	#ERROPT,(R2)+	; Was the datum optional?
	BNE	WRITE		; If so, fall thru and write.
MESSAG:	MOV	(R2)+,(R3)+	; No match. get default error msg,
	MOV	R0,(R3)+	;   and code.
				; Fall thru and write.

WRITE:	MOV	#PUNCT,(R3)+	; Punctuate the text.
	MOV	#ERRBLD,R2	; Get the address of the build block.
	MOV	ERRBFA,R0	; Get the error buffer.
	MOV	(R2)+,R1	; Get the edit string.
	CALL	$EDMSG		; Build the message.
	MOV	ERRBAD,R1	; Get edit buffer.
	CLR	R2		; Get desired form
	BISB	(R1)+,R2	;    control.
	SUB	R1,R0		; Find length of buffer.
	BEQ	60$		; If none, quit.
	TST	ERRLUN		; Is there a LUN?
	BGT	50$		; If so, write it.
	MOV	R0,2(SP)	; If not, return size in R0,
	BR	60$		;    and return to caller.
50$:	QIOW$S	#IO.WVB,ERRLUN,#32.,,,,<R1,R0,R2>	; Write.
60$:	RETURN			; Return to caller.
	.END
