1
0
mirror of https://gitlab.com/camelot/kickc.git synced 2024-11-25 20:32:25 +00:00

Changed clobber string format and made difference between registers and flags more clear.

This commit is contained in:
jespergravgaard 2020-07-26 20:56:24 +02:00
parent 7e72604cf9
commit 1fb532718f
14 changed files with 97 additions and 95 deletions

View File

@ -7,22 +7,22 @@ public class AsmClobber implements Serializable {
public static final AsmClobber CLOBBER_ALL = new AsmClobber(true, true, true, true, true, true, true);
final boolean clobberA;
final boolean clobberX;
final boolean clobberY;
final boolean clobberC;
final boolean clobberN;
final boolean clobberZ;
final boolean clobberV;
final boolean registerA;
final boolean registerX;
final boolean registerY;
final boolean flagC;
final boolean flagN;
final boolean flagZ;
final boolean flagV;
public AsmClobber(boolean clobberA, boolean clobberX, boolean clobberY, boolean clobberC, boolean clobberN, boolean clobberZ, boolean clobberV) {
this.clobberA = clobberA;
this.clobberX = clobberX;
this.clobberY = clobberY;
this.clobberC = clobberC;
this.clobberN = clobberN;
this.clobberZ = clobberZ;
this.clobberV = clobberV;
public AsmClobber(boolean registerA, boolean registerX, boolean registerY, boolean flagC, boolean flagN, boolean flagZ, boolean flagV) {
this.registerA = registerA;
this.registerX = registerX;
this.registerY = registerY;
this.flagC = flagC;
this.flagN = flagN;
this.flagZ = flagZ;
this.flagV = flagV;
}
public AsmClobber() {
@ -30,7 +30,9 @@ public class AsmClobber implements Serializable {
}
/**
* Create clobber from a string containing the names of the clobbered registers/flags. EG. "AX" means that the A and X registers are clobbered.
* Create clobber from a string containing the names of the clobbered registers/flags.
* Registers are upper-case and flags are lower-case. (This is because the 65C02 has both a "Z" register and a "Z" flag. )
* EG. "AXcz" means that the A and X registers a and the carry and zero flags are clobbered.
*
* @param clobberString The clobber string.
*/
@ -39,10 +41,10 @@ public class AsmClobber implements Serializable {
clobberString.contains("A"),
clobberString.contains("X"),
clobberString.contains("Y"),
clobberString.contains("C"),
clobberString.contains("N"),
clobberString.contains("Z"),
clobberString.contains("V")
clobberString.contains("c"),
clobberString.contains("n"),
clobberString.contains("z"),
clobberString.contains("v")
);
}
@ -54,84 +56,84 @@ public class AsmClobber implements Serializable {
*/
public AsmClobber(AsmClobber clobber1, AsmClobber clobber2) {
this(
clobber1.clobberA | clobber2.clobberA,
clobber1.clobberX | clobber2.clobberX,
clobber1.clobberY | clobber2.clobberY,
clobber1.clobberC | clobber2.clobberC,
clobber1.clobberN | clobber2.clobberN,
clobber1.clobberZ | clobber2.clobberZ,
clobber1.clobberV | clobber2.clobberV
clobber1.registerA | clobber2.registerA,
clobber1.registerX | clobber2.registerX,
clobber1.registerY | clobber2.registerY,
clobber1.flagC | clobber2.flagC,
clobber1.flagN | clobber2.flagN,
clobber1.flagZ | clobber2.flagZ,
clobber1.flagV | clobber2.flagV
);
}
public boolean isClobberA() {
return clobberA;
public boolean isRegisterA() {
return registerA;
}
public boolean isClobberX() {
return clobberX;
public boolean isRegisterX() {
return registerX;
}
public boolean isClobberY() {
return clobberY;
public boolean isRegisterY() {
return registerY;
}
public boolean isClobberC() {
return clobberC;
public boolean isFlagC() {
return flagC;
}
public boolean isClobberN() {
return clobberN;
public boolean isFlagN() {
return flagN;
}
public boolean isClobberZ() {
return clobberZ;
public boolean isFlagZ() {
return flagZ;
}
public boolean isClobberV() {
return clobberV;
public boolean isFlagV() {
return flagV;
}
public AsmClobber addClobberA(boolean clobberA) {
return new AsmClobber(clobberA, this.clobberX, this.clobberY, this.clobberC, this.clobberN, this.clobberZ, this.clobberV);
public AsmClobber addRegisterA() {
return new AsmClobber(true, this.registerX, this.registerY, this.flagC, this.flagN, this.flagZ, this.flagV);
}
public AsmClobber addClobberX(boolean clobberX) {
return new AsmClobber(this.clobberA, clobberX, this.clobberY, this.clobberC, this.clobberN, this.clobberZ, this.clobberV);
public AsmClobber addRegisterX() {
return new AsmClobber(this.registerA, true, this.registerY, this.flagC, this.flagN, this.flagZ, this.flagV);
}
public AsmClobber addClobberY(boolean clobberY) {
return new AsmClobber(this.clobberA, this.clobberX, clobberY, this.clobberC, this.clobberN, this.clobberZ, this.clobberV);
public AsmClobber addRegisterY() {
return new AsmClobber(this.registerA, this.registerX, true, this.flagC, this.flagN, this.flagZ, this.flagV);
}
public AsmClobber addClobberC(boolean clobberC) {
return new AsmClobber(this.clobberA, this.clobberX, this.clobberY, clobberC, this.clobberN, this.clobberZ, this.clobberV);
public AsmClobber addFlagC() {
return new AsmClobber(this.registerA, this.registerX, this.registerY, true, this.flagN, this.flagZ, this.flagV);
}
public AsmClobber addClobberN(boolean clobberN) {
return new AsmClobber(this.clobberA, this.clobberX, this.clobberY, this.clobberC, clobberN, this.clobberZ, this.clobberV);
public AsmClobber addFlagN() {
return new AsmClobber(this.registerA, this.registerX, this.registerY, this.flagC, true, this.flagZ, this.flagV);
}
public AsmClobber addClobberZ(boolean clobberZ) {
return new AsmClobber(this.clobberA, this.clobberX, this.clobberY, this.clobberC, this.clobberN, clobberZ, this.clobberV);
public AsmClobber addFlagZ() {
return new AsmClobber(this.registerA, this.registerX, this.registerY, this.flagC, this.flagN, true, this.flagV);
}
public AsmClobber addClobberV(boolean clobberV) {
return new AsmClobber(this.clobberA, this.clobberX, this.clobberY, this.clobberC, this.clobberN, this.clobberZ, clobberV);
public AsmClobber addFlagV() {
return new AsmClobber(this.registerA, this.registerX, this.registerY, this.flagC, this.flagN, this.flagZ, true);
}
@Override
public String toString() {
return
(clobberA ? "A" : "") +
(clobberX ? "X" : "") +
(clobberY ? "Y" : "") +
(clobberC ? "C" : "") +
(clobberN ? "N" : "") +
(clobberZ ? "Z" : "") +
(clobberV ? "V" : "");
(registerA ? "A" : "") +
(registerX ? "X" : "") +
(registerY ? "Y" : "") +
(flagC ? "c" : "") +
(flagN ? "n" : "") +
(flagZ ? "z" : "") +
(flagV ? "v" : "");
}

View File

@ -289,51 +289,51 @@ public class AsmInstructionSet {
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().addClobberX(true));
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().addClobberY(true));
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().addClobberA(true));
instruction.setClobber(instruction.getClobber().addRegisterA());
} else if(instruction.hasOpcode(0x0a)) {
// Special handling of ASL A
instruction.setClobber(instruction.getClobber().addClobberA(true));
instruction.setClobber(instruction.getClobber().addRegisterA());
} else if(instruction.hasOpcode(0x2a)) {
// Special handling of ROL A
instruction.setClobber(instruction.getClobber().addClobberA(true));
instruction.setClobber(instruction.getClobber().addRegisterA());
} else if(instruction.hasOpcode(0x4a)) {
// Special handling of LSR A
instruction.setClobber(instruction.getClobber().addClobberA(true));
instruction.setClobber(instruction.getClobber().addRegisterA());
} else if(instruction.hasOpcode(0x6a)) {
// Special handling of ROR A
instruction.setClobber(instruction.getClobber().addClobberA(true));
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().addClobberC(true));
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().addClobberV(true));
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().addClobberZ(true));
instruction.setClobber(instruction.getClobber().addClobberN(true));
instruction.setClobber(instruction.getClobber().addFlagZ());
instruction.setClobber(instruction.getClobber().addFlagN());
}
}
}

View File

@ -92,28 +92,28 @@ public class AsmProgramStaticRegisterValues {
if(instruction.getAsmOpcode().getMnemonic().equals("jsr")) {
asmClobber = AsmClobber.CLOBBER_ALL;
}
if(asmClobber.isClobberA()) {
if(asmClobber.isRegisterA()) {
current.setA(null);
current.setaMem(null);
}
if(asmClobber.isClobberX()) {
if(asmClobber.isRegisterX()) {
current.setX(null);
current.setxMem(null);
}
if(asmClobber.isClobberY()) {
if(asmClobber.isRegisterY()) {
current.setY(null);
current.setyMem(null);
}
if(asmClobber.isClobberC()) {
if(asmClobber.isFlagC()) {
current.setC(null);
}
if(asmClobber.isClobberN()) {
if(asmClobber.isFlagN()) {
current.setN(null);
}
if(asmClobber.isClobberV()) {
if(asmClobber.isFlagV()) {
current.setV(null);
}
if(asmClobber.isClobberZ()) {
if(asmClobber.isFlagZ()) {
current.setZ(null);
}
String mnemnonic = asmOpcode.getMnemonic();

View File

@ -16,7 +16,7 @@ public class AsmFragmentClobber implements Comparable<AsmFragmentClobber> {
}
public AsmFragmentClobber(AsmClobber clobber) {
this(clobber.isClobberA(), clobber.isClobberX(), clobber.isClobberY());
this(clobber.isRegisterA(), clobber.isRegisterX(), clobber.isRegisterY());
}
public boolean isClobberA() {

View File

@ -31,13 +31,13 @@ public class Pass4AssertNoCpuClobber extends Pass2Base {
*/
public static Collection<Registers.Register> getClobberRegisters(AsmClobber clobber) {
List<Registers.Register> clobberRegisters = new ArrayList<>();
if(clobber.isClobberA()) {
if(clobber.isRegisterA()) {
clobberRegisters.add(Registers.getRegisterA());
}
if(clobber.isClobberX()) {
if(clobber.isRegisterX()) {
clobberRegisters.add(Registers.getRegisterX());
}
if(clobber.isClobberY()) {
if(clobber.isRegisterY()) {
clobberRegisters.add(Registers.getRegisterY());
}
return clobberRegisters;

View File

@ -98,13 +98,13 @@ public class Pass4InterruptClobberFix extends Pass2Base {
private List<String> getNonClobberedRegisterNames(AsmClobber procClobber) {
List<String> notClobberedRegisters = new ArrayList<>();
if(!procClobber.isClobberA()) {
if(!procClobber.isRegisterA()) {
notClobberedRegisters.add("a");
}
if(!procClobber.isClobberX()) {
if(!procClobber.isRegisterX()) {
notClobberedRegisters.add("x");
}
if(!procClobber.isClobberY()) {
if(!procClobber.isRegisterY()) {
notClobberedRegisters.add("y");
}
return notClobberedRegisters;

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[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 ]
Interrupt procedure irq clobbers ACNZ
Interrupt procedure irq clobbers Acnz
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 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]: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 ]
Interrupt procedure irq clobbers ACNZ
Interrupt procedure irq clobbers Acnz
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 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]: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 ]
Interrupt procedure irq clobbers ACNZ
Interrupt procedure irq clobbers Acnz
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 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 ]
Uplifting [] best 252 combination zp[1]:3 [ irq_raster_next ]
Allocated (was zp[1]:3) zp[1]:2 [ irq_raster_next ]
Interrupt procedure irq clobbers AXCNZ
Interrupt procedure irq clobbers AXcnz
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 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]:14) zp[1]:10 [ irq_cnt ]
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 AXcnzv
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 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]: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 ]
Interrupt procedure sprites_irq clobbers AXCNZV
Interrupt procedure sprites_irq clobbers AXcnzv
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 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 [do_irq] best 317 combination
Uplifting [] best 317 combination
Interrupt procedure irq clobbers ANZ
Interrupt procedure irq clobbers Anz
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 regx: in 7 [2] return - exit interrupt(HARDWARE_CLOBBER)

View File

@ -269,7 +269,7 @@ Uplift Scope []
Uplifting [main] best 302 combination
Uplifting [irq] best 302 combination
Uplifting [] best 302 combination
Interrupt procedure irq clobbers ANZ
Interrupt procedure irq clobbers Anz
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 regx: in 9 [3] return - exit interrupt(HARDWARE_CLOBBER)