Searching \ for '[PIC]: ADDWF PCL,F' 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: 'ADDWF PCL,F'.

Exact match. Not showing close matches.
PICList Thread
'[PIC]: ADDWF PCL,F'
2004\01\06@121523 by PSL

picon face
Hi all
Can any one please enlighten me on this

how many cycle does   ADDWF PCL,F
takes? is it 2 cycles like goto or is it 1 cycle?

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

2004\01\06@125111 by Hopkins

flavicon
face
1 cycle shown in the section 29 instruction set of the Mid Range Reference
manual

*************************************************

Roy Hopkins

.....rdhopkinsKILLspamspam@spam@ihug.co.nz

*************************************************
Hi all
Can any one please enlighten me on this

how many cycle does
 ADDWF PCL,F
takes? is it 2 cycles like goto or is it 1 cycle?




---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.558 / Virus Database: 350 - Release Date: 2/01/2004

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

2004\01\06@130520 by

picon face
PSL wrote :
> how many cycle does
>   ADDWF PCL,F
> takes? is it 2 cycles like goto or is it 1 cycle?


*Any* instruction that modifies
the PCL takes 2 cycles, what ever the
data sheet says...

Jan-Erik.

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

2004\01\06@131347 by Herbert Graf

flavicon
face
> Hi all
> Can any one please enlighten me on this
>
> how many cycle does
>   ADDWF PCL,F
> takes? is it 2 cycles like goto or is it 1 cycle?

       Correct me if I'm wrong, but any instruction that modifies PCL takes two
instructions since the pipeline has to be flushed. TTYL

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

2004\01\06@134940 by Andrew Warren

flavicon
face
Hopkins <PICLISTspamspam_OUTmitvma.mit.edu> wrote:

> 1 cycle shown in the section 29 instruction set of the Mid Range
> Reference manual

   Yes... In general, it's true that ADDWF takes one cycle.
   However, an ADDWF (or any other write instruction) with PCL as
   its destination requires two cycles.

   -Andy

=== Andrew Warren -- @spam@aiwKILLspamspamcypress.com
=== Principal Design Engineer
=== Cypress Semiconductor Corporation
===
=== Opinions expressed above do not
=== necessarily represent those of
=== Cypress Semiconductor Corporation

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

2004\01\06@142430 by Charles Craft

picon face
[OT]

Interesting story on CNBC today about your CEO's winemaking hobby. Pretty impressive tunnels.
Nice stock runup over the past year as well. Wow!

{Original Message removed}

2004\01\06@142841 by PSL

picon face
Oic

anyway is there any restriection in where this instruction can be use in
creating a jump table.
I know one of it is that the jump table should be with in 256 bytes(0x0000
to 0x0100) as by doing ADDWF PCL,F
we are doing a change at a max of 256.
i try the table on 0x0200 it does not work(16f876)
can any one enlighten me why?


thanks
{Original Message removed}

2004\01\06@142842 by

picon face
> Hopkins <RemoveMEPICLISTTakeThisOuTspammitvma.mit.edu> wrote:
>
> > 1 cycle shown in the section 29 instruction set of the Mid Range
> > Reference manual


And to make it even worse, in table 29-1 on page
29-3 in the same manual, there is a "note 3" that says
that "If the PCL is modified, the instruction takes 2 cycles".
*But* note 3 is only marked on the 4 skip instructions,
even if it is actualy valid for *any* instruction that
*could* modify the PCL...

Jan-Erik.

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

2004\01\06@144526 by

picon face
PSL wrote:

> anyway is there any restriection in where this instruction
> can be use in creating a jump table.
> I know one of it is that the jump table should be with in 256
> bytes(0x0000 to 0x0100) as by doing ADDWF PCL,F
> we are doing a change at a max of 256.
> i try the table on 0x0200 it does not work(16f876)
> can any one enlighten me why?


Hi.
Download and read application note AN556 from Microchip.
The text does pretty well describes "table reades" with
"computed goto's", but the code examples has some errors,
so use them with care. :-)

Jan-Erik.
PS.
You seems to have a erratic shift key on your keyboard, it
doesn't work at the beginning of a new sentence...

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

2004\01\06@162540 by Steve Smith

