Searching \ for '[PIC]: Fast goto??' 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=pic
Search entire site for: 'Fast goto??'.

Exact match. Not showing close matches.
PICList Thread
'[PIC]: Fast goto??'
2001\04\05@142621 by Roman Black

flavicon
face
Hey I just had a quirky thought, with a PIC the
goto and call instructions take 2 cycles.
All other ops take 1 cycle.

But you can change the program counter, with a
       addwf PCL,f
as done in table reads, etc.

So you can get 1 cycle goto's (fast goto?) by
keeping a set value, say 4 or 8 in the w reg
and replacing the goto commands with addwf pcl,f
commands. Assuming the other instructions don't
change w this will allow quicker bit testing and
branching. Like this:
-----------------------------------------------
(assuming w already contains 4)

       btfss blah,0            ; test the bit
       addwf pcl,f             ; fast goto 1

       (another inst here)     ;
       btfss blah,3            ; test bit 3
       addwf pcl,f             ; fast goto 2

fast_goto_1     (tag not needed)
       (other code here)
-----------------------------------------------

Yes I know it is very limited in scope but it just
happens that i'm doing some fast bit testing and
branching in a current project and this seems a
nifty way of keeping it fast. Please don't hate
me if this is an old idea and well covered in the
piclist archives. :o)
-Roman

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email spam_OUTlistservTakeThisOuTspammitvma.mit.edu with SET PICList DIGEST in the body


2001\04\05@143908 by Bob Ammerman

picon face
{Quote hidden}

Sorry Roman, it won't work:

Instructions with a destination of PCL take an extra cycle, just like a
GOTO. They have to for the same reason gotos do: the PIC prefetches
instructions, and the prefetched instruction is no longer of any use, so the
PIC has to take an extra cycle to fetch the target instruction. Pipelining
is wonderful, except when it isn't.

Bob Ammerman
RAm Systems
(contract development of high performance, high function, low-level
software)

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email .....listservKILLspamspam@spam@mitvma.mit.edu with SET PICList DIGEST in the body


2001\04\05@144607 by uter van ooijen & floortje hanneman

picon face
> So you can get 1 cycle goto's (fast goto?) by
NO
ANY instruction that changes the program counter (call, return, retfie,
goto, computed goto) takes 2 instruction cycles (because it kills the next
instruction that is already halfway executed, and it takes an extra cycle to
get the new next instruction that far).
Wouter

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email listservspamKILLspammitvma.mit.edu with SET PICList DIGEST in the body


2001\04\05@170715 by Olin Lathrop

face picon face
> Hey I just had a quirky thought, with a PIC the
> goto and call instructions take 2 cycles.
> All other ops take 1 cycle.
>
> But you can change the program counter, with a
>         addwf PCL,f

Anything that interrupts sequential program flow takes two cycles because
the pre-fetched instruction has to be discarded.  This includes any
successful SKIP, and (if I understand the architecture correctly) deliberate
modification of PCL.  In other words, I don't think there is a free lunch
here.  Nice try though.


********************************************************************
Olin Lathrop, embedded systems consultant in Littleton Massachusetts
(978) 742-9014, .....olinKILLspamspam.....embedinc.com, http://www.embedinc.com

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email EraseMElistservspam_OUTspamTakeThisOuTmitvma.mit.edu with SET PICList DIGEST in the body


2001\04\06@042220 by Roman Black

flavicon
face
Bob Ammerman wrote:
>
> >
> > But you can change the program counter, with a
> >         addwf PCL,f
> > as done in table reads, etc.
> >
> > So you can get 1 cycle goto's (fast goto?)

> Sorry Roman, it won't work:
>
> Instructions with a destination of PCL take an extra cycle, just like a
> GOTO. They have to for the same reason gotos do: the PIC prefetches
> instructions, and the prefetched instruction is no longer of any use, so the
> PIC has to take an extra cycle to fetch the target instruction. Pipelining
> is wonderful, except when it isn't.

Thanks Bob, and I apologise to the list
for my stupid idea. :o)
-Roman

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


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