The separate IF/THEN "templates" make it quicker.
When you have multiple AND's/OR's/XORNOT's etc. on the same line, then intermediate variables (T1+) are used to keep track of each "Term".
And T1+ variables are WORDs (LONGs for PBPL).
So while it looks shorter in the code listing, it really takes longer.<hr>
Well, I was trying to keep it straight PBP.
Which is why the previous example only got a "FASTer" rating.
But, if you want the "FASTest", ya gotta drop down to ASM with bank0/system variables.
Code:
val1 VAR WORD BANK0 SYSTEM
val2 VAR WORD BANK0 SYSTEM
ASM
movf val1+1, W
subwf val2+1, W
btfss STATUS, Z
goto NotEqual
movf val1, W
subwf val2, W
btfss STATUS, Z
goto NotEqual
L?GOTO _UserRoutine ; val1 = val2
NotEqual
ENDASM
UserRoutine:
;... yadda yadda ...
Of course, someone will probably find a "FASTest.er" way ... I hope. <hr>
ADDED:
The above can only be used once without modification.
But if you turn it into a Macro, it can be used multiple times, with different variables. (as long as they're in bank0)
Code:
val1 VAR WORD BANK0 SYSTEM
val2 VAR WORD BANK0 SYSTEM
ASM
DT_EQUAL macro v1, v2, label
local NotEqual
movf v1+1, W
subwf v2+1, W
btfss STATUS, Z
goto NotEqual
movf v1, W
subwf v2, W
btfss STATUS, Z
goto NotEqual
L?GOTO label ; v1 = v2
NotEqual
endm
ENDASM
;--- usage -------------------------
@ DT_EQUAL val1, val2, _UserRoutine ; IF val1 = val2 THEN UserRoutine
UserRoutine:
;... yadda yadda ...
hth,
Bookmarks