Searching \ for '[PIC]: Does DECFSZ...?' 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: 'Does DECFSZ...?'.

Exact match. Not showing close matches.
PICList Thread
'[PIC]: Does DECFSZ...?'
2001\04\28@212910 by Jose S. Samonte Jr.

picon face
Hello everybody!
In the Easy PIC'n book, it is written that decfsz takes 1 clock cycle, and 2
clock cycle if result is 0.
But in another book I have borrowed and read, it say that it only takes one
clock cycle, eventhough the result is 0.

Please help...

____________________________________________________________________
Get free email and a permanent address at http://www.netaddress.com/?N=1

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


2001\04\28@214614 by Drew Vassallo

picon face
>In the Easy PIC'n book, it is written that decfsz takes 1 clock cycle, and
>2
>clock cycle if result is 0.
>But in another book I have borrowed and read, it say that it only takes one
>clock cycle, eventhough the result is 0.

If you look in the MPLAB user's manual (or any datasheet that has an
Instruction Set Summary page), you can see that it clearly describes it as
requiring 1 cycle if nonzero and 2 cycles if zero.  If it is nonzero, it
really still takes 2 cycles to get to the same point in your code, except
that it executes the next line instead of skipping it.  When it "skips on
zero", it really executes a "nop" instruction before it continues on.  For
example:

decfsz FILE; 1 instruction cycle
bsf FLAG, 1 ; executed normally if F != 0, or a NOP if F=0
movlw 0xFF ; this is instruction cycle 3, regardless of whether or not F=0

You can't "save" instruction cycles if it's zero or nonzero in going through
your code.  In the example above, it will always take 2 cycles to get from
"decfsz" to "movlw".  It doesn't matter if F=0 or F!=0.

--Andrew
_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com

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


2001\04\29@012850 by Dmitry Kiryashov

flavicon
face
As a practical observation is showing the
real difference is in two examples:

;
decfsz some_reg
non_goto_command_here
;

will take 1(decfsz)+1(non_goto_command executed or skipped) clocks
to get through for any given value of some_reg

and

;
decfsz some_reg
goto_somewhere ;very particular case of it is call_somewhere ;)
;

will take 1(decfsz)+1(skipped) to get through with skipping
goto and 1(decfsz+2(goto) to get somewhere (in case of call
it can take much longer ;)

WBR Dmitry.



Drew Vassallo wrote:
{Quote hidden}

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.


2001\04\29@084725 by Bob Ammerman

picon face
Any instruction which can skip takes one cycle when it doesn't skip and two
when it does.

This is because of the way mchip implemented these skip instructions.

PICs use a pipelined scheme to process instructions: as each instruction is
being executed, the next instruction in the program is being fetched.

All a PIC does in the case of a skip is ignore the fetched instruction and
substitute a nop instead.

So, instead of thinking of skipping instructions as taking two cycles when
they skip, you can think of the skip taking one cycle and the following
forced nop taking the second cycle.

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

{Original Message removed}

2001\04\29@090722 by Olin Lathrop

face picon face
>>
In the Easy PIC'n book, it is written that decfsz takes 1 clock cycle, and 2
clock cycle if result is 0.
But in another book I have borrowed and read, it say that it only takes one
clock cycle, eventhough the result is 0.
<<

The only book that really matters is the Microchip data sheet.  Go to the
chapter "Instruction Set Summary" and look up the DECFSZ instruction.


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

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.


2001\04\29@095106 by Jose S. Samonte Jr.

picon face
Thank you sir Bob! =)
That made it so much clearer!

Kindest regards...

Bob Ammerman <.....RAMMERMANKILLspamspam@spam@PRODIGY.NET> wrote:
Any instruction which can skip takes one cycle when it doesn't skip and two
when it does.

This is because of the way mchip implemented these skip instructions.

PICs use a pipelined scheme to process instructions: as each instruction is
being executed, the next instruction in the program is being fetched.

All a PIC does in the case of a skip is ignore the fetched instruction and
substitute a nop instead.

So, instead of thinking of skipping instructions as taking two cycles when
they skip, you can think of the skip taking one cycle and the following
forced nop taking the second cycle.

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

{Original Message removed}

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