diff --git a/src/execute.c b/src/execute.c index 7ad18da..1f37999 100644 --- a/src/execute.c +++ b/src/execute.c @@ -134,8 +134,8 @@ static void executeDPImmediate(Machine *state, a64inst_instruction *inst) { writeRegister(state, dest, regType, result); updateCondNZ(state, result, regType); - state->conditionCodes.Overflow = srcVal < result; - state->conditionCodes.Carry = state->conditionCodes.Overflow; + state->conditionCodes.Overflow = getMSB(srcVal, regType) != getMSB(arithmImm, regType) && getMSB(arithmImm, regType) == getMSB(result, regType); + state->conditionCodes.Carry = srcVal >= arithmImm; break; case(a64inst_SUB): @@ -262,7 +262,7 @@ static void executeDPRegister(Machine *state, a64inst_instruction *inst) { writeRegister(state, dest, regType, result); updateCondNZ(state, result, regType); - state->conditionCodes.Overflow = getMSB(src1Val, regType) != getMSB(src2Val, regType) && getMSB(src1Val, regType) != getMSB(result, regType); + state->conditionCodes.Overflow = getMSB(src1Val, regType) != getMSB(src2Val, regType) && getMSB(src2Val, regType) == getMSB(result, regType); state->conditionCodes.Carry = src1Val >= src2Val; break;