diff --git a/src/execute.c b/src/execute.c index 55f69e6..8271719 100644 --- a/src/execute.c +++ b/src/execute.c @@ -80,7 +80,9 @@ static void writeRegister(Machine *state, a64inst_regSpecifier reg, a64inst_regT // Updates N and Z condition codes given the machine and a result value static void updateCondNZ(Machine *state, dword result, a64inst_regType regType) { - state->conditionCodes.Negative = result & ((1 << (regType ? DWORD_BITS : WORD_BITS)) - 1); + size_t msb = (regType ? DWORD_BITS : WORD_BITS) - 1; + + state->conditionCodes.Negative = result >> msb; state->conditionCodes.Zero = result == 0; } @@ -243,7 +245,7 @@ void execute_SDT(Machine *state, a64inst_instruction *inst) { } else { state->registers[inst->data.SingleTransferData.target] = readDoubleWord(state->memory, address); } - }else { + } else { if (inst->data.SingleTransferData.regType == a64inst_W) { // 32 bit access state->registers[inst->data.SingleTransferData.target] = readWord(state->memory, address);