PDA

View Full Version : ASM Help



fbraun
- 11th October 2007, 02:58
Hello All
Need to speed up some PBP instructions. Can anyone help with the ASM equivalents for the following:
if CTPeriod = 1 then PulseCount1 = PulseCount1 + 1 ;increment pulse counter
if CTPeriod = 2 then PulseCount2 = PulseCount2 + 1 ;increment pulse counter
if CTPeriod = 3 then PulseCount3 = PulseCount3 + 1 ;increment pulse counter

where:
CTPeriod = byte
PulseCount1,PulseCount2 and PulseCount3 = words

The PIC I'm using is a 18F2525

Thanks

Jerson
- 11th October 2007, 05:08
if CTPeriod = 1 then PulseCount1 = PulseCount1 + 1 ;increment pulse counter



decfsz _CTPeriod ; if CTPeriod == 1, this decrement will make it zero
goto Check2
incf _PulseCount1 ; increase the LSB
btfsc STATUS,Z ; if LSB == 0
incf _PulseCount1+1 ; increase the MSB
return
Check2:
decfsz _CTPeriod ; if CTPeriod == 2, this decrement will make it zero
goto Check3
incf _PulseCount2 ; increase the LSB
btfsc STATUS,Z ; if LSB == 0
incf _PulseCount2+1 ; increase the MSB
return
Check3:
decfsz _CTPeriod ; if CTPeriod == 3, this decrement will make it zero
goto Check4
incf _PulseCount3 ; increase the LSB
btfsc STATUS,Z ; if LSB == 0
incf _PulseCount3+1 ; increase the MSB
return
Check4:;CT_Period is greater than 3
; do something here
return


Disclaimer : Unverified code.

fbraun
- 11th October 2007, 16:05
Thank you for the code.