7.6.5 Applying Offsets to Bits within a Variable or Register


Closed Thread
Results 1 to 10 of 10

Hybrid View

  1. #1
    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

  2. #2
    Join Date
    Jan 2009
    Location
    Miami, Florida USA
    Posts
    699


    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 Charles Linquis View Post
    I don't understand the confusion.
    Sayzer wants to know what happens if Y > 7. I don't know the answer to that either. For example,

    Y = 8
    Z = X.0[Y]
    Z = ???
    "No one is completely worthless. They can always serve as a bad example."

    Anonymous

  3. #3
    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 depends on the position of the byte in memory, and is generally unpredictable. You can, however play some tricks with it.
    If you assign vars like -

    X var byte
    Y var byte

    Then PBP will assign the bytes to consecutive memory locations. In that case, bit 8 of X will be bit 0 of Y.
    Charles Linquist

  4. #4
    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 rsocor01 View Post
    Sayzer wants to know what happens if Y > 7. I don't know the answer to that either. For example,

    Y = 8
    Z = X.0[Y]
    Z = ???
    I was just referring to the question in the first post.
    I already know that what happens might not be what you would like to get.

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

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