	.title	allmem
	.ident	/851202/
;
; Grab all of memory from current heap setting to end of heap.
;
; function allmem(var p : @char):integer;
;
; Will return a pointer to the block of memory and the number
; of words available. If no memory is available, p will be set
; to nil and the function will return zero.
;
	.globl	p.gmem,h.hgh,h.end
;
	.psect
allmem::
	call	p.gmem			;grab all there is
	mov	2(sp),r0		;shuffle stack
	mov	(sp)+,(sp)
	clr	(r0)			;assume error
	clr	2(sp)
	mov	h.end,r1
	cmp	r1,h.hgh
	bhis	10$			;no more room
	mov	h.hgh,h.end		;ok, grab the lot
	tst	(r1)+
	mov	r1,(r0)			;yield address of buffer
	mov	h.hgh,2(sp)
	tst	-(r1)
	sub	r1,2(sp)		;size of buffer in words
	ror	2(sp)			;carry must be clear
10$:	return
	.end
