7.6.5 Applying Offsets to Bits within a Variable or Register


Closed Thread
Results 1 to 10 of 10

Hybrid View

  1. #1

    Default 7.6.5 Applying Offsets to Bits within a Variable or Register

    I'm a bit confused by this so I'll pose my question.

    I have a byte variable alias called "Config"

    Using the offset bits technique can I manipulate bits by doing

    Config.0[x] = 1

    x being 0 to 7 in this case

    The example in the manual uses a port alias for the demo.

    Can x be another variable?

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


    Did you find this post helpful? Yes | No

    Default Re: 7.6.5 Applying Offsets to Bits within a Variable or Register

    Yes, it can.
    Charles Linquist

  3. #3
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,185


    Did you find this post helpful? Yes | No

    Default Re: 7.6.5 Applying Offsets to Bits within a Variable or Register

    Quote Originally Posted by retepsnikrep View Post
    .....
    Can x be another variable?
    Did you mean "Variable" other than Byte in your case, or Value other than 0 ... 7 ?
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

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


    Did you find this post helpful? Yes | No

    Default Re: 7.6.5 Applying Offsets to Bits within a Variable or Register

    It actually works both ways.

    X var byte
    y var byte
    z var bit

    X = %01010101

    Y = 3
    Z = X.0[Y]
    Z = 0

    Y = 4
    Z = X.0[Y]
    Z = 1
    Charles Linquist

  5. #5
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,185


    Did you find this post helpful? Yes | No

    Default Re: 7.6.5 Applying Offsets to Bits within a Variable or Register

    x = 125
    Config.0[x] = 1

    ?
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

  6. #6
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,115


    Did you find this post helpful? Yes | No

    Default Re: 7.6.5 Applying Offsets to Bits within a Variable or Register

    Maybe bit 5? That is 0.

    Ioannis

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


    Did you find this post helpful? Yes | No

    Default Re: 7.6.5 Applying Offsets to Bits within a Variable or Register

    I don't understand the confusion.

    X var byte
    y var byte
    z var bit

    X = %01010101

    Y = 3
    Z = X.0[Y]
    Z = 0


    X is a variable, Y is a variable. Bit 3 of X is a '0'

    Y = 4
    Z = X.0[Y]
    Z = 1

    Bit 4 of X is 1
    Charles Linquist

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