diff --git a/OSBindings/Mac/Clock SignalTests/x86DecoderTests.mm b/OSBindings/Mac/Clock SignalTests/x86DecoderTests.mm index 0e3b737e9..68bf1abe1 100644 --- a/OSBindings/Mac/Clock SignalTests/x86DecoderTests.mm +++ b/OSBindings/Mac/Clock SignalTests/x86DecoderTests.mm @@ -29,14 +29,14 @@ template void test( const InstructionT &instruction, DataSize size, Operation operation, - InstructionSet::x86::DataPointer source, + std::optional source, std::optional destination = std::nullopt, std::optional operand = std::nullopt, std::optional displacement = std::nullopt) { XCTAssertEqual(instruction.operation_size(), InstructionSet::x86::DataSize(size)); XCTAssertEqual(instruction.operation, operation); - XCTAssert(instruction.source() == source); + if(source) XCTAssert(instruction.source() == *source); if(destination) XCTAssert(instruction.destination() == *destination); if(operand) XCTAssertEqual(instruction.operand(), *operand); if(displacement) XCTAssertEqual(instruction.displacement(), *displacement); @@ -557,4 +557,75 @@ std::vector::InstructionT> decode(c test(instructions[0], DataSize::DWord, Operation::ADD, Source::Immediate, ScaleIndexBase(Source::eDI), 0x9f683aa9, -0x42); } +- (void)test286LengthLimit { + const auto instructions = decode({ + 0x90, + 0x26, 0x90, + 0x26, 0x26, 0x90, + 0x26, 0x26, 0x26, 0x90, + 0x26, 0x26, 0x26, 0x26, 0x90, + 0x26, 0x26, 0x26, 0x26, 0x26, 0x90, + 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x90, + 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x90, + 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x90, + 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x90, + 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x90, + }); + + XCTAssertEqual(instructions.size(), 12); + test(instructions[0], Operation::NOP); + test(instructions[1], Operation::NOP); + test(instructions[2], Operation::NOP); + test(instructions[3], Operation::NOP); + test(instructions[4], Operation::NOP); + test(instructions[5], Operation::NOP); + test(instructions[6], Operation::NOP); + test(instructions[7], Operation::NOP); + test(instructions[8], Operation::NOP); + test(instructions[9], Operation::NOP); + test(instructions[10], Operation::Invalid); + test(instructions[11], Operation::NOP); +} + + - (void)test386LengthLimit { + const auto instructions = decode({ + 0x90, + 0x26, 0x90, + 0x26, 0x26, 0x90, + 0x26, 0x26, 0x26, 0x90, + 0x26, 0x26, 0x26, 0x26, 0x90, + 0x26, 0x26, 0x26, 0x26, 0x26, 0x90, + 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x90, + 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x90, + 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x90, + 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x90, + 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x90, + 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x90, + 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x90, + 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x90, + 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x90, + 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x90, + }); + + XCTAssertEqual(instructions.size(), 17); + test(instructions[0], Operation::NOP); + test(instructions[1], Operation::NOP); + test(instructions[2], Operation::NOP); + test(instructions[3], Operation::NOP); + test(instructions[4], Operation::NOP); + test(instructions[5], Operation::NOP); + test(instructions[6], Operation::NOP); + test(instructions[7], Operation::NOP); + test(instructions[8], Operation::NOP); + test(instructions[9], Operation::NOP); + test(instructions[10], Operation::NOP); + test(instructions[11], Operation::NOP); + test(instructions[12], Operation::NOP); + test(instructions[13], Operation::NOP); + test(instructions[14], Operation::NOP); + test(instructions[15], Operation::Invalid); + test(instructions[16], Operation::NOP); +} + + @end