// The OS/K Team licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. #define PARITY(v) __builtin_parity(v) #define SET_ZF(v) \ R(RFX) = ((v) == 0 ? (R(RFX)|ZF) : (R(RFX)&~ZF)) #define SET_SF(v) \ R(RFX) = ((long)(v) < 0 ? (R(RFX)|SF) : (R(RFX)&~SF)) #define SET_PF(v) \ R(RFX) = (PARITY(v) == 1 ? (R(RFX)|PF) : (R(RFX)&~PF)) #define SET_ZSF(v) \ SET_ZF(v); \ SET_SF(v) #define SET_ZSPF(v) \ SET_ZF(v); \ SET_SF(v); \ SET_PF(v) #define COMPARE(v1, v2) \ ulong _u1 = (ulong)v1, _u2 = (ulong)v2; \ long _s1 = (long)v1, _s2 = (long)v2; \ \ if (_u1 < _u2) R(RFX) |= CF; \ else R(RFX) &= ~CF; \ \ if ( ((_s1 < 0) && (_s1 > LONG_MAX + _s2)) \ || ((_s2 > 0) && (_s1 < LONG_MIN + _s2)) ) \ R(RFX) |= OF; \ else R(RFX) &= ~OF; \ SET_ZSF(_u1 - _u2);