public void setFlag(int bit, boolean on) {
        switch (bit) {
            case LegacyState.SREG_I:
                if (on) enableInterrupts();
                else disableInterrupts();
                break;
            case LegacyState.SREG_T: T = on; break;
            case LegacyState.SREG_H: H = on; break;
            case LegacyState.SREG_S: S = on; break;
            case LegacyState.SREG_V: V = on; break;
            case LegacyState.SREG_N: N = on; break;
            case LegacyState.SREG_Z: Z = on; break;
            case LegacyState.SREG_C: C = on; break;
        }
    }