mirror of
https://github.com/TomHarte/CLK.git
synced 2024-10-19 14:25:35 +00:00
Ensures that the operand is the only thing failing in decoding of the first instruction.
This commit is contained in:
parent
718f950071
commit
5f807b6e47
@ -15,6 +15,8 @@
|
|||||||
namespace {
|
namespace {
|
||||||
using Operation = CPU::Decoder::x86::Operation;
|
using Operation = CPU::Decoder::x86::Operation;
|
||||||
using Instruction = CPU::Decoder::x86::Instruction;
|
using Instruction = CPU::Decoder::x86::Instruction;
|
||||||
|
using Source = CPU::Decoder::x86::Source;
|
||||||
|
using Size = CPU::Decoder::x86::Size;
|
||||||
}
|
}
|
||||||
|
|
||||||
@interface x86DecoderTests : XCTestCase
|
@interface x86DecoderTests : XCTestCase
|
||||||
@ -31,7 +33,13 @@ namespace {
|
|||||||
|
|
||||||
// MARK: - Specific instruction asserts.
|
// MARK: - Specific instruction asserts.
|
||||||
|
|
||||||
/* ... TODO ... */
|
- (void)assert:(Instruction &)instruction operation:(Operation)operation size:(int)size operand:(uint16_t)operand destination:(Source)destination {
|
||||||
|
XCTAssertEqual(instruction.operation, operation);
|
||||||
|
XCTAssertEqual(instruction.operation_size(), CPU::Decoder::x86::Size(size));
|
||||||
|
XCTAssertEqual(instruction.destination(), destination);
|
||||||
|
XCTAssertEqual(instruction.source(), Source::Immediate);
|
||||||
|
XCTAssertEqual(instruction.operand(), operand);
|
||||||
|
}
|
||||||
|
|
||||||
// MARK: - Decoder
|
// MARK: - Decoder
|
||||||
|
|
||||||
@ -82,6 +90,8 @@ namespace {
|
|||||||
// 68 instructions are expected.
|
// 68 instructions are expected.
|
||||||
XCTAssertEqual(instructions.size(), 63);
|
XCTAssertEqual(instructions.size(), 63);
|
||||||
|
|
||||||
|
[self assert:instructions[0] operation:Operation::SUB size:2 operand:0xea77 destination:Source::AX];
|
||||||
|
|
||||||
// sub $0xea77,%ax
|
// sub $0xea77,%ax
|
||||||
// jb 0x00000001
|
// jb 0x00000001
|
||||||
// dec %bx
|
// dec %bx
|
||||||
|
@ -37,6 +37,7 @@ std::pair<int, Instruction> Decoder::decode(const uint8_t *source, size_t length
|
|||||||
/// Handles instructions of the form rr, kk and rr, jjkk, i.e. a destination register plus an operand.
|
/// Handles instructions of the form rr, kk and rr, jjkk, i.e. a destination register plus an operand.
|
||||||
#define RegData(op, dest, size) \
|
#define RegData(op, dest, size) \
|
||||||
SetOpSrcDestSize(op, DirectAddress, dest, size); \
|
SetOpSrcDestSize(op, DirectAddress, dest, size); \
|
||||||
|
source_ = Source::Immediate; \
|
||||||
operand_size_ = size; \
|
operand_size_ = size; \
|
||||||
phase_ = Phase::AwaitingDisplacementOrOperand
|
phase_ = Phase::AwaitingDisplacementOrOperand
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user