From 20abdc9ff6cbdb07d59ad8edd8ad63a0cb37f7d5 Mon Sep 17 00:00:00 2001 From: Johannes Muenzel Date: Sat, 25 Oct 2014 18:30:05 -0400 Subject: [PATCH] Implement store instructions STA, STX, STY --- src/machine.rs | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/src/machine.rs b/src/machine.rs index 4e7f3b8..729a8a9 100644 --- a/src/machine.rs +++ b/src/machine.rs @@ -90,6 +90,13 @@ impl Machine { self.add_with_carry(val); }, + (instruction::BMI, instruction::UseRelative(rel)) => { + let addr = self.registers.program_counter + + AddressDiff(rel as i32); + log!(log::DEBUG, "branch if minus relative. address: {}", addr); + self.branch_if_minus(addr); + }, + (instruction::DEC, instruction::UseAddress(addr)) => { self.decrement_memory(addr) } @@ -102,13 +109,6 @@ impl Machine { self.jump(addr) }, - (instruction::BMI, instruction::UseRelative(rel)) => { - let addr = self.registers.program_counter - + AddressDiff(rel as i32); - log!(log::DEBUG, "branch if minus relative. address: {}", addr); - self.branch_if_minus(addr); - }, - (instruction::LDA, instruction::UseImmediate(val)) => { log!(log::DEBUG, "load A immediate: {}", val); self.load_accumulator(val as i8); @@ -139,6 +139,16 @@ impl Machine { self.load_y_register(val as i8); }, + (instruction::STA, instruction::UseAddress(addr)) => { + self.memory.set_byte(addr, self.registers.accumulator as u8); + }, + (instruction::STX, instruction::UseAddress(addr)) => { + self.memory.set_byte(addr, self.registers.index_x as u8); + }, + (instruction::STY, instruction::UseAddress(addr)) => { + self.memory.set_byte(addr, self.registers.index_y as u8); + }, + (instruction::NOP, _) => { log!(log::DEBUG, "nop instr"); },