flavicon
face
That's because the addition to PCL is 8 bit and the high bits aren't
managed properly(16xx doesn't have 16 bit add command) you need to
increment PCLATH for the next section of the table (I only found this
out last weekend) There is a good worked example in the techref at
piclist.com. The basic understanding I got from the list (thanks David
and Jan-erik Olin and others) is that the addwf pcl is limited to 8 bits
but a direct goto is 11 bits and PCLATH 3,4 are the page bits. This
leaves bits 0-3 of PCLATH which need to be set according to the page
location on computed (addwf PCL,F)jump. Hence a table that starts at
0800h is called after setting PCLATH,3 to 1 and the continuation of the
table past 0900H requires a conditional incf PCLATH,f to continue the
table past the first 256b

Below is the example sent to me that helped lots and the link to the
techref I am no expert but the following code helped lots
Steve....

Surprisingly hard to get a straight answer.  However, assuming you are
using the 16F series, have a look at the PICLIST archives at:
http://www.piclist.com/techref/microchip/tables.htm

Here is one of the code snippets:

       fcall    Table
; will be returned here with data in W.



       ; Tony Nixon
       ; plus tweak from Dmitry Kiryashov [zews at AHA.RU]
Table   movlw High(TStart)
       addwf OffsetH,W
       movwf PCLATH
       movlw Low(TStart)
       addwf OffsetL,W
       skpnc
         incf PCLATH,F

       movwf   PCL     ;computed goto with right PCLATH
       ; end of Table subroutine.


       ; ...
       ;
       org 0x????
TStart  Retlw d'0'
       Retlw d'255'
       Retlw d'9'
       ....
       etc


As you can see, you have to account for when you roll over the 256
boundary on the address, and correct the PCLATH.

David

{Original Message removed}

2004\01\06@165652 by Bob Axtell

face picon face
Steve Smith wrote:

> That's because the addition to PCL is 8 bit and the high bits aren't
> managed properly(16xx doesn't have 16 bit add command) you need to
> increment PCLATH for the next section of the table (I only found this
> out last weekend) There is a good worked example in the techref at
> piclist.com. The basic understanding I got from the list (thanks David
> and Jan-erik Olin and others) is that the addwf pcl is limited to 8 bits
> but a direct goto is 11 bits and PCLATH 3,4 are the page bits. This
> leaves bits 0-3 of PCLATH which need to be set according to the page
> location on computed (addwf PCL,F)jump. Hence a table that starts at
> 0800h is called after setting PCLATH,3 to 1 and the continuation of the
> table past 0900H requires a conditional incf PCLATH,f to continue the
> table past the first 256b
<snip>

The easiest way to handle this is to make sure PCLATH is set right
before you perform the computed jump, THEN make sure that all possible
jumop-to locations are in the same page...The code is then trivial.

--Bob

--
             --------------
               Bob Axtell
       PIC Hardware & Firmware Dev
         http://beam.to/baxtell
             1-520-219-2363

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

2004\01\06@171110 by Olin Lathrop
face picon face
PSL wrote:
> how many cycle does
>   ADDWF PCL,F
> takes?

All modifications to the PC take two cycles.

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

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

2004\01\06@225959 by WH Tan

flavicon
face
Hi every one,

May I take the opportunity here to ask some question about PCL.

1) Is PCL post increased by PIC after execution of instruction, or is it
increased before execution of instruction?

2) Is the following set of codes have the same effect on program flow?

A1 MOVLW 0x00
  ADDWF PCL,f

A2 GOTO A2


B1 MOVLW 0xFF
  ....
  ADDWF PCL,f

B2 GOTO $-1


Tkanks & regards.

WH Tan

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

2004\01\06@235055 by Bob Ammerman

picon face
----- Original Message -----
From: "WH Tan" <RemoveMEtanwhEraseMEspamEraseMENOTES.SRC.GLOBAL.SHARP.CO.JP>
To: <RemoveMEPICLISTspam_OUTspamKILLspamMITVMA.MIT.EDU>
Sent: Tuesday, January 06, 2004 10:59 PM
Subject: Re: [PIC]: ADDWF PCL,F


> Hi every one,
>
> May I take the opportunity here to ask some question about PCL.
>
> 1) Is PCL post increased by PIC after execution of instruction, or is it
> increased before execution of instruction?

[ NOTE: My response here assumes a PIC12 or PIC16. Things are different on a
PIC18 ]

PCL is effectively incremented at the beginning of the instruction. Thus,
given the code:

   MOVLW    0x00
   ADDWF    PCL,F
   NOP
   NOP

all four instructions will execute.

With this code:

   MOVLW    1
   ADDWF    PCL,F
   NOP
   NOP

The first NOP will be skipped.

