	csect	text,0,,1,2

	xdef	_SaveMem
	xdef	_ValidateMem

*** this is the number of LONGWORDS at the start of memory to be checked
MEMSAVESIZE	equ	64
*************************************************************************
* Validate the current memory information and put up an alert if it is
* in sad shape
*************************************************************************
_ValidateMem:
	movem.L	A0/A1,-(A7)
	moveq.l	#MEMSAVESIZE,D0
	LEA	0,A0
	LEA	savearea(PC),A1
checkit:
	cmp.l	(A0)+,(A1)+
	dbne	D0,checkit
	addq	#1,D0
	beq	allok
* restore what got scrod
*	first format the message to be printed
*	we get a pointer to the address and the data portion
	move.l	-(A0),D0	get the value that was put in
	move.l	-(A1),(A0)	and replace with what should have been there
	move.l	12(A7),A1	point to where we should save the result
	move.l	D0,(A1)		save the value
	move.l	A0,4(A1)	and the address for the routine to munge
	moveq.l	#1,D0		set a result value to indicate failure
allok:
	movem.l	(a7)+,A0/A1
	rts

_SaveMem:
	movem.L	D0/A0/A1,-(A7)
	moveq.l	#MEMSAVESIZE,D0
	LEA	0,A0
	LEA	savearea(PC),A1
savelp:
	move.l	(A0)+,(A1)+
	DBF	D0,savelp
	movem.l	(A7)+,D0/A0/A1
	rts
savearea	ds.l	MEMSAVESIZE+2	;for save and compare of memory
	END
