1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-11-26 23:52:26 +00:00
CLK/Processors/65816/Implementation/65816Base.cpp
Thomas Harte b22aa5d699 Starts transcribing the addressing examples I have into tests.
Correspondingly extends the exposed register set and test-machine addressing range.
2020-10-13 21:38:30 -04:00

45 lines
1.5 KiB
C++

//
// 65816Base.cpp
// Clock Signal
//
// Created by Thomas Harte on 28/09/2020.
// Copyright © 2020 Thomas Harte. All rights reserved.
//
#include "../65816.hpp"
using namespace CPU::WDC65816;
uint16_t ProcessorBase::get_value_of_register(Register r) const {
switch (r) {
case Register::ProgramCounter: return pc_;
case Register::LastOperationAddress: return last_operation_pc_;
case Register::StackPointer: return s_.full;
case Register::Flags: return get_flags();
case Register::A: return a_.full;
case Register::X: return x_.full;
case Register::Y: return y_.full;
case Register::EmulationFlag: return emulation_flag_;
case Register::DataBank: return data_bank_ >> 16;
case Register::ProgramBank: return program_bank_ >> 16;
case Register::Direct: return direct_;
default: return 0;
}
}
void ProcessorBase::set_value_of_register(Register r, uint16_t value) {
switch (r) {
case Register::ProgramCounter: pc_ = value; break;
case Register::StackPointer: s_.full = value; break;
case Register::Flags: set_flags(uint8_t(value)); break;
case Register::A: a_.full = value; break;
case Register::X: x_.full = value; break;
case Register::Y: y_.full = value; break;
case Register::EmulationFlag: set_emulation_mode(value); break;
case Register::DataBank: data_bank_ = uint32_t(value) << 16; break;
case Register::ProgramBank: program_bank_ = uint32_t(value) << 16; break;
case Register::Direct: direct_ = value; break;
default: break;
}
}