1
0
mirror of https://github.com/mre/mos6502.git synced 2024-11-30 20:51:21 +00:00

Merge pull request #18 from typelist/master

Implement transfer instructions TAX+TXA, TAY+TYA, TSX+TXS
This commit is contained in:
Johannes Muenzel 2014-10-25 19:11:45 -04:00
commit acc31f9858

View File

@ -31,7 +31,7 @@ use address::{Address, AddressDiff};
use instruction;
use instruction::{DecodedInstr};
use memory::Memory;
use registers::{ Registers, Status, StatusArgs };
use registers::{ Registers, StackPointer, Status, StatusArgs };
use registers::{ PS_NEGATIVE, PS_OVERFLOW, PS_ZERO, PS_CARRY };
pub struct Machine {
@ -146,6 +146,35 @@ impl Machine {
self.memory.set_byte(addr, self.registers.index_y as u8);
},
(instruction::TAX, instruction::UseImplied) => {
let val = self.registers.accumulator;
self.load_x_register(val);
},
(instruction::TAY, instruction::UseImplied) => {
let val = self.registers.accumulator;
self.load_y_register(val);
},
(instruction::TSX, instruction::UseImplied) => {
let StackPointer(val) = self.registers.stack_pointer;
let val = val as i8;
self.load_x_register(val);
},
(instruction::TXA, instruction::UseImplied) => {
let val = self.registers.index_x;
self.load_accumulator(val);
},
(instruction::TXS, instruction::UseImplied) => {
// Note that this is the only 'transfer' instruction that does
// NOT set the zero and negative flags. (Because the target
// is the stack pointer)
let val = self.registers.index_x;
self.registers.stack_pointer = StackPointer(val as u8);
},
(instruction::TYA, instruction::UseImplied) => {
let val = self.registers.index_y;
self.load_accumulator(val);
},
(instruction::NOP, _) => {
debug!("nop instr");
},