Searching \ for '[PIC]: zero flag after comf' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: techref.massmind.org/techref/microchip/devices.htm?key=pic
Search entire site for: 'zero flag after comf'.

Exact match. Not showing close matches.
PICList Thread
'[PIC]: zero flag after comf'
2001\10\04@115311 by Doug Hemingway

picon face
I am creating a general macro for sending messages to an LCD display, and
have run into a problem.

Here's my code:

   clrf    counter
disloop    incf    counter,1    ;get next character position from table
   movf    counter,0    ;put char position into W
   call    mess2    ;get the character
   movwf    datalines    ;send it to lcd
   ;         housekeeping for LCD snipped
   comf    datalines,0    ;end of table has 0xff marker, so I complement it
and check for zero
   btfsc status, z    ;complemented character = 0?
   goto    exitaddr    ;yes, done
   goto    disloop    ;no, not done, get next character.
exitaddr                ;continue on
mess2    addwf    pc,1
   retlw    'H'
   retlw    'I'
   retlw    0xff

The code does not take the branch to exit.  As I read the spec sheet, the
comf command should set the z flag if the result is zero (ie, datalines
contained 0xff before the comf command).

What am I doing wrong?

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


2001\10\04@122337 by alice campbell

flavicon
face
Hello Doug,

try

   movf    counter,f   ;move counter onto itself
   btfsc   STATUS,Z    ;if its zero flag is set but nothing happens to file.


{Quote hidden}

--

_______________________________________________
Sign-up for your own FREE Personalized E-mail at Mail.com
http://www.mail.com/?sr=signup

Have you downloaded the latest calling software from Net2Phone? Click here to get it now!
http://www.net2phone.com/cgi-bin/adforward.cgi?p_key=NH211JK&url=http://commcenter.net2phone.com/




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


2001\10\04@172739 by Olin Lathrop

face picon face
> disloop    incf    counter,1    ;get next character position from table

Don't use 1 or 0 in the "d" field!  Microchip provides the W and F symbols
for a reason.  Use them.

I didn't look thru the rest of your code because I don't remember off the
top of my head which of W and F is the 1 and which is the 0.  Without
knowing which you are using reading thru the rest of your could would be a
waste of time.


********************************************************************
Olin Lathrop, embedded systems consultant in Littleton Massachusetts
(978) 742-9014, spam_OUTolinTakeThisOuTspamembedinc.com, 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


2001\10\04@175243 by Drew Vassallo

picon face
> > disloop    incf    counter,1    ;get next character position from table
>
>Don't use 1 or 0 in the "d" field!  Microchip provides the W and F symbols
>for a reason.  Use them.

I disagree.  Use what you're comfortable with.  Granted W and F may be
somewhat more convenient than 1 or 0, but that doesn't reduce their utility.
 I use 1 and 0 almost exclusively.  Why would it be any more difficult to
remember than W or F if you program often?  That is, if you can remember
that you NEED a destination for a particular instruction, then remembering 1
or 0 isn't all that tough, I'm sorry.

destinations:
1=File
0=Working register

As far as the initial problem goes, have you tried simulating that section
of the code in MPLAB?  I would imagine that checking the status bit after
that command should tell you what's happening.

And yes, COMF should set the Zero bit.

--Andrew



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

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


2001\10\04@210911 by Olin Lathrop

face picon face
> >Don't use 1 or 0 in the "d" field!  Microchip provides the W and F
symbols
> >for a reason.  Use them.
>
> I disagree.  Use what you're comfortable with.

But if you happen to have gotten comfortable with a bad programming
practise, then it is worth while breaking the bad habit.  Lots of people
seem to be "comfortable" writing useless comments or leaving them out
altogether, but that doesn't make it a good idea.  Bad or irresponsible
programming practices should be stomped on wherever they appear, before
anyone else gets comfortable with them.

Furthermore, if you ask 2000 people to take time out of their lives to help
with a problem for free, I think you have an obligation to have done all the
simple things that don't require any expertise.  Using the proper mnemonics
is something anyone can do.


********************************************************************
Olin Lathrop, embedded systems consultant in Littleton Massachusetts
(978) 742-9014, .....olinKILLspamspam@spam@embedinc.com, 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


2001\10\04@222414 by Dwayne Reid

flavicon
face
At 11:38 AM 10/4/01 -0400, Doug Hemingway wrote:
{Quote hidden}

It should work.  Just a suggestion: since you are using 0xFF as your end of
string marker, you could also use 'incfsz,W  datalines' as your test.

My thought that datalines is being changed by your LCD housekeeping stuff.

dwayne



