From 3f27338b2c113e796d28e3a41ca0dba21efcb511 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Thu, 16 Nov 2023 23:46:22 -0500 Subject: [PATCH] New guess: the definition of size_t varies? --- InstructionSets/x86/Decoder.cpp | 24 ++++++------------------ InstructionSets/x86/Decoder.hpp | 4 ++-- 2 files changed, 8 insertions(+), 20 deletions(-) diff --git a/InstructionSets/x86/Decoder.cpp b/InstructionSets/x86/Decoder.cpp index 0407e01fb..b9cbdc063 100644 --- a/InstructionSets/x86/Decoder.cpp +++ b/InstructionSets/x86/Decoder.cpp @@ -15,7 +15,7 @@ using namespace InstructionSet::x86; template -std::pair::InstructionT> Decoder::decode(const uint8_t *source, size_t length) { +std::pair::InstructionT> Decoder::decode(const uint8_t *source, uint32_t length) { // Instruction length limits: // // 8086/80186: none* @@ -26,8 +26,8 @@ std::pair::InstructionT> Decoder::decode(con // be back to wherever it started, so it's safe to spit out a NOP and reset parsing // without any loss of context. This reduces the risk of the decoder tricking a caller into // an infinite loop. - constexpr int max_instruction_length = model >= Model::i80386 ? 15 : (model == Model::i80286 ? 10 : 65536); - const uint8_t *const end = source + std::min(length, size_t(max_instruction_length - consumed_)); + constexpr uint32_t max_instruction_length = model >= Model::i80386 ? 15 : (model == Model::i80286 ? 10 : 65536); + const uint8_t *const end = source + std::min(length, max_instruction_length - consumed_); // MARK: - Prefixes (if present) and the opcode. @@ -1119,19 +1119,7 @@ template void Decoder::set_32bit_protected_mode(bool enable } // Ensure all possible decoders are built. -//template class InstructionSet::x86::Decoder; -//template class InstructionSet::x86::Decoder; -//template class InstructionSet::x86::Decoder; +template class InstructionSet::x86::Decoder; +template class InstructionSet::x86::Decoder; +template class InstructionSet::x86::Decoder; template class InstructionSet::x86::Decoder; - -template -std::pair::InstructionT> -Decoder::decode(const uint8_t *, size_t); - -template -std::pair::InstructionT> -Decoder::decode(const uint8_t *, size_t); - -template -std::pair::InstructionT> -Decoder::decode(const uint8_t *, size_t); diff --git a/InstructionSets/x86/Decoder.hpp b/InstructionSets/x86/Decoder.hpp index 00d45ac1b..23defb001 100644 --- a/InstructionSets/x86/Decoder.hpp +++ b/InstructionSets/x86/Decoder.hpp @@ -44,7 +44,7 @@ template class Decoder { The 80286 and 80386 have instruction length limits of 10 and 15 bytes respectively, so cannot overflow the field. */ - std::pair decode(const uint8_t *source, size_t length); + std::pair decode(const uint8_t *source, uint32_t length); /*! Enables or disables 32-bit protected mode. Meaningful only if the @c Model supports it. @@ -173,7 +173,7 @@ template class Decoder { // Ephemeral decoding state. Operation operation_ = Operation::Invalid; - int consumed_ = 0, operand_bytes_ = 0; + uint32_t consumed_ = 0, operand_bytes_ = 0; // Source and destination locations. Source source_ = Source::None;