From 5b62cd83cfdac2f6922938ac7d1b61a65a086f37 Mon Sep 17 00:00:00 2001 From: Gabriel Bianconi <1275491+GabrielBianconi@users.noreply.github.com> Date: Sun, 28 Aug 2022 21:42:28 -0400 Subject: [PATCH] Fix comments in extended CHIP-8 emulator Confirmed correctness [here](http://www.cs.columbia.edu/~sedwards/classes/2016/4840-spring/designs/Chip8.pdf). - `0x7xkk`: "adds", not "sets" - S(N)E: "skip", not "store" --- ch5/ch5-cpu4/src/main.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/ch5/ch5-cpu4/src/main.rs b/ch5/ch5-cpu4/src/main.rs index 6fc0db65..de7fa1d8 100644 --- a/ch5/ch5-cpu4/src/main.rs +++ b/ch5/ch5-cpu4/src/main.rs @@ -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; @@ -154,4 +155,4 @@ fn main() { assert_eq!(cpu.registers[0], 45); println!("5 + (10 * 2) + (10 * 2) = {}", cpu.registers[0]); -} \ No newline at end of file +}