mirror of
https://github.com/mre/mos6502.git
synced 2024-11-25 02:33:26 +00:00
properly inc PC
This commit is contained in:
parent
f590b2d90c
commit
3e2fecec8f
@ -34,7 +34,8 @@ fn main() {
|
||||
let mut machine = machine::Machine::new();
|
||||
|
||||
// "Load" a program
|
||||
machine.memory.set_byte(&Address(0), 5);
|
||||
machine.memory.set_byte(&Address(0), 0x69); // ADC immediate opcode
|
||||
machine.memory.set_byte(&Address(1), 0x07); // Immediate operand
|
||||
|
||||
|
||||
// Obviously this will run the full program, just
|
||||
|
@ -28,7 +28,7 @@
|
||||
use address::AddressDiff;
|
||||
use std::fmt;
|
||||
use instruction::Instruction;
|
||||
use instruction::ADC;
|
||||
use instruction::{ADC, NOP};
|
||||
use memory::Memory;
|
||||
use registers::{ Registers, Status, StatusArgs };
|
||||
use registers::{ ps_negative, ps_overflow, ps_zero, ps_carry };
|
||||
@ -55,12 +55,15 @@ impl Machine {
|
||||
|
||||
// Will need smarter logic to fetch the correct number of bytes
|
||||
// for instruction
|
||||
self.registers.program_counter.add(&AddressDiff(1));
|
||||
self.registers.program_counter = self.registers.program_counter + AddressDiff(1);
|
||||
instr
|
||||
}
|
||||
|
||||
pub fn decode_instruction(&mut self, raw_instruction: u8) -> Instruction {
|
||||
ADC
|
||||
match raw_instruction {
|
||||
0x69 => ADC,
|
||||
_ => NOP
|
||||
}
|
||||
}
|
||||
|
||||
pub fn execute_instruction(&mut self, instruction: Instruction) {
|
||||
@ -68,6 +71,9 @@ impl Machine {
|
||||
ADC => {
|
||||
println!("executing add with carry");
|
||||
self.add_with_carry(1);
|
||||
},
|
||||
NOP => {
|
||||
println!("nop instr");
|
||||
}
|
||||
_ => println!("attempting to execute unimplemented instruction")
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user