CPU: Implement TRB/TSB instructions
This commit is contained in:
parent
3cf0b0e46d
commit
f979d31971
2 changed files with 31 additions and 7 deletions
|
@ -799,9 +799,9 @@ void Cpu::STZ()
|
||||||
/*******************
|
/*******************
|
||||||
Bit test operations
|
Bit test operations
|
||||||
********************/
|
********************/
|
||||||
template<typename T> void Cpu::TestBits(T value)
|
template<typename T> void Cpu::TestBits(T value, bool alterZeroFlagOnly)
|
||||||
{
|
{
|
||||||
if(_instAddrMode <= AddrMode::ImmM) {
|
if(alterZeroFlagOnly) {
|
||||||
//"Immediate addressing only affects the z flag (with the result of the bitwise And), but does not affect the n and v flags."
|
//"Immediate addressing only affects the z flag (with the result of the bitwise And), but does not affect the n and v flags."
|
||||||
if(((T)_state.A & value) == 0) {
|
if(((T)_state.A & value) == 0) {
|
||||||
SetFlags(ProcFlags::Zero);
|
SetFlags(ProcFlags::Zero);
|
||||||
|
@ -827,20 +827,44 @@ template<typename T> void Cpu::TestBits(T value)
|
||||||
void Cpu::BIT()
|
void Cpu::BIT()
|
||||||
{
|
{
|
||||||
if(CheckFlag(ProcFlags::MemoryMode8)) {
|
if(CheckFlag(ProcFlags::MemoryMode8)) {
|
||||||
TestBits<uint8_t>(GetByteValue());
|
TestBits<uint8_t>(GetByteValue(), _instAddrMode <= AddrMode::ImmM);
|
||||||
} else {
|
} else {
|
||||||
TestBits<uint16_t>(GetWordValue());
|
TestBits<uint16_t>(GetWordValue(), _instAddrMode <= AddrMode::ImmM);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Cpu::TRB()
|
void Cpu::TRB()
|
||||||
{
|
{
|
||||||
//TODO
|
if(CheckFlag(ProcFlags::MemoryMode8)) {
|
||||||
|
TestBits<uint8_t>(GetByteValue(), true);
|
||||||
|
|
||||||
|
uint8_t value = ReadData(_operand);
|
||||||
|
value &= ~_state.A;
|
||||||
|
Write(_operand, value);
|
||||||
|
} else {
|
||||||
|
TestBits<uint16_t>(GetWordValue(), true);
|
||||||
|
|
||||||
|
uint16_t value = ReadDataWord(_operand);
|
||||||
|
value &= ~_state.A;
|
||||||
|
WriteWord(_operand, value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Cpu::TSB()
|
void Cpu::TSB()
|
||||||
{
|
{
|
||||||
//TODO
|
if(CheckFlag(ProcFlags::MemoryMode8)) {
|
||||||
|
TestBits<uint8_t>(GetByteValue(), true);
|
||||||
|
|
||||||
|
uint8_t value = ReadData(_operand);
|
||||||
|
value |= _state.A;
|
||||||
|
Write(_operand, value);
|
||||||
|
} else {
|
||||||
|
TestBits<uint16_t>(GetWordValue(), true);
|
||||||
|
|
||||||
|
uint16_t value = ReadDataWord(_operand);
|
||||||
|
value |= _state.A;
|
||||||
|
WriteWord(_operand, value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************
|
/******************
|
||||||
|
|
|
@ -205,7 +205,7 @@ private:
|
||||||
void STZ();
|
void STZ();
|
||||||
|
|
||||||
//Test bits
|
//Test bits
|
||||||
template<typename T> void TestBits(T value);
|
template<typename T> void TestBits(T value, bool alterZeroFlagOnly);
|
||||||
void BIT();
|
void BIT();
|
||||||
|
|
||||||
void TRB();
|
void TRB();
|
||||||
|
|
Loading…
Add table
Reference in a new issue