1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-06-25 18:30:07 +00:00

Add INT (including INT3), INTO.

This commit is contained in:
Thomas Harte 2023-10-11 16:01:09 -04:00
parent e75ef70c96
commit 56e639e09a
2 changed files with 25 additions and 5 deletions

View File

@ -202,7 +202,7 @@ inline void aad(CPU::RegisterPair16 &ax, uint8_t imm, Status &status) {
}
template <typename FlowControllerT>
inline void aam(CPU::RegisterPair16 &ax, uint8_t imm, Status &status, FlowControllerT &flow_controller) {
void aam(CPU::RegisterPair16 &ax, uint8_t imm, Status &status, FlowControllerT &flow_controller) {
/*
tempAL AL;
AH tempAL / imm8; (* imm8 is set to 0AH for the AAD mnemonic *)
@ -622,7 +622,7 @@ void inc(IntT &destination, Status &status) {
}
template <typename IntT, typename RegistersT, typename FlowControllerT>
inline void jump(bool condition, IntT displacement, RegistersT &registers, FlowControllerT &flow_controller) {
void jump(bool condition, IntT displacement, RegistersT &registers, FlowControllerT &flow_controller) {
/*
IF condition
THEN
@ -736,12 +736,12 @@ void not_(IntT &destination) {
}
template <typename IntT, typename RegistersT, typename FlowControllerT>
inline void call_relative(IntT offset, RegistersT &registers, FlowControllerT &flow_controller) {
void call_relative(IntT offset, RegistersT &registers, FlowControllerT &flow_controller) {
flow_controller.call(registers.ip() + offset);
}
template <typename IntT, typename FlowControllerT>
inline void call_absolute(IntT target, FlowControllerT &flow_controller) {
void call_absolute(IntT target, FlowControllerT &flow_controller) {
flow_controller.call(target);
}
@ -777,6 +777,18 @@ void call_far(InstructionT &instruction,
flow_controller.call(segment, offset);
}
template <typename FlowControllerT>
void int_(uint8_t vector, FlowControllerT &flow_controller) {
flow_controller.interrupt(vector);
}
template <typename FlowControllerT>
void into(Status &status, FlowControllerT &flow_controller) {
if(status.flag<Flag::Overflow>()) {
flow_controller.interrupt(Interrupt::OnOverflow);
}
}
template <typename IntT>
void cbw(IntT &ax) {
constexpr IntT test_bit = 1 << (sizeof(IntT) * 4 - 1);
@ -926,6 +938,9 @@ template <
Primitive::call_far<model>(instruction, flow_controller, registers, memory);
return;
case Operation::INT: Primitive::int_(instruction.operand(), flow_controller); return;
case Operation::INTO: Primitive::into(status, flow_controller); return;
case Operation::JO: jcc(status.condition<Condition::Overflow>()); return;
case Operation::JNO: jcc(!status.condition<Condition::Overflow>()); return;
case Operation::JB: jcc(status.condition<Condition::Below>()); return;

View File

@ -365,7 +365,12 @@ struct FailedExecution {
// TODO: RET
// TODO: JMP
// TODO: JCXZ
// TODO: INT, INTO
// INTO
@"CE.json.gz",
// INT, INT3
@"CC.json.gz", @"CD.json.gz",
// TODO: LAHF, SAHF
// TODO: LDS, LES