mirror of
https://github.com/TomHarte/CLK.git
synced 2025-08-08 14:25:05 +00:00
Implement BOUND.
This commit is contained in:
@@ -213,7 +213,27 @@ void into(
|
|||||||
ContextT &context
|
ContextT &context
|
||||||
) {
|
) {
|
||||||
if(context.flags.template flag<Flag::Overflow>()) {
|
if(context.flags.template flag<Flag::Overflow>()) {
|
||||||
interrupt(Interrupt::OnOverflow, context);
|
interrupt(Interrupt::Overflow, context);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename IntT, typename InstructionT, typename ContextT>
|
||||||
|
void bound(
|
||||||
|
const InstructionT &instruction,
|
||||||
|
read_t<IntT> destination,
|
||||||
|
read_t<IntT> source,
|
||||||
|
ContextT &context
|
||||||
|
) {
|
||||||
|
using sIntT = typename std::make_signed<IntT>::type;
|
||||||
|
|
||||||
|
const auto source_segment = instruction.data_segment();
|
||||||
|
context.memory.preauthorise_read(source_segment, source, 2*sizeof(IntT));
|
||||||
|
const sIntT lower_bound = sIntT(context.memory.template access<uint16_t, AccessType::PreauthorisedRead>(source_segment, source));
|
||||||
|
source += 2;
|
||||||
|
const sIntT upper_bound = sIntT(context.memory.template access<uint16_t, AccessType::PreauthorisedRead>(source_segment, source));
|
||||||
|
|
||||||
|
if(sIntT(destination) < lower_bound || sIntT(destination) > upper_bound) {
|
||||||
|
interrupt(Interrupt::BoundRangeExceeded, context);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -328,8 +328,8 @@ template <
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
// TODO: perform BOUND as of the 80186.
|
|
||||||
static_assert(int(Operation::SETMOC) == int(Operation::BOUND));
|
static_assert(int(Operation::SETMOC) == int(Operation::BOUND));
|
||||||
|
Primitive::bound<IntT>(instruction, destination_r(), source_r(), context);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@@ -12,11 +12,26 @@
|
|||||||
namespace InstructionSet::x86 {
|
namespace InstructionSet::x86 {
|
||||||
|
|
||||||
enum Interrupt {
|
enum Interrupt {
|
||||||
DivideError = 0,
|
DivideError = 0,
|
||||||
SingleStep = 1,
|
SingleStep = 1,
|
||||||
NMI = 2,
|
NMI = 2,
|
||||||
OneByte = 3,
|
Breakpoint = 3,
|
||||||
OnOverflow = 4,
|
Overflow = 4,
|
||||||
|
BoundRangeExceeded = 5,
|
||||||
|
InvalidOpcode = 6,
|
||||||
|
DeviceNotAvailable = 7,
|
||||||
|
DoubleFault = 8,
|
||||||
|
CoprocessorSegmentOverrun = 9,
|
||||||
|
InvalidTSS = 10,
|
||||||
|
SegmentNotPresent = 11,
|
||||||
|
StackSegmentFault = 12,
|
||||||
|
GeneralProtectionFault = 13,
|
||||||
|
PageFault = 14,
|
||||||
|
/* 15 is reserved */
|
||||||
|
FloatingPointException = 16,
|
||||||
|
AlignmentCheck = 17,
|
||||||
|
MachineCheck = 18,
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user