Skip to content

Fix comments in extended CHIP-8 emulator #85

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

Closed
wants to merge 1 commit into from
Closed
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
7 changes: 4 additions & 3 deletions ch5/ch5-cpu4/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,19 @@ impl CPU {
self.registers[vx as usize] = kk;
}

/// (7xkk) Add sets the value `kk` into register `vx`
/// (7xkk) Add adds the value `kk` into register `vx`
fn add(&mut self, vx: u8, kk: u8) {
self.registers[vx as usize] += kk;
}

/// (3xkk / 5xy_) SE **S**kip if **e**qual
fn se(&mut self, vx: u8, kk: u8) {
if vx == kk {
self.position_in_memory += 2;
}
}

/// () SNE **S**tore if **n**ot **e**qual
/// (4xkk) SNE **S**kip if **n**ot **e**qual
fn sne(&mut self, vx: u8, kk: u8) {
if vx != kk {
self.position_in_memory += 2;
Expand Down Expand Up @@ -154,4 +155,4 @@ fn main() {
assert_eq!(cpu.registers[0], 45);

println!("5 + (10 * 2) + (10 * 2) = {}", cpu.registers[0]);
}
}