mirror of
https://github.com/sampletext32/ParkanPlayground.git
synced 2025-05-19 20:01:17 +03:00
refactor xors
This commit is contained in:
parent
30676b36a1
commit
b0ade45f1b
@ -13,6 +13,9 @@
|
|||||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003Aud_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003FUsers_003FAdmin_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003Fa494e0aa381c41ff9484df33e5edb42535e00_003F15_003F87bd9007_003Fud_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003Aud_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003FUsers_003FAdmin_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003Fa494e0aa381c41ff9484df33e5edb42535e00_003F15_003F87bd9007_003Fud_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003Audis86_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003FUsers_003FAdmin_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003Fa494e0aa381c41ff9484df33e5edb42535e00_003F95_003F953bbb0f_003Fudis86_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003Audis86_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003FUsers_003FAdmin_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003Fa494e0aa381c41ff9484df33e5edb42535e00_003F95_003F953bbb0f_003Fudis86_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||||
<s:String x:Key="/Default/Environment/Highlighting/HighlightingSourceSnapshotLocation/@EntryValue">C:\Users\Admin\AppData\Local\JetBrains\Rider2024.3\resharper-host\temp\Rider\vAny\CoverageData\_ParkanPlayground.1073341822\Snapshot\snapshot.utdcvr</s:String>
|
<s:String x:Key="/Default/Environment/Highlighting/HighlightingSourceSnapshotLocation/@EntryValue">C:\Users\Admin\AppData\Local\JetBrains\Rider2024.3\resharper-host\temp\Rider\vAny\CoverageData\_ParkanPlayground.1073341822\Snapshot\snapshot.utdcvr</s:String>
|
||||||
|
<s:String x:Key="/Default/Environment/UnitTesting/UnitTestSessionStore/Sessions/=47ebaefe_002Da806_002D4565_002Dabe7_002D4f14ac675135/@EntryIndexedValue"><SessionState ContinuousTestingMode="0" IsActive="True" Name="All tests from &lt;X86DisassemblerTests&gt;" xmlns="urn:schemas-jetbrains-com:jetbrains-ut-session">
|
||||||
|
<Project Location="C:\Projects\CSharp\ParkanPlayground\X86DisassemblerTests" Presentation="&lt;X86DisassemblerTests&gt;" />
|
||||||
|
</SessionState></s:String>
|
||||||
|
|
||||||
<s:String x:Key="/Default/Environment/UnitTesting/UnitTestSessionStore/Sessions/=87a33e46_002D2816_002D434f_002D972a_002D703eb7a78476/@EntryIndexedValue"><SessionState ContinuousTestingMode="0" IsActive="True" Name="Session" xmlns="urn:schemas-jetbrains-com:jetbrains-ut-session">
|
<s:String x:Key="/Default/Environment/UnitTesting/UnitTestSessionStore/Sessions/=87a33e46_002D2816_002D434f_002D972a_002D703eb7a78476/@EntryIndexedValue"><SessionState ContinuousTestingMode="0" IsActive="True" Name="Session" xmlns="urn:schemas-jetbrains-com:jetbrains-ut-session">
|
||||||
<And>
|
<And>
|
||||||
@ -20,7 +23,5 @@
|
|||||||
<Project Location="C:\Projects\CSharp\ParkanPlayground\X86DisassemblerTests" Presentation="&lt;X86DisassemblerTests&gt;" />
|
<Project Location="C:\Projects\CSharp\ParkanPlayground\X86DisassemblerTests" Presentation="&lt;X86DisassemblerTests&gt;" />
|
||||||
</And>
|
</And>
|
||||||
</SessionState></s:String>
|
</SessionState></s:String>
|
||||||
<s:String x:Key="/Default/Environment/UnitTesting/UnitTestSessionStore/Sessions/=ea256cae_002Df513_002D419e_002D992a_002D13b500b3c433/@EntryIndexedValue"><SessionState ContinuousTestingMode="0" IsActive="True" Name="All tests from &lt;X86DisassemblerTests&gt;" xmlns="urn:schemas-jetbrains-com:jetbrains-ut-session">
|
|
||||||
<Project Location="C:\Projects\CSharp\ParkanPlayground\X86DisassemblerTests" Presentation="&lt;X86DisassemblerTests&gt;" />
|
|
||||||
</SessionState></s:String>
|
|
||||||
</wpf:ResourceDictionary>
|
</wpf:ResourceDictionary>
|
@ -67,10 +67,8 @@ public class XorImmWithRm16SignExtendedHandler : InstructionHandler
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read the immediate value and sign-extend it
|
// Read the immediate value and sign-extend it to 16 bits
|
||||||
byte imm8 = Decoder.ReadByte();
|
short imm16 = (sbyte)Decoder.ReadByte();
|
||||||
// Sign-extend to 16 bits by converting to sbyte first
|
|
||||||
short imm16 = (short)((sbyte)imm8);
|
|
||||||
|
|
||||||
// Format the immediate value
|
// Format the immediate value
|
||||||
string immStr = $"0x{(ushort)imm16:X4}";
|
string immStr = $"0x{(ushort)imm16:X4}";
|
||||||
|
@ -67,10 +67,8 @@ public class XorImmWithRm32SignExtendedHandler : InstructionHandler
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read the immediate value and sign-extend it
|
// Read the immediate value and sign-extend it to 32 bits
|
||||||
byte imm8 = Decoder.ReadByte();
|
int imm32 = (sbyte)Decoder.ReadByte();
|
||||||
// Sign-extend to 32 bits by converting to sbyte first
|
|
||||||
int imm32 = (int)((sbyte)imm8);
|
|
||||||
|
|
||||||
// Format the immediate value
|
// Format the immediate value
|
||||||
string immStr;
|
string immStr;
|
||||||
@ -79,15 +77,10 @@ public class XorImmWithRm32SignExtendedHandler : InstructionHandler
|
|||||||
// For negative values, show the full sign-extended 32-bit value
|
// For negative values, show the full sign-extended 32-bit value
|
||||||
immStr = $"0x{imm32:X8}";
|
immStr = $"0x{imm32:X8}";
|
||||||
}
|
}
|
||||||
else if (imm8 == 0)
|
|
||||||
{
|
|
||||||
// For zero, use the expected format
|
|
||||||
immStr = "0x00";
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// For positive values, show without leading zeros
|
// For positive values, show without leading zeros
|
||||||
immStr = $"0x{imm8:X}";
|
immStr = $"0x{imm32:X2}";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the operands
|
// Set the operands
|
||||||
|
@ -68,8 +68,7 @@ public class XorImmWithRm8Handler : InstructionHandler
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Read the immediate value
|
// Read the immediate value
|
||||||
byte imm8 = CodeBuffer[position];
|
byte imm8 = Decoder.ReadByte();
|
||||||
Decoder.SetPosition(position + 1);
|
|
||||||
|
|
||||||
// Format the immediate value
|
// Format the immediate value
|
||||||
string immStr = $"0x{imm8:X2}";
|
string immStr = $"0x{imm8:X2}";
|
||||||
|
@ -45,16 +45,7 @@ public class XorMemRegHandler : InstructionHandler
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Read the ModR/M byte
|
// Read the ModR/M byte
|
||||||
byte modRM = CodeBuffer[position++];
|
var (mod, reg, rm, destOperand) = ModRMDecoder.ReadModRM();
|
||||||
Decoder.SetPosition(position);
|
|
||||||
|
|
||||||
// Extract the fields from the ModR/M byte
|
|
||||||
byte mod = (byte)((modRM & 0xC0) >> 6);
|
|
||||||
byte reg = (byte)((modRM & 0x38) >> 3);
|
|
||||||
byte rm = (byte)(modRM & 0x07);
|
|
||||||
|
|
||||||
// Decode the destination operand
|
|
||||||
string destOperand = ModRMDecoder.DecodeModRM(mod, rm, false);
|
|
||||||
|
|
||||||
// Get the source register
|
// Get the source register
|
||||||
string srcReg = GetRegister32(reg);
|
string srcReg = GetRegister32(reg);
|
||||||
|
@ -45,16 +45,7 @@ public class XorRegMemHandler : InstructionHandler
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Read the ModR/M byte
|
// Read the ModR/M byte
|
||||||
byte modRM = CodeBuffer[position++];
|
var (mod, reg, rm, srcOperand) = ModRMDecoder.ReadModRM();
|
||||||
Decoder.SetPosition(position);
|
|
||||||
|
|
||||||
// Extract the fields from the ModR/M byte
|
|
||||||
byte mod = (byte)((modRM & 0xC0) >> 6);
|
|
||||||
byte reg = (byte)((modRM & 0x38) >> 3);
|
|
||||||
byte rm = (byte)(modRM & 0x07);
|
|
||||||
|
|
||||||
// Decode the source operand
|
|
||||||
string srcOperand = ModRMDecoder.DecodeModRM(mod, rm, false);
|
|
||||||
|
|
||||||
// Get the destination register
|
// Get the destination register
|
||||||
string destReg = GetRegister32(reg);
|
string destReg = GetRegister32(reg);
|
||||||
|
@ -281,6 +281,6 @@ public class Group1InstructionTests
|
|||||||
// Assert
|
// Assert
|
||||||
Assert.NotNull(instruction);
|
Assert.NotNull(instruction);
|
||||||
Assert.Equal("xor", instruction.Mnemonic);
|
Assert.Equal("xor", instruction.Mnemonic);
|
||||||
Assert.Equal("esi, 0x00000042", instruction.Operands);
|
Assert.Equal("esi, 0x42", instruction.Operands);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user