1
0
mirror of https://github.com/fadden/6502bench.git synced 2024-07-06 16:29:03 +00:00

Fix inline BRK no-no-continue flag

Inline BRK instructions have a problem similar to the one fixed
for JSR/JSL back in 63d7a487, but the same fix won't work because
JSR/JSL are assumed "continue", while BRK is assumed "no-continue",
and must therefore set a no-no-continue flag.  For now, we just
re-evaluate the BRK on every visit to the code.

A review of the previous fix revealed an opportunity to use the
NoContinueScript flag on subsequent visits to improve consistency.
This commit is contained in:
Andy McFadden 2020-08-22 13:47:52 -07:00
parent ba35f88d02
commit 2ec2917da5
3 changed files with 16 additions and 3 deletions

View File

@ -173,6 +173,9 @@ namespace SourceGen {
}
}
public bool NoContinueScript {
get {
return (mAttribFlags & AttribFlags.NoContinueScript) != 0;
}
set {
if (value) {
mAttribFlags |= AttribFlags.NoContinueScript;

View File

@ -691,8 +691,11 @@ namespace SourceGen {
}
}
// On first visit, check for BRK inline call.
if (firstVisit) {
// On every visit, check for BRK inline call. The default behavior for BRK
// is no-continue, the opposite of JSR/JSL.
// TODO: Ideally we'd have an explicit flag (maybe make NoContinueScript a
// tri-state) to avoid calling the plugin repeatedly.
//if (firstVisit) {
if (op == OpDef.OpBRK_Implied || op == OpDef.OpBRK_StackInt) {
bool noContinue = CheckForInlineCall(op, offset, !doContinue);
if (!noContinue) {
@ -700,7 +703,7 @@ namespace SourceGen {
doContinue = true;
}
}
}
//}
mAnattribs[offset].NoContinue = !doContinue;
if (mAnattribs[offset].DoesNotContinue) {
@ -734,6 +737,9 @@ namespace SourceGen {
break;
}
}
} else if (mAnattribs[offset].NoContinueScript) {
// Wanted to stop last time.
break;
}
// Are we about to walk into inline data?
@ -982,6 +988,7 @@ namespace SourceGen {
/// <summary>
/// Queries script extensions to check to see if a JSR or JSL is actually an inline call.
/// The script may format things.
/// </summary>
/// <param name="op">Instruction being examined.</param>
/// <param name="offset">File offset of start of instruction.</param>

View File

@ -916,6 +916,7 @@ namespace SourceGen {
//Debug.WriteLine("GenerateRange [+" + startOffset.ToString("x6") + ",+" +
// endOffset.ToString("x6") + "]");
Debug.Assert(startOffset >= 0);
Debug.Assert(endOffset >= startOffset);
@ -948,6 +949,8 @@ namespace SourceGen {
if (startOffset > 0) {
int baseOff = DataAnalysis.GetBaseOperandOffset(mProject, startOffset - 1);
if (mProject.GetAnattrib(baseOff).DoesNotContinue) {
// TODO(someday): ideally the blank line would come after inline data
// that follows a no-continue JSR/JSL/BRK
addBlank = true;
}
}