Skip to content

Commit

Permalink
Fix CALL and add test
Browse files Browse the repository at this point in the history
  • Loading branch information
ytausky committed Feb 17, 2020
1 parent 4dbf948 commit ecceca5
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/cpu/instruction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,7 @@ impl<'a> RunView<'a, InstructionExecutionState> {
self.push_byte(low_byte(pc))
}
M7 => self.execute_m1(),
_ => unreachable!(),
}
}

Expand Down
4 changes: 3 additions & 1 deletion src/cpu/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,7 @@ enum MCycle {
M5,
M6,
M7,
M8,
}

impl MCycle {
Expand All @@ -327,7 +328,8 @@ impl MCycle {
M4 => M5,
M5 => M6,
M6 => M7,
M7 => unreachable!(),
M7 => M8,
M8 => unreachable!(),
}
}
}
Expand Down
8 changes: 8 additions & 0 deletions src/cpu/tests/branch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,14 @@ fn call_bus_activity() {
assert_eq!(bench.trace, bench.expected)
}

#[test]
fn ret_after_call() {
let mut bench = TestBench::default();
bench.trace_call(0x1234);
bench.trace_ret(0x5678);
assert_eq!(bench.trace, bench.expected)
}

impl TestBench {
fn trace_call(&mut self, target: u16) {
let sp = self.cpu.data.sp;
Expand Down

0 comments on commit ecceca5

Please sign in to comment.