;
; TITLE		DISK HARDWARE READ SPEED TESTER
; FILENAME	RSPEED.ASM
; AUTHOR	Robert A. Van Valzah   4/27/79
;
;
MAXSECT	EQU	100
$-MACRO
;
PRINT	MACRO	STRING
	LOCAL	MSG,AROUND
	MVI	C,9
	LXI	D,MSG
	CALL	5
	JMP	AROUND
MSG	DB	13,10,STRING,'$'
AROUND:
	ENDM
;
;
	ORG	100H
ENTRY:
	LXI	SP,STACK ;LOCAL STACK
	CALL	GETVEC	;LINK TO CBIOS
	PRINT	'RSPEED.COM  5/21/79'
	PRINT	'ENTER NUMBER OF SECTORS PER TRACK? '
	CALL	GETNUM
	STA	NSECTS
SETSKEW:
	PRINT	'ENTER SKEW FACTOR? '
	CALL	GETNUM
	STA	SKEW
	ORA	A
	JNZ	FILLTABL
	PRINT	'ENTER SECTOR NUMBERS, ZERO WHEN DONE'
	LXI	H,STABL
TABSEC:
	CALL	GETNUM
	MOV	M,A
	ORA	A
	JZ	GOTTABL
	INX	H
	JMP	TABSEC
FILLTABL:
	LXI	H,SUT
	MVI	C,MAXSECT
ZAPTABL:
	MVI	M,0
	INX	H
	DCR	C
	JNZ	ZAPTABL
	LXI	D,STABL+1
	LDA	NSECTS
	MOV	C,A
	MVI	B,1
STORSEC:
	MOV	A,B
	STAX	D
	MVI	A,LOW(STABL)
	ADD	C
	CMP	E
	INX	D
	MVI	A,0
	STAX	D
	JZ	GOTTABL
	CALL	SECAD
	MVI	M,0FFH	;SET SECTOR USED FLAG
	LDA	SKEW
	ADD	B
	MOV	B,A
MTYSEC:
	CALL	BMODC
	CALL	SECAD
	MOV	A,M
	ORA	A
	JZ	STORSEC
	INR	B
	JMP	MTYSEC
;
SECAD:
	LXI	H,SUT
	MOV	A,B
	ADD	L
	MOV	L,A
	RNC
	INR	H
	RET
;
BMODC:
	MOV	A,B
	SUB	C
	RZ
	RC
	MOV	B,A
	RET
;
GOTTABL:
	PRINT	'PRESS ANY KEY TO READ, S TO RESET SKEW . .'
RDKEY:
	CALL	CON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