	comment	®

	ExampleRexxBlock

PURPOSE:
	Demonstration only.  It does nothing (except pring a string to the console).
	The purpose of this file is more a demonstration of the rexxBlockTest.rexx
  AREXX file than the assembler side of things, which is rediculiously simple.

USAGE:
	1> ram:ExampleRexxBlock

	Tabstops : 8
	Assemble with Macro68

	25-09-91	** written
®


	objfile	ram:ExampleRexxBlock
;	addsym
	exeobj
	strict
	newsyntax

***************************************


START:		movea.l		(_AbsExecBase).w,a6	;establish exec for calls
		movea.l		(ThisTask,a6),a3	;want to read from this shortly
		tst.l		(pr_CLI,a3)
		bne.b		.fromCLI		;branch if from CLI
..		lea		(pr_MsgPort,a3),a0	;our process base
		jsr		(_LVOWaitPort,a6)	;wait for message from starter
		lea		(pr_MsgPort,a3),a0	;our process base
		jsr		(_LVOGetMsg,a6)
		move.l		d0,d2
		beq.b		..
		jsr		(_LVOForbid,a6)
		movea.l		d2,a1			;workbench message
		jsr		(_LVOReplyMsg,a6)
		moveq		#RETURN_FAIL,d0
		rts

.fromCLI:	moveq		#0,d0			;version #
		lea	 	(dosLibName,pc),a1	;point to library name
		jsr		(_LVOOpenLibrary,a6)	;exec
		tst.l		d0
		bne.b		.rockNroll

	; As long as DOS library is rom based,	if open DOS library version 0 fails
	; then it's probably best to put the machine out of it's misery

		move.l		#AT_DeadEnd!AG_OpenLib!AO_DOSLib,d7
		jmp		(_LVOAlert,a6)

	; Print the text and exit

.rockNroll:	movea.l		d0,a6
		jsr		(_LVOOutput,a6)
		move.l		d0,d1
		move.l		#String,d2
		move.l		#StringLen,d3
		jsr		(_LVOWrite,a6)

		movea.l		a6,a1
		movea.l		(_AbsExecBase).w,a6
		jmp		(_LVOCloseLibrary,a6)


***************************************

dosLibName:
	cstr	'dos.library'


String:
	TEXTBLOCK	®
	This String was part of the source code, the text included by the
  REXXBLOCK directive follows immediately after the blank line below.

®

	REXXBLOCK	rexxBlkTest.rexx

testSym:
	TEXTBLOCK	®

	Now we're back to the source code generated text.  It really is as
  simple as that.
	I know that this was a very simple example, at the other end of the
  scale consider this;

	REXXBLOCK	compile.rexx
		my_C_language_file.c

  The AREXX file "compile.rexx" would read the filename from the source line
  immediately following the REXXBLOCK directive, submit the file to your "C"
  compiler, read the resultant object into a memory buffer and return the
  results to Macro68.

	Ok, Ok, so it won't replace linking, but you get the picture.

®

StringLen	equ	*-String

*******************************************************************************
	END
