; ******************************************************************
			.TITLE XXX_ERROR
; this module contains some handy error reporting routines
; for general usage for those people using RMS
; ******************************************************************
;
.LIBRARY/SYS$LIBRARY:LIB.MLB/
$SHRDEF
.PSECT XXX_DATA
	XXX_DESC:	.LONG 0,0
.PSECT XXX_ERROR
	$FABDEF
	$RABDEF
REPORT_ERROR::
;
;	this is a routine to be called as the rms error routine
;	it is at ast level
;	this is the choice if you want to exit on an error
;	otherwise use report_err_ret
	.WORD ^M<R2,R3,R4,R5,R6,R7,R8,R9,R10,R11>
	MOVL	4(AP),R10			;address of structure at fault
	BSBW	REPORT				;go report error
	$EXIT_S
report_err_ret::
;
;	this is a routine to be called as the rms error routine
;	it is at ast level
;	use this one if you want to return
;	and report_error if you want the program to exit
	.WORD ^M<R2,R3,R4,R5,R6,R7,R8,R9,R10,R11>
	MOVL	4(AP),R10			;address of structure at fault
	BSBW	REPORT				;go report error
	RET
REPORT_ERR::
;
;	this is a routine to be called at non-ast level
;	it's useful if you only want to report certain errors
;	R10 is the address of the structure at fault
;	R0 is the error code
;
	PUSHL	R0
	PUSHL	FAB$L_STV(R10)
	PUSHL	R0
	BRB	r
REPORT::
;
;	this is the common routine that prints the message
;
	ASSUME FAB$L_STS EQ RAB$L_STS
	PUSHL	FAB$L_STS(R10)
	PUSHL	FAB$L_STV(R10)
	MOVL	FAB$L_STS(R10),R0
	BICL	#7,R0
	ADDL2	#3,R0
	PUSHL	R0
R:
	CMPB	FAB$B_BID(R10),#FAB$C_BID
	BEQL	5$
	MOVL	RAB$L_FAB(R10),R10
5$:	MOVL	FAB$L_FNA(R10),XXX_DESC+4
	MOVZBL	FAB$B_FNS(R10),XXX_DESC
	PUSHAL	XXX_DESC
	PUSHL	#1
	PUSHL	#<SHR$_OPENIN!<21@16>>
	CALLS	#5,@#LIB$SIGNAL
	POPR	#^M<R0>
	RSB
NOFNF:
	PUSHL	#0
	CALLS	#3,@#LIB$SIGNAL
	POPR	#^M<R0>
	RSB
.end
