1
0
mirror of https://github.com/TomHarte/CLK.git synced 2025-02-16 18:30:32 +00:00

Move towards privacy.

This commit is contained in:
Thomas Harte 2023-11-14 11:39:44 -05:00
parent aafa7de536
commit a22ac2f88b

View File

@ -33,71 +33,75 @@ constexpr char TestSuiteHome[] = "/Users/tharte/Projects/ProcessorTests/8088/v1"
using Flags = InstructionSet::x86::Flags; using Flags = InstructionSet::x86::Flags;
struct Registers { struct Registers {
CPU::RegisterPair16 ax_; public:
uint8_t &al() { return ax_.halves.low; } static constexpr bool is_32bit = false;
uint8_t &ah() { return ax_.halves.high; }
uint16_t &ax() { return ax_.full; }
CPU::RegisterPair16 &axp() { return ax_; } uint8_t &al() { return ax_.halves.low; }
uint8_t &ah() { return ax_.halves.high; }
uint16_t &ax() { return ax_.full; }
CPU::RegisterPair16 cx_; CPU::RegisterPair16 &axp() { return ax_; }
uint8_t &cl() { return cx_.halves.low; }
uint8_t &ch() { return cx_.halves.high; }
uint16_t &cx() { return cx_.full; }
CPU::RegisterPair16 dx_; uint8_t &cl() { return cx_.halves.low; }
uint8_t &dl() { return dx_.halves.low; } uint8_t &ch() { return cx_.halves.high; }
uint8_t &dh() { return dx_.halves.high; } uint16_t &cx() { return cx_.full; }
uint16_t &dx() { return dx_.full; }
CPU::RegisterPair16 bx_; uint8_t &dl() { return dx_.halves.low; }
uint8_t &bl() { return bx_.halves.low; } uint8_t &dh() { return dx_.halves.high; }
uint8_t &bh() { return bx_.halves.high; } uint16_t &dx() { return dx_.full; }
uint16_t &bx() { return bx_.full; }
uint16_t sp_; uint8_t &bl() { return bx_.halves.low; }
uint16_t &sp() { return sp_; } uint8_t &bh() { return bx_.halves.high; }
uint16_t &bx() { return bx_.full; }
uint16_t bp_; uint16_t &sp() { return sp_; }
uint16_t &bp() { return bp_; } uint16_t &bp() { return bp_; }
uint16_t &si() { return si_; }
uint16_t &di() { return di_; }
uint16_t si_; uint16_t ip_;
uint16_t &si() { return si_; } uint16_t &ip() { return ip_; }
uint16_t di_; uint16_t &es() { return es_; }
uint16_t &di() { return di_; } uint16_t &cs() { return cs_; }
uint16_t &ds() { return ds_; }
uint16_t &ss() { return ss_; }
uint16_t es_, cs_, ds_, ss_; const uint16_t es() const { return es_; }
const uint16_t cs() const { return cs_; }
const uint16_t ds() const { return ds_; }
const uint16_t ss() const { return ss_; }
uint16_t ip_; bool operator ==(const Registers &rhs) const {
uint16_t &ip() { return ip_; } return
ax_.full == rhs.ax_.full &&
cx_.full == rhs.cx_.full &&
dx_.full == rhs.dx_.full &&
bx_.full == rhs.bx_.full &&
sp_ == rhs.sp_ &&
bp_ == rhs.bp_ &&
si_ == rhs.si_ &&
di_ == rhs.di_ &&
es_ == rhs.es_ &&
cs_ == rhs.cs_ &&
ds_ == rhs.ds_ &&
si_ == rhs.si_ &&
ip_ == rhs.ip_;
}
uint16_t &es() { return es_; } // TODO: make the below private and use a friend class for test population, to ensure Perform
uint16_t &cs() { return cs_; } // is free of direct accesses.
uint16_t &ds() { return ds_; } // private:
uint16_t &ss() { return ss_; } CPU::RegisterPair16 ax_;
CPU::RegisterPair16 cx_;
CPU::RegisterPair16 dx_;
CPU::RegisterPair16 bx_;
const uint16_t es() const { return es_; } uint16_t sp_;
const uint16_t cs() const { return cs_; } uint16_t bp_;
const uint16_t ds() const { return ds_; } uint16_t si_;
const uint16_t ss() const { return ss_; } uint16_t di_;
uint16_t es_, cs_, ds_, ss_;
bool operator ==(const Registers &rhs) const {
return
ax_.full == rhs.ax_.full &&
cx_.full == rhs.cx_.full &&
dx_.full == rhs.dx_.full &&
bx_.full == rhs.bx_.full &&
sp_ == rhs.sp_ &&
bp_ == rhs.bp_ &&
si_ == rhs.si_ &&
di_ == rhs.di_ &&
es_ == rhs.es_ &&
cs_ == rhs.cs_ &&
ds_ == rhs.ds_ &&
si_ == rhs.si_ &&
ip_ == rhs.ip_;
}
}; };
class Segments { class Segments {
public: public:
@ -163,14 +167,14 @@ struct Memory {
// Preauthorisation call-ins. // Preauthorisation call-ins.
// //
void preauthorise_stack_write(uint32_t length) { void preauthorise_stack_write(uint32_t length) {
uint16_t sp = registers_.sp_; uint16_t sp = registers_.sp();
while(length--) { while(length--) {
--sp; --sp;
preauthorise(InstructionSet::x86::Source::SS, sp); preauthorise(InstructionSet::x86::Source::SS, sp);
} }
} }
void preauthorise_stack_read(uint32_t length) { void preauthorise_stack_read(uint32_t length) {
uint16_t sp = registers_.sp_; uint16_t sp = registers_.sp();
while(length--) { while(length--) {
preauthorise(InstructionSet::x86::Source::SS, sp); preauthorise(InstructionSet::x86::Source::SS, sp);
++sp; ++sp;
@ -261,7 +265,7 @@ struct Memory {
std::unordered_set<uint32_t> preauthorisations; std::unordered_set<uint32_t> preauthorisations;
std::unordered_map<uint32_t, Tag> tags; std::unordered_map<uint32_t, Tag> tags;
std::vector<uint8_t> memory; std::vector<uint8_t> memory;
const Registers &registers_; Registers &registers_;
const Segments &segments_; const Segments &segments_;
void preauthorise(uint32_t address) { void preauthorise(uint32_t address) {