Advertisement
buckoka

Calc asm

Sep 21st, 2019
610
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ;-----------
  2. Calc                                            ;p-LastP -> if ( p <= LastP[ix] )
  3.             cmpV16ab    r23, LastP              ;LastP-p -> if ( 0 <= (LastP[ix]-p) )
  4.             bnz         TestRise                ;p==LastP -> if ( p == LastP[ix] )
  5.             movff16     Timestamp, Corr         ; -> Corr[ix]=time
  6.             cmpC16      MinP, r23
  7.             skpnn
  8.             bra         CountDet
  9.             bra         SetLastP                ;;
  10.            
  11. TestRise
  12.             bn          Rise                    ;p>LastP -> else
  13. CountDet
  14.             movf        PressureFall, w, a      ; -> if ( PMinC[ix] < PressureFall )
  15.             cpfslt      PMinC, b
  16.             bra         MkDetect                ; -> else
  17.             incf        PMinC, f, b             ; -> PMinC[ix]+=2
  18.             incf        PMinC, f, b
  19.             bra         SetTMin
  20. MkDetect
  21.             bsf         F_DET                   ; -> F_DET[ix]=1
  22. SetTMin
  23.             movff16     Timestamp, TMin         ; -> TMin[ix]=time
  24.             bra         SetLastP
  25.  
  26. Rise
  27.             btfss       F_DET                   ; -> if ( F_DET[ix] )
  28.             bra         NDet                    ; -> else
  29.             bcf         F_DET                   ; -> F_DET[ix]=0
  30.             clrf        PMinC, b                ; -> PMinC[ix]=0
  31.             btfss       P_FIRST                 ; -> if ( PFirst[ix] )
  32.             bra         SetFirst                ; -> else
  33.             movf        LTMinL, w, b            ;tdiff=2*TMin-2*LTMin+LCorr
  34.             subwf       TMinL, w, b
  35.             movwf       B_PeriodL, b
  36.             movff       LTMinH, WREG
  37.             subwfb      TMinH, w, b
  38.             movwf       B_PeriodH, b
  39.             bcf         STATUS, C, a
  40.             btfsc       L_CORR
  41.             bsf         STATUS, C, a
  42.             rlcf        B_PeriodL, f, b
  43.             rlcf        B_PeriodH, f, b         ;r01=tdiff
  44.            
  45.             movlw       CH_RESET0m
  46.             andwf       B_Valve, f, b           ;clear old valve
  47.             movf        Valve, w, b
  48.             iorwf       B_Valve, f, b
  49.  
  50.             cmpV16bb    Corr, TMin              ;if ( TMin[ix]==Corr[ix] )
  51.             bnz         NCorr                   ; -> else
  52.             movlw       1                       ; -> tdiff--
  53.             subwf       B_PeriodL, f, b
  54.             movlw       0
  55.             subwfb      B_PeriodH, f, b
  56.             bsf         L_CORR                  ; -> LCorr[ix]=1
  57.             bra         CheckMin
  58.  
  59. NCorr          
  60.             bcf         L_CORR                  ; -> LCorr[ix]=0
  61. CheckMin
  62. ;**************
  63.             cmpC16b     Tmin, B_Period          ; -> if ( tdiff > Tmin )
  64.             bnn         NMin
  65.             movlw       low Tmin                ; -> tdiff=Tmin
  66.             movwf       B_PeriodL, b
  67.             movlw       high Tmin
  68.             movwf       B_PeriodH, b
  69. NMin
  70.             movff16     B_Period, r01
  71.             movlw       0f0                     ; -> PressureFall=int(tdiff/8) /2
  72.             andwf       r0, f, a                ; r1H r1L r0H r0L -> r1H r1L r0H 00
  73.             swapf       r0, f, a                ; r1H r1L 00  r0H
  74.             swapf       r1, f, a                ; r1L r1H 00  r0H
  75.             andwf       r1, w, a                ; r1L 00  00  r0H r1L->W
  76.             iorwf       r0, f, a                ;         r1L r0H
  77.             movlw       PressureFallM           ; -> if ( PressureFall < PressureFallMin )
  78.             cpfsgt      r0, a                   ; -> PressureFall=PressureFallMin
  79.             movf        r0, w, a
  80.             movwf       PressureFall, a
  81.            
  82.             movff16     TMin, B_PeriodTimestamp
  83.             bra         SetLTMin
  84.  
  85.  
  86. SetFirst
  87.             bsf         P_FIRST                 ; -> PFirst[ix]=1
  88. SetLTMin
  89.             movff16     TMin, LTMin             ; -> LTMin[ix]=TMin[ix]
  90.             bra         SetLastP
  91. NDet
  92.             movf        PMinC, f, b             ; -> if ( PMinC[ix] )
  93.             bz          SetLastP
  94.             decf        PMinC, f, b             ; -> PMinC[ix]--
  95. SetLastP
  96.             movff16     r23, LastP              ; -> LastP[ix]=p
  97. ;-----------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement