

			$pagewidth(132)
			$nopaging
			$mod51
			$debug(vercount.abs)
			$nolist
			$list

			dseg

CtrA:			ds 1
CtrB:			ds 1
Dbnce:			ds 1

			cseg

			org  	000h
BEGIN:			ljmp 	100H

			org  	100H

			mov 	CtrA,#0
			mov 	CtrB,#0
			mov	Dbnce,#1
			mov	a,#1

Start:			mov 	a,CtrB		;increment the vertical counter
			xrl     CtrA,a		;A+:= A XOR B
			xrl     CtrB,#0ffh	;B+:=  NOT (B)

			mov 	a,p1		;Has the input data changed ?
			xrl     a,Dbnce		;a 1 in the accu means difference

			anl 	CtrA,a		;clear counter on no difference
			anl	CtrB,a

			cpl	a		;(a 0 in the accu means difference)
			orl	a,CtrA
			orl	a,CtrB		;a 0 in the accu means difference
						;AND timer overflowed => Change Dbnce
			cpl	a		;(a 1 in the accu means change Dbnce)
			xrl	Dbnce,a		;Effect the changes

			jmp 	start

			end

