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

Adds and satisfies test on the function code word.

Thanks to ijor's "68000 Address and Bus Error Stack Frame" re: contents.
This commit is contained in:
Thomas Harte 2020-01-04 23:58:07 -05:00
parent f0d5bbecf2
commit 9f2f547932
2 changed files with 18 additions and 4 deletions

View File

@ -239,7 +239,12 @@ class CPU::MC68000::ProcessorStorageTests {
const auto stack_frame = _machine->ram_at(0x1f8);
// Function code et al.
// XCTAssertEqual(stack_frame[0], 0x0000); // ??
XCTAssertEqual(stack_frame[0],
(0x4a9e & 0xffe0) | // Top 11 bits: decoded instruction;
0x10 | // Bit 4: read or write;
0x0 | // Bit 3: 0 = in instruction, 1 = not;
0x5 // Bits 02: FC02, i.e. bit 2 = supervisor, bit 1 = is program, bit 0 = is data.
);
// Access address.
XCTAssertEqual(stack_frame[1], 0x0000);

View File

@ -41,7 +41,8 @@
((active_step_->microcycle.operation & Microcycle::IsProgram) ? 0x02 : 0x01) | \
(is_supervisor_ << 2) | \
(active_program_ ? 0x08 : 0) | \
((active_step_->microcycle.operation & Microcycle::Read) ? 0x10 : 0) \
((active_step_->microcycle.operation & Microcycle::Read) ? 0x10 : 0) | \
(decoded_instruction_.full & 0xffe0) \
)
#define u_extend16(x) uint32_t(int16_t(x))
@ -100,8 +101,9 @@ template <class T, bool dtack_is_implicit, bool signal_will_perform> void Proces
const auto offending_address = *active_step_->microcycle.address;
active_program_ = nullptr;
active_micro_op_ = long_exception_micro_ops_;
active_step_ = &all_bus_steps_[active_micro_op_->bus_program];
populate_bus_error_steps(2, get_status(), get_bus_code(), offending_address);
program_counter_.full -= 4;
active_step_ = &all_bus_steps_[active_micro_op_->bus_program];
}
}
@ -114,9 +116,16 @@ template <class T, bool dtack_is_implicit, bool signal_will_perform> void Proces
const auto offending_address = *active_step_->microcycle.address;
active_program_ = nullptr;
active_micro_op_ = long_exception_micro_ops_;
active_step_ = &all_bus_steps_[active_micro_op_->bus_program];
populate_bus_error_steps(3, get_status(), get_bus_code(), offending_address);
program_counter_.full -= 4;
active_step_ = &all_bus_steps_[active_micro_op_->bus_program];
// TODO: the above is only correct prior to the final microcycle of an
// instruction. If an exception occurs in the final microcycle then
// the next instruction will already have moved into the current instruction
// slot (decoded_instruction_ in my terms).
// TODO: it's also not correct for a bus error that occurs during another exception.
}
// Perform the microcycle if it is of non-zero length. If this is an operation that