mirror of
https://github.com/TomHarte/CLK.git
synced 2025-08-09 05:25:01 +00:00
Add 286 and 386 instruction length tests.
This commit is contained in:
@@ -29,14 +29,14 @@ template <typename InstructionT> void test(
|
|||||||
const InstructionT &instruction,
|
const InstructionT &instruction,
|
||||||
DataSize size,
|
DataSize size,
|
||||||
Operation operation,
|
Operation operation,
|
||||||
InstructionSet::x86::DataPointer source,
|
std::optional<InstructionSet::x86::DataPointer> source,
|
||||||
std::optional<InstructionSet::x86::DataPointer> destination = std::nullopt,
|
std::optional<InstructionSet::x86::DataPointer> destination = std::nullopt,
|
||||||
std::optional<typename InstructionT::ImmediateT> operand = std::nullopt,
|
std::optional<typename InstructionT::ImmediateT> operand = std::nullopt,
|
||||||
std::optional<typename InstructionT::DisplacementT> displacement = std::nullopt) {
|
std::optional<typename InstructionT::DisplacementT> displacement = std::nullopt) {
|
||||||
|
|
||||||
XCTAssertEqual(instruction.operation_size(), InstructionSet::x86::DataSize(size));
|
XCTAssertEqual(instruction.operation_size(), InstructionSet::x86::DataSize(size));
|
||||||
XCTAssertEqual(instruction.operation, operation);
|
XCTAssertEqual(instruction.operation, operation);
|
||||||
XCTAssert(instruction.source() == source);
|
if(source) XCTAssert(instruction.source() == *source);
|
||||||
if(destination) XCTAssert(instruction.destination() == *destination);
|
if(destination) XCTAssert(instruction.destination() == *destination);
|
||||||
if(operand) XCTAssertEqual(instruction.operand(), *operand);
|
if(operand) XCTAssertEqual(instruction.operand(), *operand);
|
||||||
if(displacement) XCTAssertEqual(instruction.displacement(), *displacement);
|
if(displacement) XCTAssertEqual(instruction.displacement(), *displacement);
|
||||||
@@ -557,4 +557,75 @@ std::vector<typename InstructionSet::x86::Decoder<model>::InstructionT> decode(c
|
|||||||
test(instructions[0], DataSize::DWord, Operation::ADD, Source::Immediate, ScaleIndexBase(Source::eDI), 0x9f683aa9, -0x42);
|
test(instructions[0], DataSize::DWord, Operation::ADD, Source::Immediate, ScaleIndexBase(Source::eDI), 0x9f683aa9, -0x42);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)test286LengthLimit {
|
||||||
|
const auto instructions = decode<Model::i80286>({
|
||||||
|
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<Model::i80386>({
|
||||||
|
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
|
@end
|
||||||
|
Reference in New Issue
Block a user