Dwayne Reid   <dwaynerspamKILLspamplanet.eon.net>
Trinity Electronics Systems Ltd    Edmonton, AB, CANADA
(780) 489-3199 voice          (780) 487-6397 fax

Celebrating 17 years of Engineering Innovation (1984 - 2001)

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Do NOT send unsolicited commercial email to this email address.
This message neither grants consent to receive unsolicited
commercial email nor is intended to solicit commercial email.

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


2001\10\05@054446 by Paunonen Tommi

flavicon
face
On Thu, 4 Oct 2001, Drew Vassallo wrote:
>
> I disagree.  Use what you're comfortable with.  Granted W and F may be
> somewhat more convenient than 1 or 0, but that doesn't reduce their utility.
>
> --Andrew

No it doesn't...

Lets get a little further, we could use following from now on...

left  = 1
right = 0
up    = 1
down  = 0

Let's all fight against higher abstraction levels! ;)


"Keep your bullshit detector in good workin' condition." -Forrest Gump-

-Tommi Paunonen

--
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\10\05@130406 by Drew Vassallo

picon face
>Lets get a little further, we could use following from now on...
>
>left  = 1
>right = 0
>up    = 1
>down  = 0

Umm, yah.

Olin, considering that the datasheets specify 0 and 1 for the destinations,
I would hardly call using them "bad programming practice."

Aside from all this, I think stating that you would not "waste your time" in
helping someone if they don't use W and F rather than 0 and 1 is simply
ludicrous.  A simple check against any datasheet would let you know which is
which.  Total investigation time: around 10 seconds.

--Andrew

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

--
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\10\05@151157 by Olin Lathrop

face picon face
> Aside from all this, I think stating that you would not "waste your time"
in
> helping someone if they don't use W and F rather than 0 and 1 is simply
> ludicrous.  A simple check against any datasheet would let you know which
is
> which.  Total investigation time: around 10 seconds.

Sure, I could look it up in about 10 seconds but I shouldn't have to.  I
also want to make a deliberate point about irresponsible programming
practices.  I feel nobody deserves an answer until they've taken whatever
basic steps to do a good job that they are capable of.  I can't stop other
people from answering such messages, but I can insist that people clean up
their act before I help them.


********************************************************************
Olin Lathrop, embedded systems consultant in Littleton Massachusetts
(978) 742-9014, .....olinKILLspamspam.....embedinc.com, http://www.embedinc.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\10\05@171635 by cardcd

picon face
Hi,
Time out!
A competent and responsible experienced consultant does not require ten
seconds to equate the flags.
He knows the answer.
The only irresponsible action I have noted in the flurry has come repeatedly
from one flame thrower.
A duality of definition is _not_ ambiguity.
It can hardly be deemed irresponsible.
An assembler convention with dual definitions can only be construed as
alternative ways to do the same thing.
That is neither misleading, ambiguous, nor improper.
Complaining about it loudly is, at best irrelevant.

Now, if an experienced consultant looking to enhance his reputation is
really interested in helping people rather than showing how narrow his mind
set is, he gives a patient explanation subtly showing the omission and goes
on.
If he is really bothered, he either figuratively holds his tongue, or
unsubscribes.
The actions suggest that the intent might to take more from this forum than
is inserted.
That is not an unusual attitude, but is hardly fair.

As a buyer in the field, be assured that this exchange has caused my
procurement list to get a new entry on our "do not buy here list".

Shall we get on with sharing real information?
=============

Chuck Card in sunny Arizona
Unlimited Sunsets
+++++++++++++++++++
<snip>
Sure, I could look it up in about 10 seconds but I shouldn't have to.  I
also want to make a deliberate point about irresponsible programming
practices.  I feel nobody deserves an answer until they've taken whatever
basic steps to do a good job that they are capable of.  I can't stop other
people from answering such messages, but I can insist that people clean up
their act before I help them.


<snip>
(978) 742-9014, EraseMEolinspam_OUTspamTakeThisOuTembedinc.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\10\06@023336 by jeethur

flavicon
face
I agree with Olin.
The cleaner the code, the more comfortable i am with it.
Using W or F instead of 0 or 1 makes the code more readable.
If remembering 0 and 1 would be easier, we'd be calling em as
0 and 1 and We'd be referring PCLATH as 0x0A ...
We would have been better off writing Hex Files manually.
We humans are creative machines. We churn out code and If there
is any way we could read/write code, we would adapt it.

Sorry to disagree Drew, but thats my personal Philosophy.

Jeethu Rao


> {Original Message removed}

2001\10\06@111335 by Drew Vassallo

