	;
	; BOOTSTRAP PROGRAM FOR USE WITH TARBELL/WD1771
	; FLOPPY DISK CONTROLLER SYSTEM AND PERSCI
	; VOICE-COIL POSITIONER DISKETTE DRIVES
	;
	; BY BARRY A. WATZMAN, 5/12/78
	;
MEMT	EQU	0C000H		;MEMORY SIZE = 48K
DCOM	EQU	0E8H		;DISK COMMAND PORT.
DSTAT	EQU	DCOM		;DISK STATUS PORT
TRACK	EQU	DCOM+1		;1771 TRACK REGISTER
SECT	EQU	DCOM+2		;1771 SECTOR REGISTER
DDATA	EQU	DCOM+3		;1771 DATA PORT
WAIT	EQU	DCOM+4		;INPUT = WAIT
CPMB	EQU	MEMT-1B00H	;FOR 1.4 CP/M CP/M'D 1K DOWN FROM MEMT
BIOS	EQU	CPMB+1500H	;WHERE CBIOS STARTS
NSECTS	EQU	51		;NO OF SECTORS TO LOAD
	ORG	0		;START OF COLDSTART LOADER
BOOT:	LXI	SP,MEMT		;SET STACK POINTER
BOOT1:	LXI	B,2		;SET TRK (B) = 0, SCTR (C) = 2
	MVI	D,NSECTS	;D=NO SECTORS TO READ
	LXI	H,CPMB		;H,L = CP/M LOAD ADDR
	MOV	A,C		;GET SECTR NO IN ACC
RBLK:	CALL	READ		;READ A SECTOR
RBLK1:	JNZ	ERROR		;HOP OUT IF ERROR
	DCR	D		;DCR SECTOR COUNT
	JZ	BIOS		;HOP OUT IF DONE
	INR	C		;INR SECTOR COUNT
	MOV	A,C		;MOVE IT INTO A
	CPI	27		;SEE IF DONE 1ST TRK
	JC	RBLK2		;IF NOT DONE
	MVI	C,1		;ELSE SET SECTOR = 1
	MVI	A,40H		;SET UP 1771 COMMAND
	OUT	DCOM		;ISSUE IT
	IN	WAIT
	MVI	A,1
	OUT	WAIT
	MVI	A,72H
	OUT	WAIT
	IN	WAIT
	MVI	A,0F2H
	OUT	WAIT
	INR	B
	MOV	A,B
	OUT	TRACK
	MOV	A,C
	JMP	RBLK
;
RBLK2:	MOV	A,C
	CALL	READ1
	JMP	RBLK1
;
;
READ1:	OUT	SECT
	IN	DSTAT
	RRC
	MVI	A,1
	JC	RERR
	MVI	A,88H
	JMP	READE
;
READ:	OUT	SECT
	IN	DSTAT
        RRC
	MVI	A,1
	JC	RERR
	MVI	A,8CH
READE:	OUT	DCOM
RLOOP:	IN	WAIT
	ORA	A
	JP	RDONE
	IN	DDATA
	MOV	M,A
	INX	H
	JMP	RLOOP
;
RDONE:	IN	DSTAT
RERR:	ANI	9DH
	RET
;
;
ERROR:  CMA
	OUT	0FFH
	HLT
;
;
	ORG	07DH
	JMP	0
        END
