1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-11-29 12:50:28 +00:00

Resolve further type conversion warnings.

This commit is contained in:
Thomas Harte 2023-12-05 16:54:11 -05:00
parent fd8afb6668
commit 084efdeb2d

View File

@ -54,15 +54,16 @@ void rcl(
case 0: break; case 0: break;
case Numeric::bit_size<IntT>(): { case Numeric::bit_size<IntT>(): {
const IntT temp_carry = destination & 1; const IntT temp_carry = destination & 1;
destination = (destination >> 1) | (carry << (Numeric::bit_size<IntT>() - 1)); destination = IntT((destination >> 1) | (carry << (Numeric::bit_size<IntT>() - 1)));
carry = temp_carry; carry = temp_carry;
} break; } break;
default: { default: {
const IntT temp_carry = destination & (Numeric::top_bit<IntT>() >> (temp_count - 1)); const IntT temp_carry = destination & (Numeric::top_bit<IntT>() >> (temp_count - 1));
destination = destination = IntT(
(destination << temp_count) | (destination << temp_count) |
(destination >> (Numeric::bit_size<IntT>() + 1 - temp_count)) | (destination >> (Numeric::bit_size<IntT>() + 1 - temp_count)) |
(carry << (temp_count - 1)); (carry << (temp_count - 1))
);
carry = temp_carry ? 1 : 0; carry = temp_carry ? 1 : 0;
} break; } break;
} }
@ -103,15 +104,16 @@ void rcr(
case 0: break; case 0: break;
case Numeric::bit_size<IntT>(): { case Numeric::bit_size<IntT>(): {
const IntT temp_carry = destination & Numeric::top_bit<IntT>(); const IntT temp_carry = destination & Numeric::top_bit<IntT>();
destination = (destination << 1) | carry; destination = IntT((destination << 1) | carry);
carry = temp_carry; carry = temp_carry;
} break; } break;
default: { default: {
const IntT temp_carry = destination & (1 << (temp_count - 1)); const IntT temp_carry = destination & (1 << (temp_count - 1));
destination = destination = IntT(
(destination >> temp_count) | (destination >> temp_count) |
(destination << (Numeric::bit_size<IntT>() + 1 - temp_count)) | (destination << (Numeric::bit_size<IntT>() + 1 - temp_count)) |
(carry << (Numeric::bit_size<IntT>() - temp_count)); (carry << (Numeric::bit_size<IntT>() - temp_count))
);
carry = temp_carry; carry = temp_carry;
} break; } break;
} }
@ -159,9 +161,10 @@ void rol(
return; return;
} }
if(temp_count) { if(temp_count) {
destination = destination = IntT(
(destination << temp_count) | (destination << temp_count) |
(destination >> (Numeric::bit_size<IntT>() - temp_count)); (destination >> (Numeric::bit_size<IntT>() - temp_count))
);
} }
context.flags.template set_from<Flag::Carry>(destination & 1); context.flags.template set_from<Flag::Carry>(destination & 1);
@ -210,9 +213,10 @@ void ror(
return; return;
} }
if(temp_count) { if(temp_count) {
destination = destination = IntT(
(destination >> temp_count) | (destination >> temp_count) |
(destination << (Numeric::bit_size<IntT>() - temp_count)); (destination << (Numeric::bit_size<IntT>() - temp_count))
);
} }
context.flags.template set_from<Flag::Carry>(destination & Numeric::top_bit<IntT>()); context.flags.template set_from<Flag::Carry>(destination & Numeric::top_bit<IntT>());
@ -298,9 +302,9 @@ void sal(
context.flags.template set_from<Flag::Carry>( context.flags.template set_from<Flag::Carry>(
destination & mask destination & mask
); );
context.flags.template set_from<Flag::Overflow>( context.flags.template set_from<Flag::Overflow>(IntT(
(destination ^ (destination << 1)) & mask (destination ^ (destination << 1)) & mask
); ));
destination <<= count; destination <<= count;
} }
break; break;
@ -323,7 +327,7 @@ void sar(
destination = sign ? IntT(~0) : IntT(0); destination = sign ? IntT(~0) : IntT(0);
context.flags.template set_from<Flag::Carry>(sign); context.flags.template set_from<Flag::Carry>(sign);
} else { } else {
const IntT mask = 1 << (count - 1); const auto mask = IntT(1 << (count - 1));
context.flags.template set_from<Flag::Carry>(destination & mask); context.flags.template set_from<Flag::Carry>(destination & mask);
destination = (destination >> count) | (sign ? ~(IntT(~0) >> count) : 0); destination = (destination >> count) | (sign ? ~(IntT(~0) >> count) : 0);
} }
@ -349,7 +353,7 @@ void shr(
context.flags.template set_from<Flag::Carry>(0); context.flags.template set_from<Flag::Carry>(0);
destination = 0; destination = 0;
} else { } else {
const IntT mask = 1 << (count - 1); const auto mask = IntT(1 << (count - 1));
context.flags.template set_from<Flag::Carry>(destination & mask); context.flags.template set_from<Flag::Carry>(destination & mask);
destination >>= count; destination >>= count;
} }