Searching \ for 'How do I NOT a number?' 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/index.htm?key=how+not+number
Search entire site for: 'How do I NOT a number?'.

Truncated match.
PICList Thread
'How do I NOT a number?'
1998\04\30@115639 by Hearn

flavicon
face
Dear all,

I need to NOT a number for a control project my school is doing. However,
the instruction set for the PIC chip does not have a NOT. I think you can
do it using XOR but i'm not sure how that works.

Please help,
Michael Hearn and Tom Furlong (Fallibroome High School, England)

1998\04\30@123009 by Keith Howell

flavicon
face
Michael Hearn wrote:
>
> I need to NOT a number for a control project my school is doing. However,
> the instruction set for the PIC chip does not have a NOT. I think you can
> do it using XOR but i'm not sure how that works.

Sure.
       result = your_number XOR -1

or in assembler, where W contains your number:

       xorlw   -1

This inverts all the bits in the W reg.

1998\04\30@123017 by John Halleck

flavicon
face
On Thu, 30 Apr 1998, Michael Hearn wrote:

> Dear all,
>
> I need to NOT a number for a control project my school is doing. However,
> the instruction set for the PIC chip does not have a NOT. I think you can
> do it using XOR but i'm not sure how that works.

 The answer to the question as asked:
    XOR with a constant that has bits set
      is equivalent to
    NOT of each position that has a one bit set.

 But I suspect that's not the question you really want.


>
> Please help,
> Michael Hearn and Tom Furlong (Fallibroome High School, England)
>

1998\04\30@123021 by n Midgley

flavicon
face
Hah! A question I can answer!

COMF f,d complements f and puts the result in d.

Regards

John M

1998\04\30@123730 by Sean Breheny

face picon face
At 04:29 PM 4/30/98 +0100, you wrote:
>Dear all,
>
>I need to NOT a number for a control project my school is doing. However,
>the instruction set for the PIC chip does not have a NOT. I think you can
>do it using XOR but i'm not sure how that works.
>
>Please help,
>Michael Hearn and Tom Furlong (Fallibroome High School, England)
>

NOT x is equivalent to XOR x 0xFF if x is 8 bits long, but the PIC does
have a comf f,d instruction which accomplishes this same thing. f is the
address of the ram location you want to not, and d=1 to store the result
back in that location, d=0 to store the result in the W register(without
affecting the ram location). As far as I know,all pics have this instruction.

Good luck,

Sean

+--------------------------------+
| Sean Breheny                   |
| Amateur Radio Callsign: KA3YXM |
| Electrical Engineering Student |
+--------------------------------+
Fight injustice, please look at
http://www.all.org

Personal page: http://www.people.cornell.edu/pages/shb7
spam_OUTshb7TakeThisOuTspamcornell.edu
Phone(USA): (607) 253-0315

1998\04\30@123801 by Mike Keitz

picon face
On Thu, 30 Apr 1998 16:29:33 +0100 Michael Hearn
<.....michael.hearnKILLspamspam@spam@FALLIBROOME.CHESHIRE.SCH.UK> writes:
>Dear all,
>
>I need to NOT a number for a control project my school is doing.
>However,
>the instruction set for the PIC chip does not have a NOT.

Yes it does; the instruction is 'comf' (Complement F).  It inverts all
bits in a byte.  It is very similar to 'clrf' and 'movf' in that the
result can be sent to W or back to RAM.

Of course you can also complement using xor.  Xoring with 0xff inverts
all bits.  This is useful to complement ('NOT') W without needing to copy
to RAM first.  Just use xorlw h'ff' (Hexadecimal FF is binary 11111111).

(W= 01011100 before)
       xorlw   h'ff'
(Now W = 10100011)



_____________________________________________________________________
You don't need to buy Internet access to use free Internet e-mail.
Get completely free e-mail from Juno at http://www.juno.com
Or call Juno at (800) 654-JUNO [654-5866]

1998\04\30@125349 by andre

flavicon
face
Michael:
Pic has every thing you need .
for example how to do NOT function.

       movlw    b'1'           ; load 1 in w
       movwf    temp         ; save it here
       movwf    portb         ; send it to  portb  rb0 is 1 you can use led
       comf       temp,w     ; complement  temp  ( NOT)
       movwf    portb        ; now portb rb0  is 0

hope this helps
Andre


Michael Hearn wrote:

{Quote hidden}

--








==========================================
= http://www.compufire.com               =
= andrespamKILLspamcompufire.com             =
= .....mcu-engineeringKILLspamspam.....compufire.com   =
= Andre Abelian: Engine Electronics, Inc.=
= Tel 909-589-5485  Fax 909-598-5695     =
==========================================


'How do I NOT a number?'
1998\05\01@050654 by Jason Bent
flavicon
picon face
> Date:          Thu, 30 Apr 1998 16:29:33 +0100
> From:          Michael Hearn <EraseMEmichael.hearnspam_OUTspamTakeThisOuTFALLIBROOME.CHESHIRE.SCH.UK>> > Subject:       How do I NOT a number?

> Dear all,
>
> I need to NOT a number for a control project my school is doing. However,
> the instruction set for the PIC chip does not have a NOT. I think you can
> do it using XOR but i'm not sure how that works.
>
> Please help,
> Michael Hearn and Tom Furlong (Fallibroome High School, England)
>
>
There are at least THREE ways. Other people have covered XOR and
COMF, which you use 99% of the time. Another litle trick is

 255 - A = NOT A

For an 8 bit register (  (2^n)-1 - A, for an 'n' bit register)

This can be a useful to know if you need to compliment the W register
and put the result back in the W register. You need a register set to
255 (FF hex) which can be done once at the start of your code and
left there (or find a register that is naturally FFh by default).

SUBWF   REG,0

Where REG is the register containing FFh. Will invert the contents of
the W reg and put the results back in the W reg.

This is a bit obscure but when you need to make your code run as fast
as possible then knowing little tricks like this one can help.

Jason (Technician - Manchester University, England)

______________________________________________________________________

A conclusion is simply the point where you got tired of thinking.

PGP Public key available on request.

Phone/Fax +44 (0)161 275 4094


Jason.Bentspamspam_OUTman.ac.uk

1998\05\01@091846 by Walter Banks

picon face
----------
> From: Jason Bent <@spam@mbcjabtKILLspamspamMAIL1.MCC.AC.UK>
> There are at least THREE ways. Other people have covered XOR and
> COMF, which you use 99% of the time. Another litle trick is
>
>   255 - A = NOT A
>


This is the 8 bit version of the more general case of
NOT A  = -A -1 on any two's compliment processor.
This will work on any word size. It is a compiler
optimization that is very useful in some cases.

Walter Banks

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