1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-11-22 12:33:29 +00:00

Fix repetition. Sufficient for tests.

This commit is contained in:
Thomas Harte 2023-10-19 14:40:03 -04:00
parent 387a952328
commit efb854ddfa
2 changed files with 30 additions and 16 deletions

View File

@ -1401,18 +1401,22 @@ void cmps(const InstructionT &instruction, MemoryT &memory, RegistersT &register
}
Source source_segment = instruction.segment_override();
if(source_segment == Source::None) source_segment = Source::DS;
if(source_segment == Source::None) {
source_segment = Source::DS;
} else {
printf("");
}
if constexpr (std::is_same_v<AddressT, uint16_t>) {
IntT source = memory.template access<IntT>(source_segment, registers.si());
IntT destination = memory.template access<IntT>(Source::ES, registers.di());
Primitive::sub<false, false>(destination, source, status);
IntT lhs = memory.template access<IntT>(source_segment, registers.si());
IntT rhs = memory.template access<IntT>(Source::ES, registers.di());
Primitive::sub<false, false>(lhs, rhs, status);
registers.si() += status.direction<AddressT>();
registers.di() += status.direction<AddressT>();
} else {
IntT source = memory.template access<IntT>(source_segment, registers.esi());
IntT destination = memory.template access<IntT>(Source::ES, registers.edi());
Primitive::sub<false, false>(destination, source, status);
IntT lhs = memory.template access<IntT>(source_segment, registers.esi());
IntT rhs = memory.template access<IntT>(Source::ES, registers.edi());
Primitive::sub<false, false>(lhs, rhs, status);
registers.esi() += status.direction<AddressT>();
registers.edi() += status.direction<AddressT>();
}

View File

@ -230,14 +230,21 @@ class FlowController {
void halt() {}
void wait() {}
void begin_instruction() {
should_repeat_ = false;
}
void repeat_last() {
// TODO.
should_repeat_ = true;
}
bool should_repeat() const {
return should_repeat_;
}
private:
Memory &memory_;
Registers &registers_;
Status &status_;
bool should_repeat_ = false;
void push(uint16_t value, bool is_flags = false) {
// Perform the push in two steps because it's possible for SP to underflow, and so that FlagsL and
@ -708,14 +715,17 @@ struct FailedExecution {
// Execute instruction.
execution_support.registers.ip_ += decoded.first;
InstructionSet::x86::perform<InstructionSet::x86::Model::i8086>(
decoded.second,
execution_support.status,
execution_support.flow_controller,
execution_support.registers,
execution_support.memory,
execution_support.io
);
do {
execution_support.flow_controller.begin_instruction();
InstructionSet::x86::perform<InstructionSet::x86::Model::i8086>(
decoded.second,
execution_support.status,
execution_support.flow_controller,
execution_support.registers,
execution_support.memory,
execution_support.io
);
} while (execution_support.flow_controller.should_repeat());
// Compare final state.
Registers intended_registers;