1
0
mirror of https://gitlab.com/camelot/kickc.git synced 2024-12-18 08:30:18 +00:00

Implemented somewhat Better ASM static value analysis. Also recognizes ZP sta zp5, ldx zp5.

This commit is contained in:
jespergravgaard 2017-11-13 23:41:23 +01:00
parent 5ed20ccc76
commit 148f9ae072
8 changed files with 942 additions and 102 deletions

View File

@ -55,4 +55,8 @@ public class AsmInstruction implements AsmLine {
public void setParameter(String parameter) {
this.parameter = parameter;
}
public void setType(AsmInstructionType type) {
this.type = type;
}
}

View File

@ -46,12 +46,15 @@ public class AsmProgramStaticRegisterValues {
AsmClobber clobber = instructionType.getClobber();
if (clobber.isClobberA()) {
current.setA(null);
current.setaMem(null);
}
if (clobber.isClobberX()) {
current.setX(null);
current.setxMem(null);
}
if (clobber.isClobberY()) {
current.setY(null);
current.setyMem(null);
}
if (clobber.isClobberC()) {
current.setC(null);
@ -66,35 +69,44 @@ public class AsmProgramStaticRegisterValues {
current.setZ(null);
}
if (instructionType.getMnemnonic().equals("lda") && instructionType.getAddressingMode().equals(AsmAddressingMode.IMM)) {
current.setA(instruction.getParameter());
try {
int immValue = Integer.parseInt(instruction.getParameter());
current.setZ(immValue == 0);
current.setN(immValue > 127);
current.setA(immValue);
} catch (NumberFormatException e) {
// ignore
}
}
if (instructionType.getMnemnonic().equals("sta") && (instructionType.getAddressingMode().equals(AsmAddressingMode.ZP)||instructionType.getAddressingMode().equals(AsmAddressingMode.ABS))) {
current.setaMem(instruction.getParameter());
}
if (instructionType.getMnemnonic().equals("ldx") && instructionType.getAddressingMode().equals(AsmAddressingMode.IMM)) {
current.setX(instruction.getParameter());
try {
int immValue = Integer.parseInt(instruction.getParameter());
current.setZ(immValue == 0);
current.setN(immValue > 127);
current.setX(immValue);
} catch (NumberFormatException e) {
// ignore
}
}
if (instructionType.getMnemnonic().equals("stx") && (instructionType.getAddressingMode().equals(AsmAddressingMode.ZP)||instructionType.getAddressingMode().equals(AsmAddressingMode.ABS))) {
current.setxMem(instruction.getParameter());
}
if (instructionType.getMnemnonic().equals("ldy") && instructionType.getAddressingMode().equals(AsmAddressingMode.IMM)) {
current.setY(instruction.getParameter());
try {
int immValue = Integer.parseInt(instruction.getParameter());
current.setZ(immValue == 0);
current.setN(immValue > 127);
current.setY(immValue);
} catch (NumberFormatException e) {
// ignore
}
}
if (instructionType.getMnemnonic().equals("sty") && (instructionType.getAddressingMode().equals(AsmAddressingMode.ZP)||instructionType.getAddressingMode().equals(AsmAddressingMode.ABS))) {
current.setyMem(instruction.getParameter());
}
if (instructionType.getMnemnonic().equals("sec")) {
current.setC(Boolean.TRUE);
}
@ -109,13 +121,16 @@ public class AsmProgramStaticRegisterValues {
* Known values of registers/flags at an instruction. null where value is unknown.
*/
public static class AsmRegisterValues {
private Integer a;
private Integer x;
private Integer y;
private String a;
private String x;
private String y;
private Boolean c;
private Boolean v;
private Boolean n;
private Boolean z;
private String aMem;
private String xMem;
private String yMem;
public AsmRegisterValues() {
}
@ -128,17 +143,24 @@ public class AsmProgramStaticRegisterValues {
this.v = original.getV();
this.n = original.getN();
this.z = original.getZ();
this.aMem = original.getaMem();
this.xMem = original.getxMem();
this.yMem = original.getyMem();
}
public Integer getA() {
public String getA() {
return a;
}
public Integer getX() {
public String getaMem() {
return aMem;
}
public String getX() {
return x;
}
public Integer getY() {
public String getY() {
return y;
}
@ -158,18 +180,38 @@ public class AsmProgramStaticRegisterValues {
return z;
}
public void setA(Integer a) {
this.a = a;
}
public void setX(Integer x) {
public void setX(String x) {
this.x = x;
}
public void setY(Integer y) {
public void setY(String y) {
this.y = y;
}
public void setA(String a) {
this.a = a;
}
public void setaMem(String aMem) {
this.aMem = aMem;
}
public String getxMem() {
return xMem;
}
public void setxMem(String xMem) {
this.xMem = xMem;
}
public String getyMem() {
return yMem;
}
public void setyMem(String yMem) {
this.yMem = yMem;
}
public void setC(Boolean c) {
this.c = c;
}

View File

@ -9,6 +9,7 @@ import dk.camelot64.kickc.model.Program;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
/**
* Optimization performed on Assembler Code (Asm Code).
@ -49,4 +50,12 @@ public abstract class Pass5AsmOptimization {
}
}
}
public boolean remove(ListIterator<AsmLine> lineIt) {
getLog().append("Removing instruction " + lineIt.previous());
lineIt.remove();
return true;
}
}

View File

@ -5,6 +5,7 @@ import dk.camelot64.kickc.model.Program;
import java.util.ArrayList;
import java.util.List;
import java.util.ListIterator;
/**
* Maps out register values entering all instructions. Removes unnecessary loads / clears / sets
@ -18,63 +19,92 @@ public class Pass5UnnecesaryLoadElimination extends Pass5AsmOptimization {
@Override
public boolean optimize() {
AsmProgramStaticRegisterValues staticValues = new AsmProgramStaticRegisterValues(getAsmProgram());
List<AsmLine> removes = new ArrayList<>();
//List<AsmLine> removes = new ArrayList<>();
boolean modified = false;
for (AsmSegment segment : getAsmProgram().getSegments()) {
for (AsmLine line : segment.getLines()) {
List<AsmLine> lines = segment.getLines();
ListIterator<AsmLine> lineIt = lines.listIterator();
while (lineIt.hasNext()) {
AsmLine line = lineIt.next();
if (line instanceof AsmInstruction) {
AsmInstruction instruction = (AsmInstruction) line;
AsmInstructionType instructionType = instruction.getType();
if (instructionType.getMnemnonic().equals("lda") && instructionType.getAddressingMode().equals(AsmAddressingMode.IMM)) {
try {
int immValue = Integer.parseInt(instruction.getParameter());
AsmProgramStaticRegisterValues.AsmRegisterValues instructionValues = staticValues.getValues(instruction);
if (instructionValues.getA() != null && instructionValues.getA().equals(immValue)) {
removes.add(instruction);
}
} catch (NumberFormatException e) {
// ignore
String immValue = instruction.getParameter();
AsmProgramStaticRegisterValues.AsmRegisterValues instructionValues = staticValues.getValues(instruction);
if (instructionValues.getA() != null && instructionValues.getA().equals(immValue)) {
modified = remove(lineIt);
}
}
if (instructionType.getMnemnonic().equals("lda") && (instructionType.getAddressingMode().equals(AsmAddressingMode.ZP)||instructionType.getAddressingMode().equals(AsmAddressingMode.ABS))) {
String memValue = instruction.getParameter();
AsmProgramStaticRegisterValues.AsmRegisterValues instructionValues = staticValues.getValues(instruction);
if (instructionValues.getaMem() != null && instructionValues.getaMem().equals(memValue)) {
modified = remove(lineIt);
} else if (instructionValues.getxMem() != null && instructionValues.getxMem().equals(memValue)) {
getLog().append("Replacing instruction "+instruction+" with TXA");
instruction.setType(AsmInstructionSet.getInstructionType("txa", AsmAddressingMode.NON, null, false));
instruction.setParameter(null);
} else if (instructionValues.getyMem() != null && instructionValues.getyMem().equals(memValue)) {
getLog().append("Replacing instruction "+instruction+" with TYA");
instruction.setType(AsmInstructionSet.getInstructionType("tya", AsmAddressingMode.NON, null, false));
instruction.setParameter(null);
}
}
if (instructionType.getMnemnonic().equals("ldx") && instructionType.getAddressingMode().equals(AsmAddressingMode.IMM)) {
try {
int immValue = Integer.parseInt(instruction.getParameter());
AsmProgramStaticRegisterValues.AsmRegisterValues instructionValues = staticValues.getValues(instruction);
if (instructionValues.getX() != null && instructionValues.getX().equals(immValue)) {
removes.add(instruction);
}
} catch (NumberFormatException e) {
// ignore
String immValue = instruction.getParameter();
AsmProgramStaticRegisterValues.AsmRegisterValues instructionValues = staticValues.getValues(instruction);
if (instructionValues.getX() != null && instructionValues.getX().equals(immValue)) {
modified = remove(lineIt);
}
}
if (instructionType.getMnemnonic().equals("ldx") && (instructionType.getAddressingMode().equals(AsmAddressingMode.ZP)||instructionType.getAddressingMode().equals(AsmAddressingMode.ABS))) {
String memValue = instruction.getParameter();
AsmProgramStaticRegisterValues.AsmRegisterValues instructionValues = staticValues.getValues(instruction);
if (instructionValues.getxMem() != null && instructionValues.getxMem().equals(memValue)) {
modified = remove(lineIt);
} else if (instructionValues.getaMem() != null && instructionValues.getaMem().equals(memValue)) {
getLog().append("Replacing instruction "+instruction+" with TAX");
instruction.setType(AsmInstructionSet.getInstructionType("tax", AsmAddressingMode.NON, null, false));
instruction.setParameter(null);
}
}
if (instructionType.getMnemnonic().equals("ldy") && instructionType.getAddressingMode().equals(AsmAddressingMode.IMM)) {
try {
int immValue = Integer.parseInt(instruction.getParameter());
AsmProgramStaticRegisterValues.AsmRegisterValues instructionValues = staticValues.getValues(instruction);
if (instructionValues.getY() != null && instructionValues.getY().equals(immValue)) {
removes.add(instruction);
}
} catch (NumberFormatException e) {
// ignore
String immValue = instruction.getParameter();
AsmProgramStaticRegisterValues.AsmRegisterValues instructionValues = staticValues.getValues(instruction);
if (instructionValues.getY() != null && instructionValues.getY().equals(immValue)) {
modified = remove(lineIt);
}
}
if (instructionType.getMnemnonic().equals("ldy") && (instructionType.getAddressingMode().equals(AsmAddressingMode.ZP)||instructionType.getAddressingMode().equals(AsmAddressingMode.ABS))) {
String memValue = instruction.getParameter();
AsmProgramStaticRegisterValues.AsmRegisterValues instructionValues = staticValues.getValues(instruction);
if (instructionValues.getyMem() != null && instructionValues.getyMem().equals(memValue)) {
modified = remove(lineIt);
} else if (instructionValues.getaMem() != null && instructionValues.getaMem().equals(memValue)) {
getLog().append("Replacing instruction "+instruction+" with TAY");
instruction.setType(AsmInstructionSet.getInstructionType("tay", AsmAddressingMode.NON, null, false));
instruction.setParameter(null);
}
}
if (instructionType.getMnemnonic().equals("clc")) {
AsmProgramStaticRegisterValues.AsmRegisterValues instructionValues = staticValues.getValues(instruction);
if (Boolean.FALSE.equals(instructionValues.getC())) {
removes.add(instruction);
modified = remove(lineIt);
}
}
if (instructionType.getMnemnonic().equals("sec")) {
AsmProgramStaticRegisterValues.AsmRegisterValues instructionValues = staticValues.getValues(instruction);
if (Boolean.TRUE.equals(instructionValues.getC())) {
removes.add(instruction);
modified = remove(lineIt);
}
}
}
}
}
remove(removes);
return removes.size() > 0;
return modified;
}
}

View File

@ -90,7 +90,6 @@ line: {
sec
sbc $ff
sta yd
lda yd
cmp xd
bcs b3
ldx x0
@ -120,7 +119,6 @@ line: {
sec
sbc y1
sta yd
lda yd
cmp xd
bcs b6
ldx x0
@ -156,7 +154,6 @@ line: {
sec
sbc $ff
sta yd
lda yd
cmp xd
bcs b10
ldx x1
@ -184,7 +181,6 @@ line: {
sec
sbc y1
sta yd
lda yd
cmp xd
bcs b13
ldx x1

View File

@ -18340,6 +18340,10 @@ init_screen: {
}
Removing instruction lda #0
Removing instruction lda yd
Removing instruction lda yd
Removing instruction lda yd
Removing instruction lda yd
Removing instruction ldy #0
Removing instruction lda #0
Succesful ASM optimization Pass5UnnecesaryLoadElimination
@ -18504,7 +18508,6 @@ line: {
sbc $ff
sta yd
//SEG50 [28] if((byte) line::yd#1>=(byte) line::xd#1) goto line::@3 [ line::x0#0 line::x1#0 line::y0#0 line::y1#0 line::xd#1 line::yd#1 ] ( main:0::lines:7::line:20 [ lines::l#2 line::x0#0 line::x1#0 line::y0#0 line::y1#0 line::xd#1 line::yd#1 ] ) -- zpby1_ge_zpby2_then_la1
lda yd
cmp xd
bcs b3
//SEG51 line::@17
@ -18568,7 +18571,6 @@ line: {
sbc y1
sta yd
//SEG81 [43] if((byte) line::yd#0>=(byte) line::xd#1) goto line::@6 [ line::x0#0 line::x1#0 line::y0#0 line::y1#0 line::xd#1 line::yd#0 ] ( main:0::lines:7::line:20 [ lines::l#2 line::x0#0 line::x1#0 line::y0#0 line::y1#0 line::xd#1 line::yd#0 ] ) -- zpby1_ge_zpby2_then_la1
lda yd
cmp xd
bcs b6
//SEG82 line::@20
@ -18640,7 +18642,6 @@ line: {
sbc $ff
sta yd
//SEG113 [59] if((byte) line::yd#3>=(byte) line::xd#0) goto line::@10 [ line::x0#0 line::x1#0 line::y0#0 line::y1#0 line::xd#0 line::yd#3 ] ( main:0::lines:7::line:20 [ lines::l#2 line::x0#0 line::x1#0 line::y0#0 line::y1#0 line::xd#0 line::yd#3 ] ) -- zpby1_ge_zpby2_then_la1
lda yd
cmp xd
bcs b10
//SEG114 line::@24
@ -18701,7 +18702,6 @@ line: {
sbc y1
sta yd
//SEG142 [73] if((byte) line::yd#10>=(byte) line::xd#0) goto line::@13 [ line::x0#0 line::x1#0 line::y0#0 line::y1#0 line::xd#0 line::yd#10 ] ( main:0::lines:7::line:20 [ lines::l#2 line::x0#0 line::x1#0 line::y0#0 line::y1#0 line::xd#0 line::yd#10 ] ) -- zpby1_ge_zpby2_then_la1
lda yd
cmp xd
bcs b13
//SEG143 line::@27
@ -19467,7 +19467,6 @@ line: {
sbc $ff
sta yd
//SEG50 [28] if((byte) line::yd#1>=(byte) line::xd#1) goto line::@3 [ line::x0#0 line::x1#0 line::y0#0 line::y1#0 line::xd#1 line::yd#1 ] ( main:0::lines:7::line:20 [ lines::l#2 line::x0#0 line::x1#0 line::y0#0 line::y1#0 line::xd#1 line::yd#1 ] ) -- zpby1_ge_zpby2_then_la1
lda yd
cmp xd
bcs b3
//SEG51 line::@17
@ -19531,7 +19530,6 @@ line: {
sbc y1
sta yd
//SEG81 [43] if((byte) line::yd#0>=(byte) line::xd#1) goto line::@6 [ line::x0#0 line::x1#0 line::y0#0 line::y1#0 line::xd#1 line::yd#0 ] ( main:0::lines:7::line:20 [ lines::l#2 line::x0#0 line::x1#0 line::y0#0 line::y1#0 line::xd#1 line::yd#0 ] ) -- zpby1_ge_zpby2_then_la1
lda yd
cmp xd
bcs b6
//SEG82 line::@20
@ -19603,7 +19601,6 @@ line: {
sbc $ff
sta yd
//SEG113 [59] if((byte) line::yd#3>=(byte) line::xd#0) goto line::@10 [ line::x0#0 line::x1#0 line::y0#0 line::y1#0 line::xd#0 line::yd#3 ] ( main:0::lines:7::line:20 [ lines::l#2 line::x0#0 line::x1#0 line::y0#0 line::y1#0 line::xd#0 line::yd#3 ] ) -- zpby1_ge_zpby2_then_la1
lda yd
cmp xd
bcs b10
//SEG114 line::@24
@ -19664,7 +19661,6 @@ line: {
sbc y1
sta yd
//SEG142 [73] if((byte) line::yd#10>=(byte) line::xd#0) goto line::@13 [ line::x0#0 line::x1#0 line::y0#0 line::y1#0 line::xd#0 line::yd#10 ] ( main:0::lines:7::line:20 [ lines::l#2 line::x0#0 line::x1#0 line::y0#0 line::y1#0 line::xd#0 line::yd#10 ] ) -- zpby1_ge_zpby2_then_la1
lda yd
cmp xd
bcs b13
//SEG143 line::@27
@ -20402,7 +20398,6 @@ line: {
sbc $ff
sta yd
//SEG50 [28] if((byte) line::yd#1>=(byte) line::xd#1) goto line::@3 [ line::x0#0 line::x1#0 line::y0#0 line::y1#0 line::xd#1 line::yd#1 ] ( main:0::lines:7::line:20 [ lines::l#2 line::x0#0 line::x1#0 line::y0#0 line::y1#0 line::xd#1 line::yd#1 ] ) -- zpby1_ge_zpby2_then_la1
lda yd
cmp xd
bcs b3
//SEG51 line::@17
@ -20463,7 +20458,6 @@ line: {
sbc y1
sta yd
//SEG81 [43] if((byte) line::yd#0>=(byte) line::xd#1) goto line::@6 [ line::x0#0 line::x1#0 line::y0#0 line::y1#0 line::xd#1 line::yd#0 ] ( main:0::lines:7::line:20 [ lines::l#2 line::x0#0 line::x1#0 line::y0#0 line::y1#0 line::xd#1 line::yd#0 ] ) -- zpby1_ge_zpby2_then_la1
lda yd
cmp xd
bcs b6
//SEG82 line::@20
@ -20531,7 +20525,6 @@ line: {
sbc $ff
sta yd
//SEG113 [59] if((byte) line::yd#3>=(byte) line::xd#0) goto line::@10 [ line::x0#0 line::x1#0 line::y0#0 line::y1#0 line::xd#0 line::yd#3 ] ( main:0::lines:7::line:20 [ lines::l#2 line::x0#0 line::x1#0 line::y0#0 line::y1#0 line::xd#0 line::yd#3 ] ) -- zpby1_ge_zpby2_then_la1
lda yd
cmp xd
bcs b10
//SEG114 line::@24
@ -20589,7 +20582,6 @@ line: {
sbc y1
sta yd
//SEG142 [73] if((byte) line::yd#10>=(byte) line::xd#0) goto line::@13 [ line::x0#0 line::x1#0 line::y0#0 line::y1#0 line::xd#0 line::yd#10 ] ( main:0::lines:7::line:20 [ lines::l#2 line::x0#0 line::x1#0 line::y0#0 line::y1#0 line::xd#0 line::yd#10 ] ) -- zpby1_ge_zpby2_then_la1
lda yd
cmp xd
bcs b13
//SEG143 line::@27
@ -21254,7 +21246,6 @@ line: {
sbc $ff
sta yd
//SEG50 [28] if((byte) line::yd#1>=(byte) line::xd#1) goto line::@3 [ line::x0#0 line::x1#0 line::y0#0 line::y1#0 line::xd#1 line::yd#1 ] ( main:0::lines:7::line:20 [ lines::l#2 line::x0#0 line::x1#0 line::y0#0 line::y1#0 line::xd#1 line::yd#1 ] ) -- zpby1_ge_zpby2_then_la1
lda yd
cmp xd
bcs b3
//SEG51 line::@17
@ -21315,7 +21306,6 @@ line: {
sbc y1
sta yd
//SEG81 [43] if((byte) line::yd#0>=(byte) line::xd#1) goto line::@6 [ line::x0#0 line::x1#0 line::y0#0 line::y1#0 line::xd#1 line::yd#0 ] ( main:0::lines:7::line:20 [ lines::l#2 line::x0#0 line::x1#0 line::y0#0 line::y1#0 line::xd#1 line::yd#0 ] ) -- zpby1_ge_zpby2_then_la1
lda yd
cmp xd
bcs b6
//SEG82 line::@20
@ -21383,7 +21373,6 @@ line: {
sbc $ff
sta yd
//SEG113 [59] if((byte) line::yd#3>=(byte) line::xd#0) goto line::@10 [ line::x0#0 line::x1#0 line::y0#0 line::y1#0 line::xd#0 line::yd#3 ] ( main:0::lines:7::line:20 [ lines::l#2 line::x0#0 line::x1#0 line::y0#0 line::y1#0 line::xd#0 line::yd#3 ] ) -- zpby1_ge_zpby2_then_la1
lda yd
cmp xd
bcs b10
//SEG114 line::@24
@ -21441,7 +21430,6 @@ line: {
sbc y1
sta yd
//SEG142 [73] if((byte) line::yd#10>=(byte) line::xd#0) goto line::@13 [ line::x0#0 line::x1#0 line::y0#0 line::y1#0 line::xd#0 line::yd#10 ] ( main:0::lines:7::line:20 [ lines::l#2 line::x0#0 line::x1#0 line::y0#0 line::y1#0 line::xd#0 line::yd#10 ] ) -- zpby1_ge_zpby2_then_la1
lda yd
cmp xd
bcs b13
//SEG143 line::@27
@ -22450,7 +22438,6 @@ line: {
sbc $ff
sta yd
//SEG50 [28] if((byte) line::yd#1>=(byte) line::xd#1) goto line::@3 [ line::x0#0 line::x1#0 line::y0#0 line::y1#0 line::xd#1 line::yd#1 ] ( main:0::lines:7::line:20 [ lines::l#2 line::x0#0 line::x1#0 line::y0#0 line::y1#0 line::xd#1 line::yd#1 ] ) -- zpby1_ge_zpby2_then_la1
lda yd
cmp xd
bcs b3
//SEG51 line::@17
@ -22511,7 +22498,6 @@ line: {
sbc y1
sta yd
//SEG81 [43] if((byte) line::yd#0>=(byte) line::xd#1) goto line::@6 [ line::x0#0 line::x1#0 line::y0#0 line::y1#0 line::xd#1 line::yd#0 ] ( main:0::lines:7::line:20 [ lines::l#2 line::x0#0 line::x1#0 line::y0#0 line::y1#0 line::xd#1 line::yd#0 ] ) -- zpby1_ge_zpby2_then_la1
lda yd
cmp xd
bcs b6
//SEG82 line::@20
@ -22579,7 +22565,6 @@ line: {
sbc $ff
sta yd
//SEG113 [59] if((byte) line::yd#3>=(byte) line::xd#0) goto line::@10 [ line::x0#0 line::x1#0 line::y0#0 line::y1#0 line::xd#0 line::yd#3 ] ( main:0::lines:7::line:20 [ lines::l#2 line::x0#0 line::x1#0 line::y0#0 line::y1#0 line::xd#0 line::yd#3 ] ) -- zpby1_ge_zpby2_then_la1
lda yd
cmp xd
bcs b10
//SEG114 line::@24
@ -22637,7 +22622,6 @@ line: {
sbc y1
sta yd
//SEG142 [73] if((byte) line::yd#10>=(byte) line::xd#0) goto line::@13 [ line::x0#0 line::x1#0 line::y0#0 line::y1#0 line::xd#0 line::yd#10 ] ( main:0::lines:7::line:20 [ lines::l#2 line::x0#0 line::x1#0 line::y0#0 line::y1#0 line::xd#0 line::yd#10 ] ) -- zpby1_ge_zpby2_then_la1
lda yd
cmp xd
bcs b13
//SEG143 line::@27

View File

@ -22,7 +22,6 @@ animate: {
clc
adc #1
sta XPOS+0
lda XPOS+0
cmp #$28
bne b1
lda #0
@ -32,7 +31,6 @@ animate: {
clc
adc #1
sta YPOS+0
lda YPOS+0
cmp #$19
bne b2
lda #0
@ -41,7 +39,7 @@ animate: {
ldx XPOS+1
dex
stx XPOS+1
lda XPOS+1
txa
cmp #$ff
bne b3
lda #$28
@ -51,7 +49,6 @@ animate: {
clc
adc #1
sta YPOS+2
lda YPOS+2
cmp #$19
bne b4
lda #0
@ -60,7 +57,7 @@ animate: {
ldx YPOS+3
dex
stx YPOS+3
lda YPOS+3
txa
cmp #$ff
bne breturn
lda #$19
@ -69,10 +66,8 @@ animate: {
clc
adc #7
sta XPOS+3
lda XPOS+3
cmp #$28
bcc breturn
lda XPOS+3
sec
sbc #$28
sta XPOS+3

View File

@ -8395,6 +8395,429 @@ initscreen: {
rts
}
Removing instruction lda XPOS+0
Removing instruction lda YPOS+0
Replacing instruction lda XPOS+1 with TXA
Removing instruction lda YPOS+2
Replacing instruction lda YPOS+3 with TXA
Removing instruction lda XPOS+3
Succesful ASM optimization Pass5UnnecesaryLoadElimination
ASSEMBLER
//SEG0 Basic Upstart
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
//SEG1 Global Constants & labels
.const SCREEN = $400
.const COLORS = $d800
.const FILL = $e6
.const numpoints = 6
XPOS: .byte 5, $f, 6, $22, $15, $1f
YPOS: .byte 5, 8, $e, 2, $11, $16
COLS: .byte 1, 2, 3, 4, 5, 7
//SEG2 @begin
bbegin:
//SEG3 @5
b5:
//SEG4 [0] call main param-assignment [ ] ( )
//SEG5 [1] phi from @5 to main [phi:@5->main]
main_from_b5:
jsr main
//SEG6 @end
bend:
//SEG7 main
main: {
//SEG8 [2] call initscreen param-assignment [ ] ( main:0 [ ] )
//SEG9 [85] phi from main to initscreen [phi:main->initscreen]
initscreen_from_main:
jsr initscreen
//SEG10 main::@1
b1:
//SEG11 [3] call render param-assignment [ ] ( main:0 [ ] )
//SEG12 [46] phi from main::@1 to render [phi:main::@1->render]
render_from_b1:
jsr render
//SEG13 main::@4
b4:
//SEG14 [4] call animate param-assignment [ ] ( main:0 [ ] )
jsr animate
//SEG15 main::@5
b5:
//SEG16 [5] if(true) goto main::@1 [ ] ( main:0 [ ] ) -- true_then_la1
jmp b1
//SEG17 main::@return
breturn:
//SEG18 [6] return [ ] ( main:0 [ ] )
rts
}
//SEG19 animate
animate: {
//SEG20 [7] (byte~) animate::$0 ← * (const byte[]) XPOS#0+(byte) 0 [ animate::$0 ] ( main:0::animate:4 [ animate::$0 ] ) -- aby=_deref_cowo1
lda XPOS+0
//SEG21 [8] (byte~) animate::$1 ← (byte~) animate::$0 + (byte) 1 [ animate::$1 ] ( main:0::animate:4 [ animate::$1 ] ) -- aby=aby_plus_1
clc
adc #1
//SEG22 [9] *((const byte[]) XPOS#0+(byte) 0) ← (byte~) animate::$1 [ ] ( main:0::animate:4 [ ] ) -- _deref_cowo1=aby
sta XPOS+0
//SEG23 [10] (byte~) animate::$2 ← * (const byte[]) XPOS#0+(byte) 0 [ animate::$2 ] ( main:0::animate:4 [ animate::$2 ] ) -- aby=_deref_cowo1
//SEG24 [11] if((byte~) animate::$2!=(byte) 40) goto animate::@1 [ ] ( main:0::animate:4 [ ] ) -- aby_neq_coby1_then_la1
cmp #$28
bne b1
//SEG25 animate::@7
b7:
//SEG26 [12] *((const byte[]) XPOS#0+(byte) 0) ← (byte) 0 [ ] ( main:0::animate:4 [ ] ) -- _deref_cowo1=coby2
lda #0
sta XPOS+0
//SEG27 animate::@1
b1:
//SEG28 [13] (byte~) animate::$5 ← * (const byte[]) YPOS#0+(byte) 0 [ animate::$5 ] ( main:0::animate:4 [ animate::$5 ] ) -- aby=_deref_cowo1
lda YPOS+0
//SEG29 [14] (byte~) animate::$6 ← (byte~) animate::$5 + (byte) 1 [ animate::$6 ] ( main:0::animate:4 [ animate::$6 ] ) -- aby=aby_plus_1
clc
adc #1
//SEG30 [15] *((const byte[]) YPOS#0+(byte) 0) ← (byte~) animate::$6 [ ] ( main:0::animate:4 [ ] ) -- _deref_cowo1=aby
sta YPOS+0
//SEG31 [16] (byte~) animate::$7 ← * (const byte[]) YPOS#0+(byte) 0 [ animate::$7 ] ( main:0::animate:4 [ animate::$7 ] ) -- aby=_deref_cowo1
//SEG32 [17] if((byte~) animate::$7!=(byte) 25) goto animate::@2 [ ] ( main:0::animate:4 [ ] ) -- aby_neq_coby1_then_la1
cmp #$19
bne b2
//SEG33 animate::@8
b8:
//SEG34 [18] *((const byte[]) YPOS#0+(byte) 0) ← (byte) 0 [ ] ( main:0::animate:4 [ ] ) -- _deref_cowo1=coby2
lda #0
sta YPOS+0
//SEG35 animate::@2
b2:
//SEG36 [19] (byte~) animate::$10 ← * (const byte[]) XPOS#0+(byte) 1 [ animate::$10 ] ( main:0::animate:4 [ animate::$10 ] ) -- xby=_deref_cowo1
ldx XPOS+1
//SEG37 [20] (byte~) animate::$11 ← (byte~) animate::$10 - (byte) 1 [ animate::$11 ] ( main:0::animate:4 [ animate::$11 ] ) -- xby=xby_minus_1
dex
//SEG38 [21] *((const byte[]) XPOS#0+(byte) 1) ← (byte~) animate::$11 [ ] ( main:0::animate:4 [ ] ) -- _deref_cowo1=xby
stx XPOS+1
//SEG39 [22] (byte~) animate::$12 ← * (const byte[]) XPOS#0+(byte) 1 [ animate::$12 ] ( main:0::animate:4 [ animate::$12 ] ) -- aby=_deref_cowo1
txa
//SEG40 [23] if((byte~) animate::$12!=(byte) 255) goto animate::@3 [ ] ( main:0::animate:4 [ ] ) -- aby_neq_coby1_then_la1
cmp #$ff
bne b3
//SEG41 animate::@9
b9:
//SEG42 [24] *((const byte[]) XPOS#0+(byte) 1) ← (byte) 40 [ ] ( main:0::animate:4 [ ] ) -- _deref_cowo1=coby2
lda #$28
sta XPOS+1
//SEG43 animate::@3
b3:
//SEG44 [25] (byte~) animate::$15 ← * (const byte[]) YPOS#0+(byte) 2 [ animate::$15 ] ( main:0::animate:4 [ animate::$15 ] ) -- aby=_deref_cowo1
lda YPOS+2
//SEG45 [26] (byte~) animate::$16 ← (byte~) animate::$15 + (byte) 1 [ animate::$16 ] ( main:0::animate:4 [ animate::$16 ] ) -- aby=aby_plus_1
clc
adc #1
//SEG46 [27] *((const byte[]) YPOS#0+(byte) 2) ← (byte~) animate::$16 [ ] ( main:0::animate:4 [ ] ) -- _deref_cowo1=aby
sta YPOS+2
//SEG47 [28] (byte~) animate::$17 ← * (const byte[]) YPOS#0+(byte) 2 [ animate::$17 ] ( main:0::animate:4 [ animate::$17 ] ) -- aby=_deref_cowo1
//SEG48 [29] if((byte~) animate::$17!=(byte) 25) goto animate::@4 [ ] ( main:0::animate:4 [ ] ) -- aby_neq_coby1_then_la1
cmp #$19
bne b4
//SEG49 animate::@10
b10:
//SEG50 [30] *((const byte[]) YPOS#0+(byte) 2) ← (byte) 0 [ ] ( main:0::animate:4 [ ] ) -- _deref_cowo1=coby2
lda #0
sta YPOS+2
//SEG51 animate::@4
b4:
//SEG52 [31] (byte~) animate::$20 ← * (const byte[]) YPOS#0+(byte) 3 [ animate::$20 ] ( main:0::animate:4 [ animate::$20 ] ) -- xby=_deref_cowo1
ldx YPOS+3
//SEG53 [32] (byte~) animate::$21 ← (byte~) animate::$20 - (byte) 1 [ animate::$21 ] ( main:0::animate:4 [ animate::$21 ] ) -- xby=xby_minus_1
dex
//SEG54 [33] *((const byte[]) YPOS#0+(byte) 3) ← (byte~) animate::$21 [ ] ( main:0::animate:4 [ ] ) -- _deref_cowo1=xby
stx YPOS+3
//SEG55 [34] (byte~) animate::$22 ← * (const byte[]) YPOS#0+(byte) 3 [ animate::$22 ] ( main:0::animate:4 [ animate::$22 ] ) -- aby=_deref_cowo1
txa
//SEG56 [35] if((byte~) animate::$22!=(byte) 255) goto animate::@return [ ] ( main:0::animate:4 [ ] ) -- aby_neq_coby1_then_la1
cmp #$ff
bne breturn
//SEG57 animate::@11
b11:
//SEG58 [36] *((const byte[]) YPOS#0+(byte) 3) ← (byte) 25 [ ] ( main:0::animate:4 [ ] ) -- _deref_cowo1=coby2
lda #$19
sta YPOS+3
//SEG59 [37] (byte~) animate::$25 ← * (const byte[]) XPOS#0+(byte) 3 [ animate::$25 ] ( main:0::animate:4 [ animate::$25 ] ) -- aby=_deref_cowo1
lda XPOS+3
//SEG60 [38] (byte~) animate::$26 ← (byte~) animate::$25 + (byte) 7 [ animate::$26 ] ( main:0::animate:4 [ animate::$26 ] ) -- aby=aby_plus_coby1
clc
adc #7
//SEG61 [39] *((const byte[]) XPOS#0+(byte) 3) ← (byte~) animate::$26 [ ] ( main:0::animate:4 [ ] ) -- _deref_cowo1=aby
sta XPOS+3
//SEG62 [40] (byte~) animate::$27 ← * (const byte[]) XPOS#0+(byte) 3 [ animate::$27 ] ( main:0::animate:4 [ animate::$27 ] ) -- aby=_deref_cowo1
//SEG63 [41] if((byte~) animate::$27<(byte) 40) goto animate::@return [ ] ( main:0::animate:4 [ ] ) -- aby_lt_coby1_then_la1
cmp #$28
bcc breturn
//SEG64 animate::@12
b12:
//SEG65 [42] (byte~) animate::$30 ← * (const byte[]) XPOS#0+(byte) 3 [ animate::$30 ] ( main:0::animate:4 [ animate::$30 ] ) -- aby=_deref_cowo1
lda XPOS+3
//SEG66 [43] (byte~) animate::$31 ← (byte~) animate::$30 - (byte) 40 [ animate::$31 ] ( main:0::animate:4 [ animate::$31 ] ) -- aby=aby_minus_coby1
sec
sbc #$28
//SEG67 [44] *((const byte[]) XPOS#0+(byte) 3) ← (byte~) animate::$31 [ ] ( main:0::animate:4 [ ] ) -- _deref_cowo1=aby
sta XPOS+3
//SEG68 animate::@return
breturn:
//SEG69 [45] return [ ] ( main:0::animate:4 [ ] )
rts
}
//SEG70 render
render: {
.label x = 5
.label colline = 3
.label y = 2
//SEG71 [47] phi from render to render::@1 [phi:render->render::@1]
b1_from_render:
//SEG72 [47] phi (byte*) render::colline#5 = (const byte*) COLORS#0 [phi:render->render::@1#0] -- zpptrby1=cowo1
lda #<COLORS
sta colline
lda #>COLORS
sta colline+1
//SEG73 [47] phi (byte) render::y#4 = (byte) 0 [phi:render->render::@1#1] -- zpby1=coby1
lda #0
sta y
jmp b1
//SEG74 [47] phi from render::@3 to render::@1 [phi:render::@3->render::@1]
b1_from_b3:
//SEG75 [47] phi (byte*) render::colline#5 = (byte*) render::colline#1 [phi:render::@3->render::@1#0] -- register_copy
//SEG76 [47] phi (byte) render::y#4 = (byte) render::y#1 [phi:render::@3->render::@1#1] -- register_copy
//SEG77 render::@1
b1:
//SEG78 [48] phi from render::@1 to render::@2 [phi:render::@1->render::@2]
b2_from_b1:
//SEG79 [48] phi (byte) render::x#2 = (byte) 0 [phi:render::@1->render::@2#0] -- zpby1=coby1
lda #0
sta x
jmp b2
//SEG80 [48] phi from render::@5 to render::@2 [phi:render::@5->render::@2]
b2_from_b5:
//SEG81 [48] phi (byte) render::x#2 = (byte) render::x#1 [phi:render::@5->render::@2#0] -- register_copy
//SEG82 render::@2
b2:
//SEG83 [49] (byte) findcol::x#0 ← (byte) render::x#2 [ render::y#4 render::colline#5 render::x#2 findcol::x#0 ] ( main:0::render:3 [ render::y#4 render::colline#5 render::x#2 findcol::x#0 ] )
// (byte) findcol::x#0 = (byte) render::x#2 // register copy zp ZP_BYTE:5
//SEG84 [50] (byte) findcol::y#0 ← (byte) render::y#4 [ render::y#4 render::colline#5 render::x#2 findcol::x#0 findcol::y#0 ] ( main:0::render:3 [ render::y#4 render::colline#5 render::x#2 findcol::x#0 findcol::y#0 ] )
// (byte) findcol::y#0 = (byte) render::y#4 // register copy zp ZP_BYTE:2
//SEG85 [51] call findcol param-assignment [ render::y#4 render::colline#5 render::x#2 findcol::return#0 ] ( main:0::render:3 [ render::y#4 render::colline#5 render::x#2 findcol::return#0 ] )
//SEG86 [60] phi from render::@2 to findcol [phi:render::@2->findcol]
findcol_from_b2:
jsr findcol
//SEG87 render::@5
b5:
//SEG88 [52] (byte) render::col#0 ← (byte) findcol::return#0 [ render::y#4 render::colline#5 render::x#2 render::col#0 ] ( main:0::render:3 [ render::y#4 render::colline#5 render::x#2 render::col#0 ] ) -- aby=yby
tya
//SEG89 [53] *((byte*) render::colline#5 + (byte) render::x#2) ← (byte) render::col#0 [ render::y#4 render::colline#5 render::x#2 ] ( main:0::render:3 [ render::y#4 render::colline#5 render::x#2 ] ) -- zpptrby1_derefidx_zpby1=aby
ldy x
sta (colline),y
//SEG90 [54] (byte) render::x#1 ← ++ (byte) render::x#2 [ render::y#4 render::colline#5 render::x#1 ] ( main:0::render:3 [ render::y#4 render::colline#5 render::x#1 ] ) -- zpby1=_inc_zpby1
inc x
//SEG91 [55] if((byte) render::x#1!=(byte) 40) goto render::@2 [ render::y#4 render::colline#5 render::x#1 ] ( main:0::render:3 [ render::y#4 render::colline#5 render::x#1 ] ) -- zpby1_neq_coby1_then_la1
lda x
cmp #$28
bne b2_from_b5
//SEG92 render::@3
b3:
//SEG93 [56] (byte*) render::colline#1 ← (byte*) render::colline#5 + (byte) 40 [ render::y#4 render::colline#1 ] ( main:0::render:3 [ render::y#4 render::colline#1 ] ) -- zpptrby1=zpptrby1_plus_coby1
lda colline
clc
adc #$28
sta colline
bcc !+
inc colline+1
!:
//SEG94 [57] (byte) render::y#1 ← ++ (byte) render::y#4 [ render::y#1 render::colline#1 ] ( main:0::render:3 [ render::y#1 render::colline#1 ] ) -- zpby1=_inc_zpby1
inc y
//SEG95 [58] if((byte) render::y#1!=(byte) 25) goto render::@1 [ render::y#1 render::colline#1 ] ( main:0::render:3 [ render::y#1 render::colline#1 ] ) -- zpby1_neq_coby1_then_la1
lda y
cmp #$19
bne b1_from_b3
//SEG96 render::@return
breturn:
//SEG97 [59] return [ ] ( main:0::render:3 [ ] )
rts
}
//SEG98 findcol
findcol: {
.label x = 5
.label y = 2
.label xp = 7
.label yp = 8
.label diff = 7
.label mindiff = 6
//SEG99 [61] phi from findcol to findcol::@1 [phi:findcol->findcol::@1]
b1_from_findcol:
//SEG100 [61] phi (byte) findcol::mincol#10 = (byte) 0 [phi:findcol->findcol::@1#0] -- yby=coby1
ldy #0
//SEG101 [61] phi (byte) findcol::mindiff#10 = (byte) 255 [phi:findcol->findcol::@1#1] -- zpby1=coby1
lda #$ff
sta mindiff
//SEG102 [61] phi (byte) findcol::i#10 = (byte) 0 [phi:findcol->findcol::@1#2] -- xby=coby1
ldx #0
//SEG103 findcol::@1
b1:
//SEG104 [62] (byte) findcol::xp#0 ← (const byte[]) XPOS#0 *idx (byte) findcol::i#10 [ findcol::x#0 findcol::y#0 findcol::i#10 findcol::mindiff#10 findcol::mincol#10 findcol::xp#0 ] ( main:0::render:3::findcol:51 [ render::y#4 render::colline#5 render::x#2 findcol::x#0 findcol::y#0 findcol::i#10 findcol::mindiff#10 findcol::mincol#10 findcol::xp#0 ] ) -- zpby1=cowo1_derefidx_xby
lda XPOS,x
sta xp
//SEG105 [63] (byte) findcol::yp#0 ← (const byte[]) YPOS#0 *idx (byte) findcol::i#10 [ findcol::x#0 findcol::y#0 findcol::i#10 findcol::mindiff#10 findcol::mincol#10 findcol::xp#0 findcol::yp#0 ] ( main:0::render:3::findcol:51 [ render::y#4 render::colline#5 render::x#2 findcol::x#0 findcol::y#0 findcol::i#10 findcol::mindiff#10 findcol::mincol#10 findcol::xp#0 findcol::yp#0 ] ) -- zpby1=cowo1_derefidx_xby
lda YPOS,x
sta yp
//SEG106 [64] if((byte) findcol::x#0!=(byte) findcol::xp#0) goto findcol::@2 [ findcol::x#0 findcol::y#0 findcol::i#10 findcol::mindiff#10 findcol::mincol#10 findcol::xp#0 findcol::yp#0 ] ( main:0::render:3::findcol:51 [ render::y#4 render::colline#5 render::x#2 findcol::x#0 findcol::y#0 findcol::i#10 findcol::mindiff#10 findcol::mincol#10 findcol::xp#0 findcol::yp#0 ] ) -- zpby1_neq_zpby2_then_la1
lda x
cmp xp
bne b2
//SEG107 findcol::@9
b9:
//SEG108 [65] if((byte) findcol::y#0!=(byte) findcol::yp#0) goto findcol::@2 [ findcol::x#0 findcol::y#0 findcol::i#10 findcol::mindiff#10 findcol::mincol#10 findcol::xp#0 findcol::yp#0 ] ( main:0::render:3::findcol:51 [ render::y#4 render::colline#5 render::x#2 findcol::x#0 findcol::y#0 findcol::i#10 findcol::mindiff#10 findcol::mincol#10 findcol::xp#0 findcol::yp#0 ] ) -- zpby1_neq_zpby2_then_la1
lda y
cmp yp
bne b2
//SEG109 [66] phi from findcol::@9 to findcol::@return [phi:findcol::@9->findcol::@return]
breturn_from_b9:
//SEG110 [66] phi (byte) findcol::return#0 = (byte) 0 [phi:findcol::@9->findcol::@return#0] -- yby=coby1
ldy #0
//SEG111 findcol::@return
breturn:
//SEG112 [67] return [ findcol::return#0 ] ( main:0::render:3::findcol:51 [ render::y#4 render::colline#5 render::x#2 findcol::return#0 ] )
rts
//SEG113 findcol::@2
b2:
//SEG114 [68] if((byte) findcol::x#0>=(byte) findcol::xp#0) goto findcol::@4 [ findcol::x#0 findcol::y#0 findcol::i#10 findcol::mindiff#10 findcol::mincol#10 findcol::xp#0 findcol::yp#0 ] ( main:0::render:3::findcol:51 [ render::y#4 render::colline#5 render::x#2 findcol::x#0 findcol::y#0 findcol::i#10 findcol::mindiff#10 findcol::mincol#10 findcol::xp#0 findcol::yp#0 ] ) -- zpby1_ge_zpby2_then_la1
lda x
cmp xp
bcs b4
//SEG115 findcol::@12
b12:
//SEG116 [69] (byte) findcol::diff#1 ← (byte) findcol::xp#0 - (byte) findcol::x#0 [ findcol::x#0 findcol::y#0 findcol::i#10 findcol::mindiff#10 findcol::mincol#10 findcol::yp#0 findcol::diff#1 ] ( main:0::render:3::findcol:51 [ render::y#4 render::colline#5 render::x#2 findcol::x#0 findcol::y#0 findcol::i#10 findcol::mindiff#10 findcol::mincol#10 findcol::yp#0 findcol::diff#1 ] ) -- zpby1=zpby1_minus_zpby2
lda diff
sec
sbc x
sta diff
//SEG117 [70] phi from findcol::@12 findcol::@4 to findcol::@5 [phi:findcol::@12/findcol::@4->findcol::@5]
b5_from_b12:
b5_from_b4:
//SEG118 [70] phi (byte) findcol::diff#4 = (byte) findcol::diff#1 [phi:findcol::@12/findcol::@4->findcol::@5#0] -- register_copy
//SEG119 findcol::@5
b5:
//SEG120 [71] if((byte) findcol::y#0>=(byte) findcol::yp#0) goto findcol::@6 [ findcol::x#0 findcol::y#0 findcol::i#10 findcol::mindiff#10 findcol::mincol#10 findcol::yp#0 findcol::diff#4 ] ( main:0::render:3::findcol:51 [ render::y#4 render::colline#5 render::x#2 findcol::x#0 findcol::y#0 findcol::i#10 findcol::mindiff#10 findcol::mincol#10 findcol::yp#0 findcol::diff#4 ] ) -- zpby1_ge_zpby2_then_la1
lda y
cmp yp
bcs b6
//SEG121 findcol::@14
b14:
//SEG122 [72] (byte~) findcol::$12 ← (byte) findcol::yp#0 - (byte) findcol::y#0 [ findcol::x#0 findcol::y#0 findcol::i#10 findcol::mindiff#10 findcol::mincol#10 findcol::diff#4 findcol::$12 ] ( main:0::render:3::findcol:51 [ render::y#4 render::colline#5 render::x#2 findcol::x#0 findcol::y#0 findcol::i#10 findcol::mindiff#10 findcol::mincol#10 findcol::diff#4 findcol::$12 ] ) -- aby=zpby1_minus_zpby2
lda yp
sec
sbc y
//SEG123 [73] (byte) findcol::diff#3 ← (byte) findcol::diff#4 + (byte~) findcol::$12 [ findcol::x#0 findcol::y#0 findcol::i#10 findcol::mindiff#10 findcol::mincol#10 findcol::diff#3 ] ( main:0::render:3::findcol:51 [ render::y#4 render::colline#5 render::x#2 findcol::x#0 findcol::y#0 findcol::i#10 findcol::mindiff#10 findcol::mincol#10 findcol::diff#3 ] ) -- aby=zpby1_plus_aby
clc
adc diff
//SEG124 [74] phi from findcol::@14 findcol::@6 to findcol::@7 [phi:findcol::@14/findcol::@6->findcol::@7]
b7_from_b14:
b7_from_b6:
//SEG125 [74] phi (byte) findcol::diff#6 = (byte) findcol::diff#3 [phi:findcol::@14/findcol::@6->findcol::@7#0] -- register_copy
//SEG126 findcol::@7
b7:
//SEG127 [75] if((byte) findcol::diff#6>=(byte) findcol::mindiff#10) goto findcol::@21 [ findcol::x#0 findcol::y#0 findcol::i#10 findcol::mindiff#10 findcol::mincol#10 findcol::diff#6 ] ( main:0::render:3::findcol:51 [ render::y#4 render::colline#5 render::x#2 findcol::x#0 findcol::y#0 findcol::i#10 findcol::mindiff#10 findcol::mincol#10 findcol::diff#6 ] ) -- aby_ge_zpby1_then_la1
cmp mindiff
bcs b21
//SEG128 findcol::@16
b16:
//SEG129 [76] (byte) findcol::mincol#1 ← (const byte[]) COLS#0 *idx (byte) findcol::i#10 [ findcol::x#0 findcol::y#0 findcol::i#10 findcol::diff#6 findcol::mincol#1 ] ( main:0::render:3::findcol:51 [ render::y#4 render::colline#5 render::x#2 findcol::x#0 findcol::y#0 findcol::i#10 findcol::diff#6 findcol::mincol#1 ] ) -- yby=cowo1_derefidx_xby
ldy COLS,x
//SEG130 [77] phi from findcol::@16 findcol::@21 to findcol::@8 [phi:findcol::@16/findcol::@21->findcol::@8]
b8_from_b16:
b8_from_b21:
//SEG131 [77] phi (byte) findcol::mindiff#11 = (byte) findcol::diff#6 [phi:findcol::@16/findcol::@21->findcol::@8#0] -- register_copy
//SEG132 [77] phi (byte) findcol::mincol#2 = (byte) findcol::mincol#1 [phi:findcol::@16/findcol::@21->findcol::@8#1] -- register_copy
//SEG133 findcol::@8
b8:
//SEG134 [78] (byte) findcol::i#1 ← ++ (byte) findcol::i#10 [ findcol::x#0 findcol::y#0 findcol::i#1 findcol::mincol#2 findcol::mindiff#11 ] ( main:0::render:3::findcol:51 [ render::y#4 render::colline#5 render::x#2 findcol::x#0 findcol::y#0 findcol::i#1 findcol::mincol#2 findcol::mindiff#11 ] ) -- xby=_inc_xby
inx
//SEG135 [79] if((byte) findcol::i#1<(const byte) numpoints#0) goto findcol::@19 [ findcol::x#0 findcol::y#0 findcol::i#1 findcol::mincol#2 findcol::mindiff#11 ] ( main:0::render:3::findcol:51 [ render::y#4 render::colline#5 render::x#2 findcol::x#0 findcol::y#0 findcol::i#1 findcol::mincol#2 findcol::mindiff#11 ] ) -- xby_lt_coby1_then_la1
cpx #numpoints
bcc b19
//SEG136 [66] phi from findcol::@8 to findcol::@return [phi:findcol::@8->findcol::@return]
breturn_from_b8:
//SEG137 [66] phi (byte) findcol::return#0 = (byte) findcol::mincol#2 [phi:findcol::@8->findcol::@return#0] -- register_copy
jmp breturn
//SEG138 findcol::@19
b19:
//SEG139 [80] (byte~) findcol::mindiff#13 ← (byte) findcol::mindiff#11 [ findcol::x#0 findcol::y#0 findcol::i#1 findcol::mindiff#13 findcol::mincol#2 ] ( main:0::render:3::findcol:51 [ render::y#4 render::colline#5 render::x#2 findcol::x#0 findcol::y#0 findcol::i#1 findcol::mindiff#13 findcol::mincol#2 ] ) -- zpby1=aby
sta mindiff
//SEG140 [61] phi from findcol::@19 to findcol::@1 [phi:findcol::@19->findcol::@1]
b1_from_b19:
//SEG141 [61] phi (byte) findcol::mincol#10 = (byte) findcol::mincol#2 [phi:findcol::@19->findcol::@1#0] -- register_copy
//SEG142 [61] phi (byte) findcol::mindiff#10 = (byte~) findcol::mindiff#13 [phi:findcol::@19->findcol::@1#1] -- register_copy
//SEG143 [61] phi (byte) findcol::i#10 = (byte) findcol::i#1 [phi:findcol::@19->findcol::@1#2] -- register_copy
jmp b1
//SEG144 findcol::@21
b21:
//SEG145 [81] (byte~) findcol::mindiff#14 ← (byte) findcol::mindiff#10 [ findcol::x#0 findcol::y#0 findcol::i#10 findcol::mincol#10 findcol::mindiff#14 ] ( main:0::render:3::findcol:51 [ render::y#4 render::colline#5 render::x#2 findcol::x#0 findcol::y#0 findcol::i#10 findcol::mincol#10 findcol::mindiff#14 ] ) -- aby=zpby1
lda mindiff
jmp b8_from_b21
//SEG146 findcol::@6
b6:
//SEG147 [82] (byte~) findcol::$14 ← (byte) findcol::y#0 - (byte) findcol::yp#0 [ findcol::x#0 findcol::y#0 findcol::i#10 findcol::mindiff#10 findcol::mincol#10 findcol::diff#4 findcol::$14 ] ( main:0::render:3::findcol:51 [ render::y#4 render::colline#5 render::x#2 findcol::x#0 findcol::y#0 findcol::i#10 findcol::mindiff#10 findcol::mincol#10 findcol::diff#4 findcol::$14 ] ) -- aby=zpby1_minus_zpby2
lda y
sec
sbc yp
//SEG148 [83] (byte) findcol::diff#2 ← (byte) findcol::diff#4 + (byte~) findcol::$14 [ findcol::x#0 findcol::y#0 findcol::i#10 findcol::mindiff#10 findcol::mincol#10 findcol::diff#2 ] ( main:0::render:3::findcol:51 [ render::y#4 render::colline#5 render::x#2 findcol::x#0 findcol::y#0 findcol::i#10 findcol::mindiff#10 findcol::mincol#10 findcol::diff#2 ] ) -- aby=zpby1_plus_aby
clc
adc diff
jmp b7_from_b6
//SEG149 findcol::@4
b4:
//SEG150 [84] (byte) findcol::diff#0 ← (byte) findcol::x#0 - (byte) findcol::xp#0 [ findcol::x#0 findcol::y#0 findcol::i#10 findcol::mindiff#10 findcol::mincol#10 findcol::yp#0 findcol::diff#0 ] ( main:0::render:3::findcol:51 [ render::y#4 render::colline#5 render::x#2 findcol::x#0 findcol::y#0 findcol::i#10 findcol::mindiff#10 findcol::mincol#10 findcol::yp#0 findcol::diff#0 ] ) -- zpby1=zpby2_minus_zpby1
lda x
sec
sbc diff
sta diff
jmp b5_from_b4
}
//SEG151 initscreen
initscreen: {
.label screen = 3
//SEG152 [86] phi from initscreen to initscreen::@1 [phi:initscreen->initscreen::@1]
b1_from_initscreen:
//SEG153 [86] phi (byte*) initscreen::screen#2 = (const byte*) SCREEN#0 [phi:initscreen->initscreen::@1#0] -- zpptrby1=cowo1
lda #<SCREEN
sta screen
lda #>SCREEN
sta screen+1
jmp b1
//SEG154 [86] phi from initscreen::@1 to initscreen::@1 [phi:initscreen::@1->initscreen::@1]
b1_from_b1:
//SEG155 [86] phi (byte*) initscreen::screen#2 = (byte*) initscreen::screen#1 [phi:initscreen::@1->initscreen::@1#0] -- register_copy
//SEG156 initscreen::@1
b1:
//SEG157 [87] *((byte*) initscreen::screen#2) ← (const byte) FILL#0 [ initscreen::screen#2 ] ( main:0::initscreen:2 [ initscreen::screen#2 ] ) -- _deref_zpptrby1=coby1
ldy #0
lda #FILL
sta (screen),y
//SEG158 [88] (byte*) initscreen::screen#1 ← ++ (byte*) initscreen::screen#2 [ initscreen::screen#1 ] ( main:0::initscreen:2 [ initscreen::screen#1 ] ) -- zpptrby1=_inc_zpptrby1
inc screen
bne !+
inc screen+1
!:
//SEG159 [89] if((byte*) initscreen::screen#1<(const byte*) SCREEN#0+(word) 1000) goto initscreen::@1 [ initscreen::screen#1 ] ( main:0::initscreen:2 [ initscreen::screen#1 ] ) -- zpptrby1_lt_cowo1_then_la1
lda screen+1
cmp #>SCREEN+$3e8
bcc b1_from_b1
bne !+
lda screen
cmp #<SCREEN+$3e8
bcc b1_from_b1
!:
//SEG160 initscreen::@return
breturn:
//SEG161 [90] return [ ] ( main:0::initscreen:2 [ ] )
rts
}
Replacing label b2_from_b5 with b2
Replacing label b1_from_b3 with b1
Replacing label b8_from_b21 with b8
@ -8471,7 +8894,6 @@ animate: {
//SEG22 [9] *((const byte[]) XPOS#0+(byte) 0) ← (byte~) animate::$1 [ ] ( main:0::animate:4 [ ] ) -- _deref_cowo1=aby
sta XPOS+0
//SEG23 [10] (byte~) animate::$2 ← * (const byte[]) XPOS#0+(byte) 0 [ animate::$2 ] ( main:0::animate:4 [ animate::$2 ] ) -- aby=_deref_cowo1
lda XPOS+0
//SEG24 [11] if((byte~) animate::$2!=(byte) 40) goto animate::@1 [ ] ( main:0::animate:4 [ ] ) -- aby_neq_coby1_then_la1
cmp #$28
bne b1
@ -8490,7 +8912,6 @@ animate: {
//SEG30 [15] *((const byte[]) YPOS#0+(byte) 0) ← (byte~) animate::$6 [ ] ( main:0::animate:4 [ ] ) -- _deref_cowo1=aby
sta YPOS+0
//SEG31 [16] (byte~) animate::$7 ← * (const byte[]) YPOS#0+(byte) 0 [ animate::$7 ] ( main:0::animate:4 [ animate::$7 ] ) -- aby=_deref_cowo1
lda YPOS+0
//SEG32 [17] if((byte~) animate::$7!=(byte) 25) goto animate::@2 [ ] ( main:0::animate:4 [ ] ) -- aby_neq_coby1_then_la1
cmp #$19
bne b2
@ -8508,7 +8929,7 @@ animate: {
//SEG38 [21] *((const byte[]) XPOS#0+(byte) 1) ← (byte~) animate::$11 [ ] ( main:0::animate:4 [ ] ) -- _deref_cowo1=xby
stx XPOS+1
//SEG39 [22] (byte~) animate::$12 ← * (const byte[]) XPOS#0+(byte) 1 [ animate::$12 ] ( main:0::animate:4 [ animate::$12 ] ) -- aby=_deref_cowo1
lda XPOS+1
txa
//SEG40 [23] if((byte~) animate::$12!=(byte) 255) goto animate::@3 [ ] ( main:0::animate:4 [ ] ) -- aby_neq_coby1_then_la1
cmp #$ff
bne b3
@ -8527,7 +8948,6 @@ animate: {
//SEG46 [27] *((const byte[]) YPOS#0+(byte) 2) ← (byte~) animate::$16 [ ] ( main:0::animate:4 [ ] ) -- _deref_cowo1=aby
sta YPOS+2
//SEG47 [28] (byte~) animate::$17 ← * (const byte[]) YPOS#0+(byte) 2 [ animate::$17 ] ( main:0::animate:4 [ animate::$17 ] ) -- aby=_deref_cowo1
lda YPOS+2
//SEG48 [29] if((byte~) animate::$17!=(byte) 25) goto animate::@4 [ ] ( main:0::animate:4 [ ] ) -- aby_neq_coby1_then_la1
cmp #$19
bne b4
@ -8545,7 +8965,7 @@ animate: {
//SEG54 [33] *((const byte[]) YPOS#0+(byte) 3) ← (byte~) animate::$21 [ ] ( main:0::animate:4 [ ] ) -- _deref_cowo1=xby
stx YPOS+3
//SEG55 [34] (byte~) animate::$22 ← * (const byte[]) YPOS#0+(byte) 3 [ animate::$22 ] ( main:0::animate:4 [ animate::$22 ] ) -- aby=_deref_cowo1
lda YPOS+3
txa
//SEG56 [35] if((byte~) animate::$22!=(byte) 255) goto animate::@return [ ] ( main:0::animate:4 [ ] ) -- aby_neq_coby1_then_la1
cmp #$ff
bne breturn
@ -8562,7 +8982,6 @@ animate: {
//SEG61 [39] *((const byte[]) XPOS#0+(byte) 3) ← (byte~) animate::$26 [ ] ( main:0::animate:4 [ ] ) -- _deref_cowo1=aby
sta XPOS+3
//SEG62 [40] (byte~) animate::$27 ← * (const byte[]) XPOS#0+(byte) 3 [ animate::$27 ] ( main:0::animate:4 [ animate::$27 ] ) -- aby=_deref_cowo1
lda XPOS+3
//SEG63 [41] if((byte~) animate::$27<(byte) 40) goto animate::@return [ ] ( main:0::animate:4 [ ] ) -- aby_lt_coby1_then_la1
cmp #$28
bcc breturn
@ -8900,7 +9319,6 @@ animate: {
//SEG22 [9] *((const byte[]) XPOS#0+(byte) 0) ← (byte~) animate::$1 [ ] ( main:0::animate:4 [ ] ) -- _deref_cowo1=aby
sta XPOS+0
//SEG23 [10] (byte~) animate::$2 ← * (const byte[]) XPOS#0+(byte) 0 [ animate::$2 ] ( main:0::animate:4 [ animate::$2 ] ) -- aby=_deref_cowo1
lda XPOS+0
//SEG24 [11] if((byte~) animate::$2!=(byte) 40) goto animate::@1 [ ] ( main:0::animate:4 [ ] ) -- aby_neq_coby1_then_la1
cmp #$28
bne b1
@ -8918,7 +9336,6 @@ animate: {
//SEG30 [15] *((const byte[]) YPOS#0+(byte) 0) ← (byte~) animate::$6 [ ] ( main:0::animate:4 [ ] ) -- _deref_cowo1=aby
sta YPOS+0
//SEG31 [16] (byte~) animate::$7 ← * (const byte[]) YPOS#0+(byte) 0 [ animate::$7 ] ( main:0::animate:4 [ animate::$7 ] ) -- aby=_deref_cowo1
lda YPOS+0
//SEG32 [17] if((byte~) animate::$7!=(byte) 25) goto animate::@2 [ ] ( main:0::animate:4 [ ] ) -- aby_neq_coby1_then_la1
cmp #$19
bne b2
@ -8935,7 +9352,7 @@ animate: {
//SEG38 [21] *((const byte[]) XPOS#0+(byte) 1) ← (byte~) animate::$11 [ ] ( main:0::animate:4 [ ] ) -- _deref_cowo1=xby
stx XPOS+1
//SEG39 [22] (byte~) animate::$12 ← * (const byte[]) XPOS#0+(byte) 1 [ animate::$12 ] ( main:0::animate:4 [ animate::$12 ] ) -- aby=_deref_cowo1
lda XPOS+1
txa
//SEG40 [23] if((byte~) animate::$12!=(byte) 255) goto animate::@3 [ ] ( main:0::animate:4 [ ] ) -- aby_neq_coby1_then_la1
cmp #$ff
bne b3
@ -8953,7 +9370,6 @@ animate: {
//SEG46 [27] *((const byte[]) YPOS#0+(byte) 2) ← (byte~) animate::$16 [ ] ( main:0::animate:4 [ ] ) -- _deref_cowo1=aby
sta YPOS+2
//SEG47 [28] (byte~) animate::$17 ← * (const byte[]) YPOS#0+(byte) 2 [ animate::$17 ] ( main:0::animate:4 [ animate::$17 ] ) -- aby=_deref_cowo1
lda YPOS+2
//SEG48 [29] if((byte~) animate::$17!=(byte) 25) goto animate::@4 [ ] ( main:0::animate:4 [ ] ) -- aby_neq_coby1_then_la1
cmp #$19
bne b4
@ -8970,7 +9386,7 @@ animate: {
//SEG54 [33] *((const byte[]) YPOS#0+(byte) 3) ← (byte~) animate::$21 [ ] ( main:0::animate:4 [ ] ) -- _deref_cowo1=xby
stx YPOS+3
//SEG55 [34] (byte~) animate::$22 ← * (const byte[]) YPOS#0+(byte) 3 [ animate::$22 ] ( main:0::animate:4 [ animate::$22 ] ) -- aby=_deref_cowo1
lda YPOS+3
txa
//SEG56 [35] if((byte~) animate::$22!=(byte) 255) goto animate::@return [ ] ( main:0::animate:4 [ ] ) -- aby_neq_coby1_then_la1
cmp #$ff
bne breturn
@ -8986,7 +9402,6 @@ animate: {
//SEG61 [39] *((const byte[]) XPOS#0+(byte) 3) ← (byte~) animate::$26 [ ] ( main:0::animate:4 [ ] ) -- _deref_cowo1=aby
sta XPOS+3
//SEG62 [40] (byte~) animate::$27 ← * (const byte[]) XPOS#0+(byte) 3 [ animate::$27 ] ( main:0::animate:4 [ animate::$27 ] ) -- aby=_deref_cowo1
lda XPOS+3
//SEG63 [41] if((byte~) animate::$27<(byte) 40) goto animate::@return [ ] ( main:0::animate:4 [ ] ) -- aby_lt_coby1_then_la1
cmp #$28
bcc breturn
@ -9284,7 +9699,6 @@ animate: {
//SEG22 [9] *((const byte[]) XPOS#0+(byte) 0) ← (byte~) animate::$1 [ ] ( main:0::animate:4 [ ] ) -- _deref_cowo1=aby
sta XPOS+0
//SEG23 [10] (byte~) animate::$2 ← * (const byte[]) XPOS#0+(byte) 0 [ animate::$2 ] ( main:0::animate:4 [ animate::$2 ] ) -- aby=_deref_cowo1
lda XPOS+0
//SEG24 [11] if((byte~) animate::$2!=(byte) 40) goto animate::@1 [ ] ( main:0::animate:4 [ ] ) -- aby_neq_coby1_then_la1
cmp #$28
bne b1
@ -9302,7 +9716,6 @@ animate: {
//SEG30 [15] *((const byte[]) YPOS#0+(byte) 0) ← (byte~) animate::$6 [ ] ( main:0::animate:4 [ ] ) -- _deref_cowo1=aby
sta YPOS+0
//SEG31 [16] (byte~) animate::$7 ← * (const byte[]) YPOS#0+(byte) 0 [ animate::$7 ] ( main:0::animate:4 [ animate::$7 ] ) -- aby=_deref_cowo1
lda YPOS+0
//SEG32 [17] if((byte~) animate::$7!=(byte) 25) goto animate::@2 [ ] ( main:0::animate:4 [ ] ) -- aby_neq_coby1_then_la1
cmp #$19
bne b2
@ -9319,7 +9732,7 @@ animate: {
//SEG38 [21] *((const byte[]) XPOS#0+(byte) 1) ← (byte~) animate::$11 [ ] ( main:0::animate:4 [ ] ) -- _deref_cowo1=xby
stx XPOS+1
//SEG39 [22] (byte~) animate::$12 ← * (const byte[]) XPOS#0+(byte) 1 [ animate::$12 ] ( main:0::animate:4 [ animate::$12 ] ) -- aby=_deref_cowo1
lda XPOS+1
txa
//SEG40 [23] if((byte~) animate::$12!=(byte) 255) goto animate::@3 [ ] ( main:0::animate:4 [ ] ) -- aby_neq_coby1_then_la1
cmp #$ff
bne b3
@ -9337,7 +9750,6 @@ animate: {
//SEG46 [27] *((const byte[]) YPOS#0+(byte) 2) ← (byte~) animate::$16 [ ] ( main:0::animate:4 [ ] ) -- _deref_cowo1=aby
sta YPOS+2
//SEG47 [28] (byte~) animate::$17 ← * (const byte[]) YPOS#0+(byte) 2 [ animate::$17 ] ( main:0::animate:4 [ animate::$17 ] ) -- aby=_deref_cowo1
lda YPOS+2
//SEG48 [29] if((byte~) animate::$17!=(byte) 25) goto animate::@4 [ ] ( main:0::animate:4 [ ] ) -- aby_neq_coby1_then_la1
cmp #$19
bne b4
@ -9354,7 +9766,7 @@ animate: {
//SEG54 [33] *((const byte[]) YPOS#0+(byte) 3) ← (byte~) animate::$21 [ ] ( main:0::animate:4 [ ] ) -- _deref_cowo1=xby
stx YPOS+3
//SEG55 [34] (byte~) animate::$22 ← * (const byte[]) YPOS#0+(byte) 3 [ animate::$22 ] ( main:0::animate:4 [ animate::$22 ] ) -- aby=_deref_cowo1
lda YPOS+3
txa
//SEG56 [35] if((byte~) animate::$22!=(byte) 255) goto animate::@return [ ] ( main:0::animate:4 [ ] ) -- aby_neq_coby1_then_la1
cmp #$ff
bne breturn
@ -9370,7 +9782,6 @@ animate: {
//SEG61 [39] *((const byte[]) XPOS#0+(byte) 3) ← (byte~) animate::$26 [ ] ( main:0::animate:4 [ ] ) -- _deref_cowo1=aby
sta XPOS+3
//SEG62 [40] (byte~) animate::$27 ← * (const byte[]) XPOS#0+(byte) 3 [ animate::$27 ] ( main:0::animate:4 [ animate::$27 ] ) -- aby=_deref_cowo1
lda XPOS+3
//SEG63 [41] if((byte~) animate::$27<(byte) 40) goto animate::@return [ ] ( main:0::animate:4 [ ] ) -- aby_lt_coby1_then_la1
cmp #$28
bcc breturn
@ -9612,6 +10023,380 @@ initscreen: {
rts
}
Removing instruction lda XPOS+3
Succesful ASM optimization Pass5UnnecesaryLoadElimination
ASSEMBLER
//SEG0 Basic Upstart
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
//SEG1 Global Constants & labels
.const SCREEN = $400
.const COLORS = $d800
.const FILL = $e6
.const numpoints = 6
XPOS: .byte 5, $f, 6, $22, $15, $1f
YPOS: .byte 5, 8, $e, 2, $11, $16
COLS: .byte 1, 2, 3, 4, 5, 7
//SEG2 @begin
//SEG3 @5
//SEG4 [0] call main param-assignment [ ] ( )
//SEG5 [1] phi from @5 to main [phi:@5->main]
jsr main
//SEG6 @end
//SEG7 main
main: {
//SEG8 [2] call initscreen param-assignment [ ] ( main:0 [ ] )
//SEG9 [85] phi from main to initscreen [phi:main->initscreen]
jsr initscreen
//SEG10 main::@1
b1:
//SEG11 [3] call render param-assignment [ ] ( main:0 [ ] )
//SEG12 [46] phi from main::@1 to render [phi:main::@1->render]
jsr render
//SEG13 main::@4
//SEG14 [4] call animate param-assignment [ ] ( main:0 [ ] )
jsr animate
//SEG15 main::@5
//SEG16 [5] if(true) goto main::@1 [ ] ( main:0 [ ] ) -- true_then_la1
jmp b1
//SEG17 main::@return
//SEG18 [6] return [ ] ( main:0 [ ] )
rts
}
//SEG19 animate
animate: {
//SEG20 [7] (byte~) animate::$0 ← * (const byte[]) XPOS#0+(byte) 0 [ animate::$0 ] ( main:0::animate:4 [ animate::$0 ] ) -- aby=_deref_cowo1
lda XPOS+0
//SEG21 [8] (byte~) animate::$1 ← (byte~) animate::$0 + (byte) 1 [ animate::$1 ] ( main:0::animate:4 [ animate::$1 ] ) -- aby=aby_plus_1
clc
adc #1
//SEG22 [9] *((const byte[]) XPOS#0+(byte) 0) ← (byte~) animate::$1 [ ] ( main:0::animate:4 [ ] ) -- _deref_cowo1=aby
sta XPOS+0
//SEG23 [10] (byte~) animate::$2 ← * (const byte[]) XPOS#0+(byte) 0 [ animate::$2 ] ( main:0::animate:4 [ animate::$2 ] ) -- aby=_deref_cowo1
//SEG24 [11] if((byte~) animate::$2!=(byte) 40) goto animate::@1 [ ] ( main:0::animate:4 [ ] ) -- aby_neq_coby1_then_la1
cmp #$28
bne b1
//SEG25 animate::@7
//SEG26 [12] *((const byte[]) XPOS#0+(byte) 0) ← (byte) 0 [ ] ( main:0::animate:4 [ ] ) -- _deref_cowo1=coby2
lda #0
sta XPOS+0
//SEG27 animate::@1
b1:
//SEG28 [13] (byte~) animate::$5 ← * (const byte[]) YPOS#0+(byte) 0 [ animate::$5 ] ( main:0::animate:4 [ animate::$5 ] ) -- aby=_deref_cowo1
lda YPOS+0
//SEG29 [14] (byte~) animate::$6 ← (byte~) animate::$5 + (byte) 1 [ animate::$6 ] ( main:0::animate:4 [ animate::$6 ] ) -- aby=aby_plus_1
clc
adc #1
//SEG30 [15] *((const byte[]) YPOS#0+(byte) 0) ← (byte~) animate::$6 [ ] ( main:0::animate:4 [ ] ) -- _deref_cowo1=aby
sta YPOS+0
//SEG31 [16] (byte~) animate::$7 ← * (const byte[]) YPOS#0+(byte) 0 [ animate::$7 ] ( main:0::animate:4 [ animate::$7 ] ) -- aby=_deref_cowo1
//SEG32 [17] if((byte~) animate::$7!=(byte) 25) goto animate::@2 [ ] ( main:0::animate:4 [ ] ) -- aby_neq_coby1_then_la1
cmp #$19
bne b2
//SEG33 animate::@8
//SEG34 [18] *((const byte[]) YPOS#0+(byte) 0) ← (byte) 0 [ ] ( main:0::animate:4 [ ] ) -- _deref_cowo1=coby2
lda #0
sta YPOS+0
//SEG35 animate::@2
b2:
//SEG36 [19] (byte~) animate::$10 ← * (const byte[]) XPOS#0+(byte) 1 [ animate::$10 ] ( main:0::animate:4 [ animate::$10 ] ) -- xby=_deref_cowo1
ldx XPOS+1
//SEG37 [20] (byte~) animate::$11 ← (byte~) animate::$10 - (byte) 1 [ animate::$11 ] ( main:0::animate:4 [ animate::$11 ] ) -- xby=xby_minus_1
dex
//SEG38 [21] *((const byte[]) XPOS#0+(byte) 1) ← (byte~) animate::$11 [ ] ( main:0::animate:4 [ ] ) -- _deref_cowo1=xby
stx XPOS+1
//SEG39 [22] (byte~) animate::$12 ← * (const byte[]) XPOS#0+(byte) 1 [ animate::$12 ] ( main:0::animate:4 [ animate::$12 ] ) -- aby=_deref_cowo1
txa
//SEG40 [23] if((byte~) animate::$12!=(byte) 255) goto animate::@3 [ ] ( main:0::animate:4 [ ] ) -- aby_neq_coby1_then_la1
cmp #$ff
bne b3
//SEG41 animate::@9
//SEG42 [24] *((const byte[]) XPOS#0+(byte) 1) ← (byte) 40 [ ] ( main:0::animate:4 [ ] ) -- _deref_cowo1=coby2
lda #$28
sta XPOS+1
//SEG43 animate::@3
b3:
//SEG44 [25] (byte~) animate::$15 ← * (const byte[]) YPOS#0+(byte) 2 [ animate::$15 ] ( main:0::animate:4 [ animate::$15 ] ) -- aby=_deref_cowo1
lda YPOS+2
//SEG45 [26] (byte~) animate::$16 ← (byte~) animate::$15 + (byte) 1 [ animate::$16 ] ( main:0::animate:4 [ animate::$16 ] ) -- aby=aby_plus_1
clc
adc #1
//SEG46 [27] *((const byte[]) YPOS#0+(byte) 2) ← (byte~) animate::$16 [ ] ( main:0::animate:4 [ ] ) -- _deref_cowo1=aby
sta YPOS+2
//SEG47 [28] (byte~) animate::$17 ← * (const byte[]) YPOS#0+(byte) 2 [ animate::$17 ] ( main:0::animate:4 [ animate::$17 ] ) -- aby=_deref_cowo1
//SEG48 [29] if((byte~) animate::$17!=(byte) 25) goto animate::@4 [ ] ( main:0::animate:4 [ ] ) -- aby_neq_coby1_then_la1
cmp #$19
bne b4
//SEG49 animate::@10
//SEG50 [30] *((const byte[]) YPOS#0+(byte) 2) ← (byte) 0 [ ] ( main:0::animate:4 [ ] ) -- _deref_cowo1=coby2
lda #0
sta YPOS+2
//SEG51 animate::@4
b4:
//SEG52 [31] (byte~) animate::$20 ← * (const byte[]) YPOS#0+(byte) 3 [ animate::$20 ] ( main:0::animate:4 [ animate::$20 ] ) -- xby=_deref_cowo1
ldx YPOS+3
//SEG53 [32] (byte~) animate::$21 ← (byte~) animate::$20 - (byte) 1 [ animate::$21 ] ( main:0::animate:4 [ animate::$21 ] ) -- xby=xby_minus_1
dex
//SEG54 [33] *((const byte[]) YPOS#0+(byte) 3) ← (byte~) animate::$21 [ ] ( main:0::animate:4 [ ] ) -- _deref_cowo1=xby
stx YPOS+3
//SEG55 [34] (byte~) animate::$22 ← * (const byte[]) YPOS#0+(byte) 3 [ animate::$22 ] ( main:0::animate:4 [ animate::$22 ] ) -- aby=_deref_cowo1
txa
//SEG56 [35] if((byte~) animate::$22!=(byte) 255) goto animate::@return [ ] ( main:0::animate:4 [ ] ) -- aby_neq_coby1_then_la1
cmp #$ff
bne breturn
//SEG57 animate::@11
//SEG58 [36] *((const byte[]) YPOS#0+(byte) 3) ← (byte) 25 [ ] ( main:0::animate:4 [ ] ) -- _deref_cowo1=coby2
lda #$19
sta YPOS+3
//SEG59 [37] (byte~) animate::$25 ← * (const byte[]) XPOS#0+(byte) 3 [ animate::$25 ] ( main:0::animate:4 [ animate::$25 ] ) -- aby=_deref_cowo1
lda XPOS+3
//SEG60 [38] (byte~) animate::$26 ← (byte~) animate::$25 + (byte) 7 [ animate::$26 ] ( main:0::animate:4 [ animate::$26 ] ) -- aby=aby_plus_coby1
clc
adc #7
//SEG61 [39] *((const byte[]) XPOS#0+(byte) 3) ← (byte~) animate::$26 [ ] ( main:0::animate:4 [ ] ) -- _deref_cowo1=aby
sta XPOS+3
//SEG62 [40] (byte~) animate::$27 ← * (const byte[]) XPOS#0+(byte) 3 [ animate::$27 ] ( main:0::animate:4 [ animate::$27 ] ) -- aby=_deref_cowo1
//SEG63 [41] if((byte~) animate::$27<(byte) 40) goto animate::@return [ ] ( main:0::animate:4 [ ] ) -- aby_lt_coby1_then_la1
cmp #$28
bcc breturn
//SEG64 animate::@12
//SEG65 [42] (byte~) animate::$30 ← * (const byte[]) XPOS#0+(byte) 3 [ animate::$30 ] ( main:0::animate:4 [ animate::$30 ] ) -- aby=_deref_cowo1
//SEG66 [43] (byte~) animate::$31 ← (byte~) animate::$30 - (byte) 40 [ animate::$31 ] ( main:0::animate:4 [ animate::$31 ] ) -- aby=aby_minus_coby1
sec
sbc #$28
//SEG67 [44] *((const byte[]) XPOS#0+(byte) 3) ← (byte~) animate::$31 [ ] ( main:0::animate:4 [ ] ) -- _deref_cowo1=aby
sta XPOS+3
//SEG68 animate::@return
breturn:
//SEG69 [45] return [ ] ( main:0::animate:4 [ ] )
rts
}
//SEG70 render
render: {
.label x = 5
.label colline = 3
.label y = 2
//SEG71 [47] phi from render to render::@1 [phi:render->render::@1]
//SEG72 [47] phi (byte*) render::colline#5 = (const byte*) COLORS#0 [phi:render->render::@1#0] -- zpptrby1=cowo1
lda #<COLORS
sta colline
lda #>COLORS
sta colline+1
//SEG73 [47] phi (byte) render::y#4 = (byte) 0 [phi:render->render::@1#1] -- zpby1=coby1
lda #0
sta y
//SEG74 [47] phi from render::@3 to render::@1 [phi:render::@3->render::@1]
//SEG75 [47] phi (byte*) render::colline#5 = (byte*) render::colline#1 [phi:render::@3->render::@1#0] -- register_copy
//SEG76 [47] phi (byte) render::y#4 = (byte) render::y#1 [phi:render::@3->render::@1#1] -- register_copy
//SEG77 render::@1
b1:
//SEG78 [48] phi from render::@1 to render::@2 [phi:render::@1->render::@2]
//SEG79 [48] phi (byte) render::x#2 = (byte) 0 [phi:render::@1->render::@2#0] -- zpby1=coby1
lda #0
sta x
//SEG80 [48] phi from render::@5 to render::@2 [phi:render::@5->render::@2]
//SEG81 [48] phi (byte) render::x#2 = (byte) render::x#1 [phi:render::@5->render::@2#0] -- register_copy
//SEG82 render::@2
b2:
//SEG83 [49] (byte) findcol::x#0 ← (byte) render::x#2 [ render::y#4 render::colline#5 render::x#2 findcol::x#0 ] ( main:0::render:3 [ render::y#4 render::colline#5 render::x#2 findcol::x#0 ] )
// (byte) findcol::x#0 = (byte) render::x#2 // register copy zp ZP_BYTE:5
//SEG84 [50] (byte) findcol::y#0 ← (byte) render::y#4 [ render::y#4 render::colline#5 render::x#2 findcol::x#0 findcol::y#0 ] ( main:0::render:3 [ render::y#4 render::colline#5 render::x#2 findcol::x#0 findcol::y#0 ] )
// (byte) findcol::y#0 = (byte) render::y#4 // register copy zp ZP_BYTE:2
//SEG85 [51] call findcol param-assignment [ render::y#4 render::colline#5 render::x#2 findcol::return#0 ] ( main:0::render:3 [ render::y#4 render::colline#5 render::x#2 findcol::return#0 ] )
//SEG86 [60] phi from render::@2 to findcol [phi:render::@2->findcol]
jsr findcol
//SEG87 render::@5
//SEG88 [52] (byte) render::col#0 ← (byte) findcol::return#0 [ render::y#4 render::colline#5 render::x#2 render::col#0 ] ( main:0::render:3 [ render::y#4 render::colline#5 render::x#2 render::col#0 ] ) -- aby=yby
tya
//SEG89 [53] *((byte*) render::colline#5 + (byte) render::x#2) ← (byte) render::col#0 [ render::y#4 render::colline#5 render::x#2 ] ( main:0::render:3 [ render::y#4 render::colline#5 render::x#2 ] ) -- zpptrby1_derefidx_zpby1=aby
ldy x
sta (colline),y
//SEG90 [54] (byte) render::x#1 ← ++ (byte) render::x#2 [ render::y#4 render::colline#5 render::x#1 ] ( main:0::render:3 [ render::y#4 render::colline#5 render::x#1 ] ) -- zpby1=_inc_zpby1
inc x
//SEG91 [55] if((byte) render::x#1!=(byte) 40) goto render::@2 [ render::y#4 render::colline#5 render::x#1 ] ( main:0::render:3 [ render::y#4 render::colline#5 render::x#1 ] ) -- zpby1_neq_coby1_then_la1
lda x
cmp #$28
bne b2
//SEG92 render::@3
//SEG93 [56] (byte*) render::colline#1 ← (byte*) render::colline#5 + (byte) 40 [ render::y#4 render::colline#1 ] ( main:0::render:3 [ render::y#4 render::colline#1 ] ) -- zpptrby1=zpptrby1_plus_coby1
lda colline
clc
adc #$28
sta colline
bcc !+
inc colline+1
!:
//SEG94 [57] (byte) render::y#1 ← ++ (byte) render::y#4 [ render::y#1 render::colline#1 ] ( main:0::render:3 [ render::y#1 render::colline#1 ] ) -- zpby1=_inc_zpby1
inc y
//SEG95 [58] if((byte) render::y#1!=(byte) 25) goto render::@1 [ render::y#1 render::colline#1 ] ( main:0::render:3 [ render::y#1 render::colline#1 ] ) -- zpby1_neq_coby1_then_la1
lda y
cmp #$19
bne b1
//SEG96 render::@return
//SEG97 [59] return [ ] ( main:0::render:3 [ ] )
rts
}
//SEG98 findcol
findcol: {
.label x = 5
.label y = 2
.label xp = 7
.label yp = 8
.label diff = 7
.label mindiff = 6
//SEG99 [61] phi from findcol to findcol::@1 [phi:findcol->findcol::@1]
//SEG100 [61] phi (byte) findcol::mincol#10 = (byte) 0 [phi:findcol->findcol::@1#0] -- yby=coby1
ldy #0
//SEG101 [61] phi (byte) findcol::mindiff#10 = (byte) 255 [phi:findcol->findcol::@1#1] -- zpby1=coby1
lda #$ff
sta mindiff
//SEG102 [61] phi (byte) findcol::i#10 = (byte) 0 [phi:findcol->findcol::@1#2] -- xby=coby1
ldx #0
//SEG103 findcol::@1
b1:
//SEG104 [62] (byte) findcol::xp#0 ← (const byte[]) XPOS#0 *idx (byte) findcol::i#10 [ findcol::x#0 findcol::y#0 findcol::i#10 findcol::mindiff#10 findcol::mincol#10 findcol::xp#0 ] ( main:0::render:3::findcol:51 [ render::y#4 render::colline#5 render::x#2 findcol::x#0 findcol::y#0 findcol::i#10 findcol::mindiff#10 findcol::mincol#10 findcol::xp#0 ] ) -- zpby1=cowo1_derefidx_xby
lda XPOS,x
sta xp
//SEG105 [63] (byte) findcol::yp#0 ← (const byte[]) YPOS#0 *idx (byte) findcol::i#10 [ findcol::x#0 findcol::y#0 findcol::i#10 findcol::mindiff#10 findcol::mincol#10 findcol::xp#0 findcol::yp#0 ] ( main:0::render:3::findcol:51 [ render::y#4 render::colline#5 render::x#2 findcol::x#0 findcol::y#0 findcol::i#10 findcol::mindiff#10 findcol::mincol#10 findcol::xp#0 findcol::yp#0 ] ) -- zpby1=cowo1_derefidx_xby
lda YPOS,x
sta yp
//SEG106 [64] if((byte) findcol::x#0!=(byte) findcol::xp#0) goto findcol::@2 [ findcol::x#0 findcol::y#0 findcol::i#10 findcol::mindiff#10 findcol::mincol#10 findcol::xp#0 findcol::yp#0 ] ( main:0::render:3::findcol:51 [ render::y#4 render::colline#5 render::x#2 findcol::x#0 findcol::y#0 findcol::i#10 findcol::mindiff#10 findcol::mincol#10 findcol::xp#0 findcol::yp#0 ] ) -- zpby1_neq_zpby2_then_la1
lda x
cmp xp
bne b2
//SEG107 findcol::@9
//SEG108 [65] if((byte) findcol::y#0!=(byte) findcol::yp#0) goto findcol::@2 [ findcol::x#0 findcol::y#0 findcol::i#10 findcol::mindiff#10 findcol::mincol#10 findcol::xp#0 findcol::yp#0 ] ( main:0::render:3::findcol:51 [ render::y#4 render::colline#5 render::x#2 findcol::x#0 findcol::y#0 findcol::i#10 findcol::mindiff#10 findcol::mincol#10 findcol::xp#0 findcol::yp#0 ] ) -- zpby1_neq_zpby2_then_la1
lda y
cmp yp
bne b2
//SEG109 [66] phi from findcol::@9 to findcol::@return [phi:findcol::@9->findcol::@return]
//SEG110 [66] phi (byte) findcol::return#0 = (byte) 0 [phi:findcol::@9->findcol::@return#0] -- yby=coby1
ldy #0
//SEG111 findcol::@return
breturn:
//SEG112 [67] return [ findcol::return#0 ] ( main:0::render:3::findcol:51 [ render::y#4 render::colline#5 render::x#2 findcol::return#0 ] )
rts
//SEG113 findcol::@2
b2:
//SEG114 [68] if((byte) findcol::x#0>=(byte) findcol::xp#0) goto findcol::@4 [ findcol::x#0 findcol::y#0 findcol::i#10 findcol::mindiff#10 findcol::mincol#10 findcol::xp#0 findcol::yp#0 ] ( main:0::render:3::findcol:51 [ render::y#4 render::colline#5 render::x#2 findcol::x#0 findcol::y#0 findcol::i#10 findcol::mindiff#10 findcol::mincol#10 findcol::xp#0 findcol::yp#0 ] ) -- zpby1_ge_zpby2_then_la1
lda x
cmp xp
bcs b4
//SEG115 findcol::@12
//SEG116 [69] (byte) findcol::diff#1 ← (byte) findcol::xp#0 - (byte) findcol::x#0 [ findcol::x#0 findcol::y#0 findcol::i#10 findcol::mindiff#10 findcol::mincol#10 findcol::yp#0 findcol::diff#1 ] ( main:0::render:3::findcol:51 [ render::y#4 render::colline#5 render::x#2 findcol::x#0 findcol::y#0 findcol::i#10 findcol::mindiff#10 findcol::mincol#10 findcol::yp#0 findcol::diff#1 ] ) -- zpby1=zpby1_minus_zpby2
lda diff
sec
sbc x
sta diff
//SEG117 [70] phi from findcol::@12 findcol::@4 to findcol::@5 [phi:findcol::@12/findcol::@4->findcol::@5]
//SEG118 [70] phi (byte) findcol::diff#4 = (byte) findcol::diff#1 [phi:findcol::@12/findcol::@4->findcol::@5#0] -- register_copy
//SEG119 findcol::@5
b5:
//SEG120 [71] if((byte) findcol::y#0>=(byte) findcol::yp#0) goto findcol::@6 [ findcol::x#0 findcol::y#0 findcol::i#10 findcol::mindiff#10 findcol::mincol#10 findcol::yp#0 findcol::diff#4 ] ( main:0::render:3::findcol:51 [ render::y#4 render::colline#5 render::x#2 findcol::x#0 findcol::y#0 findcol::i#10 findcol::mindiff#10 findcol::mincol#10 findcol::yp#0 findcol::diff#4 ] ) -- zpby1_ge_zpby2_then_la1
lda y
cmp yp
bcs b6
//SEG121 findcol::@14
//SEG122 [72] (byte~) findcol::$12 ← (byte) findcol::yp#0 - (byte) findcol::y#0 [ findcol::x#0 findcol::y#0 findcol::i#10 findcol::mindiff#10 findcol::mincol#10 findcol::diff#4 findcol::$12 ] ( main:0::render:3::findcol:51 [ render::y#4 render::colline#5 render::x#2 findcol::x#0 findcol::y#0 findcol::i#10 findcol::mindiff#10 findcol::mincol#10 findcol::diff#4 findcol::$12 ] ) -- aby=zpby1_minus_zpby2
lda yp
sec
sbc y
//SEG123 [73] (byte) findcol::diff#3 ← (byte) findcol::diff#4 + (byte~) findcol::$12 [ findcol::x#0 findcol::y#0 findcol::i#10 findcol::mindiff#10 findcol::mincol#10 findcol::diff#3 ] ( main:0::render:3::findcol:51 [ render::y#4 render::colline#5 render::x#2 findcol::x#0 findcol::y#0 findcol::i#10 findcol::mindiff#10 findcol::mincol#10 findcol::diff#3 ] ) -- aby=zpby1_plus_aby
clc
adc diff
//SEG124 [74] phi from findcol::@14 findcol::@6 to findcol::@7 [phi:findcol::@14/findcol::@6->findcol::@7]
//SEG125 [74] phi (byte) findcol::diff#6 = (byte) findcol::diff#3 [phi:findcol::@14/findcol::@6->findcol::@7#0] -- register_copy
//SEG126 findcol::@7
b7:
//SEG127 [75] if((byte) findcol::diff#6>=(byte) findcol::mindiff#10) goto findcol::@21 [ findcol::x#0 findcol::y#0 findcol::i#10 findcol::mindiff#10 findcol::mincol#10 findcol::diff#6 ] ( main:0::render:3::findcol:51 [ render::y#4 render::colline#5 render::x#2 findcol::x#0 findcol::y#0 findcol::i#10 findcol::mindiff#10 findcol::mincol#10 findcol::diff#6 ] ) -- aby_ge_zpby1_then_la1
cmp mindiff
bcs b21
//SEG128 findcol::@16
//SEG129 [76] (byte) findcol::mincol#1 ← (const byte[]) COLS#0 *idx (byte) findcol::i#10 [ findcol::x#0 findcol::y#0 findcol::i#10 findcol::diff#6 findcol::mincol#1 ] ( main:0::render:3::findcol:51 [ render::y#4 render::colline#5 render::x#2 findcol::x#0 findcol::y#0 findcol::i#10 findcol::diff#6 findcol::mincol#1 ] ) -- yby=cowo1_derefidx_xby
ldy COLS,x
//SEG130 [77] phi from findcol::@16 findcol::@21 to findcol::@8 [phi:findcol::@16/findcol::@21->findcol::@8]
//SEG131 [77] phi (byte) findcol::mindiff#11 = (byte) findcol::diff#6 [phi:findcol::@16/findcol::@21->findcol::@8#0] -- register_copy
//SEG132 [77] phi (byte) findcol::mincol#2 = (byte) findcol::mincol#1 [phi:findcol::@16/findcol::@21->findcol::@8#1] -- register_copy
//SEG133 findcol::@8
b8:
//SEG134 [78] (byte) findcol::i#1 ← ++ (byte) findcol::i#10 [ findcol::x#0 findcol::y#0 findcol::i#1 findcol::mincol#2 findcol::mindiff#11 ] ( main:0::render:3::findcol:51 [ render::y#4 render::colline#5 render::x#2 findcol::x#0 findcol::y#0 findcol::i#1 findcol::mincol#2 findcol::mindiff#11 ] ) -- xby=_inc_xby
inx
//SEG135 [79] if((byte) findcol::i#1<(const byte) numpoints#0) goto findcol::@19 [ findcol::x#0 findcol::y#0 findcol::i#1 findcol::mincol#2 findcol::mindiff#11 ] ( main:0::render:3::findcol:51 [ render::y#4 render::colline#5 render::x#2 findcol::x#0 findcol::y#0 findcol::i#1 findcol::mincol#2 findcol::mindiff#11 ] ) -- xby_lt_coby1_then_la1
cpx #numpoints
bcc b19
//SEG136 [66] phi from findcol::@8 to findcol::@return [phi:findcol::@8->findcol::@return]
//SEG137 [66] phi (byte) findcol::return#0 = (byte) findcol::mincol#2 [phi:findcol::@8->findcol::@return#0] -- register_copy
jmp breturn
//SEG138 findcol::@19
b19:
//SEG139 [80] (byte~) findcol::mindiff#13 ← (byte) findcol::mindiff#11 [ findcol::x#0 findcol::y#0 findcol::i#1 findcol::mindiff#13 findcol::mincol#2 ] ( main:0::render:3::findcol:51 [ render::y#4 render::colline#5 render::x#2 findcol::x#0 findcol::y#0 findcol::i#1 findcol::mindiff#13 findcol::mincol#2 ] ) -- zpby1=aby
sta mindiff
//SEG140 [61] phi from findcol::@19 to findcol::@1 [phi:findcol::@19->findcol::@1]
//SEG141 [61] phi (byte) findcol::mincol#10 = (byte) findcol::mincol#2 [phi:findcol::@19->findcol::@1#0] -- register_copy
//SEG142 [61] phi (byte) findcol::mindiff#10 = (byte~) findcol::mindiff#13 [phi:findcol::@19->findcol::@1#1] -- register_copy
//SEG143 [61] phi (byte) findcol::i#10 = (byte) findcol::i#1 [phi:findcol::@19->findcol::@1#2] -- register_copy
jmp b1
//SEG144 findcol::@21
b21:
//SEG145 [81] (byte~) findcol::mindiff#14 ← (byte) findcol::mindiff#10 [ findcol::x#0 findcol::y#0 findcol::i#10 findcol::mincol#10 findcol::mindiff#14 ] ( main:0::render:3::findcol:51 [ render::y#4 render::colline#5 render::x#2 findcol::x#0 findcol::y#0 findcol::i#10 findcol::mincol#10 findcol::mindiff#14 ] ) -- aby=zpby1
lda mindiff
jmp b8
//SEG146 findcol::@6
b6:
//SEG147 [82] (byte~) findcol::$14 ← (byte) findcol::y#0 - (byte) findcol::yp#0 [ findcol::x#0 findcol::y#0 findcol::i#10 findcol::mindiff#10 findcol::mincol#10 findcol::diff#4 findcol::$14 ] ( main:0::render:3::findcol:51 [ render::y#4 render::colline#5 render::x#2 findcol::x#0 findcol::y#0 findcol::i#10 findcol::mindiff#10 findcol::mincol#10 findcol::diff#4 findcol::$14 ] ) -- aby=zpby1_minus_zpby2
lda y
sec
sbc yp
//SEG148 [83] (byte) findcol::diff#2 ← (byte) findcol::diff#4 + (byte~) findcol::$14 [ findcol::x#0 findcol::y#0 findcol::i#10 findcol::mindiff#10 findcol::mincol#10 findcol::diff#2 ] ( main:0::render:3::findcol:51 [ render::y#4 render::colline#5 render::x#2 findcol::x#0 findcol::y#0 findcol::i#10 findcol::mindiff#10 findcol::mincol#10 findcol::diff#2 ] ) -- aby=zpby1_plus_aby
clc
adc diff
jmp b7
//SEG149 findcol::@4
b4:
//SEG150 [84] (byte) findcol::diff#0 ← (byte) findcol::x#0 - (byte) findcol::xp#0 [ findcol::x#0 findcol::y#0 findcol::i#10 findcol::mindiff#10 findcol::mincol#10 findcol::yp#0 findcol::diff#0 ] ( main:0::render:3::findcol:51 [ render::y#4 render::colline#5 render::x#2 findcol::x#0 findcol::y#0 findcol::i#10 findcol::mindiff#10 findcol::mincol#10 findcol::yp#0 findcol::diff#0 ] ) -- zpby1=zpby2_minus_zpby1
lda x
sec
sbc diff
sta diff
jmp b5
}
//SEG151 initscreen
initscreen: {
.label screen = 3
//SEG152 [86] phi from initscreen to initscreen::@1 [phi:initscreen->initscreen::@1]
//SEG153 [86] phi (byte*) initscreen::screen#2 = (const byte*) SCREEN#0 [phi:initscreen->initscreen::@1#0] -- zpptrby1=cowo1
lda #<SCREEN
sta screen
lda #>SCREEN
sta screen+1
//SEG154 [86] phi from initscreen::@1 to initscreen::@1 [phi:initscreen::@1->initscreen::@1]
//SEG155 [86] phi (byte*) initscreen::screen#2 = (byte*) initscreen::screen#1 [phi:initscreen::@1->initscreen::@1#0] -- register_copy
//SEG156 initscreen::@1
b1:
//SEG157 [87] *((byte*) initscreen::screen#2) ← (const byte) FILL#0 [ initscreen::screen#2 ] ( main:0::initscreen:2 [ initscreen::screen#2 ] ) -- _deref_zpptrby1=coby1
ldy #0
lda #FILL
sta (screen),y
//SEG158 [88] (byte*) initscreen::screen#1 ← ++ (byte*) initscreen::screen#2 [ initscreen::screen#1 ] ( main:0::initscreen:2 [ initscreen::screen#1 ] ) -- zpptrby1=_inc_zpptrby1
inc screen
bne !+
inc screen+1
!:
//SEG159 [89] if((byte*) initscreen::screen#1<(const byte*) SCREEN#0+(word) 1000) goto initscreen::@1 [ initscreen::screen#1 ] ( main:0::initscreen:2 [ initscreen::screen#1 ] ) -- zpptrby1_lt_cowo1_then_la1
lda screen+1
cmp #>SCREEN+$3e8
bcc b1
bne !+
lda screen
cmp #<SCREEN+$3e8
bcc b1
!:
//SEG160 initscreen::@return
//SEG161 [90] return [ ] ( main:0::initscreen:2 [ ] )
rts
}
FINAL SYMBOL TABLE
(label) @5
(label) @begin
@ -9819,7 +10604,6 @@ animate: {
//SEG22 [9] *((const byte[]) XPOS#0+(byte) 0) ← (byte~) animate::$1 [ ] ( main:0::animate:4 [ ] ) -- _deref_cowo1=aby
sta XPOS+0
//SEG23 [10] (byte~) animate::$2 ← * (const byte[]) XPOS#0+(byte) 0 [ animate::$2 ] ( main:0::animate:4 [ animate::$2 ] ) -- aby=_deref_cowo1
lda XPOS+0
//SEG24 [11] if((byte~) animate::$2!=(byte) 40) goto animate::@1 [ ] ( main:0::animate:4 [ ] ) -- aby_neq_coby1_then_la1
cmp #$28
bne b1
@ -9837,7 +10621,6 @@ animate: {
//SEG30 [15] *((const byte[]) YPOS#0+(byte) 0) ← (byte~) animate::$6 [ ] ( main:0::animate:4 [ ] ) -- _deref_cowo1=aby
sta YPOS+0
//SEG31 [16] (byte~) animate::$7 ← * (const byte[]) YPOS#0+(byte) 0 [ animate::$7 ] ( main:0::animate:4 [ animate::$7 ] ) -- aby=_deref_cowo1
lda YPOS+0
//SEG32 [17] if((byte~) animate::$7!=(byte) 25) goto animate::@2 [ ] ( main:0::animate:4 [ ] ) -- aby_neq_coby1_then_la1
cmp #$19
bne b2
@ -9854,7 +10637,7 @@ animate: {
//SEG38 [21] *((const byte[]) XPOS#0+(byte) 1) ← (byte~) animate::$11 [ ] ( main:0::animate:4 [ ] ) -- _deref_cowo1=xby
stx XPOS+1
//SEG39 [22] (byte~) animate::$12 ← * (const byte[]) XPOS#0+(byte) 1 [ animate::$12 ] ( main:0::animate:4 [ animate::$12 ] ) -- aby=_deref_cowo1
lda XPOS+1
txa
//SEG40 [23] if((byte~) animate::$12!=(byte) 255) goto animate::@3 [ ] ( main:0::animate:4 [ ] ) -- aby_neq_coby1_then_la1
cmp #$ff
bne b3
@ -9872,7 +10655,6 @@ animate: {
//SEG46 [27] *((const byte[]) YPOS#0+(byte) 2) ← (byte~) animate::$16 [ ] ( main:0::animate:4 [ ] ) -- _deref_cowo1=aby
sta YPOS+2
//SEG47 [28] (byte~) animate::$17 ← * (const byte[]) YPOS#0+(byte) 2 [ animate::$17 ] ( main:0::animate:4 [ animate::$17 ] ) -- aby=_deref_cowo1
lda YPOS+2
//SEG48 [29] if((byte~) animate::$17!=(byte) 25) goto animate::@4 [ ] ( main:0::animate:4 [ ] ) -- aby_neq_coby1_then_la1
cmp #$19
bne b4
@ -9889,7 +10671,7 @@ animate: {
//SEG54 [33] *((const byte[]) YPOS#0+(byte) 3) ← (byte~) animate::$21 [ ] ( main:0::animate:4 [ ] ) -- _deref_cowo1=xby
stx YPOS+3
//SEG55 [34] (byte~) animate::$22 ← * (const byte[]) YPOS#0+(byte) 3 [ animate::$22 ] ( main:0::animate:4 [ animate::$22 ] ) -- aby=_deref_cowo1
lda YPOS+3
txa
//SEG56 [35] if((byte~) animate::$22!=(byte) 255) goto animate::@return [ ] ( main:0::animate:4 [ ] ) -- aby_neq_coby1_then_la1
cmp #$ff
bne breturn
@ -9905,13 +10687,11 @@ animate: {
//SEG61 [39] *((const byte[]) XPOS#0+(byte) 3) ← (byte~) animate::$26 [ ] ( main:0::animate:4 [ ] ) -- _deref_cowo1=aby
sta XPOS+3
//SEG62 [40] (byte~) animate::$27 ← * (const byte[]) XPOS#0+(byte) 3 [ animate::$27 ] ( main:0::animate:4 [ animate::$27 ] ) -- aby=_deref_cowo1
lda XPOS+3
//SEG63 [41] if((byte~) animate::$27<(byte) 40) goto animate::@return [ ] ( main:0::animate:4 [ ] ) -- aby_lt_coby1_then_la1
cmp #$28
bcc breturn
//SEG64 animate::@12
//SEG65 [42] (byte~) animate::$30 ← * (const byte[]) XPOS#0+(byte) 3 [ animate::$30 ] ( main:0::animate:4 [ animate::$30 ] ) -- aby=_deref_cowo1
lda XPOS+3
//SEG66 [43] (byte~) animate::$31 ← (byte~) animate::$30 - (byte) 40 [ animate::$31 ] ( main:0::animate:4 [ animate::$31 ] ) -- aby=aby_minus_coby1
sec
sbc #$28