;*******************************************************************
;                           Mach2001.asm
;*******************************************************************
	LIST    P=16C84;f=inhx8m
	
_CP_OFF         equ     H'3FFF'                 ;code protect off
_PWRTE_ON       equ     H'3FFF'                 ;Power on timer on
_WDT_OFF        equ     H'3FFB'                 ;watch dog timer off
_XT_OSC         equ     H'3FFD'                 ;crystal oscillator
	__CONFIG       _CP_OFF & _PWRTE_ON & _WDT_OFF & _XT_OSC
						;configure programmer directive
w       equ     0       ; register destination numbers.
f       equ     1       
same    equ     1
z       equ     2       ; status flags
zero    equ     2
c       equ     0
carry   equ     0
	
count1  equ     0C      ; wait counter ls digit file register C
count2  equ     0D      ; wait counter ms digit file register D
portb   equ     06      ; port b I/O register f6
porta   equ     05      ; port a I/O register f5
status  equ     03      ; status register f3
;
;
;
	org     0       ; origin
;
init   
	movlw   0
	tris    portb                   ; set portb as outputs
	movwf   portb                   ; set portb levels all low
;-----------------------------------------------------------------------
; Start usermodificable code :
;-----------------------------------------------------------------------
start
	movlw   04                      ; FAL
	movwf   portb                   
	call    wait_sec                ; Wait approx. 1 Sec 
;
	movlw   0                       ; Stop
	movwf   portb                   
	call    wait_sec                ; Wait approx. 1 Sec
;   
	movlw   05                      ; RAL
	movwf   portb                   
	call    wait_sec                ; Wait approx. 1 Sec 
;
	movlw   0                       ; Stop
	movwf   portb                   
	call    wait_sec                ; Wait approx. 1 Sec
;
	movlw   08                      ; FAR
	movwf   portb                   
	call    wait_sec                ; Wait approx. 1 Sec
;
	movlw   0                       ; Stop
	movwf   portb                   
	call    wait_sec                ; Wait approx. 1 Sec
;    
	movlw   0A                      ; RAR
	movwf   portb                   
	call    wait_sec                ; Wait approx. 1 Sec
;              
	movlw   0                       ; Stop
	movwf   portb                   
	call    wait_sec                ; Wait approx. 1 Sec
;
	movlw   0C                      ; Forward
	movwf   portb                   
	call    wait_sec                ; Wait approx. 1 Sec 
;
	movlw   0                       ; Stop 5 seconds after forward
	movwf   portb                   
	call    wait_sec_5              ; Wait approx. 5 Sec
;   
	movlw   0D                      ; Anticlockwise
	movwf   portb                   
	call    wait_sec                ; Wait approx. 1 Sec 
;
	movlw   0                       ; Stop
	movwf   portb                   
	call    wait_sec                ; Wait approx. 1 Sec
;
	movlw   0E                      ; Clockwise
	movwf   portb                   
	call    wait_sec                ; Wait approx. 1 Sec
;
	movlw   0                       ; Stop
	movwf   portb                   
	call    wait_sec                ; Wait approx. 1 Sec
;    
	movlw   0F                      ; Backwards
	movwf   portb                   
	call    wait_sec                ; Wait approx. 1 Sec
;              
	movlw   0                       ; Stop
	movwf   portb                   
	call    wait_sec                ; Wait approx. 1 Sec
	goto    start
	
;      
; ----------------------------
; wait subroutines 
; ----------------------------
wait_min
	call    wait_sec_30
	call    wait_sec_30
	return
wait_sec_30
	call    wait_sec_10
	call    wait_sec_10
	call    wait_sec_10
	return
wait_sec_10
	call    wait_sec_5
	call    wait_sec_5
	return
wait_sec_5
	call    wait_sec
	call    wait_sec
	call    wait_sec
	call    wait_sec
	call    wait_sec
	return
wait_sec
	call    wait1
	call    wait1
	return
wait1
	call    wait0
	call    wait0
	call    wait0
	call    wait0
	return
wait0    
	movlw   .200            ; load count1 with decimal 200
	movwf   count1
d1      movlw   .200            ; load count2 with decimal 200
	movwf   count2  
			      
	
d2      decfsz  count2,same     ; decrement and skip next line if zero
	goto    d2              ; if not zero           
	decfsz  count1,same     ; decrement count1 if count2 is zero
	goto    d1              ; do inside loop again if count2 nz
	return
; ----------------------------        
	END