mirror of
https://github.com/TomHarte/CLK.git
synced 2025-02-09 02:31:22 +00:00
Fix spelling of Preauthorised, think further on return types.
This commit is contained in:
parent
78df0d19e4
commit
ef83ac855a
@ -193,18 +193,18 @@ namespace Primitive {
|
|||||||
|
|
||||||
// The below takes a reference in order properly to handle PUSH SP, which should place the value of SP after the
|
// The below takes a reference in order properly to handle PUSH SP, which should place the value of SP after the
|
||||||
// push onto the stack.
|
// push onto the stack.
|
||||||
template <typename IntT, bool preauthorised, typename MemoryT, typename RegistersT>
|
template <typename IntT, bool Preauthorised, typename MemoryT, typename RegistersT>
|
||||||
void push(IntT &value, MemoryT &memory, RegistersT ®isters) {
|
void push(IntT &value, MemoryT &memory, RegistersT ®isters) {
|
||||||
registers.sp_ -= sizeof(IntT);
|
registers.sp_ -= sizeof(IntT);
|
||||||
memory.template access<IntT, preauthorised ? AccessType::PreAuthorised : AccessType::Write>(
|
memory.template access<IntT, Preauthorised ? AccessType::Preauthorised : AccessType::Write>(
|
||||||
InstructionSet::x86::Source::SS,
|
InstructionSet::x86::Source::SS,
|
||||||
registers.sp_) = value;
|
registers.sp_) = value;
|
||||||
memory.template write_back<IntT>();
|
memory.template write_back<IntT>();
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename IntT, bool preauthorised, typename MemoryT, typename RegistersT>
|
template <typename IntT, bool Preauthorised, typename MemoryT, typename RegistersT>
|
||||||
IntT pop(MemoryT &memory, RegistersT ®isters) {
|
IntT pop(MemoryT &memory, RegistersT ®isters) {
|
||||||
const auto value = memory.template access<IntT, preauthorised ? AccessType::PreAuthorised : AccessType::Read>(
|
const auto value = memory.template access<IntT, Preauthorised ? AccessType::Preauthorised : AccessType::Read>(
|
||||||
InstructionSet::x86::Source::SS,
|
InstructionSet::x86::Source::SS,
|
||||||
registers.sp_);
|
registers.sp_);
|
||||||
registers.sp_ += sizeof(IntT);
|
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::Immediate: flow_controller.call(instruction.segment(), instruction.offset()); return;
|
||||||
|
|
||||||
case Source::Indirect:
|
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::Preauthorised>(instruction, pointer, registers, memory);
|
||||||
break;
|
break;
|
||||||
case Source::IndirectNoBase:
|
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::Preauthorised>(instruction, pointer, registers, memory);
|
||||||
break;
|
break;
|
||||||
case Source::DirectAddress:
|
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::Preauthorised>(instruction, pointer, registers, memory);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -954,7 +954,7 @@ void lea(
|
|||||||
RegistersT ®isters
|
RegistersT ®isters
|
||||||
) {
|
) {
|
||||||
// TODO: address size.
|
// TODO: address size.
|
||||||
destination = IntT(address<model, uint16_t, AccessType::PreAuthorised>(instruction, instruction.source(), registers, memory));
|
destination = IntT(address<model, uint16_t, AccessType::Preauthorised>(instruction, instruction.source(), registers, memory));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename AddressT, typename InstructionT, typename MemoryT, typename RegistersT>
|
template <typename AddressT, typename InstructionT, typename MemoryT, typename RegistersT>
|
||||||
|
@ -31,8 +31,8 @@ enum class AccessType {
|
|||||||
/// The requested value has already been authorised for whatever form of access is now intended, so there's no
|
/// The requested value has already been authorised for whatever form of access is now intended, so there's no
|
||||||
/// need further to inspect. This is done e.g. by operations that will push multiple values to the stack to verify that
|
/// 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
|
/// all necessary stack space is available ahead of pushing anything, though each individual push will then result in
|
||||||
/// a further `PreAuthorised` access.
|
/// a further `Preauthorised` access.
|
||||||
PreAuthorised,
|
Preauthorised,
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Performs @c instruction querying @c registers and/or @c memory as required, using @c io for port input/output,
|
/// Performs @c instruction querying @c registers and/or @c memory as required, using @c io for port input/output,
|
||||||
|
@ -170,10 +170,20 @@ struct Memory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename IntT, AccessType type> struct ReturnType;
|
template <typename IntT, AccessType type> struct ReturnType;
|
||||||
|
|
||||||
|
// Reads: return a value directly.
|
||||||
template <typename IntT> struct ReturnType<IntT, AccessType::Read> { using type = IntT; };
|
template <typename IntT> struct ReturnType<IntT, AccessType::Read> { 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 &; };
|
||||||
|
|
||||||
|
// 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::Write> { using type = IntT &; };
|
||||||
template <typename IntT> struct ReturnType<IntT, AccessType::ReadModifyWrite> { 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::Preauthorised> { using type = IntT &; };
|
||||||
|
|
||||||
// Entry point for the 8086; simply notes that memory was accessed.
|
// Entry point for the 8086; simply notes that memory was accessed.
|
||||||
template <typename IntT, AccessType type>
|
template <typename IntT, AccessType type>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user