From 99e7de5a8ba5f467646523871693c347ff41313e Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Thu, 16 Nov 2023 15:24:35 -0500 Subject: [PATCH] Colocate memory. --- Machines/PCCompatible/PCCompatible.cpp | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/Machines/PCCompatible/PCCompatible.cpp b/Machines/PCCompatible/PCCompatible.cpp index bd456ee5b..6a76867f6 100644 --- a/Machines/PCCompatible/PCCompatible.cpp +++ b/Machines/PCCompatible/PCCompatible.cpp @@ -16,6 +16,8 @@ #include "../ScanProducer.hpp" #include "../TimedMachine.hpp" +#include + namespace PCCompatible { struct Registers { @@ -113,15 +115,13 @@ class Segments { const Registers ®isters_; }; +// TODO: send writes to the ROM area off to nowhere. struct Memory { public: using AccessType = InstructionSet::x86::AccessType; // Constructor. - Memory(Registers ®isters, const Segments &segments) : registers_(registers), segments_(segments) { - memory.resize(1024*1024); - std::fill(memory.begin(), memory.end(), 0xff); - } + Memory(Registers ®isters, const Segments &segments) : registers_(registers), segments_(segments) {} // // Preauthorisation call-ins. Since only an 8088 is currently modelled, all accesses are implicitly authorised. @@ -154,13 +154,6 @@ struct Memory { // Accesses an address based on physical location. template typename InstructionSet::x86::Accessor::type access(uint32_t address) { - // TODO: send writes to the ROM area off to nowhere. -// if constexpr (is_writeable(type)) { -// if(address >= 0xc'0000) { -// -// } -// } - // Dispense with the single-byte case trivially. if constexpr (std::is_same_v) { return memory[address]; @@ -229,11 +222,11 @@ struct Memory { // Population. // void install(size_t address, const uint8_t *data, size_t length) { - std::copy(data, data + length, memory.begin() + address); + std::copy(data, data + length, memory.begin() + std::vector::difference_type(address)); } private: - std::vector memory; + std::array memory{0xff}; Registers ®isters_; const Segments &segments_;