Skip to content

Commit

Permalink
warning when instructions are in .data
Browse files Browse the repository at this point in the history
  • Loading branch information
Shin-703 committed Aug 13, 2024
1 parent 9118ac0 commit fb54b76
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/rars/assembler/Assembler.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ public class Assembler {
// macro definition segment
private int externAddress;
private boolean autoAlign;
private boolean instructionInDataWarningGiven;
private Directives dataDirective;
private RISCVprogram fileCurrentlyBeingAssembled;
private TokenList globalDeclarationList;
Expand Down Expand Up @@ -206,6 +207,13 @@ public void assemble(ArrayList<RISCVprogram> tokenizedProgramFiles, boolean exte
if (errors.errorsOccurred()) {
throw new AssemblyException(errors);
}
// add warning if instructions were written in .data
if (Memory.inDataSegment(statement.getAddress()) && !instructionInDataWarningGiven) {
errors.add(new ErrorMessage(true, statement.getSourceProgram(), statement.getSourceLine(),
statement.getStrippedTokenList().get(0).getStartPos(),
"Instructions in .data !"));
instructionInDataWarningGiven = true;
}
if (statement.getInstruction() instanceof BasicInstruction) {
//if statement is in .text, add to machineList
if (Memory.inTextSegment(statement.getAddress()))
Expand Down

0 comments on commit fb54b76

Please sign in to comment.