;
;         "lb_ext_disp.txt"      
;
;------------------------------------------------------------
;
WDT_off:
      wdr
        ; Clear WDRF in MCUSR
      in tmp0,MCUSR
      cbr tmp0,(1<<WDRF)
      out MCUSR,tmp0
        ; Write logical one to WDCE and WDE
        ; Keep old prescaler setting to prevent unintentional Watchdog Reset
      in  tmp0,WDTCSR
      ori tmp0,(1<<WDCE)|(1<<WDE)
      out WDTCSR,tmp0
        ; Turn off WDT
      cbr tmp0,(1<<WDE)
      out WDTCSR,tmp0
    ret
;------------------------------------------------------------
;    bfr1:bfr0,   
; rdbf+0=, rdbf+1=, rdbf+2=, rdbf+3=
; rdbf+5=  ( )
bin_dec:
	push tmp0
  push tmp1
  push tmp3
 x10t:
   ldi tmp1,high(10000)
   ldi tmp0,low(10000)
  rcall xt_rept
   sts (dp_rdbf+4),tmp3
 x1t:
   ldi tmp1,high(1000)
   ldi tmp0,low(1000)
  rcall xt_rept
   sts (dp_rdbf+3),tmp3
 x10d:
   clr tmp1
   ldi tmp0,100
  rcall xt_rept
   sts (dp_rdbf+2),tmp3
 x1d:
   ldi tmp0,10
   clr tmp3
  xt_b:
    inc tmp3
    sub bfr0,tmp0
    brcc xt_b
    add bfr0,tmp0
    dec tmp3
  sts (dp_rdbf+1),tmp3
  sts dp_rdbf,bfr0
	pop tmp3
	pop tmp1
	pop tmp0
 ret
;----------------------
xt_rept:
   clr tmp3
 xt_a:
    inc tmp3
    sub bfr0,tmp0
    sbc bfr1,tmp1
    brcc xt_a
   add bfr0,tmp0
   adc bfr1,tmp1
   dec tmp3
  ret
;
;------------------------------------------------------------
;
bin_seg:
  push tmp0
  push zl
  push zh
  push xl
  push xh
  ldwi x,dp_rdbf
 rcall sg_rept ; x1
 rcall sg_rept ; x10
 rcall sg_rept ; x100
 rcall sg_rept ; x1000
  pop xh
  pop xl
  pop zh
  pop zl
  pop tmp0
 ret
;----------------------
sg_rept:
   ldwi z,znak
   ld tmp0,x
   add zl,tmp0
   brcc sg_rt0
   inc zh
 sg_rt0:
   lsl zl
   rol zh
   lpm tmp0,z
   st x+,tmp0
  ret
;
;------------------------------------------------------------
;