1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-07-03 11:30:02 +00:00

Imports NOT tests, fixes NOT overflow and carry flags.

This commit is contained in:
Thomas Harte 2019-06-25 22:18:11 -04:00
parent 2c813a2692
commit 79066f8628
2 changed files with 74 additions and 0 deletions

View File

@ -3004,6 +3004,77 @@ class CPU::MC68000::ProcessorStorageTests {
XCTAssertEqual(4, _machine->get_cycle_count());
}
// MARK: NOT
- (void)testNOTb {
_machine->set_program({
0x4600 // NOT.B D0
});
auto state = _machine->get_processor_state();
state.data[0] = 0x12345678;
_machine->set_processor_state(state);
_machine->run_for_instructions(1);
state = _machine->get_processor_state();
XCTAssertEqual(state.data[0], 0x12345687);
XCTAssertEqual(state.status & Flag::ConditionCodes, Flag::Negative);
XCTAssertEqual(4, _machine->get_cycle_count());
}
- (void)testNOTw {
_machine->set_program({
0x4640 // NOT.w D0
});
auto state = _machine->get_processor_state();
state.data[0] = 0x12340000;
state.status |= Flag::ConditionCodes;
_machine->set_processor_state(state);
_machine->run_for_instructions(1);
state = _machine->get_processor_state();
XCTAssertEqual(state.data[0], 0x1234ffff);
XCTAssertEqual(state.status & Flag::ConditionCodes, Flag::Negative | Flag::Extend);
XCTAssertEqual(4, _machine->get_cycle_count());
}
- (void)testNOTl_Dn {
_machine->set_program({
0x4680 // NOT.l D0
});
auto state = _machine->get_processor_state();
state.data[0] = 0xffffff00;
state.status |= Flag::ConditionCodes;
_machine->set_processor_state(state);
_machine->run_for_instructions(1);
state = _machine->get_processor_state();
XCTAssertEqual(state.data[0], 0x000000ff);
XCTAssertEqual(state.status & Flag::ConditionCodes, Flag::Extend);
XCTAssertEqual(6, _machine->get_cycle_count());
}
- (void)testNOTl_XXXl {
_machine->set_program({
0x46b9, 0x0000, 0x3000 // NOT.L ($3000).L
});
*_machine->ram_at(0x3000) = 0xf001;
*_machine->ram_at(0x3002) = 0x2311;
auto state = _machine->get_processor_state();
state.status |= Flag::Extend;
_machine->set_processor_state(state);
_machine->run_for_instructions(1);
state = _machine->get_processor_state();
XCTAssertEqual(*_machine->ram_at(0x3000), 0x0ffe);
XCTAssertEqual(*_machine->ram_at(0x3002), 0xdcee);
XCTAssertEqual(state.status & Flag::ConditionCodes, Flag::Extend);
XCTAssertEqual(28, _machine->get_cycle_count());
}
// MARK: PEA
- (void)testPEA_A1 {

View File

@ -1468,18 +1468,21 @@ template <class T, bool dtack_is_implicit, bool signal_will_perform> void Proces
active_program_->destination->halves.low.halves.low ^= 0xff;
zero_result_ = active_program_->destination->halves.low.halves.low;
negative_flag_ = zero_result_ & 0x80;
overflow_flag_ = carry_flag_ = 0;
break;
case Operation::NOTw:
active_program_->destination->halves.low.full ^= 0xffff;
zero_result_ = active_program_->destination->halves.low.full;
negative_flag_ = zero_result_ & 0x8000;
overflow_flag_ = carry_flag_ = 0;
break;
case Operation::NOTl:
active_program_->destination->full ^= 0xffffffff;
zero_result_ = active_program_->destination->full;
negative_flag_ = zero_result_ & 0x80000000;
overflow_flag_ = carry_flag_ = 0;
break;
#define sbcd() \