From 44b483c8d810b474e4fda38d9fe25e7fedf0824c Mon Sep 17 00:00:00 2001 From: Andy McFadden Date: Sun, 1 Aug 2021 18:15:44 -0700 Subject: [PATCH] Fix table formatting for embedded destinations The code for formatting an address table allows you to specify that code start tags should be placed on all targets. However, unnecessary tags are undesirable, and it's not necessary to add a tag if the target is already treated as executable code. So the implementation tested to see if the target address was already an instruction. The code was incorrectly testing for "is instruction", rather than "is instruction start", which meant that if the table entry pointed at an instruction embedded inside another instruction we would conclude that the tag wasn't necessary, when in fact it was. Not only weren't we getting a useful table entry, we were adding a symbolic reference to a hidden label. (issue #103) --- SourceGen/MainController.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/SourceGen/MainController.cs b/SourceGen/MainController.cs index 02d9c4c..a202ba4 100644 --- a/SourceGen/MainController.cs +++ b/SourceGen/MainController.cs @@ -2712,7 +2712,11 @@ namespace SourceGen { TypedRangeSet undoSet = new TypedRangeSet(); foreach (int offset in dlg.AllTargetOffsets) { - if (!mProject.GetAnattrib(offset).IsInstruction) { + // We don't need to add a "code start" tag if this is already the + // start of an instruction. We do need to add one if it's the *middle* + // of an instruction, e.g. the table points inside a "BIT abs". So we + // test against IsInstructionStart, not IsInstruction. + if (!mProject.GetAnattrib(offset).IsInstructionStart) { CodeAnalysis.AnalyzerTag oldType = mProject.AnalyzerTags[offset]; if (oldType == CodeAnalysis.AnalyzerTag.Code) { continue; // already set