Searching \ for '[PIC]: 18F program flow control question' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/microchip/devices.htm?key=18F
Search entire site for: '18F program flow control question'.

Exact match. Not showing close matches.
PICList Thread
'[PIC]: 18F program flow control question'
2002\12\17@165851 by Josh Koffman

flavicon
face
Ok, odd subject, admittedly. I'm a bit confused by the various methods
of program control on the 18F. On the 16F it's easy, GOTO and CALL. But
with the 18F there's now BRA (Branch) and RCALL as well. Here is my
(likely wrong) understanding. GOTO and CALL use the full addressing,
which BRA and RCALL are sort of relative to the current PC value. As I
don't truly understand everything about the PC and it's cronies, I'm
likely wrong. In general though, what would be prefereable to use, say
in an ISR? I know not to use CAll or RCALL unless there will be a return
somewhere, but in an ISR is there an advantage to using BRA over GOTO
(in a small program anyways)?

Thanks,
Josh
--
A common mistake that people make when trying to design something
completely foolproof is to underestimate the ingenuity of complete
fools.
       -Douglas Adams

--
http://www.piclist.com hint: To leave the PICList
spam_OUTpiclist-unsubscribe-requestTakeThisOuTspammitvma.mit.edu>

2002\12\17@185155 by Dr Martin Hill

flavicon
face
As far as I know, the difference is that CALL and GOTO are longer
instructions and take up more memory space than RCALL and BRA, but can jump
or call to anywhere in the memory space whereas RCALL and BRA can only go to
somewhere close to the start point.  If your code is small you should be
able to use RCALL and BRA all the time.

As far as I know, that's the only difference.  Could well be wrong though
:-)

Martin


{Original Message removed}

2002\12\18@052712 by Kari Lehikko

flavicon
face
I always write the code with BRA and RCALL and change the commands to
GOTO and CALL if linker reports that the jump is too long for the
shorter commands.

- K

Josh Koffman wrote:
>
> Ok, odd subject, admittedly. I'm a bit confused by the various methods
> of program control on the 18F. On the 16F it's easy, GOTO and CALL. But

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads

2002\12\18@055953 by cdb

flavicon
face
Bra can branch within +/- 64 of words of instruction
goto can go anywhere

Bra can also be used like an IF Break function

if test==0
{
 do this
}
Break; // flip to Finish      Bra goes here
if test==1
{
do something else
}

Finish:
return

       bc  DoSomethingElse

DoThis
   {
    -----
    -----
    bra Finish
   }

DoSomeThingElse
  {
    ------
   ------
  ------
 }
Finish

Colin

cdb, .....bodgy1KILLspamspam@spam@optusnet.com.au on 18/12/2002

Light travels faster than sound. That's why some people appear bright
until they speak!

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads

2002\12\18@075030 by Olin Lathrop

face picon face
> Ok, odd subject, admittedly. I'm a bit confused by the various methods
> of program control on the 18F. On the 16F it's easy, GOTO and CALL.

And the various SKIPs, and direct writes to PCL.

> But
> with the 18F there's now BRA (Branch) and RCALL as well. Here is my
> (likely wrong) understanding. GOTO and CALL use the full addressing,
> which BRA and RCALL are sort of relative to the current PC value.

Not sortof, they *are* relative to the PC.

> As I
> don't truly understand everything about the PC and it's cronies, I'm
> likely wrong. In general though, what would be prefereable to use, say
> in an ISR? I know not to use CAll or RCALL unless there will be a return
> somewhere, but in an ISR is there an advantage to using BRA over GOTO
> (in a small program anyways)?

BRA is preferable if the target is within the +-2Kbyte range.  Generally,
use BRA and RCALL within a module, and GOTO and CALL between modules.  If
the BRA or RCALL target is out of range, the assembler will let you know.


*****************************************************************
Embed Inc, embedded system specialists in Littleton Massachusetts
(978) 742-9014, http://www.embedinc.com

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads

2002\12\18@082708 by Olin Lathrop

face picon face
> Bra can branch within +/- 64 of words of instruction

Where did you get this bit of "wisdom" from!?

The BRA instruction contains 11 bits of signed offset, so it's range is
+-1K instructions or +-2K bytes.  The conditional branch instructions like
BC contain an 8 bit signed offset, so have a range of about +-128
instructions.

This is all quite clear and easy to find in the manual.


*****************************************************************
Embed Inc, embedded system specialists in Littleton Massachusetts
(978) 742-9014, http://www.embedinc.com

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads

2002\12\18@155157 by cdb

flavicon
face
Actually the Microchip program instruction states +/- 64 one word
instructions
--
cdb, bodgy1spamKILLspamoptusnet.com.au on 19/12/2002

Light travels faster than sound. That's why some people appear bright
until they speak!

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads

2002\12\18@160648 by Jan-Erik Soderholm

face picon face
>Actually the Microchip program instruction states +/- 64 one word
>instructions
>--
>cdb, .....bodgy1KILLspamspam.....optusnet.com.au on 19/12/2002


Well, it depends.

BC, BN, BNC, BNN, BNOV, BNZ, BOV  :   -128 to +127 words
BRA                               :  -1024 to +1023 words
RCALL                             :  -1024 to +1023 words
CALL                              :  any address
GOTO                              :  any address



Jan-Erik Svderholm
S:t Anna Data

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads

More... (looser matching)
- Last day of these posts
- In 2002 , 2003 only
- Today
- New search...