mirror of
https://github.com/TomHarte/CLK.git
synced 2025-01-16 11:30:22 +00:00
Implement BOUND.
This commit is contained in:
parent
60cec9fc67
commit
1552500b10
@ -213,7 +213,27 @@ void into(
|
||||
ContextT &context
|
||||
) {
|
||||
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;
|
||||
} else {
|
||||
// TODO: perform BOUND as of the 80186.
|
||||
static_assert(int(Operation::SETMOC) == int(Operation::BOUND));
|
||||
Primitive::bound<IntT>(instruction, destination_r(), source_r(), context);
|
||||
}
|
||||
return;
|
||||
|
||||
|
@ -12,11 +12,26 @@
|
||||
namespace InstructionSet::x86 {
|
||||
|
||||
enum Interrupt {
|
||||
DivideError = 0,
|
||||
SingleStep = 1,
|
||||
NMI = 2,
|
||||
OneByte = 3,
|
||||
OnOverflow = 4,
|
||||
DivideError = 0,
|
||||
SingleStep = 1,
|
||||
NMI = 2,
|
||||
Breakpoint = 3,
|
||||
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,
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user