mirror of
https://github.com/mre/mos6502.git
synced 2025-01-09 07:30:55 +00:00
get immediate operand when opcode is ADC Immediate
This commit is contained in:
parent
3e2fecec8f
commit
3563f6362c
@ -48,7 +48,9 @@ pub enum Instruction
|
|||||||
// NV BDIZC A X Y S PC M
|
// NV BDIZC A X Y S PC M
|
||||||
//
|
//
|
||||||
// | outputs | inputs
|
// | outputs | inputs
|
||||||
{ ADC // ADd with Carry................ | NV ...ZC A = A + M + C
|
{
|
||||||
|
ADC(i8) // ADd with Carry................ | NV ...ZC A = A + M + C
|
||||||
|
|
||||||
, AND // logical AND (bitwise)......... | N. ...Z. A = A && M
|
, AND // logical AND (bitwise)......... | N. ...Z. A = A && M
|
||||||
, ASL // Arithmetic Shift Left......... | N. ...ZC A = M << 1
|
, ASL // Arithmetic Shift Left......... | N. ...ZC A = M << 1
|
||||||
, BCC // Branch if Carry Clear......... | .. ..... PC = !C
|
, BCC // Branch if Carry Clear......... | .. ..... PC = !C
|
||||||
|
@ -50,27 +50,27 @@ impl Machine {
|
|||||||
*self = Machine::new();
|
*self = Machine::new();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn fetch_instruction(&mut self) -> u8 {
|
pub fn fetch_instruction(&mut self) -> i8 {
|
||||||
let instr = self.memory.get_byte(&self.registers.program_counter);
|
let instr = self.memory.get_byte(&self.registers.program_counter);
|
||||||
|
|
||||||
// Will need smarter logic to fetch the correct number of bytes
|
// Will need smarter logic to fetch the correct number of bytes
|
||||||
// for instruction
|
// for instruction
|
||||||
self.registers.program_counter = self.registers.program_counter + AddressDiff(1);
|
self.registers.program_counter = self.registers.program_counter + AddressDiff(1);
|
||||||
instr
|
instr as i8
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn decode_instruction(&mut self, raw_instruction: u8) -> Instruction {
|
pub fn decode_instruction(&mut self, raw_instruction: i8) -> Instruction {
|
||||||
match raw_instruction {
|
match raw_instruction {
|
||||||
0x69 => ADC,
|
0x69 => ADC(self.fetch_instruction()),
|
||||||
_ => NOP
|
_ => NOP
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn execute_instruction(&mut self, instruction: Instruction) {
|
pub fn execute_instruction(&mut self, instruction: Instruction) {
|
||||||
match instruction {
|
match instruction {
|
||||||
ADC => {
|
ADC(immediate) => {
|
||||||
println!("executing add with carry");
|
println!("executing add with carry");
|
||||||
self.add_with_carry(1);
|
self.add_with_carry(immediate);
|
||||||
},
|
},
|
||||||
NOP => {
|
NOP => {
|
||||||
println!("nop instr");
|
println!("nop instr");
|
||||||
|
Loading…
Reference in New Issue
Block a user