Key Min Max Mask
k1 00000001B 00000100B 00000111B
K2 00001000B 00100000B 00111000B
K3 01000000B 10000000B 11000000B
;--------------------------------------------------------------------
DATA595=MIN(1) OR MIN(2) OR MIN(3)
DO
CALL KEY_INPUT(KEY)
IN KEY<>0 THEN
A = DATA595 AND MASK(KEY)
IF A = MAX(KEY) THEN
A = MIN(KEY)
ELSE
A = A + A
END IF
DATA595 = (DATA595 AND (NOT MASK(KEY))) OR A
KEY = 0
END IF