mirror of
https://github.com/TomHarte/CLK.git
synced 2025-04-09 15:39:08 +00:00
Improve const
ness.
This commit is contained in:
parent
09341ddbe9
commit
45f850adae
@ -524,7 +524,7 @@ template <
|
||||
const uint16_t ip = context.memory.template access<uint16_t, AccessType::PreauthorisedRead>(address);
|
||||
const uint16_t cs = context.memory.template access<uint16_t, AccessType::PreauthorisedRead>(address + 2);
|
||||
|
||||
auto flags = context.flags.get();
|
||||
const auto flags = context.flags.get();
|
||||
Primitive::push<uint16_t, true>(flags, context);
|
||||
context.flags.template set_from<Flag::Interrupt, Flag::Trap>(0);
|
||||
|
||||
|
@ -18,7 +18,7 @@ namespace InstructionSet::x86::Primitive {
|
||||
// which should place the value of SP after the push onto the stack.
|
||||
template <typename IntT, bool preauthorised, typename ContextT>
|
||||
void push(
|
||||
IntT &value,
|
||||
const IntT &value,
|
||||
ContextT &context
|
||||
) {
|
||||
context.registers.sp() -= sizeof(IntT);
|
||||
@ -45,7 +45,7 @@ IntT pop(
|
||||
|
||||
template <typename ContextT>
|
||||
void sahf(
|
||||
uint8_t &ah,
|
||||
const uint8_t &ah,
|
||||
ContextT &context
|
||||
) {
|
||||
/*
|
||||
@ -86,7 +86,7 @@ template <typename ContextT>
|
||||
void pushf(
|
||||
ContextT &context
|
||||
) {
|
||||
uint16_t value = context.flags.get();
|
||||
const uint16_t value = context.flags.get();
|
||||
push<uint16_t, false>(value, context);
|
||||
}
|
||||
|
||||
@ -121,7 +121,7 @@ void pusha(
|
||||
ContextT &context
|
||||
) {
|
||||
context.memory.preauthorise_stack_read(sizeof(IntT) * 8);
|
||||
IntT initial_sp = context.registers.sp();
|
||||
const IntT initial_sp = context.registers.sp();
|
||||
if constexpr (std::is_same_v<IntT, uint32_t>) {
|
||||
push<uint32_t, true>(context.registers.eax(), context);
|
||||
push<uint32_t, true>(context.registers.ecx(), context);
|
||||
|
@ -41,6 +41,7 @@ template <
|
||||
ContextT &context
|
||||
);
|
||||
|
||||
/// Performs an x86 INT operation; also often used by other operations to indicate an error.
|
||||
template <
|
||||
typename ContextT
|
||||
> void interrupt(
|
||||
|
@ -111,12 +111,12 @@ struct Memory {
|
||||
//
|
||||
// Helper for instruction fetch.
|
||||
//
|
||||
std::pair<const uint8_t *, size_t> next_code() {
|
||||
std::pair<const uint8_t *, size_t> next_code() const {
|
||||
const uint32_t start = segments_.cs_base_ + registers_.ip();
|
||||
return std::make_pair(&memory[start], 0x10'000 - start);
|
||||
}
|
||||
|
||||
std::pair<const uint8_t *, size_t> all() {
|
||||
std::pair<const uint8_t *, size_t> all() const {
|
||||
return std::make_pair(memory.data(), 0x10'000);
|
||||
}
|
||||
|
||||
@ -136,7 +136,7 @@ struct Memory {
|
||||
Registers ®isters_;
|
||||
const Segments &segments_;
|
||||
|
||||
uint32_t segment_base(InstructionSet::x86::Source segment) {
|
||||
uint32_t segment_base(const InstructionSet::x86::Source segment) const {
|
||||
using Source = InstructionSet::x86::Source;
|
||||
switch(segment) {
|
||||
default: return segments_.ds_base_;
|
||||
@ -146,13 +146,13 @@ struct Memory {
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t address(InstructionSet::x86::Source segment, uint16_t offset) {
|
||||
uint32_t address(const InstructionSet::x86::Source segment, const uint16_t offset) const {
|
||||
return (segment_base(segment) + offset) & 0xf'ffff;
|
||||
}
|
||||
|
||||
template <AccessType type>
|
||||
typename InstructionSet::x86::Accessor<uint16_t, type>::type
|
||||
split_word(uint32_t low_address, uint32_t high_address) {
|
||||
split_word(const uint32_t low_address, const uint32_t high_address) {
|
||||
if constexpr (is_writeable(type)) {
|
||||
write_back_address_[0] = low_address;
|
||||
write_back_address_[1] = high_address;
|
||||
|
Loading…
x
Reference in New Issue
Block a user