mirror of
https://github.com/fadden/6502bench.git
synced 2025-03-04 06:29:56 +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:
parent
ba35f88d02
commit
2ec2917da5
@ -173,6 +173,9 @@ namespace SourceGen {
|
||||
}
|
||||
}
|
||||
public bool NoContinueScript {
|
||||
get {
|
||||
return (mAttribFlags & AttribFlags.NoContinueScript) != 0;
|
||||
}
|
||||
set {
|
||||
if (value) {
|
||||
mAttribFlags |= AttribFlags.NoContinueScript;
|
||||
|
@ -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>
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user