1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-11-26 23:52:26 +00:00

Fix LODS: REP is not REPE.

This commit is contained in:
Thomas Harte 2023-10-20 21:36:50 -04:00
parent 8caad8b99d
commit dab3dcaafb
2 changed files with 15 additions and 4 deletions

View File

@ -1360,7 +1360,7 @@ bool repetition_over(const InstructionT &instruction, AddressT &eCX) {
}
template <typename AddressT, typename InstructionT, typename FlowControllerT>
void repeat(const InstructionT &instruction, Status &status, AddressT &eCX, FlowControllerT &flow_controller) {
void repeat_ene(const InstructionT &instruction, Status &status, AddressT &eCX, FlowControllerT &flow_controller) {
if(
instruction.repetition() == Repetition::None || // No repetition => stop.
!(--eCX) || // [e]cx is zero after being decremented => stop.
@ -1372,6 +1372,17 @@ void repeat(const InstructionT &instruction, Status &status, AddressT &eCX, Flow
flow_controller.repeat_last();
}
template <typename AddressT, typename InstructionT, typename FlowControllerT>
void repeat(const InstructionT &instruction, AddressT &eCX, FlowControllerT &flow_controller) {
if(
instruction.repetition() == Repetition::None || // No repetition => stop.
!(--eCX) // [e]cx is zero after being decremented => stop.
) {
return;
}
flow_controller.repeat_last();
}
template <typename IntT, typename AddressT, typename InstructionT, typename MemoryT, typename FlowControllerT>
void cmps(const InstructionT &instruction, AddressT &eCX, AddressT &eSI, AddressT &eDI, MemoryT &memory, Status &status, FlowControllerT &flow_controller) {
if(repetition_over<AddressT>(instruction, eCX)) {
@ -1388,7 +1399,7 @@ void cmps(const InstructionT &instruction, AddressT &eCX, AddressT &eSI, Address
Primitive::sub<false, false>(lhs, rhs, status);
repeat<AddressT>(instruction, status, eCX, flow_controller);
repeat_ene<AddressT>(instruction, status, eCX, flow_controller);
}
template <typename IntT, typename AddressT, typename InstructionT, typename MemoryT, typename FlowControllerT>
@ -1403,7 +1414,7 @@ void lods(const InstructionT &instruction, AddressT &eCX, AddressT &eSI, IntT &e
eAX = memory.template access<IntT>(source_segment, eSI);
eSI += status.direction<AddressT>() * sizeof(IntT);
repeat<AddressT>(instruction, status, eCX, flow_controller);
repeat<AddressT>(instruction, eCX, flow_controller);
}

View File

@ -404,7 +404,7 @@ struct FailedExecution {
// TODO: MOVS, SCAS, STOS
*/
// CMPS
// @"A6.json.gz", @"A7.json.gz",
@"A6.json.gz", @"A7.json.gz",
// LODS
@"AC.json.gz", @"AD.json.gz",