mirror of
https://github.com/FEX-Emu/FEX.git
synced 2026-10-06 18:00:17 +02:00
AF is calculated as: ((Src1 ^ Src2) ^ Res)[4] Due to the extract, this is equivalent to ((Src1 ^ Src2) ^ (Res ^ 1))[4] We already store (Res ^ 1) as the PF byte. So, it suffices to store AF Byte = Src1 ^ Src2 and then we can recover the flag value AF = (AF Byte ^ PF Byte)[4] This saves an instruction from the AF calculation. It does couple PF/AF writes. In practice, most instructions fall into one of these categories: * Both PF and AF written together, the coupling is correct. * PF written but AF invalidated, irrelevant. * Both invalidated, irrelevant. None of these require special handling. Where we do need special handling is when we want to write them separately, in which case we can fix-up the value of AF as appropriate. Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>