mirror of
https://github.com/TomHarte/CLK.git
synced 2024-12-24 12:30:17 +00:00
Incorporates RTR test, adding a ProcessorState helper.
This commit is contained in:
parent
b63231523a
commit
86fdc75feb
@ -1839,6 +1839,26 @@ class CPU::MC68000::ProcessorStorageTests {
|
||||
XCTAssertEqual(state.status & Flag::ConditionCodes, Flag::Zero);
|
||||
}
|
||||
|
||||
// MARK: RTR
|
||||
|
||||
- (void)testRTR {
|
||||
_machine->set_program({
|
||||
0x4e77 // RTR
|
||||
});
|
||||
_machine->set_initial_stack_pointer(0x2000);
|
||||
*_machine->ram_at(0x2000) = 0x7fff;
|
||||
*_machine->ram_at(0x2002) = 0;
|
||||
*_machine->ram_at(0x2004) = 0xc;
|
||||
|
||||
_machine->run_for_instructions(1);
|
||||
|
||||
const auto state = _machine->get_processor_state();
|
||||
XCTAssertEqual(state.stack_pointer(), 0x2006);
|
||||
XCTAssertEqual(state.program_counter, 0x10);
|
||||
XCTAssertEqual(state.status & Flag::ConditionCodes, Flag::ConditionCodes);
|
||||
XCTAssertEqual(20, _machine->get_cycle_count());
|
||||
}
|
||||
|
||||
// MARK: Scc
|
||||
|
||||
- (void)testSFDn {
|
||||
|
@ -220,18 +220,6 @@ class BusHandler {
|
||||
class ProcessorBase: public ProcessorStorage {
|
||||
};
|
||||
|
||||
struct ProcessorState {
|
||||
uint32_t data[8];
|
||||
uint32_t address[7];
|
||||
uint32_t user_stack_pointer, supervisor_stack_pointer;
|
||||
uint32_t program_counter;
|
||||
uint16_t status;
|
||||
|
||||
// TODO: More state needed to indicate current instruction, the processor's
|
||||
// progress through it, and anything it has fetched so far.
|
||||
// uint16_t current_instruction;
|
||||
};
|
||||
|
||||
enum Flag: uint16_t {
|
||||
Trace = 0x8000,
|
||||
Supervisor = 0x2000,
|
||||
@ -245,6 +233,22 @@ enum Flag: uint16_t {
|
||||
Carry = 0x0001
|
||||
};
|
||||
|
||||
struct ProcessorState {
|
||||
uint32_t data[8];
|
||||
uint32_t address[7];
|
||||
uint32_t user_stack_pointer, supervisor_stack_pointer;
|
||||
uint32_t program_counter;
|
||||
uint16_t status;
|
||||
|
||||
uint32_t stack_pointer() const {
|
||||
return (status & Flag::Supervisor) ? supervisor_stack_pointer : user_stack_pointer;
|
||||
}
|
||||
|
||||
// TODO: More state needed to indicate current instruction, the processor's
|
||||
// progress through it, and anything it has fetched so far.
|
||||
// uint16_t current_instruction;
|
||||
};
|
||||
|
||||
template <class T, bool dtack_is_implicit, bool signal_will_perform = false> class Processor: public ProcessorBase {
|
||||
public:
|
||||
Processor(T &bus_handler) : ProcessorBase(), bus_handler_(bus_handler) {}
|
||||
|
@ -19,7 +19,7 @@
|
||||
uint16_t( \
|
||||
get_ccr() | \
|
||||
(interrupt_level_ << 8) | \
|
||||
(trace_flag_ ? 0x8000 : 0x0000) | \
|
||||
(trace_flag_ ? 0x8000 : 0x0000) | \
|
||||
(is_supervisor_ << 13) \
|
||||
)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user