Skip to content

Commit

Permalink
feat: Wrap hex
Browse files Browse the repository at this point in the history
Closes #21
  • Loading branch information
furesoft committed Oct 26, 2024
1 parent e8aebde commit 2a9a395
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions src/MimaSim/MimaSim/ViewModels/DisassemblyPopupViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
using MimaSim.Controls;
using System;
using MimaSim.Controls;
using MimaSim.MIMA.Components;
using ReactiveUI;
using System.Linq;
using System.Text;
using System.Windows.Input;
using AvaloniaEdit.Highlighting;
using MimaSim.Core;
Expand Down Expand Up @@ -52,16 +54,28 @@ private static string Disassemble()
private static string GetRawString()
{
var raw = CPU.Instance.Program;
var stringBuilder = new StringBuilder();

return string.Join(' ', raw.Select(_ =>
foreach (var item in raw)
{
var result = (_).ToString("x");
var result = item.ToString("x");
if (result.Length == 1)
{
result = "0" + result;
}

return result;
})).ToUpper();
stringBuilder.Append(result.ToUpper());

if ((stringBuilder.Length % 10) == 0)
{
stringBuilder.Append(Environment.NewLine);
}
else
{
stringBuilder.Append(' ');
}
}

return stringBuilder.ToString().Trim();
}
}

0 comments on commit 2a9a395

Please sign in to comment.