Would like to ask if you guys mind giving me an idea on what are the instructions that I can "play" with if I intend to perform some comparison in my programme. Then, I will try to sort out how to make use of them? But of course it would be great if you don't mind giving me an example on how do I perform comparisons :) It seems that other microcontrollers, they have instructions such as Branch If Smaller Than, Branch If Bigger Than and so on. Just like the HC11. Am I right to say that I can "play" with BTSFC and BTFSS for comparison purposes? Any advice? Erm...any example? Please? :) Thank You... |
|
Comparison Instructions in PIC
Only one way:
do a signed subtraction, then excamine the result ( negative-0-positive). You can use the BIT testing instructions in the way instructions you mention, but depending on processor there may be others....like BranchNeg, BranchZero..and so on. In the 16 series the skpz and skpnz and others could be used....nowhere near as simple as in many other controllers. devonsc wrote:
--
| |||
| |||
| |||
|
There is a rather complete series of 'Special Instruction Mnemonics' that perform various tests and branch-on-condition. These mnemonics often generate two instructions and help make the code more understandable. B Branch BC Branch on Carry BDC Branch on Digit Carry BNC Branch on No Carry BNDC Branch on No Digit Carry BNZ Branch on No Zero BZ Branch on Zero SETC Set Carry SETDC Set Digit Carry SETZ Set Zero SKPC Skip on Carry SKPDC Skip on Digit Carry SKPNC Skip on No Carry SKPNDC Skip on No Digit Carry SKPNZ Skip on Non Zero SKPZ Skip on Zero So, something like this will work: <some test that modifies the Z flag> BNZ Label ... ... ... Label Of course, you can always make up your own comparison and branch macros. This can be helpful for word sized operands. --- In , Eirik Karlsen <eikarlse@o...> wrote: > Only one way: > do a signed subtraction, then excamine the result ( > negative-0-positive). > You can use the BIT testing instructions in the way instructions you > mention, > but depending on processor there may be others....like BranchNeg, > BranchZero..and so on. > In the 16 series the skpz and skpnz and others could be used....nowhere > near as simple as > in many other controllers. > > devonsc wrote: > > > > > Would like to ask if you guys mind giving me an idea on what are the > > instructions that I can "play" with if I intend to perform some > > comparison in my programme. Then, I will try to sort out how to make > > use of them? But of course it would be great if you don't mind giving > > me an example on how do I perform comparisons :) It seems that other > > microcontrollers, they have instructions such as Branch If Smaller > > Than, Branch If Bigger Than and so on. Just like the HC11. > > > > Am I right to say that I can "play" with BTSFC and BTFSS for > > comparison purposes? Any advice? Erm...any example? Please? :) > > > > Thank You... > > > > > > > > > > > > to unsubscribe, go to http://www.yahoogroups.com and follow the > > instructions > > > > > > > [click here] > > > > > ------------------------- -- > > Yahoo! Groups Links > > > > * To > > > -- > ******************************************* > VISIT MY HOME PAGE: > <http://home.online.no/~eikarlse/index.htm> > LAST UPDATED: 23/08/2003 > ******************************************* > Regards > Eirik Karlsen |
This is an extremely nice page about comparisons http://homepage.ntlworld.com/matthew.rowe/micros/virbook/logic.htm Peter van Hoof --- devonsc <> wrote: > > Would like to ask if you guys mind giving me an idea > on what are the > instructions that I can "play" with if I intend to > perform some > comparison in my programme. Then, I will try to sort > out how to make > use of them? But of course it would be great if you > don't mind giving > me an example on how do I perform comparisons :) It > seems that other > microcontrollers, they have instructions such as > Branch If Smaller > Than, Branch If Bigger Than and so on. Just like the > HC11. > > Am I right to say that I can "play" with BTSFC and > BTFSS for > comparison purposes? Any advice? Erm...any example? > Please? :) > > Thank You... > > |
|