Yes, it will reduce the number of instruction cycles in your example.
Given that you are only extracting 3 digits of your DISPFREQ variable, Algorithm #2 will be faster.
Assuming you are using PBPW not PBPL here are the instruction cycles results.
Using the DIG method: 7606 Inst Cycles
Using Algorithm #2: 7293 Inst Cycles
That is a savings of 313 instruction cycles. If you are running a 4Mhz Fosc/4 MCU then that would be a 313us savings.
Though it is a small savings on cycles and time, it does come at a cost of 3 extra byte variables to hold the values.
Here are the two code options tested.
Code:tmpDig0 var byte tmpDig1 var byte tmpDig2 var byte DISPFREQ var byte LINE2 con $c0 DISPFREQ = 1234 'Start Stopwatch in MPLAB Simulator LCDOUT $FE,LINE2,"FREQ ",DEC DISPFREQ DIG 2,DEC DISPFREQ DIG 1,",",DEC DISPFREQ DIG 0, " KHz " 'Stop Stopwatch in MPLAB Simulator 'Output: FREQ 23,4 KHz 'Start Stopwatch in MPLAB Simulator tmpDig0 = DISPFREQ // 10 tmpDig1 =DISPFREQ / 10 tmpDig1 = tmpDig1 // 10 tmpDig2 = DISPFREQ / 100 tmpDig2 = tmpDig2 // 10 LCDOUT $FE,LINE2,"FREQ ",DEC tmpDig2,DEC tmpDig1,",",DEC tmpDig0, " KHz " 'Stop Stopwatch in MPLAB Simulator 'Output: FREQ 23,4 KHz




Bookmarks