Searching \ for '[PIC]: Syntax Confusion' 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: 'Syntax Confusion'.

Exact match. Not showing close matches.
PICList Thread
'[PIC]: Syntax Confusion'
2002\01\23@110525 by Ted Mawson

flavicon
face
Hi guys,



Quick question on .asm syntax using decfsz.  What's the difference
between the two following examples please?



assume 'count' is a variable



loop      code

           code

           decfsz count, F

           goto loop

           retlw



loop      code

           code

           decfsz count, 1

           goto loop

           retlw



I understand that decfsz is decrementing count and if count=0 after the
decrement, the next 'goto loop' instruction is skipped.  I see the two
forms used all over the place and the second one makes more sense to me,
it's the use of the 'F' that's puzzling me and I haven't found any
reference (yet) to what it is.



Ted Mawson

spam_OUTTed.MawsonTakeThisOuTspamPortfolioPM.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


2002\01\23@111258 by Miguel

flavicon
face
You may use F or W...

F makes the result  in the SFR
W makes the result in the W

Wdoes not affect the SFR...

Miguel

{Original Message removed}

2002\01\23@112703 by Peter Onion

flavicon
face
On 23-Jan-02 Ted Mawson wrote:
> Hi guys,
>
>
>
> Quick question on .asm syntax using decfsz.  What's the difference
> between the two following examples please?
>
>             decfsz count, F
>
>             decfsz count, 1


decfsz is no different to all the other pic instructions that operate on a
register file....

addwf   variable,F      ;  variable = variable + W


addwf   variable,W      ;  W = variable + W


so

decfsz count, F         ; count = count - 1
                       ; skip if count == 0

decfsz count, W         ; W = count - 1
                       ; skip if W == 0

Note the Z flag is set on the result of the decrement so it doesn't matter
where the result ends up (in count or W).


The use of    0 or 1 in place of F or W is, while syntacticaly valid, just
asking for confusion.  I don't know if "0" means W or if "1" means W, but I
don't need to know because I use "W" if I mean W and "F" if I mean F !!

Peter.


----------------------------------
E-Mail: Peter Onion <.....ponionKILLspamspam@spam@srd.bt.co.uk>
Date: 23-Jan-02
Time: 16:23:24

This message was sent by XFMail
----------------------------------

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


2002\01\23@114231 by Bob Barr

flavicon
face
On Wed, 23 Jan 2002 11:03:38 -0500, Ted Mawson wrote:

{Quote hidden}

Functionally they're identical. The 'F' indicates that the result goes
to the register and not to the W register.
F and W are defined in the processor include file ( F equ 1, W equ 0).

(Note that if you use "decfsz count, W", the register will not
decrement and the code will loop forever if the count is non-zero.)

Regards, Bob

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


2002\01\23@124441 by Drew Vassallo

picon face
>Quick question on .asm syntax using decfsz.  What's the difference
>between the two following examples please?
>             decfsz count, F
>             decfsz count, 1

Wow, I've seen some fairly confusing replies to this simple question.  Hope
we didn't confuse you, Ted.

Simply:

The variable or number after the "," is the destination for the result of
the instruction.  If you want the result to be stored in the original
register ("count" in this example), then use "F" or "1".  If you want the
result to be transferred to the Working register, use "W" or "0".

You can use "F" and "1" interchangeably.  You can also use "W" and "0"
interchangeably.  This assumes you are using the appropriate .INC files for
MPASM, because that's where "F" is defined as "1" and "W" is defined as "0".
 Pretty much every "standard" PIC ASM file that you write should have these
.INC files included in the beginning of your code.

Hope that clears things up.  For more information, you can always check the
MPLAB or MPASM help files, which should explain the destination options.

--Andrew

_________________________________________________________________
Send and receive Hotmail on your mobile device: http://mobile.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


2002\01\23@140851 by uter van ooijen & floortje hanneman

picon face
>             decfsz count, F
>             decfsz count, 1

Both have the same effect, because F is nothing more than a synonym for 1.
The first is much more readable, though. Now guess what the effect of decfsz
W, F will be?

Wouter van Ooijen

Van Ooijen Technische Informatica: http://www.voti.nl
Jal compiler for PIC uC's:  http://www.voti.nl/jal
PICs kopen? http://www.voti.nl/shop

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


2002\01\23@155126 by Drew Vassallo

picon face
>Both have the same effect, because F is nothing more than a synonym for 1.
>The first is much more readable, though. Now guess what the effect of
>decfsz W, F will be?

It won't be anything, because it won't compile.  You can't use "W" as an
actual register, as it's not directly accessible in this manner.

You'd have to use:

addlw -1
btfss STATUS, Z
.
.
.

--Andrew

_________________________________________________________________
Chat with friends online, try MSN Messenger: http://messenger.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


2002\01\23@160948 by Dave Mumert

flavicon
face
Hi Drew

