 TITLE "io-test.ASM - test outputs on a PIC12C509"
;  
;   
;
;  Colin Pringle
;  7-27-02
;
;
;  
;
 LIST P=12c509, R=DEC
 INCLUDE "p12c509.inc"
 __CONFIG _CP_OFF & _WDT_OFF & _IntRC_OSC & _MCLRE_OFF

;  Variables
 CBLOCK 0x010			;  Variables in Shared 16 Bit Value
Dlay:3				;  1 Second Delay Variables
Count				;  Second Counter
Flag				;  Flags Bit
 ENDC


;mainline
	org	0
Mainline
	movwf	OSCCAL
	movlw	0
	tris	GPIO
	movlw	0x0FF ^ (1 << T0CS)
	option
	movlw	b'00001000'	;set as outputs
	tris GPIO

mainloop
	movlw	1
	movwf	GPIO
	call	OneSecDlay
	movlw	2
	movwf	GPIO
	call	OneSecDlay
	movlw	4
	movwf	GPIO
	call	OneSecDlay
	movlw	16
	movwf	GPIO
	call	OneSecDlay
	goto	mainloop


;  Subroutines
OneSecDlay			;  Delay 1 Second

  clrf    Dlay			;  Setup for a 1 Second Delay
  clrf    Dlay + 1
  movlw   5
  movwf   Dlay + 2

  decfsz  Dlay, f		;  Delay 1 second
   goto   $ - 1
  decfsz  Dlay + 1, f		;  Inner Loop, 1/5 Second Delay
   goto   $ - 3
  decfsz  Dlay + 2, f
   goto   $ - 5

  retlw	0


 End
