
	; Written By Shagratt/LSD
	
	; this creates a process of the other bit of code (after "section 
	; main") and then this first bit quits, returning control to the
	; CLI and having to other code still running.

	; Must be executed from the CLI as if relies on hunk structure.
	
	section	detatch,code	

Code:	Lea	DosName,A1
	Moveq	#0,D0
	jsr	-552(a6)			;OpenLibrary
	Move.l 	D0,_DOSBase
	Beq	.error

	lea	code,a0
	move.l	-4(a0),d3
	move.l	d3,segaddress
	move.l	#0,-4(a0)
	
	move.l	_DOSBase,a6
	move.l	#myname,d1
	move.l	#0,d2
	move.l	#4000,d4
	jsr	-138(a6)			; create proc

.error	clr.l	d0	
	rts

	*---------------------------------*

	Section	Main,Code

Start:	move.w	$dff006,$dff180
	btst	#6,$bfe001
	bne	Start

	move.l	_DOSBASE,a6			; remove code
	move.l	segaddress,d1		; from memory.
	jmp	-156(a6)			; unloadseg

	*---------------------------------*

_DOSBASE:	dc.l	0
DosName:	dc.b	"dos.library"
segaddress:	dc.l	0
myname:	dc.b	"MyTask",0

