From 269f3d3d287612aeed1b671b7c337d537f339f82 Mon Sep 17 00:00:00 2001 From: Maximilien Noal Date: Mon, 11 Nov 2024 21:28:03 +0100 Subject: [PATCH] feat: Inline function name in MASM column Signed-off-by: Maximilien Noal --- .../InstructionToStringConverter.cs | 3 + .../Models/Debugging/CpuInstructionInfo.cs | 1 + .../ViewModels/DisassemblyViewModel.cs | 113 ++++++++++++++++++ src/Spice86/Views/DisassemblyView.axaml | 4 +- 4 files changed, 120 insertions(+), 1 deletion(-) diff --git a/src/Spice86/Converters/InstructionToStringConverter.cs b/src/Spice86/Converters/InstructionToStringConverter.cs index 28dd370cb3..058c1e9b15 100644 --- a/src/Spice86/Converters/InstructionToStringConverter.cs +++ b/src/Spice86/Converters/InstructionToStringConverter.cs @@ -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()); diff --git a/src/Spice86/Models/Debugging/CpuInstructionInfo.cs b/src/Spice86/Models/Debugging/CpuInstructionInfo.cs index a168395213..e5f275c433 100644 --- a/src/Spice86/Models/Debugging/CpuInstructionInfo.cs +++ b/src/Spice86/Models/Debugging/CpuInstructionInfo.cs @@ -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; diff --git a/src/Spice86/ViewModels/DisassemblyViewModel.cs b/src/Spice86/ViewModels/DisassemblyViewModel.cs index f58a845721..ceb9e7d195 100644 --- a/src/Spice86/ViewModels/DisassemblyViewModel.cs +++ b/src/Spice86/ViewModels/DisassemblyViewModel.cs @@ -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); } @@ -272,6 +384,7 @@ private List 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, diff --git a/src/Spice86/Views/DisassemblyView.axaml b/src/Spice86/Views/DisassemblyView.axaml index eedd03cafa..a9e9b5fbf2 100644 --- a/src/Spice86/Views/DisassemblyView.axaml +++ b/src/Spice86/Views/DisassemblyView.axaml @@ -83,7 +83,9 @@ - +