Start added more .net compatibility methods

Signed-off-by: Adrian Conlon <Adrian.conlon@gmail.com>
This commit is contained in:
Adrian Conlon
2019-11-03 09:23:28 +00:00
parent 6d90ea6237
commit 20ebbd4048
3 changed files with 7 additions and 5 deletions

View File

@@ -53,8 +53,8 @@ int EightBit::Processor::execute(const uint8_t value) {
// http://graphics.stanford.edu/~seander/bithacks.html#FixedSignExtend
int8_t EightBit::Processor::signExtend(const int b, uint8_t x) {
const uint8_t m = 1 << (b - 1); // mask can be pre-computed if b is fixed
x = x & ((1 << b) - 1); // (Skip this if bits in x above position b are already zero.)
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;
}