mirror of
https://github.com/MoleskiCoder/EightBit.git
synced 2024-12-23 00:29:47 +00:00
Start added more .net compatibility methods
Signed-off-by: Adrian Conlon <Adrian.conlon@gmail.com>
This commit is contained in:
parent
6d90ea6237
commit
20ebbd4048
@ -436,7 +436,7 @@ void EightBit::Z80::bit(const int n, const uint8_t operand) {
|
|||||||
ASSUME(n <= 7);
|
ASSUME(n <= 7);
|
||||||
setFlag(F(), HC);
|
setFlag(F(), HC);
|
||||||
clearFlag(F(), NF);
|
clearFlag(F(), NF);
|
||||||
const auto discarded = operand & (1 << n);
|
const auto discarded = operand & Chip::bit(n);
|
||||||
adjustSZ<Z80>(F(), discarded);
|
adjustSZ<Z80>(F(), discarded);
|
||||||
clearFlag(F(), PF, discarded);
|
clearFlag(F(), PF, discarded);
|
||||||
}
|
}
|
||||||
@ -444,13 +444,13 @@ void EightBit::Z80::bit(const int n, const uint8_t operand) {
|
|||||||
uint8_t EightBit::Z80::res(const int n, const uint8_t operand) {
|
uint8_t EightBit::Z80::res(const int n, const uint8_t operand) {
|
||||||
ASSUME(n >= 0);
|
ASSUME(n >= 0);
|
||||||
ASSUME(n <= 7);
|
ASSUME(n <= 7);
|
||||||
return operand & ~(1 << n);
|
return operand & ~Chip::bit(n);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t EightBit::Z80::set(const int n, const uint8_t operand) {
|
uint8_t EightBit::Z80::set(const int n, const uint8_t operand) {
|
||||||
ASSUME(n >= 0);
|
ASSUME(n >= 0);
|
||||||
ASSUME(n <= 7);
|
ASSUME(n <= 7);
|
||||||
return operand | (1 << n);
|
return operand | Chip::bit(n);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EightBit::Z80::neg() {
|
void EightBit::Z80::neg() {
|
||||||
|
@ -45,6 +45,8 @@ namespace EightBit {
|
|||||||
Mask16 = Bit16 - 1
|
Mask16 = Bit16 - 1
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static constexpr uint8_t bit(const int which) noexcept { return 1 << which; }
|
||||||
|
|
||||||
static void clearFlag(uint8_t& f, const int flag) noexcept { f &= ~flag; }
|
static void clearFlag(uint8_t& f, const int flag) noexcept { f &= ~flag; }
|
||||||
static void setFlag(uint8_t& f, const int flag) noexcept { f |= flag; }
|
static void setFlag(uint8_t& f, const int flag) noexcept { f |= flag; }
|
||||||
|
|
||||||
|
@ -53,8 +53,8 @@ int EightBit::Processor::execute(const uint8_t value) {
|
|||||||
|
|
||||||
// http://graphics.stanford.edu/~seander/bithacks.html#FixedSignExtend
|
// http://graphics.stanford.edu/~seander/bithacks.html#FixedSignExtend
|
||||||
int8_t EightBit::Processor::signExtend(const int b, uint8_t x) {
|
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
|
const uint8_t m = bit(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.)
|
x = x & (bit(b) - 1); // (Skip this if bits in x above position b are already zero.)
|
||||||
const auto result = (x ^ m) - m;
|
const auto result = (x ^ m) - m;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user