mirror of
https://github.com/MoleskiCoder/EightBit.git
synced 2026-04-26 06:17:47 +00:00
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:
+7
-1
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user