Fixed overflow calculation to account for signed numbers w/ S

This commit is contained in:
Themis Demetriades 2024-06-12 17:09:07 +01:00
parent e302b21d0e
commit a009f43e83

View File

@ -49,12 +49,12 @@ static void executeDPImmediate(Machine *state, a64inst_instruction *inst) {
dword result;
case(a64inst_ADDS):
result = srcVal + arithmImm;
result = truncateValue(srcVal + arithmImm, regType);
writeRegister(state, dest, regType, result);
updateCondNZ(state, result, regType);
state->conditionCodes.Overflow = max(srcVal, arithmImm) > result;
state->conditionCodes.Carry = state->conditionCodes.Overflow;
state->conditionCodes.Overflow = getMSB(srcVal, regType) == getMSB(arithmImm, regType) && getMSB(result, regType) != getMSB(srcVal, regType);
state->conditionCodes.Carry = max(truncateValue(srcVal, regType), truncateValue(arithmImm, regType)) > result;
break;
case(a64inst_ADD):
@ -177,12 +177,12 @@ static void executeDPRegister(Machine *state, a64inst_instruction *inst) {
switch(inst->data.DPRegisterData.processOp) {
case(a64inst_ADDS):
result = src1Val + src2Val;
result = truncateValue(src1Val + src2Val, regType);
writeRegister(state, dest, regType, result);
updateCondNZ(state, result, regType);
state->conditionCodes.Overflow = max(src1Val, src2Val) > result;
state->conditionCodes.Carry = state->conditionCodes.Overflow;
state->conditionCodes.Overflow = getMSB(src1Val, regType) == getMSB(src2Val, regType) && getMSB(result, regType) != getMSB(src1Val, regType);
state->conditionCodes.Carry = max(truncateValue(src1Val, regType), truncateValue(src2Val, regType)) > result;
break;
case(a64inst_ADD):