2020-09-29 01:35:46 +00:00
|
|
|
//
|
|
|
|
// 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) {
|
2020-10-15 22:42:38 +00:00
|
|
|
case Register::ProgramCounter: return registers_.pc;
|
2020-09-29 22:42:07 +00:00
|
|
|
case Register::LastOperationAddress: return last_operation_pc_;
|
2020-11-03 02:09:32 +00:00
|
|
|
case Register::StackPointer: return registers_.s.full & (registers_.emulation_flag ? 0xff : 0xffff);
|
2020-10-11 01:33:56 +00:00
|
|
|
case Register::Flags: return get_flags();
|
2020-10-15 22:42:38 +00:00
|
|
|
case Register::A: return registers_.a.full;
|
2020-11-05 01:35:41 +00:00
|
|
|
case Register::X: return registers_.x.full;
|
|
|
|
case Register::Y: return registers_.y.full;
|
2020-10-15 22:42:38 +00:00
|
|
|
case Register::EmulationFlag: return registers_.emulation_flag;
|
|
|
|
case Register::DataBank: return registers_.data_bank >> 16;
|
|
|
|
case Register::ProgramBank: return registers_.program_bank >> 16;
|
|
|
|
case Register::Direct: return registers_.direct;
|
2020-09-29 01:35:46 +00:00
|
|
|
default: return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ProcessorBase::set_value_of_register(Register r, uint16_t value) {
|
|
|
|
switch (r) {
|
2020-10-16 01:10:32 +00:00
|
|
|
case Register::ProgramCounter: registers_.pc = value; break;
|
|
|
|
case Register::StackPointer: registers_.s.full = value; break;
|
|
|
|
case Register::Flags: set_flags(uint8_t(value)); break;
|
|
|
|
case Register::A: registers_.a.full = value; break;
|
2020-11-05 01:35:41 +00:00
|
|
|
case Register::X: registers_.x.full = value & registers_.x_mask; break;
|
|
|
|
case Register::Y: registers_.y.full = value & registers_.x_mask; break;
|
2020-10-16 01:10:32 +00:00
|
|
|
case Register::EmulationFlag: set_emulation_mode(value); break;
|
|
|
|
case Register::DataBank: registers_.data_bank = uint32_t(value & 0xff) << 16; break;
|
|
|
|
case Register::ProgramBank: registers_.program_bank = uint32_t(value &0xff) << 16; break;
|
|
|
|
case Register::Direct: registers_.direct = value; break;
|
2020-09-29 01:35:46 +00:00
|
|
|
default: break;
|
|
|
|
}
|
|
|
|
}
|