"""Logic monomers — 8-bit bitwise operations."""


def and8(a: int, b: int) -> int:
    return (a & b) & 0xFF


def or8(a: int, b: int) -> int:
    return (a | b) & 0xFF


def xor8(a: int, b: int) -> int:
    return (a ^ b) & 0xFF


def not8(a: int) -> int:
    return (~a) & 0xFF


def shl(a: int, n: int) -> int:
    return (a << n) & 0xFF


def shr(a: int, n: int) -> int:
    return (a >> n) & 0xFF


def rol(a: int, n: int) -> int:
    n = n % 8
    return ((a << n) | (a >> (8 - n))) & 0xFF


def ror(a: int, n: int) -> int:
    n = n % 8
    return ((a >> n) | (a << (8 - n))) & 0xFF
