-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
87e7f90
commit f407b17
Showing
7 changed files
with
29 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,10 @@ | ||
use crate::CPU; | ||
|
||
pub fn inc_sp() -> impl Fn(&mut CPU) { | ||
move |cpu: &mut CPU| { | ||
cpu.pc = cpu.pc.wrapping_add(1); | ||
} | ||
move |_: &mut CPU| {} | ||
} | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
use super::*; | ||
|
||
#[test] | ||
fn test_inc_sp() { | ||
let mut cpu = CPU { | ||
pc: 0xF012, | ||
..Default::default() | ||
}; | ||
inc_sp()(&mut cpu); | ||
assert_eq!(cpu.pc, 0xF013); | ||
} | ||
|
||
#[test] | ||
fn test_inc_sp_wrap() { | ||
let mut cpu = CPU { | ||
pc: 0xFFFF, | ||
..Default::default() | ||
}; | ||
inc_sp()(&mut cpu); | ||
assert_eq!(cpu.pc, 0x0000); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,10 @@ | ||
use super::super::*; | ||
|
||
pub fn nop() -> impl Fn(&mut CPU) { | ||
move |cpu: &mut CPU| { | ||
cpu.pc += 1; | ||
} | ||
move |_: &mut CPU| {} | ||
} | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
use super::*; | ||
|
||
#[test] | ||
fn test_nop() { | ||
let mut cpu = CPU::default(); | ||
nop()(&mut cpu); | ||
assert_eq!(cpu.pc, 1); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters