mirror of
https://github.com/sampletext32/ParkanPlayground.git
synced 2025-05-19 20:01:17 +03:00
53 lines
1.5 KiB
C#
53 lines
1.5 KiB
C#
![]() |
namespace X86DisassemblerTests;
|
||
|
|
||
|
using System;
|
||
|
using Xunit;
|
||
|
using X86Disassembler.X86;
|
||
|
using X86Disassembler.X86.Handlers;
|
||
|
|
||
|
/// <summary>
|
||
|
/// Tests for return instruction handlers
|
||
|
/// </summary>
|
||
|
public class ReturnInstructionTests
|
||
|
{
|
||
|
/// <summary>
|
||
|
/// Tests the RetHandler for decoding RET instruction
|
||
|
/// </summary>
|
||
|
[Fact]
|
||
|
public void RetHandler_DecodesRet_Correctly()
|
||
|
{
|
||
|
// Arrange
|
||
|
// RET (C3) - Return from procedure
|
||
|
byte[] codeBuffer = new byte[] { 0xC3 };
|
||
|
var decoder = new InstructionDecoder(codeBuffer, codeBuffer.Length);
|
||
|
|
||
|
// Act
|
||
|
var instruction = decoder.DecodeInstruction();
|
||
|
|
||
|
// Assert
|
||
|
Assert.NotNull(instruction);
|
||
|
Assert.Equal("ret", instruction.Mnemonic);
|
||
|
Assert.Equal("", instruction.Operands);
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// Tests the RetImmHandler for decoding RET imm16 instruction
|
||
|
/// </summary>
|
||
|
[Fact]
|
||
|
public void RetImmHandler_DecodesRetImm16_Correctly()
|
||
|
{
|
||
|
// Arrange
|
||
|
// RET 0x1234 (C2 34 12) - Return from procedure and pop 0x1234 bytes
|
||
|
byte[] codeBuffer = new byte[] { 0xC2, 0x34, 0x12 };
|
||
|
var decoder = new InstructionDecoder(codeBuffer, codeBuffer.Length);
|
||
|
|
||
|
// Act
|
||
|
var instruction = decoder.DecodeInstruction();
|
||
|
|
||
|
// Assert
|
||
|
Assert.NotNull(instruction);
|
||
|
Assert.Equal("ret", instruction.Mnemonic);
|
||
|
Assert.Equal("0x1234", instruction.Operands);
|
||
|
}
|
||
|
}
|