1
0
mirror of https://github.com/TomHarte/CLK.git synced 2026-04-25 11:17:26 +00:00

Fix BOUND.

7085 remaining failures.
This commit is contained in:
Thomas Harte
2025-08-06 22:19:35 -04:00
parent a8e60163e1
commit 7c4df23c1c
4 changed files with 26 additions and 19 deletions
+7 -14
View File
@@ -33,17 +33,6 @@ std::pair<int, typename Decoder<model>::InstructionT> Decoder<model>::decode(
static constexpr bool is_32bit = instruction_type(model) == InstructionType::Bits32;
const uint8_t *const end = source + std::min(length, size_t(max_instruction_length - consumed_));
const auto post_invalid = [&] {
std::pair<int, InstructionT> result;
if(max_instruction_length == 65536) {
result = std::make_pair(consumed_, InstructionT(Operation::NOP));
} else {
result = std::make_pair(consumed_, InstructionT());
}
reset_parsing();
return result;
};
// MARK: - Prefixes (if present) and the opcode.
#define Requires(x) if constexpr (model != Model::x) return undefined();
@@ -824,7 +813,7 @@ std::pair<int, typename Decoder<model>::InstructionT> Decoder<model>::decode(
break;
default:
undefined();
return undefined();
}
break;
@@ -1040,7 +1029,7 @@ std::pair<int, typename Decoder<model>::InstructionT> Decoder<model>::decode(
if(consumed_ != max_instruction_length) {
return std::make_pair(-(outstanding_bytes - bytes_to_consume), InstructionT());
} else {
return post_invalid();
return overlong();
}
}
}
@@ -1060,6 +1049,10 @@ std::pair<int, typename Decoder<model>::InstructionT> Decoder<model>::decode(
// operations would unlock an extra bit of storage for a net gain of 239 extra operation types and thereby
// alleviating any concerns over whether there'll be space to handle MMX, floating point extensions, etc.
if(operation_ == Operation::BOUND && source_ <= Source::None) {
return undefined();
}
const auto result = std::make_pair(
consumed_,
InstructionT(
@@ -1081,7 +1074,7 @@ std::pair<int, typename Decoder<model>::InstructionT> Decoder<model>::decode(
// Check for a too-long instruction.
if(consumed_ == max_instruction_length) {
return post_invalid();
return overlong();
}
// i.e. not done yet.
+9
View File
@@ -368,6 +368,15 @@ private:
reset_parsing();
return result;
}
std::pair<int, typename Decoder<model>::InstructionT> overlong() {
reset_parsing();
if(consumed_ == 65536) {
return std::make_pair(consumed_, InstructionT(Operation::NOP));
} else {
return std::make_pair(consumed_, InstructionT());
}
}
};
extern template class InstructionSet::x86::Decoder<InstructionSet::x86::Model::i8086>;
@@ -128,6 +128,12 @@ template <
);
};
const auto source_address = [&]() -> AddressT {
return AddressT(
address<AddressT, AccessType::Read>(instruction, instruction.source(), context)
);
};
// Some instructions use a pair of registers as an extended accumulator — DX:AX or EDX:EAX.
// The two following return the high and low parts of that pair; they also work in Byte mode to return AH:AL,
// i.e. AX split into high and low parts.
@@ -434,7 +440,7 @@ template <
break;
} else {
static_assert(int(Operation::SETMOC) == int(Operation::BOUND));
Primitive::bound<IntT, AddressT>(instruction, destination_r(), source_r(), context);
Primitive::bound<IntT, AddressT>(instruction, destination_r(), source_address(), context);
}
return;
@@ -41,7 +41,6 @@ NSSet *const allowList = [NSSet setWithArray:@[
// @"2F.json.gz", // DAS
// @"60.json.gz", // PUSHA
// @"61.json.gz", // POPA
// @"62.json.gz", // BOUND and (bad) mix
// @"69.json.gz", // IMUL
// @"6D.json.gz", // INS.W
// @"6F.json.gz", // OUTS.W
@@ -393,9 +392,9 @@ void apply_execution_test(
NSDictionary *metadata
) {
// NSLog(@"%@", test[@"hash"]);
if([test[@"hash"] isEqualToString:@"1d665df5828ad5bde2397f32de7cc8c95fe451c5"]) {
printf("");
}
// if([test[@"hash"] isEqualToString:@"c00a95eb3ae2b5500858bdafeb82a1e923e351c8"]) {
// printf("");
// }
InstructionSet::x86::Decoder<t_model> decoder;
const auto data = bytes(test[@"bytes"]);