commit - 0a7f71f87659d462e65e5bd93676f449a510572d
commit + 188a4b42e70bce44d0e2caf07da2462c0bc40d20
blob - 5eb4797855ab2813d2ab84f03f306b91fc948005
blob + afab9ce677416cc1b6b310459f62d5967d24d897
--- src/chip8.rs
+++ src/chip8.rs
/// Execute a given instruction.
pub fn execute(&mut self, instruction: u16) -> Result<(), String> {
let nnn = instruction & 0x0FFF;
+
match instruction & 0xF000 {
0x0 => match nnn {
// CLS
self.stack.push(self.pc + 1);
self.pc = nnn;
},
+ // SE
+ 0x3 => {
+ let reg = instruction & 0x0F00;
+ let byte = (instruction & 0x00FF) as u8;
+
+ // skip next instruction if Vx == byte
+ if self.regs[reg as usize] == byte {
+ self.pc = self.pc + 2;
+ }
+ },
_ => {
return Err(format!("{:#06x}: not an instruction", instruction));
}