0
mirror of https://github.com/sampletext32/ParkanPlayground.git synced 2025-06-20 16:18:37 +03:00

Refactor SUB handlers

This commit is contained in:
bird_egop
2025-04-13 18:22:44 +03:00
parent a04a16af7d
commit e91a0223f7
18 changed files with 493 additions and 200 deletions

View File

@ -37,28 +37,21 @@ public class SubAxImm16Handler : InstructionHandler
{
// Set the mnemonic
instruction.Mnemonic = "sub";
int position = Decoder.GetPosition();
// Check if we have enough bytes for the immediate value
if (position + 1 >= Length)
{
return false;
}
// Read the immediate value (16-bit)
byte lowByte = CodeBuffer[position++];
byte highByte = CodeBuffer[position++];
// Combine the bytes into a 16-bit value
ushort immediate = (ushort)((highByte << 8) | lowByte);
// Update the decoder position
Decoder.SetPosition(position);
var immediate = Decoder.ReadUInt16();
// Set the operands (note: we use "eax" instead of "ax" to match the disassembler's output)
instruction.Operands = $"eax, 0x{immediate:X4}";
return true;
}
}
}