You must have a different version of MPLAB.

decfsz W,F works just fine.  It even does what you would expect.

The register in the FSR pointer gets decremented and the result saved back
to that register.

It is the same as decfsz INDF,F because both INDF and W are defined as 0

Dave

{Original Message removed}

2002\01\23@162436 by Thomas C. Sefranek

face picon face
On the 18C452 you have to use WREG for W as a register, but you can use
W for the argument switch(F,W).

Dave Mumert wrote:

{Quote hidden}

>{Original Message removed}

2002\01\23@163323 by Ted Mawson

flavicon
face
Many thanks to all who offered advice on this one, you are all right but
I found Drew's answer to be the clearest.  Now I know where the F=1 and
W=0 are defined :)

Ted Mawson
Ted.MawsonspamKILLspamPortfolioPM.com

Drew Vassallo wrote...

Sent: Wednesday, January 23, 2002 12:45 PM
To: .....PICLISTKILLspamspam.....MITVMA.MIT.EDU
Subject: Re: [PIC]: Syntax Confusion

>Quick question on .asm syntax using decfsz.  What's the difference
>between the two following examples please?
>             decfsz count, F
>             decfsz count, 1

Wow, I've seen some fairly confusing replies to this simple question.
Hope
we didn't confuse you, Ted.

Simply:

The variable or number after the "," is the destination for the result
of
the instruction.  If you want the result to be stored in the original
register ("count" in this example), then use "F" or "1".  If you want
the
result to be transferred to the Working register, use "W" or "0".

You can use "F" and "1" interchangeably.  You can also use "W" and "0"
interchangeably.  This assumes you are using the appropriate .INC files
for
MPASM, because that's where "F" is defined as "1" and "W" is defined as
"0".
 Pretty much every "standard" PIC ASM file that you write should have
these
.INC files included in the beginning of your code.

Hope that clears things up.  For more information, you can always check
the
MPLAB or MPASM help files, which should explain the destination options.

--Andrew

_________________________________________________________________
Send and receive Hotmail on your mobile device: http://mobile.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

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


2002\01\23@170048 by Andrew Warren

flavicon
face
Ted Mawson <EraseMEPICLISTspam_OUTspamTakeThisOuTmitvma.mit.edu> wrote:

> Many thanks to all who offered advice on this one, you are all right
> but I found Drew's answer to be the clearest.  Now I know where the F=1
> and W=0 are defined :)

   No, you only THINK you do.

   Drew's post to the contrary, W=0 and F=1 are defined internally
   within MPASM; "DECFSZ COUNT,W" and "DECFSZ COUNT,F" will work
even if
   you don't include any .INC files.

   -Andy

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

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


2002\01\23@170446 by Drew Vassallo

picon face
>decfsz W,F works just fine.  It even does what you would expect.
>The register in the FSR pointer gets decremented and the result saved back
>to that register.

Um, that's not what I would expect at all.  If I were to take the
instruction at face value (as written), then it should reduce the *W*
register by 1 and place it back into the W register.  What you claim happens
is that it decrements the register pointed to by *FSR*, not W.  How does
that do what you expect??

>It is the same as decfsz INDF,F because both INDF and W are defined as 0

This may be true, but it is just coincidental.  Of course it would work in
this manner, as they are both defined as 0 like you said.  But that really
has nothing to do with the Working register being affected by the
instruction "decfsz," as was the original question.  It's just not usable in
that way.

--Andrew

_________________________________________________________________
Join the world s largest e-mail service with MSN Hotmail.
http://www.hotmail.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


2002\01\23@180354 by Drew Vassallo

picon face
>     Drew's post to the contrary, W=0 and F=1 are defined internally
>     within MPASM; "DECFSZ COUNT,W" and "DECFSZ COUNT,F" will work
>even if
>     you don't include any .INC files.

Interesting.  I guess I never bothered to check, except that I wonder why
they would define them in their .INC files in that case.  I suppose you
could use another compiler, and in that event they likely would not be
internally defined, so you'd need to know where they were :)

--Andrew

_________________________________________________________________
Join the world s largest e-mail service with MSN Hotmail.
http://www.hotmail.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


2002\01\24@100813 by uter van ooijen & floortje hanneman

picon face
> >Both have the same effect, because F is nothing more than a synonym for
1.
> >The first is much more readable, though. Now guess what the effect of
> >decfsz W, F will be?
>
> It won't be anything, because it won't compile.  You can't use "W" as an
> actual register, as it's not directly accessible in this manner.

Indeed it won't do what an innocent reader might expect, but this will not
prevent MPASM from accepting it!

0139   0B80          decfsz W,F
013A   0B80        decfsz 0,1

Wouter van Ooijen

Van Ooijen Technische Informatica: http://www.voti.nl
Jal compiler for PIC uC's:  http://www.voti.nl/jal
PICs kopen? http://www.voti.nl/shop

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


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