;
;      
;      enk_prog_1.txt
;
;   -
;       
;   
;
;        
;
;       
;      -
;
;-----------------------------------------
s_rled
   bcf tmpo,r_led
   bsf tmpo,l_led
   movf tmpo,w
   movwf GPIO
  goto sel0_r
g_clc_r
   btfsc flags,flg_f
   goto sel1_r
   bsf flags,flg_f
  call g_clko
 goto sel1_r
;-----------------------------------------
s_lled
   bcf tmpo,l_led
   bsf tmpo,r_led
   movf tmpo,w
   movwf GPIO
  goto sel0_l
g_clc_l
   btfsc flags,flg_f
   goto sel1_l
   bsf flags,flg_f
  call g_clko
 goto sel1_l
;-----------------------------------------
g_clko
   bcf tmpo,clock
   movf tmpo,w
   movwf GPIO
;   nop ;    
;   nop
   movlw .90 ;    
   movwf wtm_ct0 ;  wtm_ct0
t_clk
   decfsz wtm_ct0,f
  goto t_clk
   bsf tmpo,clock
   movf tmpo,w
   movwf GPIO
  retlw 0
;-----------------------------------------
start
   movf GPIO,w
   andlw masi
   movwf masr
   swapf masr,w
   addwf PCL,f
   goto hard_error ; 00    
   goto sel0_r ; 01
   goto sel0_l ; 10     00100,   00200?
   goto start ; 11
sel0_r
   movf GPIO,w
   andlw masi
   movwf masr
   swapf masr,w
   addwf PCL,f
   goto g_clc_r ; 00
   goto s_rled ; 01
   goto hard_error ; 10    
   goto start2 ; 11
sel1_r
   movf GPIO,w
   andlw masi
   movwf masr
   swapf masr,w
   addwf PCL,f
   goto sel1_r ; 00
   goto sel0_r ; 01
   goto sel2_r ; 10
   goto hard_error ; 11    
sel2_r
   movf GPIO,w
   andlw masi
   movwf masr
   swapf masr,w
   addwf PCL,f
   goto sel1_r ; 00  
   goto hard_error ; 01    
   goto sel2_r ; 10   
  goto start2 ; 11   
;-----------------------------------------
sel0_l
   movf GPIO,w
   andlw masi
   movwf masr
   swapf masr,w
   addwf PCL,f
   goto g_clc_l ; 00
   goto hard_error ; 01    
   goto s_lled ; 10
   goto start2 ; 11
sel1_l
   movf GPIO,w
   andlw masi
   movwf masr
   swapf masr,w
   addwf PCL,f
   goto sel1_l ; 00
   goto sel2_l ; 01
   goto sel0_l ; 10
   goto hard_error ; 11    
sel2_l
   movf GPIO,w
   andlw masi
   movwf masr
   swapf masr,w
   addwf PCL,f
   goto sel1_l ; 00  
   goto sel2_l ; 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
   movlw 0xFF
   movwf GPIO
   movwf tmpo
   movlw masi
   iorlw 8
   tris 6
   clrf flags
wait_sp
   movf GPIO,w
   andlw masi
   xorlw masi
   btfss STATUS,Z
   goto wait_sp ;    
   ;  -       
   ;  
   ;  -        
   ;  (      "-")
  goto start
;