
Originally Posted by
The Master
... In this case the multiple if statements are required.
I have my doubts about that.
Multiple IF statements usually just means Spaghetti.
How would i go about doing the ASM macro thing?
Well, here's one way ...
Code:
;---------------------------------------------------------------------------
ASM
IfEqual macro Bin, Cin, Lin ; Bin is a BYTE variable
RST?RP ; Cin is a constant to campare against
movlw Cin ; Lin is a label to jump to ...
subwf _vPWMPos,w ; if the condition is false
btfsc STATUS, Z
goto Lin
endm
ENDASM
;-----[Here's how you use it]----------------------------------------------
@ IfEqual _vPWMPos, 1, _L1
; code here executes if _vPWMPos = 1
L1:
@ IfEqual _vPWMPos, 2, _L2
; code here executes if _vPWMPos = 2
L2:
In most cases, it will take 4-5 instructions.
But care must be taken to insure it doesn't cross a Page Boundary.
I still think you'll be better off using BRANCH.<hr>
I think this would probably work "pin = (pinValue=PWMPos)" but i wonder if that would get compiled to the same kind of code as an if statement.
That way only works if you can use the inverse of the result ...
Code:
myPIN = !(pinValue = vPWMPos)
Of course, the inverse of that is ...
Code:
myPIN = !(pinValue != vPWMPos)
Bookmarks