mirror of https://github.com/x64dbg/zydis
Changed definition-sorting to produce deterministic output (JSON and generated tables)
This commit is contained in:
parent
7f7cbd8dcd
commit
1159966784
Binary file not shown.
|
@ -107,6 +107,7 @@ type
|
||||||
protected
|
protected
|
||||||
constructor Create(Definition: TInstructionDefinition);
|
constructor Create(Definition: TInstructionDefinition);
|
||||||
public
|
public
|
||||||
|
function CompareTo(const Other: TOpcodeExtensions): Integer;
|
||||||
function Equals(const Value: TOpcodeExtensions): Boolean; reintroduce;
|
function Equals(const Value: TOpcodeExtensions): Boolean; reintroduce;
|
||||||
published
|
published
|
||||||
property Mode: TExtInstructionMode read FMode write SetMode default imNeutral;
|
property Mode: TExtInstructionMode read FMode write SetMode default imNeutral;
|
||||||
|
@ -332,6 +333,7 @@ type
|
||||||
protected
|
protected
|
||||||
constructor Create(Definition: TInstructionDefinition);
|
constructor Create(Definition: TInstructionDefinition);
|
||||||
public
|
public
|
||||||
|
function CompareTo(const Other: TX86Flags): Integer;
|
||||||
function Equals(const Value: TX86Flags): Boolean; reintroduce;
|
function Equals(const Value: TX86Flags): Boolean; reintroduce;
|
||||||
public
|
public
|
||||||
property HasConflicts: Boolean read GetConflictState;
|
property HasConflicts: Boolean read GetConflictState;
|
||||||
|
@ -553,6 +555,7 @@ type
|
||||||
protected
|
protected
|
||||||
constructor Create(Definition: TInstructionDefinition);
|
constructor Create(Definition: TInstructionDefinition);
|
||||||
public
|
public
|
||||||
|
function CompareTo(const Other: TInstructionOperands): Integer;
|
||||||
function Equals(const Value: TInstructionOperands): Boolean; reintroduce;
|
function Equals(const Value: TInstructionOperands): Boolean; reintroduce;
|
||||||
public
|
public
|
||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
|
@ -670,6 +673,7 @@ type
|
||||||
procedure Update; inline;
|
procedure Update; inline;
|
||||||
procedure EndUpdate; inline;
|
procedure EndUpdate; inline;
|
||||||
public
|
public
|
||||||
|
function CompareTo(const Other: TInstructionDefinition): Integer;
|
||||||
function Equals(const Value: TInstructionDefinition;
|
function Equals(const Value: TInstructionDefinition;
|
||||||
CheckComment: Boolean = false;
|
CheckComment: Boolean = false;
|
||||||
CheckFilterRelatedAttributes: Boolean = true): Boolean; reintroduce;
|
CheckFilterRelatedAttributes: Boolean = true): Boolean; reintroduce;
|
||||||
|
@ -1442,6 +1446,28 @@ begin
|
||||||
FDefinition.UpdatePosition;
|
FDefinition.UpdatePosition;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TOpcodeExtensions.CompareTo(const Other: TOpcodeExtensions): Integer;
|
||||||
|
var
|
||||||
|
I, A, B: Integer;
|
||||||
|
begin
|
||||||
|
Result := Ord(FMode) - Ord(Other.FMode);
|
||||||
|
if (Result = 0) then Result := Ord(FMandatoryPrefix) - Ord(Other.FMandatoryPrefix);
|
||||||
|
if (Result = 0) then Result := Ord(FModrmMod) - Ord(Other.FModrmMod);
|
||||||
|
if (Result = 0) then Result := Ord(FModrmReg) - Ord(Other.FModrmReg);
|
||||||
|
if (Result = 0) then Result := Ord(FModrmRm) - Ord(Other.FModrmRm);
|
||||||
|
if (Result = 0) then Result := Ord(FOperandSize) - Ord(Other.FOperandSize);
|
||||||
|
if (Result = 0) then Result := Ord(FAddressSize) - Ord(Other.FAddressSize);
|
||||||
|
if (Result = 0) then
|
||||||
|
begin
|
||||||
|
for I := 0 to SizeOf(TExtBitFilters) - 1 do
|
||||||
|
begin
|
||||||
|
A := PByte(PByte(@FBitFilters) + I)^;
|
||||||
|
B := PByte(PByte(@Other.FBitFilters) + I)^;
|
||||||
|
end;
|
||||||
|
Result := A - B;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
constructor TOpcodeExtensions.Create(Definition: TInstructionDefinition);
|
constructor TOpcodeExtensions.Create(Definition: TInstructionDefinition);
|
||||||
begin
|
begin
|
||||||
inherited Create;
|
inherited Create;
|
||||||
|
@ -1721,6 +1747,27 @@ begin
|
||||||
FDefinition.UpdateValues;
|
FDefinition.UpdateValues;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TX86Flags.CompareTo(const Other: TX86Flags): Integer;
|
||||||
|
var
|
||||||
|
F, O: array[0..14] of ^TX86FlagValue;
|
||||||
|
I: Integer;
|
||||||
|
begin
|
||||||
|
Result := 0;
|
||||||
|
F[ 0] := @FCF; F[ 1] := @FPF; F[ 2] := @FAF; F[ 3] := @FZF; F[ 4] := @FSF;
|
||||||
|
F[ 5] := @FTF; F[ 6] := @FIF; F[ 7] := @FDF; F[ 8] := @FOF; F[ 9] := @FRF;
|
||||||
|
F[10] := @FVM; F[11] := @FAC; F[12] := @FVIF; F[13] := @FVIP; F[14] := @FID;
|
||||||
|
O[ 0] := @Other.FCF; O[ 1] := @Other.FPF; O[ 2] := @Other.FAF; O[ 3] := @Other.FZF;
|
||||||
|
O[ 4] := @Other.FSF; O[ 5] := @Other.FTF; O[ 6] := @Other.FIF; O[ 7] := @Other.FDF;
|
||||||
|
O[ 8] := @Other.FOF; O[ 9] := @Other.FRF; O[10] := @Other.FVM; O[11] := @Other.FAC;
|
||||||
|
O[12] := @Other.FVIF; O[13] := @Other.FVIP; O[14] := @Other.FID;
|
||||||
|
I := 0;
|
||||||
|
while (Result = 0) and (I < Length(F)) do
|
||||||
|
begin
|
||||||
|
Result := Ord(F[I]^) - Ord(O[I]^);
|
||||||
|
Inc(I);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
constructor TX86Flags.Create(Definition: TInstructionDefinition);
|
constructor TX86Flags.Create(Definition: TInstructionDefinition);
|
||||||
begin
|
begin
|
||||||
inherited Create;
|
inherited Create;
|
||||||
|
@ -2519,6 +2566,22 @@ begin
|
||||||
FDefinition.UpdateValues;
|
FDefinition.UpdateValues;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TInstructionOperands.CompareTo(const Other: TInstructionOperands): Integer;
|
||||||
|
var
|
||||||
|
I: Integer;
|
||||||
|
begin
|
||||||
|
Result := 0;
|
||||||
|
I := 0;
|
||||||
|
while (Result = 0) and (I < Length(FOperands)) do
|
||||||
|
begin
|
||||||
|
Result := Ord(FOperands[I].OperandType) - Ord(Other.FOperands[I].OperandType);
|
||||||
|
if (Result = 0) then Result := Ord(FOperands[I].Encoding) - Ord(Other.FOperands[I].Encoding);
|
||||||
|
if (Result = 0) then
|
||||||
|
Result := Ord(FOperands[I].AccessMode) - Ord(Other.FOperands[I].AccessMode);
|
||||||
|
Inc(I);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
constructor TInstructionOperands.Create(Definition: TInstructionDefinition);
|
constructor TInstructionOperands.Create(Definition: TInstructionDefinition);
|
||||||
var
|
var
|
||||||
I: Integer;
|
I: Integer;
|
||||||
|
@ -2711,6 +2774,57 @@ begin
|
||||||
Inc(FUpdateCount);
|
Inc(FUpdateCount);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TInstructionDefinition.CompareTo(const Other: TInstructionDefinition): Integer;
|
||||||
|
var
|
||||||
|
I, A, B: Integer;
|
||||||
|
begin
|
||||||
|
Result := CompareStr(FMnemonic, Other.FMnemonic);
|
||||||
|
if (Result = 0) then Result := Ord(FEncoding) - Ord(Other.FEncoding);
|
||||||
|
if (Result = 0) then Result := Ord(FOpcodeMap) - Ord(Other.FOpcodeMap);
|
||||||
|
if (Result = 0) then Result := FOpcode - Other.FOpcode;
|
||||||
|
if (Result = 0) then Result := FExtensions.CompareTo(Other.FExtensions);
|
||||||
|
if (Result = 0) then Result := FOperands.CompareTo(Other.FOperands);
|
||||||
|
if (Result = 0) then
|
||||||
|
begin
|
||||||
|
for I := 0 to SizeOf(TCPUIDFeatureFlagSet) - 1 do
|
||||||
|
begin
|
||||||
|
A := PByte(PByte(@FCPUID.FeatureFlags) + I)^;
|
||||||
|
B := PByte(PByte(@Other.FCPUID.FeatureFlags) + I)^;
|
||||||
|
end;
|
||||||
|
Result := A - B;
|
||||||
|
end;
|
||||||
|
if (Result = 0) then
|
||||||
|
begin
|
||||||
|
for I := 0 to SizeOf(TInstructionDefinitionFlags) - 1 do
|
||||||
|
begin
|
||||||
|
A := PByte(PByte(@FFlags) + I)^;
|
||||||
|
B := PByte(PByte(@Other.FFlags) + I)^;
|
||||||
|
end;
|
||||||
|
Result := A - B;
|
||||||
|
end;
|
||||||
|
if (Result = 0) then
|
||||||
|
begin
|
||||||
|
for I := 0 to SizeOf(TX86RegisterSet) - 1 do
|
||||||
|
begin
|
||||||
|
A := PByte(PByte(@FImplicitRead) + I)^;
|
||||||
|
B := PByte(PByte(@Other.FImplicitRead) + I)^;
|
||||||
|
end;
|
||||||
|
Result := A - B;
|
||||||
|
end;
|
||||||
|
if (Result = 0) then
|
||||||
|
begin
|
||||||
|
for I := 0 to SizeOf(TX86RegisterSet) - 1 do
|
||||||
|
begin
|
||||||
|
A := PByte(PByte(@FImplicitWrite) + I)^;
|
||||||
|
B := PByte(PByte(@Other.FImplicitWrite) + I)^;
|
||||||
|
end;
|
||||||
|
Result := A - B;
|
||||||
|
end;
|
||||||
|
if (Result = 0) then Result := FX86Flags.CompareTo(Other.FX86Flags);
|
||||||
|
if (Result = 0) then Result := FEVEXCD8Scale - Other.FEVEXCD8Scale;
|
||||||
|
if (Result = 0) then Result := CompareStr(FComment, Other.FComment);
|
||||||
|
end;
|
||||||
|
|
||||||
constructor TInstructionDefinition.Create(Editor: TInstructionEditor; const Mnemonic: String);
|
constructor TInstructionDefinition.Create(Editor: TInstructionEditor; const Mnemonic: String);
|
||||||
begin
|
begin
|
||||||
inherited Create;
|
inherited Create;
|
||||||
|
@ -3932,19 +4046,7 @@ begin
|
||||||
Comparison :=
|
Comparison :=
|
||||||
function(const Left, Right: TInstructionDefinition): Integer
|
function(const Left, Right: TInstructionDefinition): Integer
|
||||||
begin
|
begin
|
||||||
Result := CompareStr(Left.Mnemonic, Right.Mnemonic);
|
Result := Left.CompareTo(Right);
|
||||||
if (Result = 0) then
|
|
||||||
begin
|
|
||||||
Result := Ord(Left.Encoding) - Ord(Right.Encoding);
|
|
||||||
end;
|
|
||||||
if (Result = 0) then
|
|
||||||
begin
|
|
||||||
Result := Ord(Left.OpcodeMap) - Ord(Right.OpcodeMap);
|
|
||||||
end;
|
|
||||||
if (Result = 0) then
|
|
||||||
begin
|
|
||||||
Result := Left.Opcode - Right.Opcode;
|
|
||||||
end;
|
|
||||||
end;
|
end;
|
||||||
FDefinitions.Sort(TComparer<TInstructionDefinition>.Construct(Comparison));
|
FDefinitions.Sort(TComparer<TInstructionDefinition>.Construct(Comparison));
|
||||||
// Save to JSON
|
// Save to JSON
|
||||||
|
|
136374
assets/instructions.json
136374
assets/instructions.json
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue