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

Unified ADC accumulator handlers into a single handler

This commit is contained in:
bird_egop
2025-04-17 01:33:58 +03:00
parent 8c9b34ef09
commit 3fc0ebf1d5
79 changed files with 2564 additions and 473 deletions

View File

@ -39,26 +39,28 @@ public class DisplacementMemoryOperand : MemoryOperand
var registerName = RegisterMapper.GetRegisterName(BaseRegister, 32);
// Format the displacement value
string formattedDisplacement;
string sign;
// Handle positive and negative displacements
if (Displacement >= 0)
long absDisplacement = Math.Abs(Displacement);
string sign = Displacement >= 0 ? "+" : "-";
string format;
if (absDisplacement == 0)
{
sign = "+";
formattedDisplacement = Displacement < 256
? $"0x{Displacement:X2}"
: $"0x{Displacement:X8}";
format = "X2";
}
else if (absDisplacement <= 0xFF)
{
format = "X2";
}
else if (absDisplacement <= 0xFFFF)
{
format = "X4";
}
else
{
sign = "-";
// For negative values, take the absolute value for display
var absDisplacement = Math.Abs(Displacement);
formattedDisplacement = absDisplacement < 256
? $"0x{absDisplacement:X2}"
: $"0x{absDisplacement:X8}";
format = "X8";
}
string formattedDisplacement = $"0x{absDisplacement.ToString(format)}";
return $"{GetSizePrefix()}[{registerName}{sign}{formattedDisplacement}]";
}