From 0d164e17197e1b781d0fb2845f10b925ac6f8625 Mon Sep 17 00:00:00 2001 From: Andy McFadden Date: Wed, 14 Oct 2020 15:02:13 -0700 Subject: [PATCH] Fix PCRel sample in instruction chart Relative branches should display as $xxxx, not $xx. --- SourceGen/Tools/WpfGui/InstructionChart.xaml.cs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/SourceGen/Tools/WpfGui/InstructionChart.xaml.cs b/SourceGen/Tools/WpfGui/InstructionChart.xaml.cs index 5f0c652..e5892c5 100644 --- a/SourceGen/Tools/WpfGui/InstructionChart.xaml.cs +++ b/SourceGen/Tools/WpfGui/InstructionChart.xaml.cs @@ -159,15 +159,21 @@ namespace SourceGen.Tools.WpfGui { continue; } - int opLen = op.GetLength(StatusFlags.AllIndeterminate); + int instrLen = op.GetLength(StatusFlags.AllIndeterminate); + if (op.AddrMode == OpDef.AddressMode.PCRel) { + // Single-byte branch instructions are formatted with a 16-bit + // absolute addres. + instrLen = 3; + } + string sampleValue = "$12"; if (op.AddrMode == OpDef.AddressMode.BlockMove) { sampleValue = "#$12,#$34"; } else if (op.AddrMode == OpDef.AddressMode.DPPCRel) { sampleValue = "$12,$1234"; - } else if (opLen == 3) { + } else if (instrLen == 3) { sampleValue = "$1234"; - } else if (opLen == 4) { + } else if (instrLen == 4) { sampleValue = "$123456"; } string instrSample = mFormatter.FormatMnemonic(op.Mnemonic,