Hi there. Hope I can help you. Here an example:
E1. Test LSB and increment counter if zero:
bt list, LSB
jc odd
inc count
odd:
E2. Set first as VAL and compare with NEXT, replace if necessary:
cmp NEXT, VAL
jae nomin
mov VAL, NEXT
nomin:
E3. Time2 - Time1 and +12 if negative:
sub TIM2, TIM1
jp past
add TIM2, 12
past:
btr TIM2, 0
E4. Average is (high - low) / 2 and difference (normall - actual):
sub NHI, NLO
div NHI, 2
mov AVN, NHI
sub AHI, ALO
div AHI, 2
mov AVA, AHI
sub AVN, AVA
Feel free to mail me, if you have any questions.
Thank you in advance.