> 2) Is the following set of codes have the same effect on program flow?
>
> A1 MOVLW 0x00
>    ADDWF PCL,f
>
> A2 GOTO A2

Because W is zero, the ADDWF PCL,F is effectively a NOP, so this will
execute the MOVLW, the ADDWF and then repeat the GOTO indefiniitely.

>
> B1 MOVLW 0xFF
>    ....
>    ADDWF PCL,f
> B2 GOTO $-1

Because W is 0xFF, adding it to PCL will keep resetting PCL to point to the
ADDWF instruction. So, in this case the MOVLW will execute, and then the
ADDWF will be repeated indefinitely. The GOTO will never be reached.

[ NOTE: these explanations assume that the code involved does not span a 256
byte page boundary, and that PCLATH is properly set to point to the code
page.]

Bob Ammerman
RAm Systems

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

2004\01\07@020715 by WH Tan

flavicon
face
Hi Bob,

>> 2) Is the following set of codes have the same effect on program flow?
>>
>> A1 MOVLW 0x00
>>    ADDWF PCL,f
>>
>> A2 GOTO A2
>
> Because W is zero, the ADDWF PCL,F is effectively a NOP, so this will
> execute the MOVLW, the ADDWF and then repeat the GOTO indefiniitely.

>> B1 MOVLW 0xFF
>>    ....
>>    ADDWF PCL,f

>> B2 GOTO $-1
>
> Because W is 0xFF, adding it to PCL will keep resetting PCL to point to
the
> ADDWF instruction. So, in this case the MOVLW will execute, and then the
> ADDWF will be repeated indefinitely. The GOTO will never be reached.

I have to apology here for not stated clearly my question. Actually I was
giving 4 pieces of codes and I was comparing A1 to A2, B1 to B2.

But I thinks I get the answers from your post anyway.

Thanks a lot.
WH Tan

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

2004\01\07@072039 by Wouter van Ooijen

face picon face
> All modifications to the PC take two cycles.

To be exact: instructions that write to the PC take two cycles. Whether
they actually modify the value is not important.

Wouter van Ooijen

-- -------------------------------------------
Van Ooijen Technische Informatica: http://www.voti.nl
consultancy, development, PICmicro products

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

2004\01\07@072908 by Olin Lathrop

face picon face
WH Tan wrote:
> 1) Is PCL post increased by PIC after execution of instruction, or is
> it increased before execution of instruction?

During the execution of an instruction, the PC contains the address of that
instruction + 1.

{Quote hidden}

I'm not sure what you are asking, but GOTO $-1 will go to the previous
instruction whereas A2 GOTO A2 will go to itself.  The assembler "$" symbol
refers to the address of the current instruction.


*****************************************************************
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

2004\01\07@132347 by Andrew Warren

flavicon
face
WH Tan <EraseMEPICLISTspamspamspamBeGonemitvma.mit.edu> wrote:

> 2) Is the following set of codes have the same effect on program flow?
>
> A1 MOVLW 0x00
>    ADDWF PCL,f
>
> A2 GOTO A2

   No, these are different.  To make A1 do what A2 does, you'd need:

       A1  MOVLW -2
           ADDWF PCL

   Or, more generally:

       A1  MOVLW (A1A-A1)-1
       A1A ADDWF PCL

> B1 MOVLW 0xFF
>    ....
>    ADDWF PCL,f
>
> B2 GOTO $-1

   These are different, too.  To make B2 do what B1 does, you'd need
   something like this:

       B2  MOVLW ((B2A-B2)-1)-1
           ....
       B2A ADDWF PCL

   -Andy

=== Andrew Warren - RemoveMEaiwKILLspamspamcypress.com
===
=== Principal Design Engineer
=== Cypress Semiconductor Corporation

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

2004\01\07@142048 by Andrew Warren

flavicon
face
I just wrote:

> To make B2 do what B1 does, you'd need something like this:
>
>         B2  MOVLW ((B2A-B2)-1)-1
>             ....
>         B2A ADDWF PCL

   Sorry; B2 and B1 should be swapped in that text:

       To make B1 do what B2 does, you'd need something like:

           B1  MOVLW ((B1A-B1)-1)-1
               ....
           B1A ADDWF PCL

   -Andy

=== Andrew Warren - aiwSTOPspamspamspam_OUTcypress.com
===
=== Principal Design Engineer
=== Cypress Semiconductor Corporation

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

2004\01\08@011640 by WH Tan

flavicon
face
Thank you very much to all who response to my message.

I thinks I have a clear picture now.

Regards,
WH Tan

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics

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