![]() | ![]() | ![]() |
| |||||||
| Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc. |
![]() |
| | Tools |
| | #1 |
|
I was looking at the PIC instruction set and could not find the equivalent of a Branch on Less Than or Branch on Greater Than that I have found in other assembly languages. Does this instruction not exist for the PIC microprocessors, if so, how do you recommend I circumvent the problem of not being able to use the BLT instruction.
| |
| |
| | #2 |
|
You use the carry flag instead, but the subtract instructions are a bit weird. Sublw 5 does not subtract 5 from W - it subtracts W from 5. So, you can do, Code: sublw 5
btfss STATUS,C
goto W_was_greater_than_5
Last edited by Pommie; 13th June 2007 at 01:02 AM. | |
| |
| | #3 |
|
That's very interesting. I'm a little new to flags, do I have to reset that carry flag if I want to use it in another later similar scenario?
| |
| |
| | #4 |
|
The subtract instruction will set OR clear the flag depending on the result of the subtract. Therefore the state of the carry flag doesn't matter before the subtract instruction executes. | |
| |
| | #5 | |
| Quote:
__________________ Inside every little problem, is a big problem trying to get out. | ||
| |
|
| Tags |
| branch |
| Thread Tools | |
| Display Modes | |
| |
Similar | ||||
| Title | Starter | Forum | Replies | Latest |
| Readily Available 8ch, 10-12bit A/D | buurin | General Electronics Chat | 37 | 29th September 2006 04:23 PM |
| carry and digit carry definition | max_imum2000 | General Electronics Chat | 6 | 8th May 2006 05:40 PM |
| obvious questions..... | madmikejt12 | General Electronics Chat | 21 | 7th October 2005 09:26 PM |
| Just Joined, Got some bugs I can't find. | Thedoctorisin136 | Micro Controllers | 0 | 1st March 2005 07:07 PM |