	/*
	**	SP2.INC
	**
	**	James L. Bates
	**	Batech Corporation
	**	c/o Cogitate, Inc.
	**	24000 Telegraph
	**	Southfield, MI 48034
	**
	**	Tally ratio of timer_on/timer_off using
	**	more _asm coding than c and c library coding
	**	to will provide better throughput.
	*/
 	_asm
	{	push	es		; save segment
		push	bx		; save possible index
		mov	ax,40h		; point es to DOS area
		mov	es,ax		; 
		mov	bx,es:[6ch]	; get the lsw of timer tick
		mov	dx,addr		; get modem status address
	asm_loop:
 		in	al,dx		; read the modem status
		test	al,10h		; test for CTS
		jz	asm_cnt1	; not on
		add	word ptr c_on1+0,1	; increment timer on
		adc	word ptr c_on1+2,0	;
		jmp	short asm_cnt2
	asm_cnt1:
		add	word ptr c_off+0,1	; increment timer off
		adc	word ptr c_off+2,0	;
	asm_cnt2:
		cmp	bx,es:[6ch]	; stay in tight loop until tick
		jz	asm_loop	; same tick
		mov	bx,es:[6ch]	; update tick register
		cmp	kb_env,0	; trigger on kb only?
		jnz	asm_kbhit	;  yes...
		test	al,20h		; DSR still on?
		jz	asm_break	; no, time to exit
	asm_kbhit:
		mov	ah,1		; now check the keyboard
		int	16h		; keyboard status
		jz	asm_loop	; no key hit
	asm_break:
		pop	bx		; restore possible index
		pop	es		; restore segment
 	}

