Skip to content

Commit

Permalink
feat: Inline function name in MASM column
Browse files Browse the repository at this point in the history
Signed-off-by: Maximilien Noal <noal.maximilien@gmail.com>
  • Loading branch information
maximilien-noal committed Nov 11, 2024
1 parent d6979de commit 269f3d3
Show file tree
Hide file tree
Showing 4 changed files with 120 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/Spice86/Converters/InstructionToStringConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ public class InstructionToStringConverter : IValueConverter {
}
_outputString.Clear();
var output = new StringOutput();
if (!string.IsNullOrWhiteSpace(cpuInstructionInfo.FunctionName)) {
_outputString.AppendLine($"{cpuInstructionInfo.FunctionName} entry point");
}
// Don't use instr.ToString(), it allocates more, uses masm syntax and default options
_formatter.Format(instr, output);
_outputString.AppendLine(output.ToStringAndReset());
Expand Down
1 change: 1 addition & 0 deletions src/Spice86/Models/Debugging/CpuInstructionInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ namespace Spice86.Models.Debugging;
public partial class CpuInstructionInfo : ObservableObject {
[ObservableProperty] private string? _stringRepresentation;
[ObservableProperty] private bool _hasBreakpoint;
[ObservableProperty] private string? _functionName;
[ObservableProperty] private bool _isCsIp;
[ObservableProperty] private uint _address;
[ObservableProperty] private string? _addressInformation;
Expand Down
113 changes: 113 additions & 0 deletions src/Spice86/ViewModels/DisassemblyViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,118 @@ public CpuInstructionInfo? SelectedInstruction {

[RelayCommand(CanExecute = nameof(IsPaused))]
private async Task CopyLine() {
















































































































if (SelectedInstruction is not null) {
await _textClipboard.SetTextAsync(SelectedInstruction.StringRepresentation);
}
Expand All @@ -272,6 +384,7 @@ private List<CpuInstructionInfo> DecodeInstructions(State state, IMemory memory,
CpuInstructionInfo instructionInfo = new() {
Instruction = instruction,
Address = (uint)instructionAddress,
FunctionName = Functions.FirstOrDefault(x => x.Address == instructionAddress)?.Name,
AddressInformation = $"{instructionAddress} (0x{state.CS:x4}:{(ushort)(state.IP + byteOffset):X4})",
Length = instruction.Length,
IP16 = instruction.IP16,
Expand Down
4 changes: 3 additions & 1 deletion src/Spice86/Views/DisassemblyView.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,9 @@
<DataGridCheckBoxColumn Binding="{Binding HasBreakpoint}" Header="Breakpoint" />
<DataGridTextColumn Binding="{Binding AddressInformation}" Header="Address (CS:IP+offset)" />
<DataGridCheckBoxColumn Binding="{Binding IsCsIp}" Header="Is CS:IP" />
<DataGridTextColumn Binding="{Binding Converter={StaticResource InstructionToStringConverter}}" Header="MASM" />
<DataGridTextColumn MaxWidth="300"
Binding="{Binding Converter={StaticResource InstructionToStringConverter}}"
Header="MASM" />
<DataGridTextColumn Binding="{Binding Bytes}" Header="Bytes (Length)" />
<DataGridTextColumn Binding="{Binding SegmentPrefix}" Header="Segment Prefix" />
<DataGridTextColumn Binding="{Binding MemorySegment}" Header="Memory Segment" />
Expand Down

0 comments on commit 269f3d3

Please sign in to comment.