;
;      
;      enk_prog_1.txt
;
;   -
;       
;   
;
;        
;
;       
;      -
;
;-----------------------------------------
g_clc_r
   btfsc flags,flg_f
   goto sel1_r
   bcf tmpo,r_clock
   call gclk
 goto sel1_r
;-----------------------------------------
g_clc_l
   btfsc flags,flg_f
   goto sel1_l
   bcf tmpo,l_clock
   call gclk
 goto sel1_l
;-----------------------------------------
gclk
   movf tmpo,w
   movwf GPIO
   bsf flags,flg_f
;   nop ;      2 NOP
;   nop
   movlw mark ;    
   movwf wtm_ct0 ;  wtm_ct0
t_clk
   decfsz wtm_ct0,f
  goto t_clk
   movlw 0xFF
   movwf tmpo
   movwf GPIO
  retlw 0
;-----------------------------------------
start
   inkey
   goto hard_error ; 00    
   goto sel0_l ; 01     l_key
   goto sel0_r ; 10     r_key
   goto start ; 11   
sel0_l
  inkey
   goto g_clc_l ; 00   
   goto sel0_l ; s_lled 01       
   goto hard_error ; 10    
   goto start2 ; 11      
            ;       
sel1_l
  inkey
   goto sel1_l ; 00       
              ;  
   goto sel0_l ; 01  
   goto sel2_l ; 10   
   goto hard_error ; 11    
sel2_l
  inkey
   goto sel1_r ; 00  
   goto hard_error ; 01    
   goto sel2_l ; 10   
  goto start2 ; 11   
;-----------------------------------------
sel0_r
  inkey
   goto g_clc_r ; 00
   goto hard_error ; 01    
   goto sel0_r ; s_rled 10
   goto start2 ; 11
sel1_r
  inkey
   goto sel1_r ; 00
   goto sel2_r ; 01
   goto sel0_r ; 10
   goto hard_error ; 11    
sel2_r
  inkey
   goto sel1_r ; 00  
   goto sel2_r ; 01   
   goto hard_error ; 10    
start2
   clrf flags ; 11        
   comf flags,w ;  
   movwf tmpo ;    
   movwf GPIO
  goto start
;-----------------------------------------
;     
;  ""   
hard_error
   movlw 0xFF
   movwf GPIO
   movwf tmpo
  goto wait_sp
;-----------------------------------------
hs_init
   movlw (0xFF-(1<<T0CS))
   option ;    GP2 
   movlw 0xFF
   movwf GPIO
   movwf tmpo
   movlw masi
   iorlw (0xFF-(1<<r_clock | 1<<l_clock)
   tris 6
   clrf flags
wait_sp
   movf GPIO,w
   andlw masi
   xorlw masi
   btfss STATUS,Z
   goto wait_sp ;    
   ;  -       
   ;  
   ;  -        
   ;  (      "-")
  goto start
;