Bitwise Decode '|<'

The Bitwise Decode operator decodes a value (0 – 31) into a 32-bit long value with a single bit set high corresponding to the bit position of the original value. Bitwise Decode can be used in variable and integer constant expressions, but not in floating-point constant expressions. Example:

Pin := |< PinNum

The above example sets Pin equal to the 32-bit value whose single high-bit corresponds to the position indicated by PinNum.

 If PinNum is 3, Pin is set equal to %00000000 00000000 00000000 00001000.

 If PinNum is 31, Pin is set equal to %10000000 00000000 00000000 00000000.

 There are many uses for Bitwise Decode, but one of the most useful is to convert from an I/O pin number to the 32-bit pattern that describes that pin number in relation to the I/O registers. For example, Bitwise Decode is very handy for the mask parameter of the WAITPEQ and WAITPNE commands. 

Bitwise Decode becomes an assignment operator when it is the sole operator to the left of a variable on a line by itself. For example:

|<PinNum

This would store the decoded value of PinNum back into PinNum.

Unless otherwise noted, content on this site is licensed under the
Creative Commons Attribution-ShareAlike 4.0 International License.