change how flags works

This commit is contained in:
2026-07-16 17:57:14 +10:00
parent bb0709f6ce
commit 82f9644e15
2 changed files with 20 additions and 7 deletions

View File

@@ -5,13 +5,14 @@ static inline Instruction fetchInst(Emulator* emu) {
}
static inline void updateFlagsRegister(Emulator* emu, int32_t value) {
if (value == 0) {
emu->regs[REG_F] = FLAG_ZERO;
} else if (value < 0) {
emu->regs[REG_F] = FLAG_NEGATIVE;
} else if (value > UINT16_MAX) {
emu->regs[REG_F] = FLAG_OVERFLOW;
}
FlagsRegister flags = (FlagsRegister)emu->regs[REG_F];
flags.fields.zero = value == 0;
flags.fields.negative = value < 0;
flags.fields.overflow = value > UINT16_MAX;
emu->regs[REG_F] = flags.raw;
}
static inline void updateDevices(Emulator* emu) {