mirror of
https://github.com/sampletext32/ParkanPlayground.git
synced 2025-06-20 00:18:02 +03:00
Unified ADC accumulator handlers into a single handler
This commit is contained in:
@ -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}]";
|
||||
}
|
||||
|
@ -46,42 +46,25 @@ public class ImmediateOperand : Operand
|
||||
_ => Value
|
||||
};
|
||||
|
||||
// For 8-bit immediate values, always use at least 2 digits
|
||||
if (Size == 8)
|
||||
string format;
|
||||
|
||||
if (maskedValue == 0)
|
||||
{
|
||||
return $"0x{maskedValue:X2}";
|
||||
format = "X2";
|
||||
}
|
||||
|
||||
// For 16-bit immediate values, format depends on the value
|
||||
if (Size == 16)
|
||||
else if (maskedValue <= 0xFF)
|
||||
{
|
||||
// For small values (< 256), show without leading zeros
|
||||
if (maskedValue < 256)
|
||||
{
|
||||
return $"0x{maskedValue:X}";
|
||||
}
|
||||
|
||||
// For larger values, use at least 4 digits
|
||||
return $"0x{maskedValue:X4}";
|
||||
format = "X2";
|
||||
}
|
||||
|
||||
// For 32-bit immediate values, format depends on the instruction context
|
||||
if (Size == 32)
|
||||
else if (maskedValue <= 0xFFFF)
|
||||
{
|
||||
// For small values (0), always show as 0x00
|
||||
if (maskedValue == 0)
|
||||
{
|
||||
return "0x00";
|
||||
}
|
||||
|
||||
// For other small values (< 256), show as 0xNN
|
||||
if (maskedValue < 256)
|
||||
{
|
||||
return $"0x{maskedValue:X2}";
|
||||
}
|
||||
format = "X4";
|
||||
}
|
||||
|
||||
// For larger 32-bit values, show the full 32-bit representation
|
||||
return $"0x{maskedValue:X8}";
|
||||
else
|
||||
{
|
||||
format = "X8";
|
||||
}
|
||||
|
||||
return $"0x{maskedValue.ToString(format)}";
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user