aseg
	org	0
M0000:	NOP
M0001:	LXI	B,0800H
	MOV	D,C
	MOV	E,C
	MOV	H,C
	MOV	L,C
M0008:	LDI
	DCX	HL
	JPE	M0008
	LXI	SP,07E0H
	IM2
	MVI	A,00H
	STAI

	jmp	M00BC

	org	00bah

M00BA:	DW	M01C7
M00BC:	LXI	H,M00BA
	MOV	D,H
	MOV	E,L
	LXI	B,400H-M00BA
	LDIR
	MVI	A,0FFH		; Bitmode
	OUT	FDCPIOBC
	EI
	MVI	A,0F3H		; eeee aaee
	OUT	FDCPIOBC
	MVI	A,7FH		; Eingabemode
	OUT	FDCPIOBD
	OUT	FDCPIOAC
	MVI	A,0A9H		; Stop CPU2
	OUT	FDCPIOAD
	MVI	A,3FH		; Ausgabemode
	OUT	FDCPIOAC
	OUT	FDDPIOAC
	MVI	A,HIGH(M00BA)	; Interruptvektor
	OUT	FDCPIOAC
	MVI	A,04H		; Letzter zu lesender Sektor
	STA	M07F2
	MVI	A,0C3H		; Vorbereiten Start CPU2
	STA	M0000
	LXI	H,M01DD
	SHLD	M0001
	MVI	A,0EEH
M0101:	STA	M03FC		; akt. Laufwerk
	OUT	FDSEL
	LXI	H,0400H		; Ladeadresse 'SYL'
	MOV	B,L
	SHLD	M03F0
	LXI	D,5006H
M0110:	IN	FDCPIOBD
	RLC
	JRNC	M0128		; Spur 0 gefunden
	DCR	D
	JRZ	M0140
	MVI	A,09H		; Positionieren zur Spur 0
	MOV	B,A
	OUT	FDCPIOAD
	MVI	A,89H
	OUT	FDCPIOAD
M0121:	DCR	C		; Zeitschleife
	JRNZ	M0121
	DJNZ	M0121
	JR	M0110
M0128:	LXI	H,M03F7
	MVI	M,04H
	MVI	A,97H
	OUT	FDCPIOAC
	MVI	A,0FFH
	OUT	FDCPIOAC
M0135:	MOV	A,M
	ORA	A
	MVI	A,87H
	JRZ	M0153
	DCR	C
	JRNZ	M0135
	DJNZ	M0135
M0140:	LDA	M03FC
	CPI	77H
	JZ	M027E
	RLCA
	JR	M0101
M014B:	DCR	E
	JRZ	M0140
	LDA	M03FD
	XRI	02H
M0153:	STA	M03FD
	LXI	H,8001H
	SHLD	M07F0
	MVI	H,00H
	SHLD	M03F5
	MOV	L,H
	SHLD	M03F3
	CALL	M0194
M0168:	MOV	A,M
	ORA	A
	JRZ	M0168
	DCR	A
	JRZ	M014B
	CALL	M01B6
	JRNZ	M0140
	CALL	M0437

; Fehler beim Ladevorgang

	LHLD	M03FA
	SHLD	M0462
	IN	A,(0AH)
	OR	01H
	OUT	(0AH),A
	LXI	B,0346H
	LXI	D,00BAH
	MOV	H,D
	MOV	L,H
M018B:	LDI
	DCX	HL
	JP	PE,M018B
	JP	M0074

M0194:	LXI	H,03F7H
	MVI	M,10H
	OUT	fddpioad
	OUT	reszve2
	MVI	A,0FFH
	OUT	FDDPIOBC
	OUT	FDDPIOBC
	MVI	A,0A5H
	OUT	FDCPIOAD
	MVI	A,7FH
	OUT	FDDPIOBC
	IN	FDDPIOBD
	LDA	M03FD
	OUT	FDCPIOAD
	inx	h
	MVI	M,00H
	RET

; Test auf 'SYL'

M01B6:	LHLD	M0400
	LXI	B,'YS'
	SBC	HL,BC
	RET	NZ
	LXI	H,M0400+2
	MVI	A,'L'
	CMP	M
	RET	NZ
	RET

; Indexinterrupt

M01C7:	EI
	PUSH	AF
	PUSH	HL
	LXI	H,M03F7
	DCR	M
	JRZ	M01D4
M01D0:	POP	HL
	POP	AF
	RETI
M01D4:	MVI	A,0BDH
	OUT	FDCPIOAD
	INX	H
	MVI	M,01H
	JR	M01D0

; Start CPU2

M01DD:	lhld	M03F0
	LDA	M07F1
	MOV	B,A
	LXI	D,M0700
	MVI	C,fddpiobd
	EXX
	LXI	B,0FEA1H
	lded	M03F3
	lhld	M03F5
	MVI	A,0BDH
	OUT	FDCPIOAD
M01F8:	MVI	A,0B5H
	OUT	FDCPIOAD
	JR	M025A
M01FE:	MOV	H,A		; neuer Sektorlaengencode
	XRA	A
	EXX
	MOV	B,A
	EXX
	JR	M0273
M0205:	IN	FDDPIOBD	; 3 * A1
	IN	FDDPIOBD
	IN	FDDPIOBD
M020B:	IN	FDDPIOBD	; 1 * FE
	CMP	B
	JRNZ	M01F8
	IN	FDDPIOBD
	CMP	E		; Spur
	JRNZ	M01F8
	IN	FDDPIOBD
	CMP	D		; Side
	JRNZ	M01F8
	IN	FDDPIOBD
	CMP	L		; Sector
	JRNZ	M01F8
	IN	FDDPIOBD
	CMP	H		; Sectorlaengencode
	JRNZ	M01FE
	MVI	A,0B5H
	OUT	FDCPIOAD
	LDA	M03FD
	BIT	1,A
	OUT	FDCPIOAD
	IN	FDDPIOBD
	JRNZ	M0239
	IN	FDDPIOBD	; 3 * A1
	IN	FDDPIOBD
	IN	FDDPIOBD
M0239:	IN	FDDPIOBD	; 1 * FB
	EXX
	INI			; Sector lesen
	INI
	INI
	INIR
	EX	DE,HL
	INI			; CRC lesen
	INI
	MVI	A,0B5H
	OUT	FDCPIOAD
	EX	DE,HL
	LDA	M07F1
	MOV	B,A
	EXX
	LDA	M07F2
	CMP	L
	JRZ	M0267
	INC	L
M025A:	LDA	M03FD
	BIT	1,A
	OUT	FDCPIOAD
	IN	FDDPIOBD
	JRZ	M0205
M0265:	JR	M020B
M0267:	MVI	A,03H
	OUT	FDCPIOAC
	sta	M03F8
	JR	M0265
	LXI	B,1EDAH
M0273:	sta	M07F1		; 00
	MVI	A,02H
	sta	M07F2		; 2 Sectoren
	JP	M01F8
M027E:	MVI	A,0FFH
	OUT	FDSEL



	org	03f0h
M03F0:	DEFL	003F0H
M03F3:	DEFL	003F3H
M03F5:	DEFL	003F5H
M03F8:	DEFL	003F8H
M03FA:	DEFL	003FAH
M03FC:	DEFL	003FCH
M03FD:	DEFL	003FDH
M0400:	DEFL	00400H
M0437:	DEFL	00437H
M0460:	DEFL	00460H
M0462:	DEFL	00462H
M0464:	DEFL	00464H
M046C:	DEFL	0046CH
M07F0:	DEFL	007F0H
M07F1:	DEFL	007F1H
M07F2:	DEFL	007F2H
