;++
;
;  Macro:	OUTPUT
;
;  Author:	Hunter Goatley, goathunter@WKUVX1.BITNET
;
;  Functional description:
;
;	This macro will cause a string to be printed to SYS$OUTPUT by
;	storing the string as an ASCID string and generating a CALLS
;	to LIB$PUT_OUTPUT.  The ASCID strings are stored in a psect
;	named RO_DEBUG_DATA.
;
;  Formal parameters:
;
;	STRING		- The string to be written to SYS$OUTPUT
;
;  Sample call:
;
;	OUTPUT	<This is a debug message>
;
;--
	.MACRO	OUTPUT	STRING,?TEXT			;* Macro to print text;
	;;
	; Save the current code psect context;
	;;
	.SAVE_PSECT LOCAL_BLOCK				;* Save this PSECT;
	;;
	;  Now switch to the data psect;
	;;
	.PSECT	_RO_DEBUG_DATA,NOEXE,WRT,LONG,SHR	;* Change to data PSECT;
	;;
	;  Align the string on a longword boundary and create it as an
	;  ASCID string.;
	;;
	.ALIGN	LONG					;* Align on longword;
 TEXT:	.ASCID	~STRING~				;* Create .ASCID string;
	;;
	;  Because TEXT is a local label, save the current pointer;
	;;
	..OUTPUT_TEXT = TEXT				;* Save the address;
	;;
	;  Now move back to the code psect and generate the CALLS to;
	;  LIB$PUT_OUTPUT;
	;;
	.RESTORE_PSECT					;* Go back to code;
	PUSHAQ	..OUTPUT_TEXT				; Write the string;
	CALLS	#1,G^LIB$PUT_OUTPUT			; ... to SYS$OUTPUT;
	.ENDM	OUTPUT					;* End of OUTPUT macro;
