mirror of
https://github.com/sampletext32/ParkanPlayground.git
synced 2025-06-19 07:59:47 +03:00
Added AddEaxImmHandler for decoding ADD EAX, imm32 instruction (opcode 0x05)
This commit is contained in:
52
X86DisassemblerTests/AddEaxImmHandlerTests.cs
Normal file
52
X86DisassemblerTests/AddEaxImmHandlerTests.cs
Normal file
@ -0,0 +1,52 @@
|
||||
namespace X86DisassemblerTests;
|
||||
|
||||
using System;
|
||||
using Xunit;
|
||||
using X86Disassembler.X86;
|
||||
using X86Disassembler.X86.Handlers.Add;
|
||||
|
||||
/// <summary>
|
||||
/// Tests for ADD EAX, imm32 instruction handler
|
||||
/// </summary>
|
||||
public class AddEaxImmHandlerTests
|
||||
{
|
||||
/// <summary>
|
||||
/// Tests the AddEaxImmHandler for decoding ADD EAX, imm32 instruction
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void AddEaxImmHandler_DecodesAddEaxImm32_Correctly()
|
||||
{
|
||||
// Arrange
|
||||
// ADD EAX, 0x12345678 (05 78 56 34 12)
|
||||
byte[] codeBuffer = new byte[] { 0x05, 0x78, 0x56, 0x34, 0x12 };
|
||||
var decoder = new InstructionDecoder(codeBuffer, codeBuffer.Length);
|
||||
|
||||
// Act
|
||||
var instruction = decoder.DecodeInstruction();
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(instruction);
|
||||
Assert.Equal("add", instruction.Mnemonic);
|
||||
Assert.Equal("eax, 0x12345678", instruction.Operands);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tests the AddEaxImmHandler for handling insufficient bytes
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void AddEaxImmHandler_HandlesInsufficientBytes_Gracefully()
|
||||
{
|
||||
// Arrange
|
||||
// ADD EAX, ?? (05) - missing immediate value
|
||||
byte[] codeBuffer = new byte[] { 0x05 };
|
||||
var decoder = new InstructionDecoder(codeBuffer, codeBuffer.Length);
|
||||
|
||||
// Act
|
||||
var instruction = decoder.DecodeInstruction();
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(instruction);
|
||||
Assert.Equal("add", instruction.Mnemonic);
|
||||
Assert.Equal("eax, ??", instruction.Operands);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user