1
0
mirror of https://github.com/TomHarte/CLK.git synced 2025-04-21 02:37:44 +00:00

Split the preauthorised tracks.

This commit is contained in:
Thomas Harte 2023-11-01 14:31:42 -04:00
parent ef83ac855a
commit 097b328075
3 changed files with 11 additions and 9 deletions

View File

@ -196,7 +196,7 @@ namespace Primitive {
template <typename IntT, bool Preauthorised, typename MemoryT, typename RegistersT>
void push(IntT &value, MemoryT &memory, RegistersT &registers) {
registers.sp_ -= sizeof(IntT);
memory.template access<IntT, Preauthorised ? AccessType::Preauthorised : AccessType::Write>(
memory.template access<IntT, Preauthorised ? AccessType::PreauthorisedWrite : AccessType::Write>(
InstructionSet::x86::Source::SS,
registers.sp_) = value;
memory.template write_back<IntT>();
@ -204,7 +204,7 @@ void push(IntT &value, MemoryT &memory, RegistersT &registers) {
template <typename IntT, bool Preauthorised, typename MemoryT, typename RegistersT>
IntT pop(MemoryT &memory, RegistersT &registers) {
const auto value = memory.template access<IntT, Preauthorised ? AccessType::Preauthorised : AccessType::Read>(
const auto value = memory.template access<IntT, Preauthorised ? AccessType::PreauthorisedRead : AccessType::Read>(
InstructionSet::x86::Source::SS,
registers.sp_);
registers.sp_ += sizeof(IntT);
@ -850,13 +850,13 @@ void call_far(InstructionT &instruction,
case Source::Immediate: flow_controller.call(instruction.segment(), instruction.offset()); return;
case Source::Indirect:
source_address = address<model, Source::Indirect, uint16_t, AccessType::Preauthorised>(instruction, pointer, registers, memory);
source_address = address<model, Source::Indirect, uint16_t, AccessType::Read>(instruction, pointer, registers, memory);
break;
case Source::IndirectNoBase:
source_address = address<model, Source::IndirectNoBase, uint16_t, AccessType::Preauthorised>(instruction, pointer, registers, memory);
source_address = address<model, Source::IndirectNoBase, uint16_t, AccessType::Read>(instruction, pointer, registers, memory);
break;
case Source::DirectAddress:
source_address = address<model, Source::DirectAddress, uint16_t, AccessType::Preauthorised>(instruction, pointer, registers, memory);
source_address = address<model, Source::DirectAddress, uint16_t, AccessType::Read>(instruction, pointer, registers, memory);
break;
}
@ -954,7 +954,7 @@ void lea(
RegistersT &registers
) {
// TODO: address size.
destination = IntT(address<model, uint16_t, AccessType::Preauthorised>(instruction, instruction.source(), registers, memory));
destination = IntT(address<model, uint16_t, AccessType::Read>(instruction, instruction.source(), registers, memory));
}
template <typename AddressT, typename InstructionT, typename MemoryT, typename RegistersT>

View File

@ -32,7 +32,8 @@ enum class AccessType {
/// need further to inspect. This is done e.g. by operations that will push multiple values to the stack to verify that
/// all necessary stack space is available ahead of pushing anything, though each individual push will then result in
/// a further `Preauthorised` access.
Preauthorised,
PreauthorisedRead,
PreauthorisedWrite,
};
/// Performs @c instruction querying @c registers and/or @c memory as required, using @c io for port input/output,

View File

@ -173,17 +173,18 @@ struct Memory {
// Reads: return a value directly.
template <typename IntT> struct ReturnType<IntT, AccessType::Read> { using type = IntT; };
template <typename IntT> struct ReturnType<IntT, AccessType::PreauthorisedRead> { using type = IntT; };
// Byte writes: return a reference directly to the byte.
template <> struct ReturnType<uint8_t, AccessType::Write> { using type = uint8_t &; };
template <> struct ReturnType<uint8_t, AccessType::ReadModifyWrite> { using type = uint8_t &; };
template <> struct ReturnType<uint8_t, AccessType::Preauthorised> { using type = uint8_t &; };
template <> struct ReturnType<uint8_t, AccessType::PreauthorisedWrite> { using type = uint8_t &; };
// Larger writes: I'm on the fence here as to the proper approach to latching and writeback here;
// so offered as a separate case but with a conclusion yet to reach.
template <typename IntT> struct ReturnType<IntT, AccessType::Write> { using type = IntT &; };
template <typename IntT> struct ReturnType<IntT, AccessType::ReadModifyWrite> { using type = IntT &; };
template <typename IntT> struct ReturnType<IntT, AccessType::Preauthorised> { using type = IntT &; };
template <typename IntT> struct ReturnType<IntT, AccessType::PreauthorisedWrite> { using type = IntT &; };
// Entry point for the 8086; simply notes that memory was accessed.
template <typename IntT, AccessType type>