Pseudo SET, IN keyword

Language reference ›› Constants ››
Parent Previous Next

PMP does not support the standard Pascal SET, but uses the SET syntax for special purposes like bit masks:

[BitA, BitB, BitC..BitD] defines a constant bit mask where the bit positions BitA and BitB are set, along with all bits from BitC to BitD.


The standard IN keyword may be used to check a bit within any expression result as a pseudo SET.


Special behavior: If an element is a BOOLEAN variable, the bit number of this variable is used.

When the assigned variable is a SFR, any of its fields values may be defined inside the pseudo-set:

OSCCON := [IOSCF = 0b110, SCS];

  IO_Bit: boolean @ PORTC.1;
  VarLong: longint;
  VarByte: byte;

  BitA = 2; BitB = 4;
  BitMask = [BitA, BitB, IO_Bit]; { Equivalent to [2, 4, 1]: constant b'00010110' }

  VarLong := BitMask;
  VarByte := BitB;
  IF 2 IN BitMask THEN // Evaluated as always True at compile time
    IF 4 IN [1, BitB..31] THEN // Evaluated as always True at compile time
      IF BitA IN VarLong THEN  // True since bit 2 is set in VarLong
        IF VarByte IN VarLong THEN // True since VarByte=4 and bit 4 is set in VarLong