'Timing info:
'There are 120 half-cycles in a 60Hz AC waveform
'We want to be able to trigger a triac at any of 256 
'points inside each half-cycle.  So:
'1 Half cycle takes 8 1/3 mS
'1/256 of one half cycle takes about 32.6uS
'The Pause function here waits (34 * 0xD)uS, plus 3uS overhead
'Overhead includes CALL PAUSE.
'This was originally assembled using Parallax's "8051 style" 
'assembler, and was not optimized any further.  I suppose
'it could be modified to be closer to 32 or 33uS, but it is
'sufficient for my testing purposes.

list 16c84

	movlw	0xFD	'11111101
	tris	0x5	'Port A
	movlw	0xFF	'11111111
	tris	0x6	'Port B
WaitLow:		'Wait for zero-crossing start
	btfss	0x5,0x0	'Port A, Bit 1
	goto	WaitLow	'If high, goto WaitLow
WaitHigh:		'Wait for end of Zero Crossing
	btfsc	0x5,0x0	'Port A, Bit 1
	goto	WaitHigh'If low, goto waitHigh
	call	Pause	'Wait for 0xD * 34 + 3 uS
	bcf	0x5,0x1	'Put Low on port A, Bit 1
	movlw	0x3	'Put 3 into W
	movwf	0xD	'Put W into 0xD
	call	Pause	'Call Pause, 105 uS
	bsf	0x5,0x1	'Put High on Port A, Bit 1
	decf	0xE	'Decrement E
	movf	0x6,W	'Copy Port B to W
	movwf	0xD	'Copy W to 0xD
	goto	Start	'Wait for zero Crossing
Pause:			'This pauses for 0xD * 34 + 3 Micro Seconds
			'Our goal is approx. 32 uS per 0xD
			'But this is close enough for testing
	movlw	0xA	'Move 10 to W
	movwf	0xC	'Move W to 0xC
Label1:
	decfsz	0xC	'Decrement C
	goto	Label1	'If C is not zero, goto Label1
	decfsz	0xD	'Decrement D
	goto	Pause	'If D is not zero, goto Pause
	return		'Return
