;:sys36864
	;.opt oo
	*= 820
rom	= $8000
chkrom	= $fd02
restore	= $fe5e
flag	= 2
strout	= $ab1e
getterm	= $b7eb
chkcom	= $aefd
lo	= 20
hi	= lo+1
axout	= $bdcd
return	= $aad7
cbm80	= $fd10
chrgot	= 121
	jmp start
text1	.byte "\x93achtung ! es war bereits ein modulstart" 
	 .byt 13
	.byte "ab $8000 vorhanden ! seine adressen:" 
	 .byt 13
	.byte "reset:   " 
	 .byt 0
text2	.byte "restore: " 
	 .byt 0
start	jsr chrgot
	bne goon
	sta rom+4
	rts
goon	jsr chkcom
	jsr getterm
	stx flag
	jsr chkrom
	bne norom
	lda #<text1
	ldy #>text1
	jsr strout
	ldx rom
	lda rom+1
	jsr axout
	jsr return
	lda #<text2
	ldy #>text2
	jsr strout
	ldx rom+2
	lda rom+3
	jsr axout
	jsr return
norom	lda lo
	ldy hi
	sta rom
	sty rom+1
	ldx flag
	bne mitrest
	lda #<restore
	ldy #>restore
mitrest	sta rom+2
	sty rom+3
	ldx #5
setrom	lda cbm80-1,x
	sta rom+3,x
	dex
	bne setrom
	rts
