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?
Re: 7.6.5 Applying Offsets to Bits within a Variable or Register
Re: 7.6.5 Applying Offsets to Bits within a Variable or Register
Quote:
Originally Posted by
retepsnikrep
.....
Can x be another variable?
Did you mean "Variable" other than Byte in your case, or Value other than 0 ... 7 ?
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
Re: 7.6.5 Applying Offsets to Bits within a Variable or Register
x = 125
Config.0[x] = 1
?
Re: 7.6.5 Applying Offsets to Bits within a Variable or Register
Maybe bit 5? That is 0.
Ioannis
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
Re: 7.6.5 Applying Offsets to Bits within a Variable or Register
Quote:
Originally Posted by
Charles Linquis
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 = ???
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.
Re: 7.6.5 Applying Offsets to Bits within a Variable or Register
Quote:
Originally Posted by
rsocor01
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.
:D