Counting bits


Results 1 to 4 of 4

Thread: Counting bits

Threaded View

  1. #2
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Hi Russ,

    Not particularly "Sneaky" ... but it's "Quick".
    Code:
    Counter  VAR BYTE BANK0
    ODD      VAR Counter.0
    TestWord VAR WORD BANK0
    
    ASM
        clrf   _Counter
        btfsc  _TestWord,0
        incf   _Counter, F
        btfsc  _TestWord,1
        incf   _Counter, F
        btfsc  _TestWord,2
        incf   _Counter, F
        btfsc  _TestWord,3
        incf   _Counter, F
    ENDASM
    
    If ODD THEN
      ; ODD number of bits in the TestWord<3:0>
    ENDIF
    Last edited by Darrel Taylor; - 10th October 2008 at 08:57. Reason: Changed Count to Counter
    DT

Similar Threads

  1. Bits, Bytes Words and Arrays
    By Melanie in forum FAQ - Frequently Asked Questions
    Replies: 24
    Last Post: - 14th June 2016, 07:55
  2. Reading in Manchester code
    By brid0030 in forum Code Examples
    Replies: 0
    Last Post: - 10th March 2009, 21:55
  3. PIC's ports individual bits manipulation - how to?
    By flotulopex in forum mel PIC BASIC Pro
    Replies: 38
    Last Post: - 27th February 2007, 22:34
  4. Need clever way to convert 10 bits to 8 bits
    By MikeTamu in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 2nd September 2005, 15:13
  5. error on compiling
    By parker in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 16th June 2005, 14:31

Members who have read this thread : 0

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

Posting Permissions

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