inverting all bits in a byte


Closed Thread
Results 1 to 8 of 8

Hybrid View

  1. #1
    Join Date
    Apr 2014
    Location
    OK
    Posts
    557


    Did you find this post helpful? Yes | No

    Default Re: inverting all bits in a byte

    There is a simple ASM command, COMF. This is what it would look like:

    @ BANKSEL _byteA
    @ COMF _byteA, F

    The first line moves the BSR (Bank Select Register) to the BANK containing your variable. The variable is preceded by an underscore for ASM; _byteA.

    The second line executes the command, Compliment F (F is your variable). The appending ", F" puts the result back in your variable, byteA.

    Hope this helps

  2. #2


    Did you find this post helpful? Yes | No

    Default Re: inverting all bits in a byte

    Use the ^ operator for Bitwise Exclusive OR

    ByteA = ByteA ^ %11111111 Inverts the bits of ByteA

  3. #3
    Join Date
    Jun 2011
    Location
    Indian Harbour Nova Scotia
    Posts
    108


    Did you find this post helpful? Yes | No

    Default Re: inverting all bits in a byte

    thanks Dick

Similar Threads

  1. An easy way to get bits to byte
    By longpole001 in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 6th November 2015, 11:16
  2. Problem with bits in byte array....
    By HenrikOlsson in forum mel PIC BASIC Pro
    Replies: 15
    Last Post: - 19th October 2011, 06:27
  3. Accessing several bits together in a byte or word...
    By rossfree in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 7th May 2007, 18:07
  4. Bits in Byte Arrays
    By crhomberg in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 24th April 2007, 22:37
  5. reading first four bits of a byte
    By kamet in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 2nd January 2007, 08:50

Members who have read this thread : 1

You do not have permission to view the list of names.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts