;
;    soft_uim.txt      
;
;--------------------------------------------------------------------
; -------------------------------------
;   
;
;
;
;
;
; -------------------------------------
termotos
  btfss port_m,M_DAT
  goto er_kz
 call term_strt ;  
 btfsc m_flags,m_erd
  goto er_blok ;    
rept_tst
  btfss kd_flags,mark
  goto rept_tst
  bcf kd_flags,mark
   btfss port_m,M_DAT
   goto er_kz
rept_tst_1
  btfss kd_flags,mark
  goto rept_tst_1
  bcf kd_flags,mark
   btfss port_m,M_DAT
   goto er_kz
rept_tst_2
  btfss kd_flags,mark
  goto rept_tst_2
  bcf kd_flags,mark
   btfss port_m,M_DAT
   goto er_kz
 call m_rd9 ;  
 btfsc m_flags,m_erd
  goto er_blok ;    
 call m_crck ;   
 btfsc m_flags,m_ecrc ;   CRC
  goto er_blok2 ;    
 call manus ;   
 call kopy_am ;      
 call drift ;    
 bsf mt_flags,shot ;    
 call divider ;    - 
 bcf mt_flags,shot ;    
 call segmes ;  -        
  ;   
 call dabuf ;   
; -------------------------------------
;     
;    
  movlw t_mk_tmp
  movwf FSR
  movf kd_pos5,w
  call t_mk_transf
  incf FSR,f
  movf kd_pos4,w
  call t_mk_transf
  incf FSR,f
  movf kd_pos3,w
  call t_mk_transf
; -------------------------------------
t_mt_not
 call prepare ;      NJU6432BF/KS0035P
 call w_ksda ;    
rept_tst03
  movlw 0 ;  ,      
  movwf t_mk_rga
  movlw t_mk_rga
  movwf FSR
  call t_mk_trb ;   
 call retime
  t_slot .200
rept_tst3
  btfsc kd_flags,mark
  goto rept_tst31
  btfss PORTA,t_mk_RxD ;      
  goto zahvat ;  mark        zahvat
  goto rept_tst3
rept_tst31
  bcf kd_flags,mark
   btfss port_m,M_DAT
   goto er_kz
rept_tst4
  btfss kd_flags,mark
  goto rept_tst4
  bcf kd_flags,mark
   btfss port_m,M_DAT
   goto er_kz
rept_tst5
  btfss kd_flags,mark
  goto rept_tst5
  bcf kd_flags,mark
   btfss port_m,M_DAT
   goto er_kz
 goto termotos
;
;-----------------------
;      zahvat
zahvat
  btfss PORTA,t_mk_RxD
  goto zahvat ;    
   call t_mt_prep
   call retime
  goto rept_tst4 ;    rept_tst4
;
;--------------------------------------------
;
er_blok2
    btfsc m_flags,m_crcl
    goto shads_e
    movlw 3 ;     = 1+3=4
    movwf m_ercnt
    bsf m_flags,m_crcl
    goto rept_tst_2
shads_e
   decfsz m_ercnt,f
   goto rept_tst_2
   bcf m_flags,m_crcl
er_blok
   ; systems OFF
   btfsc port_m,L_APU
   goto er_kz ;      m_dttc
   bsf port_m,L_APU ;  
mor_0
   btfsc port_m,l_debl ;   
   goto mor_0
   movlw .100
   movwf m_tmp
wmor_0
   decfsz m_tmp,f ; 
mor_1
   btfss port_m,l_debl ;   " "
   goto mor_1
wmor_1
   btfss kd_flags,mark ;    3 
   goto wmor_1
   bcf kd_flags,mark
wmor_2
   btfss kd_flags,mark
   goto wmor_2
   bcf kd_flags,mark
wmor_3
   btfss kd_flags,mark
   goto wmor_3
   bcf kd_flags,mark
  goto hot_init ;      
;
;--------------------------------------------
;   
er_kz
   bsf port_m,L_APU ;  
   ; systems OFF
	 movlw high str_kz
   movwf kd_strn_h
   movlw low str_kz
   movwf kd_strn_l
   call prints
   call er_out ;  'E1 LAn-0' 
kz_stop
   btfss port_m,M_DAT ;   
   goto kz_stop
   goto mor_0 ;    
;
;--------------------------------------------
;  
retime
  bcf T1CON,TMR1ON ;   -
  clrf TMR1L
  clrf TMR1H
  bcf PIR1,TMR1IF
  bsf T1CON,TMR1ON ;   -
 return
;--------------------------------------------
;
;--------------------------------------------
;