The technique really depends on what you want to do with the lower two bits of save. Do you want to branch on a condition or use it as a number between 0-3?
Branching:
btfsc save, 0
goto Set
btfsc save, 1
goto Set
goto NeitherSet
Getting value of bits 0&1:
movf save, W
andlw B'00000011'
;Value of lower bits of save now in W.
the issue is if the number is 11 then your stuck :
Code:
btfsc save, 0
;Set flag1
btfsc save, 1
;Set flag2
;test both flags if none are set then its 00
;if flag 1 is set but flag2 isnt it was a 01
;if flag 1 isnt set and flag2 is then it is 10
;if both flags are set then it was 11
It really depends on what be80be wants to test for:
My example only tested if either one or the other bit was set hence the statement goto NeitherSet at the end. To test for any value you could just do something like this:
#define TestValue 2
movf save, W
andlw B'00000011'
sublw TestValue
btfsc STATUS, Z
goto Match
If it's 01 then it will keep checking if becomes 00 it will it goto. I get it now What i haven't been doing is movf save, w is it better to define TestValue then to set it in cblock or do thay do the same thing I always just used define for like port pins Thank you both this has help a lot. What I'm trying to do is If the last bits become 00 then act on that till thay become 01 say I first put b'00000000' in save my input is high so when it is reads it it will change the last bit to a 1 then if it gos back to 00
In my code example you have to use #define because sublw will only accept a literal (constant) and not a variable (GPR). To use a variable you would have to use subwf variable, W instead.
If it's 01 then it will keep checking if becomes 00 it will it goto.