Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use correct timings in JMP #208

Merged
merged 1 commit into from
Jan 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions core/src/mos6502.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,10 +206,10 @@ Pipeline Mos6502::parse_next_instruction() {
result.push([=]() { stack_.push_byte(registers_->a); });
break;
case Instruction::JmpAbsolute:
result.push([=]() { ++registers_->pc; });
result.push([=]() { tmp_ = mmu_->read_byte(registers_->pc++); });
result.push([=]() {
registers_->pc =
mmu_->read_word(registers_->pc - static_cast<uint16_t>(1));
const uint16_t pch = mmu_->read_byte(registers_->pc) << 8u;
registers_->pc = pch | tmp_;
});
break;
case Instruction::BvcRelative:
Expand Down
3 changes: 2 additions & 1 deletion core/test/src/test_cpu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1156,7 +1156,8 @@ TEST_F(CpuTest, jmp) {
stage_instruction(JMP);
expected.pc = 0x1234;

EXPECT_CALL(mmu, read_word(registers.pc + 1)).WillOnce(Return(0x1234));
EXPECT_CALL(mmu, read_byte(registers.pc + 1u)).WillOnce(Return(0x34));
EXPECT_CALL(mmu, read_byte(registers.pc + 2u)).WillOnce(Return(0x12));

step_execution(3);

Expand Down