concatenating 4 bytes into one pseudo 32 bit counter?


Results 1 to 12 of 12

Threaded View

  1. #3
    Join Date
    Sep 2009
    Posts
    755


    Did you find this post helpful? Yes | No

    Default Re: concatenating 4 bytes into one pseudo 32 bit counter?

    Why not use LONG variable? PBP will do everything for you.
    Before LONG I use something like this
    Code:
    A var byte
    B var byte
    C var byte
    etc
    main: 
    
    GOTO main
    
    Init: ' start value of each byte
    A=0
    B=0
    etc...
    RETURN
    
    Inc:
    A=A+1
    IF A=0 THEN
      B=B+1
      IF B=0 THEN
       C=C+1
       IF C=0 THEN
          D=D+1
       ENDIF
      ENDIF
    ENDIF
    A is lowest byte, D is highest.
    A,B,C,D is 0 only on overflow, so if lowest byte overflow(IT go from 255 to 0) you need to add 1 to second byte.
    For example if you want to calculate actual value of counter you need to do it like this:
    32bitResult=D*2^24+C*2^16+B*2^8+A
    Hope that I understand what exactly you need.
    EDIT:
    Sorry for long, you use 16F. I didn't use 16F since LONG variable is added to PBP...
    Last edited by pedja089; - 26th August 2011 at 12:29.

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