AnyVar.[bitfield] Syntax Question
Bob Drury
Posts: 236
in Propeller 2
BitField = BF[9:0] = AddPins above Base (Size) = Bs[9:5] BasePin = Bp[4:0]
BF[9:0] = Bs[9:5] + Bp[4:0] = S4S3S2S1S0_ P4P3P2P1P0 = BF9BF8BF7BF6BF5BF4BF3BF2BF1BF0
A bitfield is a 10-bit value which contains a base-bit number in bits 4..0 and an additional-bits number in bits 9..5.
Not really sure what the signifigance of BitField has in the variable index ? Bitfield ends up being a binary number losing it's relation to BaseBits and AddBitSize.
Regards
Bob (WRD)
Comments
These are features of certain Prop2 instructions. So it's hardwired. In Pasm2 there is two types of bitfields: One is for 32-bit general register indexing, the other one is for the 64 I/O pin indexing. The difference being the size the bitfields. For 32-bit registers it's 5+5=10 bits. For the 64 pins it's 6+5=11 bits.
I'm not sure if it applies to Spin2 or not ...
Cool, in Spin it can be tacked onto an array index too. eg: AnyVar[index].[bitfield]
So the key syntax detail is the "." preceding the bitfield.
PinField has instructions such as PINLOW(PinField) which has a function of setting the basePin and the addpins to low . But what spin instruction uses BitField in a similar prescribed manner?
AnyVar.[BitField] what does it do? BF[9:0] = BS[9:5] + BP[4:0] = S4S3S2S1S0_ P4P3P2P1P0 The following program seems to imply individual bits can be returned for status using the BaseBit
Bs[9:5] = 0 and Bp[4:0] = 0-31 for each bit position in HubVar[0].[BitField] but the use of AddBits Bs[9:5] with BaseBit =0 does not seem to return calculated bit number. For example
when Addbits Bs[9:5] =32 and BaseBit Bp[4:0] = 0 Y := HubVar[0].[%100000] = 2 where HubVar[0] is %1010_1010_1010_1010_1010_1010_1010_1010 there is something I am missing.
Regards and Thanks
Bob (WRD)
Since 32 is out of range I'll assume you mean Addbits = 1. A value of one means two bits of the variable. Given the hubvar = %1010_1010_1010_1010_1010_1010_1010_1010 and you're extracting two bits it's not surprising the result is %10 or 2.
An example of what I have used
Yes "Addbits" should be 1 not 32. Y := HubVar[0].[%100000] so the penny just dropped. The "AddBits" is the request of how many bits to return plus the BaseBit, will try out thanks.
Regards
Bob (WRD)