mirror of
https://github.com/MoleskiCoder/EightBit.git
synced 2024-12-23 00:29:47 +00:00
Add a higher/lower nibble mask
Signed-off-by: Adrian Conlon <Adrian.conlon@gmail.com>
This commit is contained in:
parent
ae177b9b92
commit
116f9961c4
@ -31,7 +31,7 @@ namespace EightBit {
|
||||
}
|
||||
|
||||
virtual register16_t& AF() final {
|
||||
af.low &= 0xf0;
|
||||
af.low = higherNibble(af.low);
|
||||
return af;
|
||||
}
|
||||
|
||||
|
@ -602,7 +602,7 @@ void EightBit::Z80::rrd(uint8_t& a, uint8_t& f) {
|
||||
++MEMPTR().word;
|
||||
const auto memory = BUS().read();
|
||||
BUS().write(promoteNibble(a) | highNibble(memory));
|
||||
a = (a & 0xf0) | lowNibble(memory);
|
||||
a = higherNibble(a) | lowerNibble(memory);
|
||||
adjustSZPXY<Z80>(f, a);
|
||||
clearFlag(f, NF | HC);
|
||||
}
|
||||
@ -612,7 +612,7 @@ void EightBit::Z80::rld(uint8_t& a, uint8_t& f) {
|
||||
++MEMPTR().word;
|
||||
const auto memory = BUS().read();
|
||||
BUS().write(promoteNibble(memory) | lowNibble(a));
|
||||
a = (a & 0xf0) | highNibble(memory);
|
||||
a = higherNibble(a) | highNibble(memory);
|
||||
adjustSZPXY<Z80>(f, a);
|
||||
clearFlag(f, NF | HC);
|
||||
}
|
||||
@ -709,16 +709,16 @@ int EightBit::Z80::execute(const uint8_t opcode) {
|
||||
auto& a = af.high;
|
||||
auto& f = af.low;
|
||||
|
||||
auto prefixed = m_prefixCB || m_prefixED;
|
||||
if (UNLIKELY(prefixed)) {
|
||||
const auto prefixed = m_prefixCB || m_prefixED;
|
||||
if (LIKELY(!prefixed)) {
|
||||
executeOther(a, f, x, y, z, p, q);
|
||||
} else {
|
||||
if (m_prefixCB)
|
||||
executeCB(a, f, x, y, z);
|
||||
else if (m_prefixED)
|
||||
executeED(a, f, x, y, z, p, q);
|
||||
else
|
||||
UNREACHABLE;
|
||||
} else {
|
||||
executeOther(a, f, x, y, z, p, q);
|
||||
}
|
||||
|
||||
ASSUME(cycles() > 0);
|
||||
|
@ -61,6 +61,9 @@ namespace EightBit {
|
||||
static int highNibble(const int value) { return value >> 4; }
|
||||
static int lowNibble(const int value) { return value & Mask4; }
|
||||
|
||||
static int higherNibble(const int value) { return value & 0xf0; }
|
||||
static int lowerNibble(const int value) { return lowNibble(value); }
|
||||
|
||||
static int promoteNibble(const int value) { return value << 4; }
|
||||
static int demoteNibble(const int value) { return highNibble(value); }
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user