32 bit counter


Closed Thread
Results 1 to 5 of 5

Thread: 32 bit counter

  1. #1
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107

    Default 32 bit counter

    I use the following assembly routine whenever I need a 16 bit counter

    infsnz var
    incf var + 1

    but now I need a 32 bit counter (in assembly).
    Apparently, I'm not smart enough to figure it out for myself.

    Can someone please show me how to implement my 32 bit counter?
    Charles Linquist

  2. #2
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    almost the same, but you'll need Var+2 and var +3

    Maybe some stuff could be extracted from
    http://www.piclist.com/techref/micro...frtomath32.asm
    http://www.piclist.com/techref/micro...32bmath-ph.htm
    Last edited by mister_e; - 19th December 2007 at 03:04.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  3. #3
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default

    It appears that the best routine would be

    count32

    incfsz var
    bra doneproc
    incfsz var + 1
    bra doneproc
    incfsz var + 2
    bra doneproc
    incf var + 3
    bnc doneproc
    bsf eflag,0


    doneproc



    but I can't test it tonight. Can anyone find anything wrong with this?
    Charles Linquist

  4. #4
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    This has to work... hey that was easier than you thought right?

    EDIT it runs smooth on MPSIM... well for that i may trust MPSIM
    Last edited by mister_e; - 19th December 2007 at 03:53.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  5. #5
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default

    I tried it this morning. It works. The technique works with any number of bits.
    Charles Linquist

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. AT/PS2 Keybord - PIC Interface?
    By Kamikaze47 in forum Code Examples
    Replies: 73
    Last Post: - 9th August 2009, 16:10
  3. PICBasic newbie problem
    By ELCouz in forum mel PIC BASIC Pro
    Replies: 32
    Last Post: - 12th February 2008, 00:55
  4. Microcontroller with 2 way paging application problem
    By oneohthree in forum mel PIC BASIC Pro
    Replies: 30
    Last Post: - 20th April 2007, 17:27
  5. USART interrupt not interrupting right
    By Morpheus in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 6th March 2005, 01:07

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