1
0
mirror of https://gitlab.com/camelot/kickc.git synced 2024-12-28 01:29:44 +00:00

Moved clobber info to a constructor parameter. Added clobber info for SP, PC, d, i.

This commit is contained in:
jespergravgaard 2020-07-26 22:51:34 +02:00
parent 1fb532718f
commit dcb68b8c1a
15 changed files with 320 additions and 377 deletions

View File

@ -5,7 +5,7 @@ import java.io.Serializable;
/** Information about what registers/flags of the CPU an ASM instruction clobbers */ /** Information about what registers/flags of the CPU an ASM instruction clobbers */
public class AsmClobber implements Serializable { public class AsmClobber implements Serializable {
public static final AsmClobber CLOBBER_ALL = new AsmClobber(true, true, true, true, true, true, true); public static final AsmClobber CLOBBER_ALL = new AsmClobber(true, true, true, true, true, true, true, true, true, true, true);
final boolean registerA; final boolean registerA;
final boolean registerX; final boolean registerX;
@ -14,8 +14,14 @@ public class AsmClobber implements Serializable {
final boolean flagN; final boolean flagN;
final boolean flagZ; final boolean flagZ;
final boolean flagV; final boolean flagV;
final boolean flagI;
final boolean flagD;
/** true if the program counter is modified (not just incremented to the next instruction). */
final boolean registerPC;
/** true if the stack pointer is modified.*/
final boolean registerSP;
public AsmClobber(boolean registerA, boolean registerX, boolean registerY, boolean flagC, boolean flagN, boolean flagZ, boolean flagV) { public AsmClobber(boolean registerA, boolean registerX, boolean registerY, boolean flagC, boolean flagN, boolean flagZ, boolean flagV, boolean flagI, boolean flagD, boolean registerPC, boolean registerSP) {
this.registerA = registerA; this.registerA = registerA;
this.registerX = registerX; this.registerX = registerX;
this.registerY = registerY; this.registerY = registerY;
@ -23,10 +29,14 @@ public class AsmClobber implements Serializable {
this.flagN = flagN; this.flagN = flagN;
this.flagZ = flagZ; this.flagZ = flagZ;
this.flagV = flagV; this.flagV = flagV;
this.flagI = flagI;
this.flagD = flagD;
this.registerPC = registerPC;
this.registerSP = registerSP;
} }
public AsmClobber() { public AsmClobber() {
this(false, false, false, false, false, false, false); this(false, false, false, false, false, false, false, false, false, false, false);
} }
/** /**
@ -44,7 +54,11 @@ public class AsmClobber implements Serializable {
clobberString.contains("c"), clobberString.contains("c"),
clobberString.contains("n"), clobberString.contains("n"),
clobberString.contains("z"), clobberString.contains("z"),
clobberString.contains("v") clobberString.contains("v"),
clobberString.contains("i"),
clobberString.contains("d"),
clobberString.contains("P"),
clobberString.contains("S")
); );
} }
@ -62,7 +76,11 @@ public class AsmClobber implements Serializable {
clobber1.flagC | clobber2.flagC, clobber1.flagC | clobber2.flagC,
clobber1.flagN | clobber2.flagN, clobber1.flagN | clobber2.flagN,
clobber1.flagZ | clobber2.flagZ, clobber1.flagZ | clobber2.flagZ,
clobber1.flagV | clobber2.flagV clobber1.flagV | clobber2.flagV,
clobber1.flagI | clobber2.flagI,
clobber1.flagD | clobber2.flagD,
clobber1.registerPC | clobber2.registerPC,
clobber1.registerSP | clobber2.registerSP
); );
} }
@ -95,35 +113,22 @@ public class AsmClobber implements Serializable {
return flagV; return flagV;
} }
public AsmClobber addRegisterA() { public boolean isFlagI() {
return new AsmClobber(true, this.registerX, this.registerY, this.flagC, this.flagN, this.flagZ, this.flagV); return flagI;
} }
public AsmClobber addRegisterX() { public boolean isFlagD() {
return new AsmClobber(this.registerA, true, this.registerY, this.flagC, this.flagN, this.flagZ, this.flagV); return flagD;
} }
public AsmClobber addRegisterY() { public boolean isRegisterPC() {
return new AsmClobber(this.registerA, this.registerX, true, this.flagC, this.flagN, this.flagZ, this.flagV); return registerPC;
} }
public AsmClobber addFlagC() { public boolean isRegisterSP() {
return new AsmClobber(this.registerA, this.registerX, this.registerY, true, this.flagN, this.flagZ, this.flagV); return registerSP;
} }
public AsmClobber addFlagN() {
return new AsmClobber(this.registerA, this.registerX, this.registerY, this.flagC, true, this.flagZ, this.flagV);
}
public AsmClobber addFlagZ() {
return new AsmClobber(this.registerA, this.registerX, this.registerY, this.flagC, this.flagN, true, this.flagV);
}
public AsmClobber addFlagV() {
return new AsmClobber(this.registerA, this.registerX, this.registerY, this.flagC, this.flagN, this.flagZ, true);
}
@Override @Override
public String toString() { public String toString() {
return return
@ -133,7 +138,11 @@ public class AsmClobber implements Serializable {
(flagC ? "c" : "") + (flagC ? "c" : "") +
(flagN ? "n" : "") + (flagN ? "n" : "") +
(flagZ ? "z" : "") + (flagZ ? "z" : "") +
(flagV ? "v" : ""); (flagV ? "v" : "") +
(flagI ? "i" : "") +
(flagD ? "d" : "") +
(registerPC ? "P" : "") +
(registerSP ? "S" : "") ;
} }

View File

@ -18,342 +18,288 @@ public class AsmInstructionSet {
public AsmInstructionSet() { public AsmInstructionSet() {
this.instructions = new ArrayList<>(); this.instructions = new ArrayList<>();
this.instructionsMap = new HashMap<>(); this.instructionsMap = new HashMap<>();
add(0x00, "brk", AsmAddressingMode.NON, 7.0); add(0x00, "brk", AsmAddressingMode.NON, 7.0, "");
add(0x01, "ora", AsmAddressingMode.IZX, 6.0); add(0x01, "ora", AsmAddressingMode.IZX, 6.0, "Azn");
add(0x01, "ora", AsmAddressingMode.IZX, 6.0); add(0x01, "ora", AsmAddressingMode.IZX, 6.0, "Azn");
add(0x02, "kil", AsmAddressingMode.NON, 0.0); add(0x02, "kil", AsmAddressingMode.NON, 0.0, "");
add(0x03, "slo", AsmAddressingMode.IZX, 8.0); add(0x03, "slo", AsmAddressingMode.IZX, 8.0, "Aczn");
add(0x04, "nop", AsmAddressingMode.ZP, 3.0); add(0x04, "nop", AsmAddressingMode.ZP, 3.0, "");
add(0x05, "ora", AsmAddressingMode.ZP, 3.0); add(0x05, "ora", AsmAddressingMode.ZP, 3.0, "Azn");
add(0x06, "asl", AsmAddressingMode.ZP, 5.0); add(0x06, "asl", AsmAddressingMode.ZP, 5.0, "czn");
add(0x07, "slo", AsmAddressingMode.ZP, 5.0); add(0x07, "slo", AsmAddressingMode.ZP, 5.0, "Aczn");
add(0x08, "php", AsmAddressingMode.NON, 3.0); add(0x08, "php", AsmAddressingMode.NON, 3.0, "S");
add(0x09, "ora", AsmAddressingMode.IMM, 2.0); add(0x09, "ora", AsmAddressingMode.IMM, 2.0, "Azn");
add(0x0a, "asl", AsmAddressingMode.NON, 2.0); add(0x0a, "asl", AsmAddressingMode.NON, 2.0, "Aczn");
add(0x0b, "anc", AsmAddressingMode.IMM, 2.0); add(0x0b, "anc", AsmAddressingMode.IMM, 2.0, "Aczn");
add(0x0c, "nop", AsmAddressingMode.ABS, 4.0); add(0x0c, "nop", AsmAddressingMode.ABS, 4.0, "");
add(0x0d, "ora", AsmAddressingMode.ABS, 4.0); add(0x0d, "ora", AsmAddressingMode.ABS, 4.0, "Azn");
add(0x0e, "asl", AsmAddressingMode.ABS, 6.0); add(0x0e, "asl", AsmAddressingMode.ABS, 6.0, "czn");
add(0x0f, "slo", AsmAddressingMode.ABS, 6.0); add(0x0f, "slo", AsmAddressingMode.ABS, 6.0, "Aczn");
add(0x10, "bpl", AsmAddressingMode.REL, 2.5); add(0x10, "bpl", AsmAddressingMode.REL, 2.5, "P");
add(0x11, "ora", AsmAddressingMode.IZY, 5.5); add(0x11, "ora", AsmAddressingMode.IZY, 5.5, "Azn");
add(0x12, "kil", AsmAddressingMode.NON, 0.0); add(0x12, "kil", AsmAddressingMode.NON, 0.0, "");
add(0x13, "slo", AsmAddressingMode.IZY, 8.0); add(0x13, "slo", AsmAddressingMode.IZY, 8.0, "Aczn");
add(0x14, "nop", AsmAddressingMode.ZPX, 4.0); add(0x14, "nop", AsmAddressingMode.ZPX, 4.0, "");
add(0x15, "ora", AsmAddressingMode.ZPX, 4.0); add(0x15, "ora", AsmAddressingMode.ZPX, 4.0, "Azn");
add(0x16, "asl", AsmAddressingMode.ZPX, 6.0); add(0x16, "asl", AsmAddressingMode.ZPX, 6.0, "czn");
add(0x17, "slo", AsmAddressingMode.ZPX, 6.0); add(0x17, "slo", AsmAddressingMode.ZPX, 6.0, "Aczn");
add(0x18, "clc", AsmAddressingMode.NON, 2.0); add(0x18, "clc", AsmAddressingMode.NON, 2.0, "c");
add(0x19, "ora", AsmAddressingMode.ABY, 4.5); add(0x19, "ora", AsmAddressingMode.ABY, 4.5, "Azn");
add(0x1a, "nop", AsmAddressingMode.NON, 2.0); add(0x1a, "nop", AsmAddressingMode.NON, 2.0, "");
add(0x1b, "slo", AsmAddressingMode.ABY, 7.0); add(0x1b, "slo", AsmAddressingMode.ABY, 7.0, "Aczn");
add(0x1c, "nop", AsmAddressingMode.ABX, 4.5); add(0x1c, "nop", AsmAddressingMode.ABX, 4.5, "");
add(0x1d, "ora", AsmAddressingMode.ABX, 4.5); add(0x1d, "ora", AsmAddressingMode.ABX, 4.5, "Azn");
add(0x1e, "asl", AsmAddressingMode.ABX, 7.0); add(0x1e, "asl", AsmAddressingMode.ABX, 7.0, "czn");
add(0x1f, "slo", AsmAddressingMode.ABX, 7.0); add(0x1f, "slo", AsmAddressingMode.ABX, 7.0, "Aczn");
add(0x20, "jsr", AsmAddressingMode.ABS, 6.0); add(0x20, "jsr", AsmAddressingMode.ABS, 6.0, "PS");
add(0x21, "and", AsmAddressingMode.IZX, 6.0); add(0x21, "and", AsmAddressingMode.IZX, 6.0, "Azn");
add(0x22, "kil", AsmAddressingMode.NON, 0.0); add(0x22, "kil", AsmAddressingMode.NON, 0.0, "");
add(0x23, "rla", AsmAddressingMode.IZX, 8.0); add(0x23, "rla", AsmAddressingMode.IZX, 8.0, "Aczn");
add(0x24, "bit", AsmAddressingMode.ZP, 3.0); add(0x24, "bit", AsmAddressingMode.ZP, 3.0, "vzn");
add(0x25, "and", AsmAddressingMode.ZP, 3.0); add(0x25, "and", AsmAddressingMode.ZP, 3.0, "Azn");
add(0x26, "rol", AsmAddressingMode.ZP, 5.0); add(0x26, "rol", AsmAddressingMode.ZP, 5.0, "czn");
add(0x27, "rla", AsmAddressingMode.ZP, 5.0); add(0x27, "rla", AsmAddressingMode.ZP, 5.0, "Aczn");
add(0x28, "plp", AsmAddressingMode.NON, 4.0); add(0x28, "plp", AsmAddressingMode.NON, 4.0, "cvznS");
add(0x29, "and", AsmAddressingMode.IMM, 2.0); add(0x29, "and", AsmAddressingMode.IMM, 2.0, "Azn");
add(0x2a, "rol", AsmAddressingMode.NON, 2.0); add(0x2a, "rol", AsmAddressingMode.NON, 2.0, "Aczn");
add(0x2b, "anc", AsmAddressingMode.IMM, 2.0); add(0x2b, "anc", AsmAddressingMode.IMM, 2.0, "Aczn");
add(0x2c, "bit", AsmAddressingMode.ABS, 4.0); add(0x2c, "bit", AsmAddressingMode.ABS, 4.0, "vzn");
add(0x2d, "and", AsmAddressingMode.ABS, 4.0); add(0x2d, "and", AsmAddressingMode.ABS, 4.0, "Azn");
add(0x2e, "rol", AsmAddressingMode.ABS, 6.0); add(0x2e, "rol", AsmAddressingMode.ABS, 6.0, "czn");
add(0x2f, "rla", AsmAddressingMode.ABS, 6.0); add(0x2f, "rla", AsmAddressingMode.ABS, 6.0, "Aczn");
add(0x30, "bmi", AsmAddressingMode.REL, 2.5); add(0x30, "bmi", AsmAddressingMode.REL, 2.5, "P");
add(0x31, "and", AsmAddressingMode.IZY, 5.5); add(0x31, "and", AsmAddressingMode.IZY, 5.5, "Azn");
add(0x32, "kil", AsmAddressingMode.NON, 0.0); add(0x32, "kil", AsmAddressingMode.NON, 0.0, "");
add(0x33, "rla", AsmAddressingMode.IZY, 8.0); add(0x33, "rla", AsmAddressingMode.IZY, 8.0, "Aczn");
add(0x34, "nop", AsmAddressingMode.ZPX, 4.0); add(0x34, "nop", AsmAddressingMode.ZPX, 4.0, "");
add(0x35, "and", AsmAddressingMode.ZPX, 4.0); add(0x35, "and", AsmAddressingMode.ZPX, 4.0, "Azn");
add(0x36, "rol", AsmAddressingMode.ZPX, 6.0); add(0x36, "rol", AsmAddressingMode.ZPX, 6.0, "czn");
add(0x37, "rla", AsmAddressingMode.ZPX, 6.0); add(0x37, "rla", AsmAddressingMode.ZPX, 6.0, "Aczn");
add(0x38, "sec", AsmAddressingMode.NON, 2.0); add(0x38, "sec", AsmAddressingMode.NON, 2.0, "c");
add(0x39, "and", AsmAddressingMode.ABY, 4.5); add(0x39, "and", AsmAddressingMode.ABY, 4.5, "Azn");
add(0x3a, "nop", AsmAddressingMode.NON, 2.0); add(0x3a, "nop", AsmAddressingMode.NON, 2.0, "");
add(0x3b, "rla", AsmAddressingMode.ABY, 7.0); add(0x3b, "rla", AsmAddressingMode.ABY, 7.0, "Aczn");
add(0x3c, "nop", AsmAddressingMode.ABX, 4.5); add(0x3c, "nop", AsmAddressingMode.ABX, 4.5, "");
add(0x3d, "and", AsmAddressingMode.ABX, 4.5); add(0x3d, "and", AsmAddressingMode.ABX, 4.5, "Azn");
add(0x3e, "rol", AsmAddressingMode.ABX, 7.0); add(0x3e, "rol", AsmAddressingMode.ABX, 7.0, "czn");
add(0x3f, "rla", AsmAddressingMode.ABX, 7.0); add(0x3f, "rla", AsmAddressingMode.ABX, 7.0, "Aczn");
add(0x40, "rti", AsmAddressingMode.NON, 6.0); add(0x40, "rti", AsmAddressingMode.NON, 6.0, "cvznPS");
add(0x41, "eor", AsmAddressingMode.IZX, 6.0); add(0x41, "eor", AsmAddressingMode.IZX, 6.0, "Azn");
add(0x42, "kil", AsmAddressingMode.NON, 0.0); add(0x42, "kil", AsmAddressingMode.NON, 0.0, "");
add(0x43, "sre", AsmAddressingMode.IZX, 8.0); add(0x43, "sre", AsmAddressingMode.IZX, 8.0, "Aczn");
add(0x44, "nop", AsmAddressingMode.ZP, 3.0); add(0x44, "nop", AsmAddressingMode.ZP, 3.0, "");
add(0x45, "eor", AsmAddressingMode.ZP, 3.0); add(0x45, "eor", AsmAddressingMode.ZP, 3.0, "Azn");
add(0x46, "lsr", AsmAddressingMode.ZP, 5.0); add(0x46, "lsr", AsmAddressingMode.ZP, 5.0, "czn");
add(0x47, "sre", AsmAddressingMode.ZP, 5.0); add(0x47, "sre", AsmAddressingMode.ZP, 5.0, "Aczn");
add(0x48, "pha", AsmAddressingMode.NON, 3.0); add(0x48, "pha", AsmAddressingMode.NON, 3.0, "S");
add(0x49, "eor", AsmAddressingMode.IMM, 2.0); add(0x49, "eor", AsmAddressingMode.IMM, 2.0, "Azn");
add(0x4a, "lsr", AsmAddressingMode.NON, 2.0); add(0x4a, "lsr", AsmAddressingMode.NON, 2.0, "Aczn");
add(0x4b, "alr", AsmAddressingMode.IMM, 2.0); add(0x4b, "alr", AsmAddressingMode.IMM, 2.0, "Aczn");
add(0x4c, "jmp", AsmAddressingMode.ABS, 3.0); add(0x4c, "jmp", AsmAddressingMode.ABS, 3.0, "P");
add(0x4d, "eor", AsmAddressingMode.ABS, 4.0); add(0x4d, "eor", AsmAddressingMode.ABS, 4.0, "Azn");
add(0x4e, "lsr", AsmAddressingMode.ABS, 6.0); add(0x4e, "lsr", AsmAddressingMode.ABS, 6.0, "czn");
add(0x4f, "sre", AsmAddressingMode.ABS, 6.0); add(0x4f, "sre", AsmAddressingMode.ABS, 6.0, "Aczn");
add(0x50, "bvc", AsmAddressingMode.REL, 2.5); add(0x50, "bvc", AsmAddressingMode.REL, 2.5, "P");
add(0x51, "eor", AsmAddressingMode.IZY, 5.5); add(0x51, "eor", AsmAddressingMode.IZY, 5.5, "Azn");
add(0x52, "kil", AsmAddressingMode.NON, 0.0); add(0x52, "kil", AsmAddressingMode.NON, 0.0, "");
add(0x53, "sre", AsmAddressingMode.IZY, 8.0); add(0x53, "sre", AsmAddressingMode.IZY, 8.0, "Aczn");
add(0x54, "nop", AsmAddressingMode.ZPX, 4.0); add(0x54, "nop", AsmAddressingMode.ZPX, 4.0, "");
add(0x55, "eor", AsmAddressingMode.ZPX, 4.0); add(0x55, "eor", AsmAddressingMode.ZPX, 4.0, "Azn");
add(0x56, "lsr", AsmAddressingMode.ZPX, 6.0); add(0x56, "lsr", AsmAddressingMode.ZPX, 6.0, "czn");
add(0x57, "sre", AsmAddressingMode.ZPX, 6.0); add(0x57, "sre", AsmAddressingMode.ZPX, 6.0, "Aczn");
add(0x58, "cli", AsmAddressingMode.NON, 2.0); add(0x58, "cli", AsmAddressingMode.NON, 2.0, "i");
add(0x59, "eor", AsmAddressingMode.ABY, 4.5); add(0x59, "eor", AsmAddressingMode.ABY, 4.5, "Azn");
add(0x5a, "nop", AsmAddressingMode.NON, 2.0); add(0x5a, "nop", AsmAddressingMode.NON, 2.0, "");
add(0x5b, "sre", AsmAddressingMode.ABY, 7.0); add(0x5b, "sre", AsmAddressingMode.ABY, 7.0, "Aczn");
add(0x5c, "nop", AsmAddressingMode.ABX, 4.5); add(0x5c, "nop", AsmAddressingMode.ABX, 4.5, "");
add(0x5d, "eor", AsmAddressingMode.ABX, 4.5); add(0x5d, "eor", AsmAddressingMode.ABX, 4.5, "Azn");
add(0x5e, "lsr", AsmAddressingMode.ABX, 7.0); add(0x5e, "lsr", AsmAddressingMode.ABX, 7.0, "czn");
add(0x5f, "sre", AsmAddressingMode.ABX, 7.0); add(0x5f, "sre", AsmAddressingMode.ABX, 7.0, "Aczn");
add(0x60, "rts", AsmAddressingMode.NON, 6.0); add(0x60, "rts", AsmAddressingMode.NON, 6.0, "PS");
add(0x61, "adc", AsmAddressingMode.IZX, 6.0); add(0x61, "adc", AsmAddressingMode.IZX, 6.0, "Acvzn");
add(0x62, "kil", AsmAddressingMode.NON, 0.0); add(0x62, "kil", AsmAddressingMode.NON, 0.0, "");
add(0x63, "rra", AsmAddressingMode.IZX, 8.0); add(0x63, "rra", AsmAddressingMode.IZX, 8.0, "Acvzn");
add(0x64, "nop", AsmAddressingMode.ZP, 3.0); add(0x64, "nop", AsmAddressingMode.ZP, 3.0, "");
add(0x65, "adc", AsmAddressingMode.ZP, 3.0); add(0x65, "adc", AsmAddressingMode.ZP, 3.0, "Acvzn");
add(0x66, "ror", AsmAddressingMode.ZP, 5.0); add(0x66, "ror", AsmAddressingMode.ZP, 5.0, "czn");
add(0x67, "rra", AsmAddressingMode.ZP, 5.0); add(0x67, "rra", AsmAddressingMode.ZP, 5.0, "Acvzn");
add(0x68, "pla", AsmAddressingMode.NON, 4.0); add(0x68, "pla", AsmAddressingMode.NON, 4.0, "AznS");
add(0x69, "adc", AsmAddressingMode.IMM, 2.0); add(0x69, "adc", AsmAddressingMode.IMM, 2.0, "Acvzn");
add(0x6a, "ror", AsmAddressingMode.NON, 2.0); add(0x6a, "ror", AsmAddressingMode.NON, 2.0, "Aczn");
add(0x6b, "arr", AsmAddressingMode.IMM, 2.0); add(0x6b, "arr", AsmAddressingMode.IMM, 2.0, "Acvzn");
add(0x6c, "jmp", AsmAddressingMode.IND, 5.0); add(0x6c, "jmp", AsmAddressingMode.IND, 5.0, "P");
add(0x6d, "adc", AsmAddressingMode.ABS, 4.0); add(0x6d, "adc", AsmAddressingMode.ABS, 4.0, "Acvzn");
add(0x6e, "ror", AsmAddressingMode.ABS, 6.0); add(0x6e, "ror", AsmAddressingMode.ABS, 6.0, "czn");
add(0x6f, "rra", AsmAddressingMode.ABS, 6.0); add(0x6f, "rra", AsmAddressingMode.ABS, 6.0, "Acvzn");
add(0x70, "bvs", AsmAddressingMode.REL, 2.5); add(0x70, "bvs", AsmAddressingMode.REL, 2.5, "P");
add(0x71, "adc", AsmAddressingMode.IZY, 5.5); add(0x71, "adc", AsmAddressingMode.IZY, 5.5, "Acvzn");
add(0x72, "kil", AsmAddressingMode.NON, 0.0); add(0x72, "kil", AsmAddressingMode.NON, 0.0, "");
add(0x73, "rra", AsmAddressingMode.IZY, 8.0); add(0x73, "rra", AsmAddressingMode.IZY, 8.0, "Acvzn");
add(0x74, "nop", AsmAddressingMode.ZPX, 4.0); add(0x74, "nop", AsmAddressingMode.ZPX, 4.0, "");
add(0x75, "adc", AsmAddressingMode.ZPX, 4.0); add(0x75, "adc", AsmAddressingMode.ZPX, 4.0, "Acvzn");
add(0x76, "ror", AsmAddressingMode.ZPX, 6.0); add(0x76, "ror", AsmAddressingMode.ZPX, 6.0, "czn");
add(0x77, "rra", AsmAddressingMode.ZPX, 6.0); add(0x77, "rra", AsmAddressingMode.ZPX, 6.0, "Acvzn");
add(0x78, "sei", AsmAddressingMode.NON, 2.0); add(0x78, "sei", AsmAddressingMode.NON, 2.0, "i");
add(0x79, "adc", AsmAddressingMode.ABY, 4.5); add(0x79, "adc", AsmAddressingMode.ABY, 4.5, "Acvzn");
add(0x7a, "nop", AsmAddressingMode.NON, 2.0); add(0x7a, "nop", AsmAddressingMode.NON, 2.0, "");
add(0x7b, "rra", AsmAddressingMode.ABY, 7.0); add(0x7b, "rra", AsmAddressingMode.ABY, 7.0, "Acvzn");
add(0x7c, "nop", AsmAddressingMode.ABX, 4.5); add(0x7c, "nop", AsmAddressingMode.ABX, 4.5, "");
add(0x7d, "adc", AsmAddressingMode.ABX, 4.5); add(0x7d, "adc", AsmAddressingMode.ABX, 4.5, "Acvzn");
add(0x7e, "ror", AsmAddressingMode.ABX, 7.0); add(0x7e, "ror", AsmAddressingMode.ABX, 7.0, "czn");
add(0x7f, "rra", AsmAddressingMode.ABX, 7.0); add(0x7f, "rra", AsmAddressingMode.ABX, 7.0, "Acvzn");
add(0x80, "nop", AsmAddressingMode.IMM, 2.0); add(0x80, "nop", AsmAddressingMode.IMM, 2.0, "");
add(0x81, "sta", AsmAddressingMode.IZX, 6.0); add(0x81, "sta", AsmAddressingMode.IZX, 6.0, "");
add(0x82, "nop", AsmAddressingMode.IMM, 2.0); add(0x82, "nop", AsmAddressingMode.IMM, 2.0, "");
add(0x83, "sax", AsmAddressingMode.IZX, 6.0); add(0x83, "sax", AsmAddressingMode.IZX, 6.0, "");
add(0x84, "sty", AsmAddressingMode.ZP, 3.0); add(0x84, "sty", AsmAddressingMode.ZP, 3.0, "");
add(0x85, "sta", AsmAddressingMode.ZP, 3.0); add(0x85, "sta", AsmAddressingMode.ZP, 3.0, "");
add(0x86, "stx", AsmAddressingMode.ZP, 3.0); add(0x86, "stx", AsmAddressingMode.ZP, 3.0, "");
add(0x87, "sax", AsmAddressingMode.ZP, 3.0); add(0x87, "sax", AsmAddressingMode.ZP, 3.0, "");
add(0x88, "dey", AsmAddressingMode.NON, 2.0); add(0x88, "dey", AsmAddressingMode.NON, 2.0, "Yzn");
add(0x89, "nop", AsmAddressingMode.IMM, 2.0); add(0x89, "nop", AsmAddressingMode.IMM, 2.0, "");
add(0x8a, "txa", AsmAddressingMode.NON, 2.0); add(0x8a, "txa", AsmAddressingMode.NON, 2.0, "Azn");
add(0x8b, "xaa", AsmAddressingMode.IMM, 2.0); add(0x8b, "xaa", AsmAddressingMode.IMM, 2.0, "Azn");
add(0x8c, "sty", AsmAddressingMode.ABS, 4.0); add(0x8c, "sty", AsmAddressingMode.ABS, 4.0, "");
add(0x8d, "sta", AsmAddressingMode.ABS, 4.0); add(0x8d, "sta", AsmAddressingMode.ABS, 4.0, "");
add(0x8e, "stx", AsmAddressingMode.ABS, 4.0); add(0x8e, "stx", AsmAddressingMode.ABS, 4.0, "");
add(0x8f, "sax", AsmAddressingMode.ABS, 4.0); add(0x8f, "sax", AsmAddressingMode.ABS, 4.0, "");
add(0x90, "bcc", AsmAddressingMode.REL, 2.5); add(0x90, "bcc", AsmAddressingMode.REL, 2.5, "P");
add(0x91, "sta", AsmAddressingMode.IZY, 6.0); add(0x91, "sta", AsmAddressingMode.IZY, 6.0, "");
add(0x92, "kil", AsmAddressingMode.NON, 0.0); add(0x92, "kil", AsmAddressingMode.NON, 0.0, "");
add(0x93, "ahx", AsmAddressingMode.IZY, 6.0); add(0x93, "ahx", AsmAddressingMode.IZY, 6.0, "");
add(0x94, "sty", AsmAddressingMode.ZPX, 4.0); add(0x94, "sty", AsmAddressingMode.ZPX, 4.0, "");
add(0x95, "sta", AsmAddressingMode.ZPX, 4.0); add(0x95, "sta", AsmAddressingMode.ZPX, 4.0, "");
add(0x96, "stx", AsmAddressingMode.ZPY, 4.0); add(0x96, "stx", AsmAddressingMode.ZPY, 4.0, "");
add(0x97, "sax", AsmAddressingMode.ZPY, 4.0); add(0x97, "sax", AsmAddressingMode.ZPY, 4.0, "");
add(0x98, "tya", AsmAddressingMode.NON, 2.0); add(0x98, "tya", AsmAddressingMode.NON, 2.0, "Azn");
add(0x99, "sta", AsmAddressingMode.ABY, 5.0); add(0x99, "sta", AsmAddressingMode.ABY, 5.0, "");
add(0x9a, "txs", AsmAddressingMode.NON, 2.0); add(0x9a, "txs", AsmAddressingMode.NON, 2.0, "S");
add(0x9b, "tas", AsmAddressingMode.ABY, 5.0); add(0x9b, "tas", AsmAddressingMode.ABY, 5.0, "");
add(0x9c, "shy", AsmAddressingMode.ABX, 5.0); add(0x9c, "shy", AsmAddressingMode.ABX, 5.0, "");
add(0x9d, "sta", AsmAddressingMode.ABX, 5.0); add(0x9d, "sta", AsmAddressingMode.ABX, 5.0, "");
add(0x9e, "shx", AsmAddressingMode.ABY, 5.0); add(0x9e, "shx", AsmAddressingMode.ABY, 5.0, "");
add(0x9f, "ahx", AsmAddressingMode.ABY, 5.0); add(0x9f, "ahx", AsmAddressingMode.ABY, 5.0, "");
add(0xa0, "ldy", AsmAddressingMode.IMM, 2.0); add(0xa0, "ldy", AsmAddressingMode.IMM, 2.0, "Yzn");
add(0xa1, "lda", AsmAddressingMode.IZX, 6.0); add(0xa1, "lda", AsmAddressingMode.IZX, 6.0, "Azn");
add(0xa2, "ldx", AsmAddressingMode.IMM, 2.0); add(0xa2, "ldx", AsmAddressingMode.IMM, 2.0, "Xzn");
add(0xa3, "lax", AsmAddressingMode.IZX, 6.0); add(0xa3, "lax", AsmAddressingMode.IZX, 6.0, "AXzn");
add(0xa4, "ldy", AsmAddressingMode.ZP, 3.0); add(0xa4, "ldy", AsmAddressingMode.ZP, 3.0, "Yzn");
add(0xa5, "lda", AsmAddressingMode.ZP, 3.0); add(0xa5, "lda", AsmAddressingMode.ZP, 3.0, "Azn");
add(0xa6, "ldx", AsmAddressingMode.ZP, 3.0); add(0xa6, "ldx", AsmAddressingMode.ZP, 3.0, "Xzn");
add(0xa7, "lax", AsmAddressingMode.ZP, 3.0); add(0xa7, "lax", AsmAddressingMode.ZP, 3.0, "AXzn");
add(0xa8, "tay", AsmAddressingMode.NON, 2.0); add(0xa8, "tay", AsmAddressingMode.NON, 2.0, "Yzn");
add(0xa9, "lda", AsmAddressingMode.IMM, 2.0); add(0xa9, "lda", AsmAddressingMode.IMM, 2.0, "Azn");
add(0xaa, "tax", AsmAddressingMode.NON, 2.0); add(0xaa, "tax", AsmAddressingMode.NON, 2.0, "Xzn");
add(0xab, "lax", AsmAddressingMode.IMM, 2.0); add(0xab, "lax", AsmAddressingMode.IMM, 2.0, "AXzn");
add(0xac, "ldy", AsmAddressingMode.ABS, 4.0); add(0xac, "ldy", AsmAddressingMode.ABS, 4.0, "Yzn");
add(0xad, "lda", AsmAddressingMode.ABS, 4.0); add(0xad, "lda", AsmAddressingMode.ABS, 4.0, "Azn");
add(0xae, "ldx", AsmAddressingMode.ABS, 4.0); add(0xae, "ldx", AsmAddressingMode.ABS, 4.0, "Xzn");
add(0xaf, "lax", AsmAddressingMode.ABS, 4.0); add(0xaf, "lax", AsmAddressingMode.ABS, 4.0, "AXzn");
add(0xb0, "bcs", AsmAddressingMode.REL, 2.5); add(0xb0, "bcs", AsmAddressingMode.REL, 2.5, "P");
add(0xb1, "lda", AsmAddressingMode.IZY, 5.5); add(0xb1, "lda", AsmAddressingMode.IZY, 5.5, "Azn");
add(0xb2, "kil", AsmAddressingMode.NON, 0.0); add(0xb2, "kil", AsmAddressingMode.NON, 0.0, "");
add(0xb3, "lax", AsmAddressingMode.IZY, 5.5); add(0xb3, "lax", AsmAddressingMode.IZY, 5.5, "AXzn");
add(0xb4, "ldy", AsmAddressingMode.ZPX, 4.0); add(0xb4, "ldy", AsmAddressingMode.ZPX, 4.0, "Yzn");
add(0xb5, "lda", AsmAddressingMode.ZPX, 4.0); add(0xb5, "lda", AsmAddressingMode.ZPX, 4.0, "Azn");
add(0xb6, "ldx", AsmAddressingMode.ZPY, 4.0); add(0xb6, "ldx", AsmAddressingMode.ZPY, 4.0, "Xzn");
add(0xb7, "lax", AsmAddressingMode.ZPY, 4.0); add(0xb7, "lax", AsmAddressingMode.ZPY, 4.0, "AXzn");
add(0xb8, "clv", AsmAddressingMode.NON, 2.0); add(0xb8, "clv", AsmAddressingMode.NON, 2.0, "v");
add(0xb9, "lda", AsmAddressingMode.ABY, 4.5); add(0xb9, "lda", AsmAddressingMode.ABY, 4.5, "Azn");
add(0xba, "tsx", AsmAddressingMode.NON, 2.0); add(0xba, "tsx", AsmAddressingMode.NON, 2.0, "Xzn");
add(0xbb, "las", AsmAddressingMode.ABY, 4.5); add(0xbb, "las", AsmAddressingMode.ABY, 4.5, "AXzn");
add(0xbc, "ldy", AsmAddressingMode.ABX, 4.5); add(0xbc, "ldy", AsmAddressingMode.ABX, 4.5, "Yzn");
add(0xbd, "lda", AsmAddressingMode.ABX, 4.5); add(0xbd, "lda", AsmAddressingMode.ABX, 4.5, "Azn");
add(0xbe, "ldx", AsmAddressingMode.ABY, 4.5); add(0xbe, "ldx", AsmAddressingMode.ABY, 4.5, "Xzn");
add(0xbf, "lax", AsmAddressingMode.ABY, 4.5); add(0xbf, "lax", AsmAddressingMode.ABY, 4.5, "AXzn");
add(0xc0, "cpy", AsmAddressingMode.IMM, 2.0); add(0xc0, "cpy", AsmAddressingMode.IMM, 2.0, "czn");
add(0xc1, "cmp", AsmAddressingMode.IZX, 6.0); add(0xc1, "cmp", AsmAddressingMode.IZX, 6.0, "czn");
add(0xc2, "nop", AsmAddressingMode.IMM, 2.0); add(0xc2, "nop", AsmAddressingMode.IMM, 2.0, "");
add(0xc3, "dcp", AsmAddressingMode.IZX, 8.0); add(0xc3, "dcp", AsmAddressingMode.IZX, 8.0, "czn");
add(0xc4, "cpy", AsmAddressingMode.ZP, 3.0); add(0xc4, "cpy", AsmAddressingMode.ZP, 3.0, "czn");
add(0xc5, "cmp", AsmAddressingMode.ZP, 3.0); add(0xc5, "cmp", AsmAddressingMode.ZP, 3.0, "czn");
add(0xc6, "dec", AsmAddressingMode.ZP, 5.0); add(0xc6, "dec", AsmAddressingMode.ZP, 5.0, "zn");
add(0xc7, "dcp", AsmAddressingMode.ZP, 5.0); add(0xc7, "dcp", AsmAddressingMode.ZP, 5.0, "czn");
add(0xc8, "iny", AsmAddressingMode.NON, 2.0); add(0xc8, "iny", AsmAddressingMode.NON, 2.0, "Yzn");
add(0xc9, "cmp", AsmAddressingMode.IMM, 2.0); add(0xc9, "cmp", AsmAddressingMode.IMM, 2.0, "czn");
add(0xca, "dex", AsmAddressingMode.NON, 2.0); add(0xca, "dex", AsmAddressingMode.NON, 2.0, "Xzn");
add(0xcb, "axs", AsmAddressingMode.IMM, 2.0); add(0xcb, "axs", AsmAddressingMode.IMM, 2.0, "Xczn");
add(0xcc, "cpy", AsmAddressingMode.ABS, 4.0); add(0xcc, "cpy", AsmAddressingMode.ABS, 4.0, "czn");
add(0xcd, "cmp", AsmAddressingMode.ABS, 4.0); add(0xcd, "cmp", AsmAddressingMode.ABS, 4.0, "czn");
add(0xce, "dec", AsmAddressingMode.ABS, 6.0); add(0xce, "dec", AsmAddressingMode.ABS, 6.0, "zn");
add(0xcf, "dcp", AsmAddressingMode.ABS, 6.0); add(0xcf, "dcp", AsmAddressingMode.ABS, 6.0, "czn");
add(0xd0, "bne", AsmAddressingMode.REL, 2.5); add(0xd0, "bne", AsmAddressingMode.REL, 2.5, "P");
add(0xd1, "cmp", AsmAddressingMode.IZY, 5.5); add(0xd1, "cmp", AsmAddressingMode.IZY, 5.5, "czn");
add(0xd2, "kil", AsmAddressingMode.NON, 0.0); add(0xd2, "kil", AsmAddressingMode.NON, 0.0, "");
add(0xd3, "dcp", AsmAddressingMode.IZY, 8.0); add(0xd3, "dcp", AsmAddressingMode.IZY, 8.0, "czn");
add(0xd4, "nop", AsmAddressingMode.ZPX, 4.0); add(0xd4, "nop", AsmAddressingMode.ZPX, 4.0, "");
add(0xd5, "cmp", AsmAddressingMode.ZPX, 4.0); add(0xd5, "cmp", AsmAddressingMode.ZPX, 4.0, "czn");
add(0xd6, "dec", AsmAddressingMode.ZPX, 6.0); add(0xd6, "dec", AsmAddressingMode.ZPX, 6.0, "zn");
add(0xd7, "dcp", AsmAddressingMode.ZPX, 6.0); add(0xd7, "dcp", AsmAddressingMode.ZPX, 6.0, "czn");
add(0xd8, "cld", AsmAddressingMode.NON, 2.0); add(0xd8, "cld", AsmAddressingMode.NON, 2.0, "d");
add(0xd9, "cmp", AsmAddressingMode.ABY, 4.5); add(0xd9, "cmp", AsmAddressingMode.ABY, 4.5, "czn");
add(0xda, "nop", AsmAddressingMode.NON, 2.0); add(0xda, "nop", AsmAddressingMode.NON, 2.0, "");
add(0xdb, "dcp", AsmAddressingMode.ABY, 7.0); add(0xdb, "dcp", AsmAddressingMode.ABY, 7.0, "czn");
add(0xdc, "nop", AsmAddressingMode.ABX, 4.5); add(0xdc, "nop", AsmAddressingMode.ABX, 4.5, "");
add(0xdd, "cmp", AsmAddressingMode.ABX, 4.5); add(0xdd, "cmp", AsmAddressingMode.ABX, 4.5, "czn");
add(0xde, "dec", AsmAddressingMode.ABX, 7.0); add(0xde, "dec", AsmAddressingMode.ABX, 7.0, "zn");
add(0xef, "cpx", AsmAddressingMode.IMM, 2.0); add(0xef, "cpx", AsmAddressingMode.IMM, 2.0, "czn");
add(0xe0, "sbc", AsmAddressingMode.IZX, 6.0); add(0xe0, "sbc", AsmAddressingMode.IZX, 6.0, "Acvzn");
add(0xe1, "nop", AsmAddressingMode.IMM, 2.0); add(0xe1, "nop", AsmAddressingMode.IMM, 2.0, "");
add(0xe2, "isc", AsmAddressingMode.IZX, 8.0); add(0xe2, "isc", AsmAddressingMode.IZX, 8.0, "Acvzn");
add(0xe3, "cpx", AsmAddressingMode.ZP, 3.0); add(0xe3, "cpx", AsmAddressingMode.ZP, 3.0, "czn");
add(0xe4, "sbc", AsmAddressingMode.ZP, 3.0); add(0xe4, "sbc", AsmAddressingMode.ZP, 3.0, "Acvzn");
add(0xe5, "inc", AsmAddressingMode.ZP, 5.0); add(0xe5, "inc", AsmAddressingMode.ZP, 5.0, "zn");
add(0xe6, "isc", AsmAddressingMode.ZP, 5.0); add(0xe6, "isc", AsmAddressingMode.ZP, 5.0, "Acvzn");
add(0xe7, "inx", AsmAddressingMode.NON, 2.0); add(0xe7, "inx", AsmAddressingMode.NON, 2.0, "Xzn");
add(0xe8, "sbc", AsmAddressingMode.IMM, 2.0); add(0xe8, "sbc", AsmAddressingMode.IMM, 2.0, "Acvzn");
add(0xe9, "nop", AsmAddressingMode.NON, 2.0); add(0xe9, "nop", AsmAddressingMode.NON, 2.0, "");
add(0xea, "sbc", AsmAddressingMode.IMM, 2.0); add(0xea, "sbc", AsmAddressingMode.IMM, 2.0, "Acvzn");
add(0xeb, "cpx", AsmAddressingMode.ABS, 4.0); add(0xeb, "cpx", AsmAddressingMode.ABS, 4.0, "czn");
add(0xec, "sbc", AsmAddressingMode.ABS, 4.0); add(0xec, "sbc", AsmAddressingMode.ABS, 4.0, "Acvzn");
add(0xed, "inc", AsmAddressingMode.ABS, 6.0); add(0xed, "inc", AsmAddressingMode.ABS, 6.0, "zn");
add(0xee, "isc", AsmAddressingMode.ABS, 6.0); add(0xee, "isc", AsmAddressingMode.ABS, 6.0, "Acvzn");
add(0xef, "dcp", AsmAddressingMode.ABX, 7.0); add(0xef, "dcp", AsmAddressingMode.ABX, 7.0, "czn");
add(0xf0, "beq", AsmAddressingMode.REL, 2.5); add(0xf0, "beq", AsmAddressingMode.REL, 2.5, "P");
add(0xf1, "sbc", AsmAddressingMode.IZY, 5.5); add(0xf1, "sbc", AsmAddressingMode.IZY, 5.5, "Acvzn");
add(0xf2, "kil", AsmAddressingMode.NON, 0.0); add(0xf2, "kil", AsmAddressingMode.NON, 0.0, "");
add(0xf3, "isc", AsmAddressingMode.IZY, 8.0); add(0xf3, "isc", AsmAddressingMode.IZY, 8.0, "Acvzn");
add(0xf4, "nop", AsmAddressingMode.ZPX, 4.0); add(0xf4, "nop", AsmAddressingMode.ZPX, 4.0, "");
add(0xf5, "sbc", AsmAddressingMode.ZPX, 4.0); add(0xf5, "sbc", AsmAddressingMode.ZPX, 4.0, "Acvzn");
add(0xf6, "inc", AsmAddressingMode.ZPX, 6.0); add(0xf6, "inc", AsmAddressingMode.ZPX, 6.0, "zn");
add(0xf7, "isc", AsmAddressingMode.ZPX, 6.0); add(0xf7, "isc", AsmAddressingMode.ZPX, 6.0, "Acvzn");
add(0xf8, "sed", AsmAddressingMode.NON, 2.0); add(0xf8, "sed", AsmAddressingMode.NON, 2.0, "d");
add(0xf9, "sbc", AsmAddressingMode.ABY, 4.5); add(0xf9, "sbc", AsmAddressingMode.ABY, 4.5, "Acvzn");
add(0xfa, "nop", AsmAddressingMode.NON, 2.0); add(0xfa, "nop", AsmAddressingMode.NON, 2.0, "");
add(0xfb, "isc", AsmAddressingMode.ABY, 7.0); add(0xfb, "isc", AsmAddressingMode.ABY, 7.0, "Acvzn");
add(0xfc, "nop", AsmAddressingMode.ABX, 4.5); add(0xfc, "nop", AsmAddressingMode.ABX, 4.5, "");
add(0xfd, "sbc", AsmAddressingMode.ABX, 4.5); add(0xfd, "sbc", AsmAddressingMode.ABX, 4.5, "Acvzn");
add(0xfe, "inc", AsmAddressingMode.ABX, 7.0); add(0xfe, "inc", AsmAddressingMode.ABX, 7.0, "zn");
add(0xff, "isc", AsmAddressingMode.ABX, 7.0); add(0xff, "isc", AsmAddressingMode.ABX, 7.0, "Acvzn");
// 65c02 instructions // 65c02 instructions
// TODO: create instruction set model that knows the different CPU's // TODO: create instruction set model that knows the different CPU's
add(0x1a, "inc", AsmAddressingMode.NON, 2.0); add(0x1a, "inc", AsmAddressingMode.NON, 2.0, "Azn");
List<String> jumps = Arrays.asList("jmp", "beq", "bne", "bcc", "bcs", "bvs", "bvc", "bmi", "bpl", "jsr");
for(AsmOpcode instruction : instructions) {
if(jumps.contains(instruction.getMnemonic())) {
instruction.setJump(true);
}
}
List<String> cxs = Arrays.asList("dex", "inx", "ldx", "tax", "tsx", "las", "lax", "axs");
for(AsmOpcode instruction : instructions) {
if(cxs.contains(instruction.getMnemonic())) {
instruction.setClobber(instruction.getClobber().addRegisterX());
}
}
List<String> cys = Arrays.asList("dey", "iny", "ldy", "tay");
for(AsmOpcode instruction : instructions) {
if(cys.contains(instruction.getMnemonic())) {
instruction.setClobber(instruction.getClobber().addRegisterY());
}
}
List<String> cas = Arrays.asList("ora", "and", "eor", "adc", "sbc", "lda", "txa", "tya", "pla", "slo", "rla", "sre", "rra", "isc", "anc", "alr", "arr", "xaa", "lax", "las");
for(AsmOpcode instruction : instructions) {
if(cas.contains(instruction.getMnemonic())) {
instruction.setClobber(instruction.getClobber().addRegisterA());
} else if(instruction.hasOpcode(0x0a)) {
// Special handling of ASL A
instruction.setClobber(instruction.getClobber().addRegisterA());
} else if(instruction.hasOpcode(0x2a)) {
// Special handling of ROL A
instruction.setClobber(instruction.getClobber().addRegisterA());
} else if(instruction.hasOpcode(0x4a)) {
// Special handling of LSR A
instruction.setClobber(instruction.getClobber().addRegisterA());
} else if(instruction.hasOpcode(0x6a)) {
// Special handling of ROR A
instruction.setClobber(instruction.getClobber().addRegisterA());
}
}
List<String> ccs = Arrays.asList("adc", "sbc", "cmp", "cpx", "cpy", "asl", "rol", "lsr", "ror", "plp", "rti", "clc", "sec", "slo", "rla", "sre", "rra", "dcp", "isc", "anc", "alr", "arr", "axs");
for(AsmOpcode instruction : instructions) {
if(ccs.contains(instruction.getMnemonic())) {
instruction.setClobber(instruction.getClobber().addFlagC());
}
}
List<String> cvs = Arrays.asList("adc", "sbc", "plp", "rti", "bit", "rra", "isc", "arr");
for(AsmOpcode instruction : instructions) {
if(cvs.contains(instruction.getMnemonic())) {
instruction.setClobber(instruction.getClobber().addFlagV());
}
}
List<String> czs = Arrays.asList("ora", "and", "eor", "adc", "sbc", "cmp", "cpx", "cpy", "dec", "dex", "dey", "inc", "inx", "iny", "asl", "rol", "lsr", "ror", "lda", "ldx", "ldy", "tax", "txa", "tay", "tya", "tsx", "txs", "pla", "plp", "rti", "bit", "slo", "rla", "sre", "rra", "lax", "dcp", "isc", "anc", "alr", "arr", "xaa", "lax", "axs", "las");
for(AsmOpcode instruction : instructions) {
if(czs.contains(instruction.getMnemonic())) {
instruction.setClobber(instruction.getClobber().addFlagZ());
instruction.setClobber(instruction.getClobber().addFlagN());
}
}
} }
/** /**
* Add an instruction to the instruction set. * Add an instruction to the instruction set.
*
* @param opcode The numeric opcode * @param opcode The numeric opcode
* @param mnemonic The lower case mnemonic * @param mnemonic The lower case mnemonic
* @param addressingMode The addressing mode * @param addressingMode The addressing mode
* @param cycles The number of cycles * @param cycles The number of cycles
*/ */
private void add(int opcode, String mnemonic, AsmAddressingMode addressingMode, double cycles) { private void add(int opcode, String mnemonic, AsmAddressingMode addressingMode, double cycles, String clobberString) {
AsmOpcode asmOpcode = new AsmOpcode(opcode, mnemonic, addressingMode, cycles); AsmOpcode asmOpcode = new AsmOpcode(opcode, mnemonic, addressingMode, cycles, clobberString);
instructions.add(asmOpcode); instructions.add(asmOpcode);
instructionsMap.put(mnemonic + "_" + addressingMode.getName(), asmOpcode); instructionsMap.put(mnemonic + "_" + addressingMode.getName(), asmOpcode);
} }
/** /**
* Get a specific instruction opcode form the instruction set * Get a specific instruction opcode form the instruction set
*
* @param mnemonic The mnemonic * @param mnemonic The mnemonic
* @param addressingMode The addressing mode * @param addressingMode The addressing mode
* @return The opcode, if is exists. Null if the instruction set does not have the opcode. * @return The opcode, if is exists. Null if the instruction set does not have the opcode.
@ -366,6 +312,7 @@ public class AsmInstructionSet {
/** /**
* Get an opcode from the instruction set in either absolute or zeropage form. * Get an opcode from the instruction set in either absolute or zeropage form.
* This will try to find a zeropage-based addressing mode if you indicate that you are interested in that. * This will try to find a zeropage-based addressing mode if you indicate that you are interested in that.
*
* @param mnemonic The mnemonic * @param mnemonic The mnemonic
* @param mode The addressing mode you want. * @param mode The addressing mode you want.
* @param isZp Indicates whether you are interested in a zeropage-based opcode. * @param isZp Indicates whether you are interested in a zeropage-based opcode.
@ -392,5 +339,4 @@ public class AsmInstructionSet {
} }
} }

View File

@ -6,8 +6,6 @@ public class AsmOpcode {
/** The mnemonic of the instruction. */ /** The mnemonic of the instruction. */
private final String mnemonic; private final String mnemonic;
// TODO: Handle mnemonic aliasing?
/** The addressing mode of the instruction. */ /** The addressing mode of the instruction. */
private final AsmAddressingMode addressingMode; private final AsmAddressingMode addressingMode;
@ -25,22 +23,15 @@ public class AsmOpcode {
*/ */
private final double cycles; private final double cycles;
/**
* True if the instruction is a jump or a branch.
* A jump is any instruction that can modify the program counter in a way that is not just incrementing it to the
* next instruction in memory. This includes JSR and RTS.
*/
private boolean jump;
/** Which registers/flags of the CPU are clobbered by the instruction. */ /** Which registers/flags of the CPU are clobbered by the instruction. */
private AsmClobber clobber; private AsmClobber clobber;
AsmOpcode(int opcode, String mnemonic, AsmAddressingMode addressingMode, double cycles) { AsmOpcode(int opcode, String mnemonic, AsmAddressingMode addressingMode, double cycles, String clobberString) {
this.opcode = new int[]{opcode}; this.opcode = new int[]{opcode};
this.mnemonic = mnemonic; this.mnemonic = mnemonic;
this.addressingMode = addressingMode; this.addressingMode = addressingMode;
this.cycles = cycles; this.cycles = cycles;
this.clobber = new AsmClobber(); this.clobber = new AsmClobber(clobberString);
} }
/** /**
@ -129,17 +120,7 @@ public class AsmOpcode {
* @return true if the instruction is a jump/branch * @return true if the instruction is a jump/branch
*/ */
public boolean isJump() { public boolean isJump() {
return jump; return clobber.isRegisterPC();
}
/**
* Modify the jump property.
* TODO: Remove this setter and initialize using the constructor instead.
*
* @param jump New jump value
*/
void setJump(boolean jump) {
this.jump = jump;
} }
/** /**

View File

@ -1,8 +1,10 @@
package dk.camelot64.kickc.asm; package dk.camelot64.kickc.asm;
import dk.camelot64.cpufamily6502.AsmAddressingMode;
import dk.camelot64.cpufamily6502.AsmOpcode; import dk.camelot64.cpufamily6502.AsmOpcode;
import dk.camelot64.kickc.model.InternalError;
/** A specific assembler instruction line (opcode, addressing mode and specific parameter value)*/ /** A specific assembler instruction line (opcode, addressing mode and specific parameter value) */
public class AsmInstruction implements AsmLine { public class AsmInstruction implements AsmLine {
private AsmOpcode asmOpcode; private AsmOpcode asmOpcode;
@ -16,6 +18,8 @@ public class AsmInstruction implements AsmLine {
public AsmInstruction(AsmOpcode asmOpcode, String parameter) { public AsmInstruction(AsmOpcode asmOpcode, String parameter) {
this.asmOpcode = asmOpcode; this.asmOpcode = asmOpcode;
this.parameter = parameter; this.parameter = parameter;
if(AsmAddressingMode.NON.equals(asmOpcode.getAddressingMode()) && parameter != null)
throw new InternalError("Opcode with NON paramter cannot have a parameter");
} }
public String getParameter() { public String getParameter() {
@ -23,6 +27,8 @@ public class AsmInstruction implements AsmLine {
} }
public void setParameter(String parameter) { public void setParameter(String parameter) {
if(AsmAddressingMode.NON.equals(asmOpcode.getAddressingMode()) && parameter != null)
throw new InternalError("Opcode with NON paramter cannot have a parameter");
this.parameter = parameter; this.parameter = parameter;
} }

View File

@ -73,6 +73,7 @@ public class Pass5DoubleJumpElimination extends Pass5AsmOptimization {
getLog().append("Replacing jump to rts with rts in " + asmInstruction.toString()); getLog().append("Replacing jump to rts with rts in " + asmInstruction.toString());
AsmOpcode rtsOpcode = AsmInstructionSet.getOpcode("rts", AsmAddressingMode.NON, false); AsmOpcode rtsOpcode = AsmInstructionSet.getOpcode("rts", AsmAddressingMode.NON, false);
asmInstruction.setAsmOpcode(rtsOpcode); asmInstruction.setAsmOpcode(rtsOpcode);
asmInstruction.setParameter(null);
optimized = true; optimized = true;
} else if(immediateJmpTarget != null && immediateJmpTarget != "rts" && !immediateJmpTarget.equals(asmInstruction.getParameter())) { } else if(immediateJmpTarget != null && immediateJmpTarget != "rts" && !immediateJmpTarget.equals(asmInstruction.getParameter())) {
getLog().append("Skipping double jump to " + immediateJmpTarget + " in " + asmInstruction.toString()); getLog().append("Skipping double jump to " + immediateJmpTarget + " in " + asmInstruction.toString());

View File

@ -38,7 +38,7 @@ public class Pass5RedundantLabelElimination extends Pass5AsmOptimization {
} }
} else if(line instanceof AsmInstruction) { } else if(line instanceof AsmInstruction) {
AsmInstruction instruction = (AsmInstruction) line; AsmInstruction instruction = (AsmInstruction) line;
if(instruction.getAsmOpcode().isJump()) { if(instruction.getAsmOpcode().isJump() && instruction.getParameter()!=null) {
String labelStr = instruction.getParameter(); String labelStr = instruction.getParameter();
String labelReplacementStr = getLabelReplacement(redundantLabelSet, currentScope, labelStr); String labelReplacementStr = getLabelReplacement(redundantLabelSet, currentScope, labelStr);
if(labelReplacementStr!=null) { if(labelReplacementStr!=null) {

View File

@ -41,7 +41,7 @@ public class Pass5UnusedLabelElimination extends Pass5AsmOptimization {
usedLabels.add(labelStr); usedLabels.add(labelStr);
} else if(line instanceof AsmInstruction) { } else if(line instanceof AsmInstruction) {
AsmInstruction instruction = (AsmInstruction) line; AsmInstruction instruction = (AsmInstruction) line;
if(instruction.getAsmOpcode().isJump()) { if(instruction.getAsmOpcode().isJump() && instruction.getParameter()!=null) {
String labelStr = currentScope + "::" + instruction.getParameter(); String labelStr = currentScope + "::" + instruction.getParameter();
usedLabels.add(labelStr); usedLabels.add(labelStr);
} }

View File

@ -2453,7 +2453,7 @@ Allocated (was zp[1]:20) zp[1]:8 [ frame_cnt ]
Allocated (was zp[1]:24) zp[1]:9 [ bitmap_init::$7 ] Allocated (was zp[1]:24) zp[1]:9 [ bitmap_init::$7 ]
Allocated (was zp[2]:28) zp[2]:10 [ bitmap_plot::plotter#0 bitmap_plot::plotter#1 memset::str#3 memset::dst#2 memset::dst#4 memset::dst#1 ] Allocated (was zp[2]:28) zp[2]:10 [ bitmap_plot::plotter#0 bitmap_plot::plotter#1 memset::str#3 memset::dst#2 memset::dst#4 memset::dst#1 ]
Allocated (was zp[2]:30) zp[2]:12 [ bitmap_plot::$0 memset::num#2 memset::end#0 bitmap_init::yoffs#2 bitmap_init::yoffs#4 bitmap_init::yoffs#1 ] Allocated (was zp[2]:30) zp[2]:12 [ bitmap_plot::$0 memset::num#2 memset::end#0 bitmap_init::yoffs#2 bitmap_init::yoffs#4 bitmap_init::yoffs#1 ]
Interrupt procedure irq clobbers Acnz Interrupt procedure irq clobbers AcnzP
Removing interrupt register storage stx regx+1 in 13 entry interrupt(HARDWARE_CLOBBER) Removing interrupt register storage stx regx+1 in 13 entry interrupt(HARDWARE_CLOBBER)
Removing interrupt register storage sty regy+1 in 13 entry interrupt(HARDWARE_CLOBBER) Removing interrupt register storage sty regy+1 in 13 entry interrupt(HARDWARE_CLOBBER)
Removing interrupt register storage regx: in 22 [10] return - exit interrupt(HARDWARE_CLOBBER) Removing interrupt register storage regx: in 22 [10] return - exit interrupt(HARDWARE_CLOBBER)

View File

@ -6169,7 +6169,7 @@ Allocated (was zp[4]:172) zp[4]:36 [ sin16s::$4 mul16u::mb#2 mul16u::mb#0 mul16u
Allocated (was zp[2]:176) zp[2]:40 [ sin16s::x1#0 div32u16u::quotient_hi#0 mul16s::$9 ] Allocated (was zp[2]:176) zp[2]:40 [ sin16s::x1#0 div32u16u::quotient_hi#0 mul16s::$9 ]
Allocated (was zp[2]:178) zp[2]:42 [ mulu16_sel::return#0 mulu16_sel::return#12 mulu16_sel::return#2 sin16s::x3_6#0 mulu16_sel::return#11 sin16s::x5#0 sin16s::x5_128#0 divr16u::dividend#3 divr16u::dividend#5 divr16u::dividend#0 mul16u::a#3 mul16u::a#6 mul16u::a#1 mul16u::a#2 mul16u::a#0 ] Allocated (was zp[2]:178) zp[2]:42 [ mulu16_sel::return#0 mulu16_sel::return#12 mulu16_sel::return#2 sin16s::x3_6#0 mulu16_sel::return#11 sin16s::x5#0 sin16s::x5_128#0 divr16u::dividend#3 divr16u::dividend#5 divr16u::dividend#0 mul16u::a#3 mul16u::a#6 mul16u::a#1 mul16u::a#2 mul16u::a#0 ]
Allocated (was zp[2]:209) zp[2]:44 [ rem16u#0 ] Allocated (was zp[2]:209) zp[2]:44 [ rem16u#0 ]
Interrupt procedure irq clobbers Acnz Interrupt procedure irq clobbers AcnzP
Removing interrupt register storage stx regx+1 in 13 entry interrupt(HARDWARE_CLOBBER) Removing interrupt register storage stx regx+1 in 13 entry interrupt(HARDWARE_CLOBBER)
Removing interrupt register storage sty regy+1 in 13 entry interrupt(HARDWARE_CLOBBER) Removing interrupt register storage sty regy+1 in 13 entry interrupt(HARDWARE_CLOBBER)
Removing interrupt register storage regx: in 22 [10] return - exit interrupt(HARDWARE_CLOBBER) Removing interrupt register storage regx: in 22 [10] return - exit interrupt(HARDWARE_CLOBBER)

View File

@ -6450,7 +6450,7 @@ Allocated (was zp[4]:171) zp[4]:39 [ sin16s::$4 mul16u::mb#2 mul16u::mb#0 mul16u
Allocated (was zp[2]:175) zp[2]:43 [ sin16s::x1#0 div32u16u::quotient_hi#0 mul16s::$9 mul16s::$12 ] Allocated (was zp[2]:175) zp[2]:43 [ sin16s::x1#0 div32u16u::quotient_hi#0 mul16s::$9 mul16s::$12 ]
Allocated (was zp[2]:177) zp[2]:45 [ mulu16_sel::return#0 mulu16_sel::return#12 mulu16_sel::return#2 sin16s::x3_6#0 mulu16_sel::return#11 sin16s::x5#0 sin16s::x5_128#0 bitmap_plot::$0 mul16s::$6 mul16s::$11 divr16u::rem#5 divr16u::rem#10 divr16u::rem#4 divr16u::rem#11 divr16u::rem#6 divr16u::rem#0 divr16u::rem#1 divr16u::rem#2 mul16u::a#3 mul16u::a#6 mul16u::a#1 mul16u::a#2 mul16u::a#0 ] Allocated (was zp[2]:177) zp[2]:45 [ mulu16_sel::return#0 mulu16_sel::return#12 mulu16_sel::return#2 sin16s::x3_6#0 mulu16_sel::return#11 sin16s::x5#0 sin16s::x5_128#0 bitmap_plot::$0 mul16s::$6 mul16s::$11 divr16u::rem#5 divr16u::rem#10 divr16u::rem#4 divr16u::rem#11 divr16u::rem#6 divr16u::rem#0 divr16u::rem#1 divr16u::rem#2 mul16u::a#3 mul16u::a#6 mul16u::a#1 mul16u::a#2 mul16u::a#0 ]
Allocated (was zp[2]:208) zp[2]:47 [ rem16u#0 ] Allocated (was zp[2]:208) zp[2]:47 [ rem16u#0 ]
Interrupt procedure irq clobbers Acnz Interrupt procedure irq clobbers AcnzP
Removing interrupt register storage stx regx+1 in 13 entry interrupt(HARDWARE_CLOBBER) Removing interrupt register storage stx regx+1 in 13 entry interrupt(HARDWARE_CLOBBER)
Removing interrupt register storage sty regy+1 in 13 entry interrupt(HARDWARE_CLOBBER) Removing interrupt register storage sty regy+1 in 13 entry interrupt(HARDWARE_CLOBBER)
Removing interrupt register storage regx: in 22 [10] return - exit interrupt(HARDWARE_CLOBBER) Removing interrupt register storage regx: in 22 [10] return - exit interrupt(HARDWARE_CLOBBER)

View File

@ -318,7 +318,7 @@ Uplifting [__start] best 252 combination
Attempting to uplift remaining variables inzp[1]:3 [ irq_raster_next ] Attempting to uplift remaining variables inzp[1]:3 [ irq_raster_next ]
Uplifting [] best 252 combination zp[1]:3 [ irq_raster_next ] Uplifting [] best 252 combination zp[1]:3 [ irq_raster_next ]
Allocated (was zp[1]:3) zp[1]:2 [ irq_raster_next ] Allocated (was zp[1]:3) zp[1]:2 [ irq_raster_next ]
Interrupt procedure irq clobbers AXcnz Interrupt procedure irq clobbers AXcnzP
Removing interrupt register storage sty regy+1 in 12 entry interrupt(HARDWARE_CLOBBER) Removing interrupt register storage sty regy+1 in 12 entry interrupt(HARDWARE_CLOBBER)
Removing interrupt register storage regy: in 26 [14] return - exit interrupt(HARDWARE_CLOBBER) Removing interrupt register storage regy: in 26 [14] return - exit interrupt(HARDWARE_CLOBBER)
Removing interrupt register storage ldy #00 in 26 [14] return - exit interrupt(HARDWARE_CLOBBER) Removing interrupt register storage ldy #00 in 26 [14] return - exit interrupt(HARDWARE_CLOBBER)

View File

@ -2536,7 +2536,7 @@ Allocated (was zp[1]:12) zp[1]:8 [ irq_sprite_ypos ]
Allocated (was zp[1]:13) zp[1]:9 [ irq_sprite_ptr ] Allocated (was zp[1]:13) zp[1]:9 [ irq_sprite_ptr ]
Allocated (was zp[1]:14) zp[1]:10 [ irq_cnt ] Allocated (was zp[1]:14) zp[1]:10 [ irq_cnt ]
Allocated (was zp[1]:17) zp[1]:11 [ sprites_irq::raster_sprite_gfx_modify ] Allocated (was zp[1]:17) zp[1]:11 [ sprites_irq::raster_sprite_gfx_modify ]
Interrupt procedure sprites_irq clobbers AXcnzv Interrupt procedure sprites_irq clobbers AXcnzvdP
Removing interrupt register storage sty regy+1 in 20 entry interrupt(HARDWARE_CLOBBER) Removing interrupt register storage sty regy+1 in 20 entry interrupt(HARDWARE_CLOBBER)
Removing interrupt register storage regy: in 54 [35] return - exit interrupt(HARDWARE_CLOBBER) Removing interrupt register storage regy: in 54 [35] return - exit interrupt(HARDWARE_CLOBBER)
Removing interrupt register storage ldy #00 in 54 [35] return - exit interrupt(HARDWARE_CLOBBER) Removing interrupt register storage ldy #00 in 54 [35] return - exit interrupt(HARDWARE_CLOBBER)

View File

@ -16860,7 +16860,7 @@ Allocated (was zp[2]:209) zp[2]:54 [ play_lock_current::playfield_line#0 play_co
Allocated (was zp[1]:211) zp[1]:56 [ play_lock_current::i#1 play_collision::i#1 ] Allocated (was zp[1]:211) zp[1]:56 [ play_lock_current::i#1 play_collision::i#1 ]
Allocated (was zp[1]:214) zp[1]:57 [ play_update_score::lines_before#0 play_remove_lines::c#0 play_lock_current::i#2 play_lock_current::i#3 play_lock_current::i#7 play_lock_current::i#9 play_collision::i#2 play_collision::i#3 play_collision::i#10 play_collision::i#12 ] Allocated (was zp[1]:214) zp[1]:57 [ play_update_score::lines_before#0 play_remove_lines::c#0 play_lock_current::i#2 play_lock_current::i#3 play_lock_current::i#7 play_lock_current::i#9 play_collision::i#2 play_collision::i#3 play_collision::i#10 play_collision::i#12 ]
Allocated (was zp[4]:216) zp[4]:58 [ play_update_score::add_bcd#0 ] Allocated (was zp[4]:216) zp[4]:58 [ play_update_score::add_bcd#0 ]
Interrupt procedure sprites_irq clobbers AXcnzv Interrupt procedure sprites_irq clobbers AXcnzvdP
Removing interrupt register storage sty regy+1 in 21 entry interrupt(HARDWARE_CLOBBER) Removing interrupt register storage sty regy+1 in 21 entry interrupt(HARDWARE_CLOBBER)
Removing interrupt register storage regy: in 55 [36] return - exit interrupt(HARDWARE_CLOBBER) Removing interrupt register storage regy: in 55 [36] return - exit interrupt(HARDWARE_CLOBBER)
Removing interrupt register storage ldy #00 in 55 [36] return - exit interrupt(HARDWARE_CLOBBER) Removing interrupt register storage ldy #00 in 55 [36] return - exit interrupt(HARDWARE_CLOBBER)

View File

@ -495,7 +495,7 @@ Uplifting [main] best 317 combination
Uplifting [irq] best 317 combination Uplifting [irq] best 317 combination
Uplifting [do_irq] best 317 combination Uplifting [do_irq] best 317 combination
Uplifting [] best 317 combination Uplifting [] best 317 combination
Interrupt procedure irq clobbers Anz Interrupt procedure irq clobbers AnzPS
Removing interrupt register storage stx regx+1 in 4 entry interrupt(HARDWARE_CLOBBER) Removing interrupt register storage stx regx+1 in 4 entry interrupt(HARDWARE_CLOBBER)
Removing interrupt register storage sty regy+1 in 4 entry interrupt(HARDWARE_CLOBBER) Removing interrupt register storage sty regy+1 in 4 entry interrupt(HARDWARE_CLOBBER)
Removing interrupt register storage regx: in 7 [2] return - exit interrupt(HARDWARE_CLOBBER) Removing interrupt register storage regx: in 7 [2] return - exit interrupt(HARDWARE_CLOBBER)

View File

@ -269,7 +269,7 @@ Uplift Scope []
Uplifting [main] best 302 combination Uplifting [main] best 302 combination
Uplifting [irq] best 302 combination Uplifting [irq] best 302 combination
Uplifting [] best 302 combination Uplifting [] best 302 combination
Interrupt procedure irq clobbers Anz Interrupt procedure irq clobbers AnzP
Removing interrupt register storage stx regx+1 in 4 entry interrupt(HARDWARE_CLOBBER) Removing interrupt register storage stx regx+1 in 4 entry interrupt(HARDWARE_CLOBBER)
Removing interrupt register storage sty regy+1 in 4 entry interrupt(HARDWARE_CLOBBER) Removing interrupt register storage sty regy+1 in 4 entry interrupt(HARDWARE_CLOBBER)
Removing interrupt register storage regx: in 9 [3] return - exit interrupt(HARDWARE_CLOBBER) Removing interrupt register storage regx: in 9 [3] return - exit interrupt(HARDWARE_CLOBBER)