mirror of
https://gitlab.com/camelot/kickc.git
synced 2024-11-20 02:32:36 +00:00
Added indexes to ASM lines in AsmProgram
This commit is contained in:
parent
47e8b6b2b9
commit
5d21c6aa97
@ -2,8 +2,11 @@ package dk.camelot64.kickc.asm;
|
|||||||
|
|
||||||
/** An assember comment */
|
/** An assember comment */
|
||||||
public class AsmComment implements AsmLine {
|
public class AsmComment implements AsmLine {
|
||||||
|
|
||||||
private String comment;
|
private String comment;
|
||||||
|
|
||||||
|
private int index;
|
||||||
|
|
||||||
public AsmComment(String comment) {
|
public AsmComment(String comment) {
|
||||||
this.comment = comment;
|
this.comment = comment;
|
||||||
}
|
}
|
||||||
@ -22,21 +25,21 @@ public class AsmComment implements AsmLine {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getInvocationCountEstimate() {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public double getEstimatedTotalCycles() {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getAsm() {
|
public String getAsm() {
|
||||||
return "// "+comment;
|
return "// "+comment;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getIndex() {
|
||||||
|
return index;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setIndex(int index) {
|
||||||
|
this.index = index;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return getAsm();
|
return getAsm();
|
||||||
|
@ -415,7 +415,7 @@ public class AsmFragment {
|
|||||||
AsmInstruction instruction;
|
AsmInstruction instruction;
|
||||||
if (paramModeCtx == null) {
|
if (paramModeCtx == null) {
|
||||||
AsmInstructionType type = AsmInstuctionSet.getInstructionType(ctx.MNEMONIC().getText(), AsmAddressingMode.NON, null);
|
AsmInstructionType type = AsmInstuctionSet.getInstructionType(ctx.MNEMONIC().getText(), AsmAddressingMode.NON, null);
|
||||||
instruction = new AsmInstruction(type, null, 1);
|
instruction = new AsmInstruction(type, null);
|
||||||
} else {
|
} else {
|
||||||
instruction = (AsmInstruction) this.visit(paramModeCtx);
|
instruction = (AsmInstruction) this.visit(paramModeCtx);
|
||||||
}
|
}
|
||||||
@ -467,7 +467,7 @@ public class AsmFragment {
|
|||||||
String mnemonic = instructionCtx.MNEMONIC().getSymbol().getText();
|
String mnemonic = instructionCtx.MNEMONIC().getSymbol().getText();
|
||||||
String parameter = (String) this.visit(exprCtx);
|
String parameter = (String) this.visit(exprCtx);
|
||||||
AsmInstructionType type = AsmInstuctionSet.getInstructionType(mnemonic, addressingMode, parameter);
|
AsmInstructionType type = AsmInstuctionSet.getInstructionType(mnemonic, addressingMode, parameter);
|
||||||
return new AsmInstruction(type, parameter, 1);
|
return new AsmInstruction(type, parameter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -7,12 +7,11 @@ public class AsmInstruction implements AsmLine {
|
|||||||
|
|
||||||
private String parameter;
|
private String parameter;
|
||||||
|
|
||||||
private int invocationCountEstimate;
|
private int index;
|
||||||
|
|
||||||
public AsmInstruction(AsmInstructionType type, String parameter, int invocationCountEstimate) {
|
public AsmInstruction(AsmInstructionType type, String parameter) {
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.parameter = parameter;
|
this.parameter = parameter;
|
||||||
this.invocationCountEstimate = invocationCountEstimate;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getParameter() {
|
public String getParameter() {
|
||||||
@ -33,16 +32,6 @@ public class AsmInstruction implements AsmLine {
|
|||||||
return type.getCycles();
|
return type.getCycles();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getInvocationCountEstimate() {
|
|
||||||
return invocationCountEstimate;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public double getEstimatedTotalCycles() {
|
|
||||||
return getInvocationCountEstimate()*getLineCycles();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getAsm() {
|
public String getAsm() {
|
||||||
return type.getAsm(parameter);
|
return type.getAsm(parameter);
|
||||||
@ -53,4 +42,13 @@ public class AsmInstruction implements AsmLine {
|
|||||||
return getAsm();
|
return getAsm();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getIndex() {
|
||||||
|
return index;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setIndex(int index) {
|
||||||
|
this.index = index;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,8 @@ public class AsmLabel implements AsmLine {
|
|||||||
|
|
||||||
private String label;
|
private String label;
|
||||||
|
|
||||||
|
private int index;
|
||||||
|
|
||||||
public AsmLabel(String label) {
|
public AsmLabel(String label) {
|
||||||
this.label = label;
|
this.label = label;
|
||||||
}
|
}
|
||||||
@ -23,21 +25,21 @@ public class AsmLabel implements AsmLine {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getInvocationCountEstimate() {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public double getEstimatedTotalCycles() {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getAsm() {
|
public String getAsm() {
|
||||||
return label+":";
|
return label+":";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getIndex() {
|
||||||
|
return index;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setIndex(int index) {
|
||||||
|
this.index = index;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return getAsm();
|
return getAsm();
|
||||||
|
@ -7,10 +7,9 @@ public interface AsmLine {
|
|||||||
|
|
||||||
public double getLineCycles();
|
public double getLineCycles();
|
||||||
|
|
||||||
public int getInvocationCountEstimate();
|
|
||||||
|
|
||||||
public double getEstimatedTotalCycles();
|
|
||||||
|
|
||||||
public String getAsm();
|
public String getAsm();
|
||||||
|
|
||||||
|
public int getIndex();
|
||||||
|
|
||||||
|
void setIndex(int index);
|
||||||
}
|
}
|
||||||
|
@ -10,8 +10,11 @@ public class AsmProgram {
|
|||||||
|
|
||||||
private List<AsmLine> lines;
|
private List<AsmLine> lines;
|
||||||
|
|
||||||
|
private int nextIndex;
|
||||||
|
|
||||||
public AsmProgram() {
|
public AsmProgram() {
|
||||||
this.lines = new ArrayList<>();
|
this.lines = new ArrayList<>();
|
||||||
|
this.nextIndex = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<AsmLine> getLines() {
|
public List<AsmLine> getLines() {
|
||||||
@ -19,6 +22,7 @@ public class AsmProgram {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void addLine(AsmLine line) {
|
public void addLine(AsmLine line) {
|
||||||
|
line.setIndex(nextIndex++);
|
||||||
lines.add(line);
|
lines.add(line);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -32,7 +36,7 @@ public class AsmProgram {
|
|||||||
|
|
||||||
public void addInstruction(String mnemonic, AsmAddressingMode addressingMode, String parameter) {
|
public void addInstruction(String mnemonic, AsmAddressingMode addressingMode, String parameter) {
|
||||||
AsmInstructionType instructionType = AsmInstuctionSet.getInstructionType(mnemonic, addressingMode, parameter);
|
AsmInstructionType instructionType = AsmInstuctionSet.getInstructionType(mnemonic, addressingMode, parameter);
|
||||||
addLine(new AsmInstruction(instructionType, parameter, 1));
|
addLine(new AsmInstruction(instructionType, parameter));
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toString(boolean comments) {
|
public String toString(boolean comments) {
|
||||||
|
Loading…
Reference in New Issue
Block a user