execbase:	equ	4
findresident:	equ	-$60
doio:		equ	-$1c8
location:	equ	$50000

org	location
load	location

dc.b	'DOS',0
dc.l	$0
dc.l	$370
start:
	move.w	#$8100,$dff096
	move.l	#location,a2
	lea.l	blocklong(pc),a3
	move.l	(a3),d1
	move.l	#0,a3
	move.l	#0,d2
checkloop:
	bclr	d2,d1
	bne	loadthis
	add.l	#$0200,a3
	addq.l	#1,d2
	tst.l	d1
	bne	checkloop
	bra	fertig_geladen

loadthis:
	move.l	execbase,a6
	move.w	#2,28(a1)
	move.l	a3,44(a1)
	move.l	a2,40(a1)
	move.l	#$0200,36(a1)
	movem.l	d1-d2/a1-a3,-(a7)
	jsr	doio(a6)
	movem.l	(a7)+,d1-d2/a1-a3
	add.l	#$0200,a3
	add.l	#$0200,a2
	addq.l	#1,d2
	tst.l	d0
	beq	checkloop
	bra	continue_boot
fertig_geladen:
	jsr	begin
continue_boot:
	move.l	execbase,a6
	lea	dosname(pc),a1
	jsr	findresident(a6)
	tst.l	d0
	beq	boot_failed
	move.l	d0,a0
	move.l	22(a0),a0
	moveq	#0,d0
	rts
boot_failed:
	moveq	#1,d0
	rts

dosname:	dc.b	'dos.library',0
blocklong:	dc.l	$00000001
even

begin:
	rts
finito:
