Fixed overflow calculation to account for signed numbers w/ S
This commit is contained in:
parent
e302b21d0e
commit
a009f43e83
@ -49,12 +49,12 @@ static void executeDPImmediate(Machine *state, a64inst_instruction *inst) {
|
|||||||
|
|
||||||
dword result;
|
dword result;
|
||||||
case(a64inst_ADDS):
|
case(a64inst_ADDS):
|
||||||
result = srcVal + arithmImm;
|
result = truncateValue(srcVal + arithmImm, regType);
|
||||||
writeRegister(state, dest, regType, result);
|
writeRegister(state, dest, regType, result);
|
||||||
|
|
||||||
updateCondNZ(state, result, regType);
|
updateCondNZ(state, result, regType);
|
||||||
state->conditionCodes.Overflow = max(srcVal, arithmImm) > result;
|
state->conditionCodes.Overflow = getMSB(srcVal, regType) == getMSB(arithmImm, regType) && getMSB(result, regType) != getMSB(srcVal, regType);
|
||||||
state->conditionCodes.Carry = state->conditionCodes.Overflow;
|
state->conditionCodes.Carry = max(truncateValue(srcVal, regType), truncateValue(arithmImm, regType)) > result;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case(a64inst_ADD):
|
case(a64inst_ADD):
|
||||||
@ -177,12 +177,12 @@ static void executeDPRegister(Machine *state, a64inst_instruction *inst) {
|
|||||||
switch(inst->data.DPRegisterData.processOp) {
|
switch(inst->data.DPRegisterData.processOp) {
|
||||||
|
|
||||||
case(a64inst_ADDS):
|
case(a64inst_ADDS):
|
||||||
result = src1Val + src2Val;
|
result = truncateValue(src1Val + src2Val, regType);
|
||||||
writeRegister(state, dest, regType, result);
|
writeRegister(state, dest, regType, result);
|
||||||
|
|
||||||
updateCondNZ(state, result, regType);
|
updateCondNZ(state, result, regType);
|
||||||
state->conditionCodes.Overflow = max(src1Val, src2Val) > result;
|
state->conditionCodes.Overflow = getMSB(src1Val, regType) == getMSB(src2Val, regType) && getMSB(result, regType) != getMSB(src1Val, regType);
|
||||||
state->conditionCodes.Carry = state->conditionCodes.Overflow;
|
state->conditionCodes.Carry = max(truncateValue(src1Val, regType), truncateValue(src2Val, regType)) > result;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case(a64inst_ADD):
|
case(a64inst_ADD):
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user