picon face
I know we've spent enough time on this already, but I just wanted to point
out that people who may be learning the language and becoming familiar with
PICs might be tempted to look at the Microchip datasheets for help.
Moreover, we continuously tell people to CHECK THE DATASHEETS when they ask
questions which may be answered by doing so.

Many of the datasheets have an Instruction Set Summary, which includes
examples of usage.  For the instruction COMF, from the 16F84 datasheet:

Example:  COMF REG1,0
Description: The contents of register  f  are comple-mented.  If  d  is 0
the result is stored in W. If  d  is 1 the result is stored back in register
f .

Before Instruction
REG1 = 0x13
After Instruction
REG1 = 0x13
W =0xEC


Note that the datashet uses "0" and gives the example on the status of W
after the instruction.  Not only that, but it says nothing of using the
mnemonics "W" or "F" as the destination.

I hardly think that someone using this syntax deserves to be "penalized" for
doing so.  By this I mean that someone looking for advice, assistance, or
information on how to improve his program's success should not be turned
away by some of the better and more experienced programmers on this list
simply for using information obtained from the Microchip datasheets.  That
doesn't show these people how to improve their skills, that just shows the
arrogance of others.

--Andrew

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

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


2001\10\07@190216 by Doug Hemingway

picon face
Thanks, Andrew.  It is the attitude exemplified by Olin that discourages
beginners in almost any endeavor.  If he doesn't want to answer because my
ignorant question doesn't fit his definition of "intelligent enough to be
bothered with", that's fine.  To flame it, and spend three times more time
in the ensuing flame war than he would have spent answering the question,
comes real close to most peoples' definition of "arrogant".

Thanks to those who did take the time to answer.

Oh, and btw, my assembler, MacPIC, hasn't got the foggiest idea of what w
and f are until I define them.  I have now done so, and substituted w and f
in the code so I won't look (or BE) quite as ignorant the next time.

Doug

{Quote hidden}

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


2001\10\07@193149 by Tony Nixon

flavicon
picon face
Doug Hemingway wrote:
{Quote hidden}

Even though it would make no difference, I would change...

 comf datalines,0

to..

 xorlw 0xFF

I have this (probably silly) "thing" about writing to a register and
reading from it on the very next instruction.

Question Time :-)
Where is the "mess2" jump table located in memory??
Is the PCLATH set up to handle it?
Is it crossing a page boundary?
Why do you want this as a MACRO? Wouldn't it be better as a subroutine?
Can you simulate it in MPLAB and see if the subroutine does in fact
return with 0xFF?

--
Best regards

Tony

mICros
http://www.bubblesoftonline.com
@spam@salesKILLspamspambubblesoftonline.com

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


2001\10\07@200047 by Drew Vassallo

picon face
>Oh, and btw, my assembler, MacPIC, hasn't got the foggiest idea of what w
>and f are until I define them.  I have now done so, and substituted w and f
>in the code so I won't look (or BE) quite as ignorant the next time.

Well, the assembler isn't really where it's defined, anyways.  The 16F84.INC
file (or whatever you're using) is where W and F are defined as 0 and 1.  As
long as you have included this file at the top of your program, it's
automatically defined and will work (should work) with MacPIC or whatever
assembler you choose.

--Andrew

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

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


2001\10\07@202332 by James Caska

picon face
Hi,
If datalines is configured as an output Port which I assume it is, then what
you write to the port is not necessarily what you read from the port. There
are different set of latches at the port pins. This probably justifies the
comment

>I have this (probably silly) "thing" about writing to a register and
>reading from it on the very next instruction.

I agree using the xorlw 0xFF will remove at least one source of error

ie

>     call    mess2    ;get the character
>     movwf    datalines    ;send it to lcd
>     ;         housekeeping for LCD snipped
>     comf    datalines,0    ;end of table has 0xff marker, so I complement
it
>     btfsc status, z    ;complemented character = 0?

becomes

       call    mess2                   ;get the character
       movwf    datalines      ;send it to lcd
       ;         housekeeping for LCD snipped
       xorlw     0xFF                  ;complement the character using xorlw
       btfsc status, z         ;complemented character = 0?

Regards,
James Caska
spamBeGonecaskaspamBeGonespamvirtualbreadboard.com
ujVM - 'The worlds smallest java virtual machine'





{Original Message removed}

2001\10\08@090639 by Olin Lathrop

face picon face
> Oh, and btw, my assembler, MacPIC, hasn't got the foggiest idea of what w
> and f are until I define them.  I have now done so, and substituted w and
f
> in the code so I won't look (or BE) quite as ignorant the next time.

Microchip provides include files for all the processors.  These define the
register names and other symbols like W and F.  Even if you don't use the
Microchip assembler you should use the include files if your assembler is
source compatible.


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

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


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