mirror of
https://github.com/TomHarte/CLK.git
synced 2024-12-11 15:49:38 +00:00
56 lines
1.3 KiB
C++
56 lines
1.3 KiB
C++
//
|
|
// Segments.hpp
|
|
// Clock Signal
|
|
//
|
|
// Created by Thomas Harte on 01/12/2023.
|
|
// Copyright © 2023 Thomas Harte. All rights reserved.
|
|
//
|
|
|
|
#pragma once
|
|
|
|
#include "Registers.hpp"
|
|
|
|
#include "../../InstructionSets/x86/Instruction.hpp"
|
|
|
|
namespace PCCompatible {
|
|
|
|
class Segments {
|
|
public:
|
|
Segments(const Registers ®isters) : registers_(registers) {}
|
|
|
|
using Source = InstructionSet::x86::Source;
|
|
|
|
/// Posted by @c perform after any operation which *might* have affected a segment register.
|
|
void did_update(Source segment) {
|
|
switch(segment) {
|
|
default: break;
|
|
case Source::ES: es_base_ = uint32_t(registers_.es()) << 4; break;
|
|
case Source::CS: cs_base_ = uint32_t(registers_.cs()) << 4; break;
|
|
case Source::DS: ds_base_ = uint32_t(registers_.ds()) << 4; break;
|
|
case Source::SS: ss_base_ = uint32_t(registers_.ss()) << 4; break;
|
|
}
|
|
}
|
|
|
|
void reset() {
|
|
did_update(Source::ES);
|
|
did_update(Source::CS);
|
|
did_update(Source::DS);
|
|
did_update(Source::SS);
|
|
}
|
|
|
|
uint32_t es_base_, cs_base_, ds_base_, ss_base_;
|
|
|
|
bool operator ==(const Segments &rhs) const {
|
|
return
|
|
es_base_ == rhs.es_base_ &&
|
|
cs_base_ == rhs.cs_base_ &&
|
|
ds_base_ == rhs.ds_base_ &&
|
|
ss_base_ == rhs.ss_base_;
|
|
}
|
|
|
|
private:
|
|
const Registers ®isters_;
|
|
};
|
|
|
|
}
|