Exemplo n.º 1
0
inline static INT32 add(INT32 a, INT32 b, UINT8 &flags) {
	INT32 aSign = a & SIGN_BIT_24;
	INT32 bSign = b & SIGN_BIT_24;
	INT32 result = a + b;
	INT32 resultSign = result & SIGN_BIT_24;
	bool overflow = (aSign == bSign) && (aSign != resultSign);
	bool carry = result & CARRY_OUT_24;
	bool negative = resultSign != 0;
	bool lessThan = (overflow && !negative) || (!overflow && negative);
	flags = setFlagTo(flags, FLAG_C, carry);
	flags = setFlagTo(flags, FLAG_N, negative);
	flags = setFlagTo(flags, FLAG_Z, result == 0);
	flags = setFlagTo(flags, FLAG_V, overflow);
	flags = setFlagTo(flags, FLAG_LT, lessThan);
	return SC(result);
}
Exemplo n.º 2
0
inline static int32_t add(int32_t a, int32_t b, uint8_t &flags) {
	int32_t aSign = a & SIGN_BIT_24;
	int32_t bSign = b & SIGN_BIT_24;
	int32_t result = a + b;
	int32_t resultSign = result & SIGN_BIT_24;
	bool overflow = (aSign == bSign) && (aSign != resultSign);
	bool carry = result & CARRY_OUT_24;
	bool negative = resultSign != 0;
	bool lessThan = (overflow && !negative) || (!overflow && negative);
	flags = setFlagTo(flags, FLAG_C, carry);
	flags = setFlagTo(flags, FLAG_N, negative);
	flags = setFlagTo(flags, FLAG_Z, result == 0);
	flags = setFlagTo(flags, FLAG_V, overflow);
	flags = setFlagTo(flags, FLAG_LT, lessThan);
	return SC(result);
}
Exemplo n.º 3
0
inline static INT32 add(INT32 a, INT32 b, UINT8 &flags) {
	INT32 aSign = a & 0x00800000;
	INT32 bSign = (b & 0x00800000) == 0;
	INT32 result = a + b;
	INT32 resultSign = result & 0x00800000;
	bool overflow = (aSign == bSign) && (aSign != resultSign);
	bool carry = result & 0x01000000;
	bool negative = resultSign != 0;
	bool lessThan = (overflow && !negative) || (!overflow && negative);
	flags = setFlagTo(flags, FLAG_C, carry);
	flags = setFlagTo(flags, FLAG_N, negative);
	flags = setFlagTo(flags, FLAG_Z, result == 0);
	flags = setFlagTo(flags, FLAG_V, overflow);
	flags = setFlagTo(flags, FLAG_LT, lessThan);
	return result;
}
Exemplo n.º 4
0
inline static INT32 asl(INT32 value, int shift, UINT8 &flags) {
	INT32 signBefore = value & SIGN_BIT_24;
	INT32 result = value << shift;
	INT32 signAfter = result & SIGN_BIT_24;
	bool overflow = signBefore != signAfter;
	flags = setFlagTo(flags, FLAG_V, overflow);
	return saturate(result, flags, signBefore != 0);
}
Exemplo n.º 5
0
inline static INT32 saturate(INT32 value, UINT8 &flags, bool negative) {
	if (isFlagSet(flags, FLAG_V)) {
		setFlagTo(flags, FLAG_N, negative);
		return negative ? MIN_24 : MAX_24;
	} else {
		return value;
	}
}
Exemplo n.º 6
0
inline static int32_t asl(int32_t value, int shift, uint8_t &flags) {
	int32_t signBefore = value & SIGN_BIT_24;
	int32_t result = value << shift;
	int32_t signAfter = result & SIGN_BIT_24;
	bool overflow = signBefore != signAfter;
	flags = setFlagTo(flags, FLAG_V, overflow);
	return saturate(result, flags, signBefore != 0);
}
Exemplo n.º 7
0
inline static int32_t saturate(int32_t value, uint8_t &flags, bool negative) {
	if (isFlagSet(flags, FLAG_V)) {
		setFlagTo(flags, FLAG_N, negative);
		return negative ? MIN_24 : MAX_24;
	} else {
		return value;
	}
}
Exemplo n.º 8
0
inline static INT32 asl(INT32 value, int shift, UINT8 &flags) {
	INT32 signBefore = value & 0x00800000;
	INT32 result = (value << shift) & 0x00ffffff;
	INT32 signAfter = result & 0x00800000;
	bool overflow = signBefore != signAfter;
	flags = setFlagTo(flags, FLAG_V, overflow);
	return saturate(result, flags);
}