Just a quick, but probably tricky question to answer, regarding the difference in the timing length between a couple of commands - this on a 40X2 at setfreq M16. I note timing for the command
has not been described in the Program size Optimization and Speed document of some years ago.
I'm needing to find any speed benefits in a program and was wondering what the timing difference might be between ....
when compared to ....
(this then excludes the need to separately extract the bit value elsewhere as in the first example). INCOMINGBYTE is received over i2c from an 18M2.
Each "if bxx = " command is used only twice (maybe thrice) throughout the program but each "bit" of the incoming byte is extracted for different purposes within its own routine, but how does it compare with the second example, timing-wise, taking into account the timing of the extraction command used in the first example?
I guess the time difference would be quite minimal, but any option to speed the program, however slight, would be an advantage.
Conversely, when compiling the separate conditions into the incoming byte to be sent over i2c - on an 18M2 - are there any more speed efficient methods than using....
Or would it be more overall speed efficient to send each variable separately over i2c and do away with extracting or testing for a bit value at the receive end, as per the first part of the question?
TIA
Code:
IF var BIT value SET THEN
I'm needing to find any speed benefits in a program and was wondering what the timing difference might be between ....
Code:
b1 = INCOMINGBYTE & %00000001
b2 = INCOMINGBYTE & %00000010
b3 = INCOMINGBYTE & %00000100
b4 = INCOMINGBYTE & %00001000
(etc)
.... other code ....
IF b4 = 8 THEN MAIN ;(or some other code)
Code:
IF INCOMINGBYTE BIT 3 SET THEN MAIN
Each "if bxx = " command is used only twice (maybe thrice) throughout the program but each "bit" of the incoming byte is extracted for different purposes within its own routine, but how does it compare with the second example, timing-wise, taking into account the timing of the extraction command used in the first example?
I guess the time difference would be quite minimal, but any option to speed the program, however slight, would be an advantage.
Conversely, when compiling the separate conditions into the incoming byte to be sent over i2c - on an 18M2 - are there any more speed efficient methods than using....
Code:
b0=0 ; reset value
if setting1=1 then : b0=1 : endif ; no 'setbit' command for 18M2
if setting2=1 then : b0=b0+2 : endif
if setting3=1 then : b0=b0+4 : endif
if setting4=1 then : b0=b0+8 : endif
(etc)
TIA