Bit-string functions
Bit-string functions operate on ANY_BIT values (BOOL, BYTE, WORD,
DWORD, LWORD). Shift/rotate functions take a bit count N : ANY_INT. The
boolean operators are also available as the
AND / OR / XOR / NOT keywords.
| Function | Parameters | Returns |
|---|---|---|
SHL | IN : ANY_BIT, N : ANY_INT | ANY_BIT |
SHR | IN : ANY_BIT, N : ANY_INT | ANY_BIT |
ROL | IN : ANY_BIT, N : ANY_INT | ANY_BIT |
ROR | IN : ANY_BIT, N : ANY_INT | ANY_BIT |
AND | IN : ANY_BIT (2+ args) | ANY_BIT |
OR | IN : ANY_BIT (2+ args) | ANY_BIT |
XOR | IN : ANY_BIT (2+ args) | ANY_BIT |
NOT | IN : ANY_BIT | ANY_BIT |
SHL, SHR — shift left / right
Section titled “SHL, SHR — shift left / right”Shift IN by N bit positions; vacated bits are filled with zeros.
SHL(IN : ANY_BIT, N : ANY_INT) : ANY_BITSHR(IN : ANY_BIT, N : ANY_INT) : ANY_BITdoubled := SHL(value, 1); // multiply by 2high := SHR(packed, 8); // move the high byte downROL, ROR — rotate left / right
Section titled “ROL, ROR — rotate left / right”Rotate IN by N positions; bits shifted out one end re-enter the other.
ROL(IN : ANY_BIT, N : ANY_INT) : ANY_BITROR(IN : ANY_BIT, N : ANY_INT) : ANY_BITrotated := ROL(pattern, 1);AND, OR, XOR — bitwise logic
Section titled “AND, OR, XOR — bitwise logic”AND, OR and XOR are variadic (two or more inputs) and combine the
inputs bit by bit.
AND(IN : ANY_BIT, ...) : ANY_BIT // 2+ argsOR(IN : ANY_BIT, ...) : ANY_BIT // 2+ argsXOR(IN : ANY_BIT, ...) : ANY_BIT // 2+ argsboth := AND(statusA, statusB);either := OR(flagsA, flagsB);changed := XOR(previous, current);NOT — bitwise complement
Section titled “NOT — bitwise complement”NOT(IN : ANY_BIT) : ANY_BITinverted := NOT(mask);