Tidy EightBit library header usage (avoids compilation error with latest VS2019, "Memory.h")

Signed-off-by: Adrian Conlon <adrian.conlon@gmail.com>
This commit is contained in:
Adrian Conlon
2021-05-29 10:31:32 +01:00
parent b1ca06447f
commit d199adb027
18 changed files with 45 additions and 58 deletions
+7 -1
View File
@@ -11,9 +11,15 @@
namespace EightBit {
class Processor : public ClockedChip {
public:
// http://graphics.stanford.edu/~seander/bithacks.html#FixedSignExtend
// b: number of bits representing the number in x
// x: sign extend this b-bit number to r
[[nodiscard]] static int8_t signExtend(int b, uint8_t x) noexcept;
[[nodiscard]] static constexpr int8_t signExtend(int b, uint8_t x) noexcept {
const uint8_t m = bit(b - 1); // mask can be pre-computed if b is fixed
x = x & (bit(b) - 1); // (Skip this if bits in x above position b are already zero.)
const auto result = (x ^ m) - m;
return result;
}
~Processor() = default;