Skip to content

Commit

Permalink
Fix state directives causing some warnings to not be raised
Browse files Browse the repository at this point in the history
  • Loading branch information
TollyH committed Jun 1, 2024
1 parent c5a0cc0 commit cfa65fd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
13 changes: 9 additions & 4 deletions AssemblerWarnings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,8 @@ public AssemblerWarnings(bool usingV1Format)
private string? lastMacroName;
private int lastMacroLineDepth;
private Stack<Assembler.ImportStackFrame> lastImportStack = new();
private FilePosition lastFilePosition = new();

private int consecutiveDatCount = 0;

private void PreAnalyzeStateUpdate()
Expand Down Expand Up @@ -452,11 +454,12 @@ private void PreAnalyzeStateUpdate()

private void PostAnalyzeStateUpdate()
{
currentAddress += (uint)newBytes.Length;
if (newBytes.Length > 0)
if (newBytes.Length == 0)
{
lastInstructionWasTerminator = terminators.Contains(instructionOpcode);
return;
}
currentAddress += (uint)newBytes.Length;
lastInstructionWasTerminator = terminators.Contains(instructionOpcode);
lastInstructionWasData = instructionIsData;
lastInstructionWasImport = instructionIsImport;
lastInstructionWasString = instructionIsString;
Expand All @@ -466,6 +469,7 @@ private void PostAnalyzeStateUpdate()
lastImportStack = importStack;
lastMacroName = macroName;
lastMacroLineDepth = macroLineDepth;
lastFilePosition = filePosition;
}

private void UpdateDisabledPositions(FilePosition filePosition)
Expand Down Expand Up @@ -687,7 +691,8 @@ private List<Warning> Analyzer_Final_Warning_0009()
{
return new List<Warning>
{
new(WarningSeverity.Warning, 0009, filePosition, mnemonic, operands, lineText[(filePosition, lastMacroLineDepth)], lastMacroName)
new(WarningSeverity.Warning, 0009, lastFilePosition, lastMnemonic, lastOperands,
lineText[(lastFilePosition, lastMacroLineDepth)], lastMacroName)
};
}
return new List<Warning>();
Expand Down
2 changes: 2 additions & 0 deletions Test/KitchenSink.asm
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,9 @@ InsertNoZeroPadding(0b1101101101001000101100111010111011011)
%ANALYZER suggestion, 0003, r
%ANALYZER suggestion, 0004, r

%ANALYZER warning, 0014, 0
HLT
%ANALYZER warning, 0014, r

:DISPLACEMENT_LABEL_1
%LABEL_OVERRIDE 1
Expand Down

0 comments on commit cfa65fd

Please sign in to comment.