1
0
mirror of https://gitlab.os-k.eu/os-k-team/kvisc.git synced 2023-08-25 14:05:46 +02:00
kvisc/vm/in/flags.h
2019-06-13 15:47:20 +02:00

33 lines
1.5 KiB
C

// 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) \
flg = ((v) == 0 ? (flg|ZF) : (flg&~ZF))
#define SET_SF(v) \
flg = ((long)(v) < 0 ? (flg|SF) : (flg&~SF))
#define SET_PF(v) \
flg = (PARITY(v) == 1 ? (flg|PF) : (flg&~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) \
if (v1 < v2) flg |= CF; \
else flg &= ~CF; \
if ( ((v2 < 0) && (v1 > LONG_MAX + v2)) \
|| ((v2 > 0) && (v1 < LONG_MIN + v2)) ) \
flg |= OF; \
else flg &= ~OF; \
SET_ZSF(v1 - v2);