;*******************************
;Stepper Motor.asm
;    
;30,11,2016

;*******************************


  
   __config  0F94

start
      bcf   05H,5 ;  0
      MOVLW   0X07     ;  
      MOVWF   19H 
      MOVLW B'00000000'
      MOVWF 05H;  0  
      BSF   03h,5;1 
      
      MOVLW B'00001001'
      MOVWF 85H ;   
      MOVLW B'01100000'
      MOVWF 9FH;  ANSEL --     
      MOVLW B'00010101'
      MOVWF 8FH; 125  
      MOVLW B'01111111'
      MOVWF 81H ;  
      MOVLW B'00000001'
      MOVWF 95H;  7  
      BCF   03H,5;0  
begin MOVLW B'11111111'
      MOVWF 20H ; 255   20h
      MOVLW B'00000110';      ! 
      MOVWF 21H ; 255   21h
      btfss 05h,0 ; GP0
      goto kn1
      goto kn2
kn1   btfss 05h,3;  GP3
      goto begin
      goto kn4
kn2   btfss 05h,3;  GP3
      goto kn3 
      goto begin
kn4   btfss 05h,3 ; GP3;      
      goto time1
      goto kn4
     
kn3   btfss 05h,0 ; GP0;      
      goto time2
      goto kn3
niz
      bsf 05h,1 
      call time
      bcf 05h,1
      bsf 05h,2
      call time
      bcf 05h,2
      bsf 05h,4
      call time   
      bcf 05h,4
      bsf 05h,5
      call time 
      bcf 05h,5 
      call sec
      btfss 05h,3 ; GP3  
      goto begin
      goto niz
verx
      bsf 05h,5
      call time
      bcf 05h,5
      bsf 05h,4
      call time
      bcf 05h,4
      bsf 05h,2
      call time   
      bcf 05h,2
      bsf 05h,1
      call time 
      bcf 05h,1
      call sec
      btfss 05h,0 ; GP0
      goto begin
      goto verx
time
      MOVLW .4 ; 35        
      MOVWF 25H; 35  25 
GEN_1
      MOVLW .4; 35              
      MOVWF 24H ; 35   24H 
GEN_2 
      DECFSZ 24H,F;   1
      GOTO GEN_2 ;   24
      DECFSZ 25H,F;  25
      GOTO GEN_1 ;   0.5  
      RETURN
sec   
      decfsz 20h,1  
      return 
      decfsz 21h,1
      return
      goto stop
time1 MOVLW B'11111111'
      MOVWF 26H ; 255   26h
w1    decfsz 26h,1
      goto w1
      btfss 05h,3 ; GP3   
      goto time1
      goto niz
time2 MOVLW B'11111111'
      MOVWF 26H ; 255   26h
w2    decfsz 26h,1
      goto w2
      btfss 05h,0 ; GP0   
      goto time2
      goto verx
stop  goto stop1
stop1 goto stop 
      end