1
0
mirror of https://gitlab.com/camelot/kickc.git synced 2025-04-09 21:37:31 +00:00

Introduced Asm Segments which establish relation between ASM code and the generating ICL.

This commit is contained in:
jespergravgaard 2017-08-01 13:58:15 +02:00
parent 14c1f7e8eb
commit 323e10ab37
20 changed files with 1969 additions and 978 deletions

View File

@ -3,27 +3,52 @@ package dk.camelot64.kickc.asm;
import dk.camelot64.kickc.asm.parser.AsmClobber;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
/** A 6502 assembler program */
/**
* A 6502 assembler program
*/
public class AsmProgram {
private List<AsmLine> lines;
/**
* The segments of the program. The segments hold the ASM lines.
*/
private List<AsmSegment> segments;
private int nextIndex;
/**
* The index of the next segment.
*/
private int nextSegmentIndex;
/**
* The index of the next line.
*/
private int nextLineIndex;
public AsmProgram() {
this.lines = new ArrayList<>();
this.nextIndex = 0;
this.segments = new ArrayList<>();
this.nextLineIndex = 0;
this.nextSegmentIndex = 0;
}
public List<AsmLine> getLines() {
return lines;
public Collection<AsmSegment> getSegments() {
return segments;
}
public AsmSegment startSegment(Integer statementIndex, String source) {
AsmSegment segment = new AsmSegment(nextSegmentIndex++, statementIndex, source);
segments.add(segment);
return segment;
}
public AsmSegment getCurrentSegment() {
return segments.get(segments.size() - 1);
}
public void addLine(AsmLine line) {
line.setIndex(nextIndex++);
lines.add(line);
line.setIndex(nextLineIndex++);
getCurrentSegment().addLine(line);
}
public void addComment(String comment) {
@ -39,18 +64,53 @@ public class AsmProgram {
addLine(new AsmInstruction(instructionType, parameter));
}
/**
* Get the number of bytes the segment occupies in memory.
* Calculated by adding up the bytes of each ASM segment in the program.
*
* @return The number of bytes
*/
public int getBytes() {
int bytes = 0;
for (AsmSegment segment : segments) {
bytes += segment.getBytes();
}
return bytes;
}
/**
* Get the number of cycles it takes to execute the segment
* Calculated by adding up the cycles of each ASM segments in the program.
*
* @return The number of cycles
*/
public double getCycles() {
double cycles = 0.0;
for (AsmSegment segment : segments) {
cycles += segment.getCycles();
}
return cycles;
}
/**
* Get the CPU registers clobbered by the instructions of the fragment
*
* @return The clobbered registers
*/
public AsmClobber getClobber() {
AsmClobber clobber = new AsmClobber();
for (AsmSegment segment : segments) {
clobber.add(segment.getClobber());
}
return clobber;
}
public String toString(boolean comments) {
StringBuffer out = new StringBuffer();
for (AsmLine line : lines) {
if(line instanceof AsmComment && !comments) {
if(!((AsmComment) line).getComment().contains("Fragment")) {
continue;
}
}
if(line instanceof AsmComment || line instanceof AsmInstruction) {
out.append(" ");
}
out.append(line.getAsm()+"\n");
StringBuilder out = new StringBuilder();
for (AsmSegment segment : segments) {
out.append(segment.toString(comments));
}
return out.toString();
}
@ -60,19 +120,5 @@ public class AsmProgram {
return toString(true);
}
/**
* Get the CPU registers clobbered by the instructions of the fragment
* @return The clobbered registers
*/
public AsmClobber getClobber() {
AsmClobber clobber = new AsmClobber();
for (AsmLine line : lines) {
if(line instanceof AsmInstruction) {
AsmInstructionType instructionType = ((AsmInstruction) line).getType();
AsmClobber lineClobber = instructionType.getClobber();
clobber.add(lineClobber);
}
}
return clobber;
}
}

View File

@ -28,76 +28,83 @@ public class AsmProgramStaticRegisterValues {
private void initValues() {
AsmRegisterValues current = new AsmRegisterValues();
for (AsmLine line : program.getLines()) {
if (line instanceof AsmLabel) {
current = new AsmRegisterValues();
} else if (line instanceof AsmInstruction) {
AsmInstruction instruction = (AsmInstruction) line;
values.put(instruction, current);
current = new AsmRegisterValues(current);
AsmInstructionType instructionType = instruction.getType();
AsmClobber clobber = instructionType.getClobber();
if (clobber.isClobberA()) {
current.setA(null);
}
if (clobber.isClobberX()) {
current.setX(null);
}
if (clobber.isClobberY()) {
current.setY(null);
}
if (clobber.isClobberC()) {
current.setC(null);
}
if (clobber.isClobberN()) {
current.setN(null);
}
if (clobber.isClobberV()) {
current.setV(null);
}
if (clobber.isClobberZ()) {
current.setZ(null);
}
if (instructionType.getMnemnonic().equals("lda") && instructionType.getAddressingMode().equals(AsmAddressingMode.IMM)) {
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("ldx") && instructionType.getAddressingMode().equals(AsmAddressingMode.IMM)) {
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("ldy") && instructionType.getAddressingMode().equals(AsmAddressingMode.IMM)) {
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("sec")) {
current.setC(Boolean.TRUE);
}
if (instructionType.getMnemnonic().equals("clc")) {
current.setC(Boolean.FALSE);
}
for (AsmSegment segment : program.getSegments()) {
for (AsmLine line : segment.getLines()) {
current = updateStaticRegisterValues(current, line);
}
}
}
private AsmRegisterValues updateStaticRegisterValues(AsmRegisterValues current, AsmLine line) {
if (line instanceof AsmLabel) {
current = new AsmRegisterValues();
} else if (line instanceof AsmInstruction) {
AsmInstruction instruction = (AsmInstruction) line;
values.put(instruction, current);
current = new AsmRegisterValues(current);
AsmInstructionType instructionType = instruction.getType();
AsmClobber clobber = instructionType.getClobber();
if (clobber.isClobberA()) {
current.setA(null);
}
if (clobber.isClobberX()) {
current.setX(null);
}
if (clobber.isClobberY()) {
current.setY(null);
}
if (clobber.isClobberC()) {
current.setC(null);
}
if (clobber.isClobberN()) {
current.setN(null);
}
if (clobber.isClobberV()) {
current.setV(null);
}
if (clobber.isClobberZ()) {
current.setZ(null);
}
if (instructionType.getMnemnonic().equals("lda") && instructionType.getAddressingMode().equals(AsmAddressingMode.IMM)) {
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("ldx") && instructionType.getAddressingMode().equals(AsmAddressingMode.IMM)) {
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("ldy") && instructionType.getAddressingMode().equals(AsmAddressingMode.IMM)) {
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("sec")) {
current.setC(Boolean.TRUE);
}
if (instructionType.getMnemnonic().equals("clc")) {
current.setC(Boolean.FALSE);
}
}
return current;
}
/**
* Known values of registers/flags at an instruction. null where value is unknown.
*/

View File

@ -0,0 +1,147 @@
package dk.camelot64.kickc.asm;
import dk.camelot64.kickc.asm.parser.AsmClobber;
import java.util.ArrayList;
import java.util.List;
/**
* A segment of an ASM program. The segment has a number of methods/attributes that describe the lines of the segment.
* Typically each ICL statement becomes a single ASM segment through the AsmFragment subsystem.
*/
public class AsmSegment {
/**
* The lines of the segment.
*/
private List<AsmLine> lines;
/**
* Index of the segment.
*/
private int index;
/**
* Index of the ICL statement that the segment is generated from,
*/
private Integer statementIdx;
/**
* Readable name of the ICL source of the segment.
*/
private String source;
/**
* Readable name of the fragment used to generate the segment.
*/
private String fragment;
public AsmSegment(int index, Integer statementIdx, String source) {
this.lines = new ArrayList<>();
this.index = index;
this.statementIdx = statementIdx;
this.source = source;
}
public List<AsmLine> getLines() {
return lines;
}
public void addLine(AsmLine line) {
lines.add(line);
}
public int getIndex() {
return index;
}
public Integer getStatementIdx() {
return statementIdx;
}
public String getSource() {
return source;
}
public void setFragment(String fragment) {
this.fragment = fragment;
}
/**
* Get the number of bytes the segment occupies in memory.
* Per default calculated by adding up the bytes of each ASM line in the segment.
*
* @return The number of bytes
*/
public int getBytes() {
int bytes = 0;
for (AsmLine line : lines) {
bytes += line.getLineBytes();
}
return bytes;
}
/**
* Get the number of cycles it takes to execute the segment
* Per default calculated by adding up the cycles of each ASM line in the segment.
*
* @return The number of cycles
*/
public double getCycles() {
double cycles = 0.0;
for (AsmLine line : lines) {
cycles += line.getLineCycles();
}
return cycles;
}
/**
* Get the registers clobbered when executing the segment
* Per default calculated by adding up the clobber of each ASM line in the segment.
*
* @return The registers clobbered
*/
public AsmClobber getClobber() {
AsmClobber clobber = new AsmClobber();
for (AsmLine line : lines) {
if (line instanceof AsmInstruction) {
clobber.add(((AsmInstruction) line).getType().getClobber());
}
}
return clobber;
}
public String toString(boolean comments) {
StringBuffer out = new StringBuffer();
if (comments) {
out.append("//SEG").append(getIndex());
if (source != null) {
out.append(" ").append(source);
}
if (fragment!=null) {
out.append(" -- ");
out.append(fragment).append(" ");
}
out.append("\n");
}
for (AsmLine line : lines) {
if (line instanceof AsmComment && !comments) {
if (!((AsmComment) line).getComment().contains("Fragment")) {
continue;
}
}
if (line instanceof AsmComment || line instanceof AsmInstruction) {
out.append(" ");
}
out.append(line.getAsm() + "\n");
}
return out.toString();
}
@Override
public String toString() {
return toString(true);
}
}

View File

@ -25,7 +25,7 @@ public class Program {
/** Information about loops. */
private NaturalLoopSet loopSet;
/** The register allocation for the vairalbes used during ASM code generation. */
/** The register allocation for the variables used during ASM code generation. */
private RegisterAllocation allocation;
/** The live ranges of all variables. */
private LiveRangeVariables liveRangeVariables;

View File

@ -54,7 +54,7 @@ public class Pass3AssertNoCpuClobber extends Pass2Base {
continue;
}
if(aliveVarRegister.equals(register)) {
registerCycles += countCycles(asm);
registerCycles += asm.getCycles();
}
if(assignedVars.contains(aliveVar)) {
// No need to register that is assigned by the statement - it will be clobbered
@ -77,17 +77,6 @@ public class Pass3AssertNoCpuClobber extends Pass2Base {
return clobberProblem;
}
private int countCycles(AsmProgram asm) {
int instructionCycles = 0;
for (AsmLine asmLine : asm.getLines()) {
if(asmLine instanceof AsmInstruction) {
double lineCycles = ((AsmInstruction) asmLine).getType().getCycles();
instructionCycles += lineCycles;
}
}
return instructionCycles;
}
/**
* Get the variables assigned to by a specific statement

View File

@ -31,6 +31,7 @@ public class Pass4CodeGeneration {
// Generate entry points (if needed)
genBlockEntryPoints(asm, block);
// Generate label
asm.startSegment(null, block.getLabel().getFullName());
asm.addLabel(block.getLabel().getFullName().replace('@', 'B').replace(':', '_'));
// Generate statements
genStatements(asm, block);
@ -51,7 +52,9 @@ public class Pass4CodeGeneration {
AsmCodegenAluState aluState = new AsmCodegenAluState();
while (statementsIt.hasNext()) {
Statement statement = statementsIt.next();
generateStatementAsm(asm, block, statement, aluState);
if(!(statement instanceof StatementPhiBlock)) {
generateStatementAsm(asm, block, statement, aluState);
}
}
}
@ -66,6 +69,8 @@ public class Pass4CodeGeneration {
*/
public void generateStatementAsm(AsmProgram asm, ControlFlowBlock block, Statement statement, AsmCodegenAluState aluState) {
asm.startSegment(statement.getIndex(), statement.toString(program));
// IF the previous statement was added to the ALU register - generate the composite ASM fragment
if (aluState.hasAluAssignment()) {
StatementAssignment assignmentAlu = aluState.getAluAssignment();
@ -74,7 +79,7 @@ public class Pass4CodeGeneration {
}
StatementAssignment assignment = (StatementAssignment) statement;
AsmFragment asmFragment = new AsmFragment(assignment, assignmentAlu, program);
asm.addComment(statement.toString(program) + " // " + asmFragment.getSignature());
asm.getCurrentSegment().setFragment(asmFragment.getSignature());
asmFragment.generate(asm);
aluState.clear();
return;
@ -100,13 +105,13 @@ public class Pass4CodeGeneration {
asm.addComment(lValue.toString(program) + " = " + assignment.getrValue2().toString(program) + " // register copy " + getRegister(lValue));
} else {
AsmFragment asmFragment = new AsmFragment(assignment, program);
asm.addComment(statement.toString(program) + " // " + asmFragment.getSignature());
asm.getCurrentSegment().setFragment(asmFragment.getSignature());
asmFragment.generate(asm);
}
}
} else if (statement instanceof StatementConditionalJump) {
AsmFragment asmFragment = new AsmFragment((StatementConditionalJump) statement, block, program, getGraph());
asm.addComment(statement.toString(program) + " // " + asmFragment.getSignature());
asm.getCurrentSegment().setFragment(asmFragment.getSignature());
asmFragment.generate(asm);
} else if (statement instanceof StatementCall) {
StatementCall call = (StatementCall) statement;
@ -168,6 +173,8 @@ public class Pass4CodeGeneration {
}
private void genBlockPhiTransition(AsmProgram asm, ControlFlowBlock fromBlock, ControlFlowBlock toBlock) {
Statement toFirstStatement = toBlock.getStatements().get(0);
asm.startSegment(toFirstStatement.getIndex(), "["+toFirstStatement.getIndex()+"]"+" phi from " + fromBlock.getLabel().getFullName()+" to "+toBlock.getLabel().getFullName());
asm.addLabel((toBlock.getLabel().getFullName() + "_from_" + fromBlock.getLabel().getLocalName()).replace('@', 'B').replace(':', '_'));
if (toBlock.hasPhiBlock()) {
StatementPhiBlock phiBlock = toBlock.getPhiBlock();
@ -183,7 +190,7 @@ public class Pass4CodeGeneration {
});
for (StatementPhiBlock.PhiRValue phiRValue : phiRValues) {
if (phiRValue.getPredecessor().equals(fromBlock.getLabel())) {
genAsmMove(asm, phiVariable.getVariable(), phiRValue.getrValue());
genAsmMove(asm, phiVariable.getVariable(), phiRValue.getrValue(), phiBlock);
break;
}
}
@ -200,12 +207,13 @@ public class Pass4CodeGeneration {
}
}
private void genAsmMove(AsmProgram asm, LValue lValue, RValue rValue) {
private void genAsmMove(AsmProgram asm, LValue lValue, RValue rValue, Statement statement) {
asm.startSegment(statement.getIndex(), "["+statement.getIndex() + "] phi " +lValue.toString(program) + " = " + rValue.toString(program));
if (isRegisterCopy(lValue, rValue)) {
asm.addComment(lValue.toString(program) + " = " + rValue.toString(program) + " // register copy " + getRegister(lValue));
asm.getCurrentSegment().setFragment("register_copy");
} else {
AsmFragment asmFragment = new AsmFragment(lValue, rValue, program);
asm.addComment(lValue.toString(program) + " = " + rValue.toString(program) + " // " + asmFragment.getSignature());
asm.getCurrentSegment().setFragment(asmFragment.getSignature());
asmFragment.generate(asm);
}
}

View File

@ -3,12 +3,15 @@ package dk.camelot64.kickc.passes;
import dk.camelot64.kickc.CompileLog;
import dk.camelot64.kickc.asm.AsmLine;
import dk.camelot64.kickc.asm.AsmProgram;
import dk.camelot64.kickc.asm.AsmSegment;
import dk.camelot64.kickc.icl.Program;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
/** Optimization performed on Assembler Code (Asm Code).
/**
* Optimization performed on Assembler Code (Asm Code).
* Optimizations are performed repeatedly until none of them yield any result
**/
public abstract class Pass5AsmOptimization {
@ -37,11 +40,14 @@ public abstract class Pass5AsmOptimization {
}
public void remove(List<AsmLine> remove) {
for (Iterator<AsmLine> iterator = getAsmProgram().getLines().iterator(); iterator.hasNext(); ) {
AsmLine line = iterator.next();
if (remove.contains(line)) {
log.append("Removing instruction "+line.getAsm());
iterator.remove();
Collection<AsmSegment> segments = getAsmProgram().getSegments();
for (AsmSegment segment : segments) {
for (Iterator<AsmLine> iterator = segment.getLines().iterator(); iterator.hasNext(); ) {
AsmLine line = iterator.next();
if (remove.contains(line)) {
log.append("Removing instruction " + line.getAsm());
iterator.remove();
}
}
}
}

View File

@ -1,16 +1,15 @@
package dk.camelot64.kickc.passes;
import dk.camelot64.kickc.CompileLog;
import dk.camelot64.kickc.asm.AsmInstruction;
import dk.camelot64.kickc.asm.AsmLabel;
import dk.camelot64.kickc.asm.AsmLine;
import dk.camelot64.kickc.asm.AsmProgram;
import dk.camelot64.kickc.asm.*;
import dk.camelot64.kickc.icl.Program;
import java.util.ArrayList;
import java.util.List;
/** Optimize assembler code by removing jumps to labels immediately following the jump */
/**
* Optimize assembler code by removing jumps to labels immediately following the jump
*/
public class Pass5NextJumpElimination extends Pass5AsmOptimization {
public Pass5NextJumpElimination(Program program, CompileLog log) {
@ -20,23 +19,26 @@ public class Pass5NextJumpElimination extends Pass5AsmOptimization {
public boolean optimize() {
List<AsmLine> removeLines = new ArrayList<>();
AsmInstruction candidate = null;
for (AsmLine line : getAsmProgram().getLines()) {
if(candidate!=null) {
if(line instanceof AsmLabel) {
if(((AsmLabel) line).getLabel().equals(candidate.getParameter())) {
removeLines.add(candidate);
for (AsmSegment segment : getAsmProgram().getSegments()) {
for (AsmLine line : segment.getLines()) {
if (candidate != null) {
if (line instanceof AsmLabel) {
if (((AsmLabel) line).getLabel().equals(candidate.getParameter())) {
removeLines.add(candidate);
}
}
}
if (line instanceof AsmInstruction) {
candidate = null;
AsmInstruction instruction = (AsmInstruction) line;
if (instruction.getType().isJump()) {
candidate = instruction;
}
}
}
if(line instanceof AsmInstruction) {
candidate = null;
AsmInstruction instruction = (AsmInstruction) line;
if(instruction.getType().isJump()) {
candidate = instruction;
}
}
}
remove(removeLines);
return removeLines.size()>0;
return removeLines.size() > 0;
}
}

View File

@ -8,7 +8,9 @@ import dk.camelot64.kickc.icl.Program;
import java.util.ArrayList;
import java.util.List;
/** Maps out register values entering all instructions. Removes unnecessary loads / clears / sets */
/**
* Maps out register values entering all instructions. Removes unnecessary loads / clears / sets
*/
public class Pass5UnnecesaryLoadElimination extends Pass5AsmOptimization {
public Pass5UnnecesaryLoadElimination(Program program, CompileLog log) {
@ -19,59 +21,62 @@ public class Pass5UnnecesaryLoadElimination extends Pass5AsmOptimization {
public boolean optimize() {
AsmProgramStaticRegisterValues staticValues = new AsmProgramStaticRegisterValues(getAsmProgram());
List<AsmLine> removes = new ArrayList<>();
for (AsmLine line : getAsmProgram().getLines()) {
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());
for (AsmSegment segment : getAsmProgram().getSegments()) {
for (AsmLine line : segment.getLines()) {
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
}
}
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
}
}
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
}
}
if (instructionType.getMnemnonic().equals("clc")) {
AsmProgramStaticRegisterValues.AsmRegisterValues instructionValues = staticValues.getValues(instruction);
if (instructionValues.getA() != null && instructionValues.getA().equals(immValue)) {
if (Boolean.FALSE.equals(instructionValues.getC())) {
removes.add(instruction);
}
} catch (NumberFormatException e) {
// ignore
}
}
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
}
}
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
}
}
if(instructionType.getMnemnonic().equals("clc")) {
AsmProgramStaticRegisterValues.AsmRegisterValues instructionValues = staticValues.getValues(instruction);
if(Boolean.FALSE.equals(instructionValues.getC())) {
removes.add(instruction);
}
}
if(instructionType.getMnemnonic().equals("sec")) {
AsmProgramStaticRegisterValues.AsmRegisterValues instructionValues = staticValues.getValues(instruction);
if(Boolean.TRUE.equals(instructionValues.getC())) {
removes.add(instruction);
if (instructionType.getMnemnonic().equals("sec")) {
AsmProgramStaticRegisterValues.AsmRegisterValues instructionValues = staticValues.getValues(instruction);
if (Boolean.TRUE.equals(instructionValues.getC())) {
removes.add(instruction);
}
}
}
}
}
remove(removes);
return removes.size()>0;
return removes.size() > 0;
}
}

View File

@ -1126,66 +1126,74 @@ zp byte:5 [ e#3 e#5 e#1 e#2 ]
zp byte:6 [ y#2 y#4 y#1 ]
INITIAL ASM
//SEG0 @BEGIN
BBEGIN:
//SEG1 [0] phi from @BEGIN to @1
B1_from_BBEGIN:
// (byte) y#2 = (byte) 0 // zpby1=coby1
//SEG2 [0] phi (byte) y#2 = (byte) 0 -- zpby1=coby1
lda #0
sta 6
// (byte) e#3 = (byte) 12 // zpby1=coby1
//SEG3 [0] phi (byte) e#3 = (byte) 12 -- zpby1=coby1
lda #12
sta 5
// (byte) x#2 = (byte) 0 // zpby1=coby1
//SEG4 [0] phi (byte) x#2 = (byte) 0 -- zpby1=coby1
lda #0
sta 4
// (byte*) cursor#3 = (word) 1024 // zpptrby1=cowo1
//SEG5 [0] phi (byte*) cursor#3 = (word) 1024 -- zpptrby1=cowo1
lda #<1024
sta 2
lda #>1024
sta 2+1
jmp B1
//SEG6 [0] phi from @3 to @1
B1_from_B3:
// (byte) y#2 = (byte) y#4 // register copy zp byte:6
// (byte) e#3 = (byte) e#5 // register copy zp byte:5
// (byte) x#2 = (byte) x#1 // register copy zp byte:4
// (byte*) cursor#3 = (byte*) cursor#5 // register copy zp ptr byte:2
//SEG7 [0] phi (byte) y#2 = (byte) y#4 -- register_copy
//SEG8 [0] phi (byte) e#3 = (byte) e#5 -- register_copy
//SEG9 [0] phi (byte) x#2 = (byte) x#1 -- register_copy
//SEG10 [0] phi (byte*) cursor#3 = (byte*) cursor#5 -- register_copy
jmp B1
//SEG11 @1
B1:
// [1] *((byte*) cursor#3) ← (byte) 81 [ cursor#3 x#2 e#3 y#2 ] // _star_zpptrby1=coby1
//SEG12 [1] *((byte*) cursor#3) ← (byte) 81 [ cursor#3 x#2 e#3 y#2 ] -- _star_zpptrby1=coby1
ldy #0
lda #81
sta (2),y
// [2] (byte) x#1 ← (byte) x#2 + (byte) 1 [ x#1 cursor#3 e#3 y#2 ] // zpby1=zpby1_plus_1
//SEG13 [2] (byte) x#1 ← (byte) x#2 + (byte) 1 [ x#1 cursor#3 e#3 y#2 ] -- zpby1=zpby1_plus_1
inc 4
// [3] (byte*) cursor#1 ← (byte*) cursor#3 + (byte) 1 [ x#1 e#3 cursor#1 y#2 ] // zpptrby1=zpptrby1_plus_1
//SEG14 [3] (byte*) cursor#1 ← (byte*) cursor#3 + (byte) 1 [ x#1 e#3 cursor#1 y#2 ] -- zpptrby1=zpptrby1_plus_1
inc 2
bne !+
inc 2+1
!:
// [4] (byte) e#1 ← (byte) e#3 + (byte) 24 [ x#1 e#1 cursor#1 y#2 ] // zpby1=zpby1_plus_coby1
//SEG15 [4] (byte) e#1 ← (byte) e#3 + (byte) 24 [ x#1 e#1 cursor#1 y#2 ] -- zpby1=zpby1_plus_coby1
lda 5
clc
adc #24
sta 5
// [5] if((byte) 39<(byte) e#1) goto @2 [ x#1 e#1 cursor#1 y#2 ] // coby1_lt_zpby1_then_la1
//SEG16 [5] if((byte) 39<(byte) e#1) goto @2 [ x#1 e#1 cursor#1 y#2 ] -- coby1_lt_zpby1_then_la1
lda #39
cmp 5
bcc B2
//SEG17 [6] phi from @1 to @3
B3_from_B1:
// (byte) y#4 = (byte) y#2 // register copy zp byte:6
// (byte) e#5 = (byte) e#1 // register copy zp byte:5
// (byte*) cursor#5 = (byte*) cursor#1 // register copy zp ptr byte:2
//SEG18 [6] phi (byte) y#4 = (byte) y#2 -- register_copy
//SEG19 [6] phi (byte) e#5 = (byte) e#1 -- register_copy
//SEG20 [6] phi (byte*) cursor#5 = (byte*) cursor#1 -- register_copy
jmp B3
//SEG21 @3
B3:
// [7] if((byte) x#1<(byte) 40) goto @1 [ cursor#5 x#1 e#5 y#4 ] // zpby1_lt_coby1_then_la1
//SEG22 [7] if((byte) x#1<(byte) 40) goto @1 [ cursor#5 x#1 e#5 y#4 ] -- zpby1_lt_coby1_then_la1
lda 4
cmp #40
bcc B1_from_B3
jmp BEND
//SEG23 @END
BEND:
//SEG24 @2
B2:
// [8] (byte) y#1 ← (byte) y#2 + (byte) 1 [ x#1 e#1 cursor#1 y#1 ] // zpby1=zpby1_plus_1
//SEG25 [8] (byte) y#1 ← (byte) y#2 + (byte) 1 [ x#1 e#1 cursor#1 y#1 ] -- zpby1=zpby1_plus_1
inc 6
// [9] (byte*) cursor#2 ← (byte*) cursor#1 + (byte) 40 [ x#1 e#1 cursor#2 y#1 ] // zpptrby1=zpptrby1_plus_coby1
//SEG26 [9] (byte*) cursor#2 ← (byte*) cursor#1 + (byte) 40 [ x#1 e#1 cursor#2 y#1 ] -- zpptrby1=zpptrby1_plus_coby1
lda 2
clc
adc #40
@ -1193,15 +1201,16 @@ B2:
bcc !+
inc 2+1
!:
// [10] (byte) e#2 ← (byte) e#1 - (byte) 39 [ x#1 cursor#2 e#2 y#1 ] // zpby1=zpby1_minus_coby1
//SEG27 [10] (byte) e#2 ← (byte) e#1 - (byte) 39 [ x#1 cursor#2 e#2 y#1 ] -- zpby1=zpby1_minus_coby1
lda 5
sec
sbc #39
sta 5
//SEG28 [6] phi from @2 to @3
B3_from_B2:
// (byte) y#4 = (byte) y#1 // register copy zp byte:6
// (byte) e#5 = (byte) e#2 // register copy zp byte:5
// (byte*) cursor#5 = (byte*) cursor#2 // register copy zp ptr byte:2
//SEG29 [6] phi (byte) y#4 = (byte) y#1 -- register_copy
//SEG30 [6] phi (byte) e#5 = (byte) e#2 -- register_copy
//SEG31 [6] phi (byte*) cursor#5 = (byte*) cursor#2 -- register_copy
jmp B3
Removing instruction jmp B1
@ -1209,63 +1218,71 @@ Removing instruction jmp B3
Removing instruction jmp BEND
Succesful ASM optimization Pass5NextJumpElimination
ASSEMBLER
//SEG0 @BEGIN
BBEGIN:
//SEG1 [0] phi from @BEGIN to @1
B1_from_BBEGIN:
// (byte) y#2 = (byte) 0 // zpby1=coby1
//SEG2 [0] phi (byte) y#2 = (byte) 0 -- zpby1=coby1
lda #0
sta 6
// (byte) e#3 = (byte) 12 // zpby1=coby1
//SEG3 [0] phi (byte) e#3 = (byte) 12 -- zpby1=coby1
lda #12
sta 5
// (byte) x#2 = (byte) 0 // zpby1=coby1
//SEG4 [0] phi (byte) x#2 = (byte) 0 -- zpby1=coby1
lda #0
sta 4
// (byte*) cursor#3 = (word) 1024 // zpptrby1=cowo1
//SEG5 [0] phi (byte*) cursor#3 = (word) 1024 -- zpptrby1=cowo1
lda #<1024
sta 2
lda #>1024
sta 2+1
jmp B1
//SEG6 [0] phi from @3 to @1
B1_from_B3:
// (byte) y#2 = (byte) y#4 // register copy zp byte:6
// (byte) e#3 = (byte) e#5 // register copy zp byte:5
// (byte) x#2 = (byte) x#1 // register copy zp byte:4
// (byte*) cursor#3 = (byte*) cursor#5 // register copy zp ptr byte:2
//SEG7 [0] phi (byte) y#2 = (byte) y#4 -- register_copy
//SEG8 [0] phi (byte) e#3 = (byte) e#5 -- register_copy
//SEG9 [0] phi (byte) x#2 = (byte) x#1 -- register_copy
//SEG10 [0] phi (byte*) cursor#3 = (byte*) cursor#5 -- register_copy
//SEG11 @1
B1:
// [1] *((byte*) cursor#3) ← (byte) 81 [ cursor#3 x#2 e#3 y#2 ] // _star_zpptrby1=coby1
//SEG12 [1] *((byte*) cursor#3) ← (byte) 81 [ cursor#3 x#2 e#3 y#2 ] -- _star_zpptrby1=coby1
ldy #0
lda #81
sta (2),y
// [2] (byte) x#1 ← (byte) x#2 + (byte) 1 [ x#1 cursor#3 e#3 y#2 ] // zpby1=zpby1_plus_1
//SEG13 [2] (byte) x#1 ← (byte) x#2 + (byte) 1 [ x#1 cursor#3 e#3 y#2 ] -- zpby1=zpby1_plus_1
inc 4
// [3] (byte*) cursor#1 ← (byte*) cursor#3 + (byte) 1 [ x#1 e#3 cursor#1 y#2 ] // zpptrby1=zpptrby1_plus_1
//SEG14 [3] (byte*) cursor#1 ← (byte*) cursor#3 + (byte) 1 [ x#1 e#3 cursor#1 y#2 ] -- zpptrby1=zpptrby1_plus_1
inc 2
bne !+
inc 2+1
!:
// [4] (byte) e#1 ← (byte) e#3 + (byte) 24 [ x#1 e#1 cursor#1 y#2 ] // zpby1=zpby1_plus_coby1
//SEG15 [4] (byte) e#1 ← (byte) e#3 + (byte) 24 [ x#1 e#1 cursor#1 y#2 ] -- zpby1=zpby1_plus_coby1
lda 5
clc
adc #24
sta 5
// [5] if((byte) 39<(byte) e#1) goto @2 [ x#1 e#1 cursor#1 y#2 ] // coby1_lt_zpby1_then_la1
//SEG16 [5] if((byte) 39<(byte) e#1) goto @2 [ x#1 e#1 cursor#1 y#2 ] -- coby1_lt_zpby1_then_la1
lda #39
cmp 5
bcc B2
//SEG17 [6] phi from @1 to @3
B3_from_B1:
// (byte) y#4 = (byte) y#2 // register copy zp byte:6
// (byte) e#5 = (byte) e#1 // register copy zp byte:5
// (byte*) cursor#5 = (byte*) cursor#1 // register copy zp ptr byte:2
//SEG18 [6] phi (byte) y#4 = (byte) y#2 -- register_copy
//SEG19 [6] phi (byte) e#5 = (byte) e#1 -- register_copy
//SEG20 [6] phi (byte*) cursor#5 = (byte*) cursor#1 -- register_copy
//SEG21 @3
B3:
// [7] if((byte) x#1<(byte) 40) goto @1 [ cursor#5 x#1 e#5 y#4 ] // zpby1_lt_coby1_then_la1
//SEG22 [7] if((byte) x#1<(byte) 40) goto @1 [ cursor#5 x#1 e#5 y#4 ] -- zpby1_lt_coby1_then_la1
lda 4
cmp #40
bcc B1_from_B3
//SEG23 @END
BEND:
//SEG24 @2
B2:
// [8] (byte) y#1 ← (byte) y#2 + (byte) 1 [ x#1 e#1 cursor#1 y#1 ] // zpby1=zpby1_plus_1
//SEG25 [8] (byte) y#1 ← (byte) y#2 + (byte) 1 [ x#1 e#1 cursor#1 y#1 ] -- zpby1=zpby1_plus_1
inc 6
// [9] (byte*) cursor#2 ← (byte*) cursor#1 + (byte) 40 [ x#1 e#1 cursor#2 y#1 ] // zpptrby1=zpptrby1_plus_coby1
//SEG26 [9] (byte*) cursor#2 ← (byte*) cursor#1 + (byte) 40 [ x#1 e#1 cursor#2 y#1 ] -- zpptrby1=zpptrby1_plus_coby1
lda 2
clc
adc #40
@ -1273,76 +1290,85 @@ B2:
bcc !+
inc 2+1
!:
// [10] (byte) e#2 ← (byte) e#1 - (byte) 39 [ x#1 cursor#2 e#2 y#1 ] // zpby1=zpby1_minus_coby1
//SEG27 [10] (byte) e#2 ← (byte) e#1 - (byte) 39 [ x#1 cursor#2 e#2 y#1 ] -- zpby1=zpby1_minus_coby1
lda 5
sec
sbc #39
sta 5
//SEG28 [6] phi from @2 to @3
B3_from_B2:
// (byte) y#4 = (byte) y#1 // register copy zp byte:6
// (byte) e#5 = (byte) e#2 // register copy zp byte:5
// (byte*) cursor#5 = (byte*) cursor#2 // register copy zp ptr byte:2
//SEG29 [6] phi (byte) y#4 = (byte) y#1 -- register_copy
//SEG30 [6] phi (byte) e#5 = (byte) e#2 -- register_copy
//SEG31 [6] phi (byte*) cursor#5 = (byte*) cursor#2 -- register_copy
jmp B3
Removing instruction jmp B1
Succesful ASM optimization Pass5NextJumpElimination
ASSEMBLER
//SEG0 @BEGIN
BBEGIN:
//SEG1 [0] phi from @BEGIN to @1
B1_from_BBEGIN:
// (byte) y#2 = (byte) 0 // zpby1=coby1
//SEG2 [0] phi (byte) y#2 = (byte) 0 -- zpby1=coby1
lda #0
sta 6
// (byte) e#3 = (byte) 12 // zpby1=coby1
//SEG3 [0] phi (byte) e#3 = (byte) 12 -- zpby1=coby1
lda #12
sta 5
// (byte) x#2 = (byte) 0 // zpby1=coby1
//SEG4 [0] phi (byte) x#2 = (byte) 0 -- zpby1=coby1
lda #0
sta 4
// (byte*) cursor#3 = (word) 1024 // zpptrby1=cowo1
//SEG5 [0] phi (byte*) cursor#3 = (word) 1024 -- zpptrby1=cowo1
lda #<1024
sta 2
lda #>1024
sta 2+1
//SEG6 [0] phi from @3 to @1
B1_from_B3:
// (byte) y#2 = (byte) y#4 // register copy zp byte:6
// (byte) e#3 = (byte) e#5 // register copy zp byte:5
// (byte) x#2 = (byte) x#1 // register copy zp byte:4
// (byte*) cursor#3 = (byte*) cursor#5 // register copy zp ptr byte:2
//SEG7 [0] phi (byte) y#2 = (byte) y#4 -- register_copy
//SEG8 [0] phi (byte) e#3 = (byte) e#5 -- register_copy
//SEG9 [0] phi (byte) x#2 = (byte) x#1 -- register_copy
//SEG10 [0] phi (byte*) cursor#3 = (byte*) cursor#5 -- register_copy
//SEG11 @1
B1:
// [1] *((byte*) cursor#3) ← (byte) 81 [ cursor#3 x#2 e#3 y#2 ] // _star_zpptrby1=coby1
//SEG12 [1] *((byte*) cursor#3) ← (byte) 81 [ cursor#3 x#2 e#3 y#2 ] -- _star_zpptrby1=coby1
ldy #0
lda #81
sta (2),y
// [2] (byte) x#1 ← (byte) x#2 + (byte) 1 [ x#1 cursor#3 e#3 y#2 ] // zpby1=zpby1_plus_1
//SEG13 [2] (byte) x#1 ← (byte) x#2 + (byte) 1 [ x#1 cursor#3 e#3 y#2 ] -- zpby1=zpby1_plus_1
inc 4
// [3] (byte*) cursor#1 ← (byte*) cursor#3 + (byte) 1 [ x#1 e#3 cursor#1 y#2 ] // zpptrby1=zpptrby1_plus_1
//SEG14 [3] (byte*) cursor#1 ← (byte*) cursor#3 + (byte) 1 [ x#1 e#3 cursor#1 y#2 ] -- zpptrby1=zpptrby1_plus_1
inc 2
bne !+
inc 2+1
!:
// [4] (byte) e#1 ← (byte) e#3 + (byte) 24 [ x#1 e#1 cursor#1 y#2 ] // zpby1=zpby1_plus_coby1
//SEG15 [4] (byte) e#1 ← (byte) e#3 + (byte) 24 [ x#1 e#1 cursor#1 y#2 ] -- zpby1=zpby1_plus_coby1
lda 5
clc
adc #24
sta 5
// [5] if((byte) 39<(byte) e#1) goto @2 [ x#1 e#1 cursor#1 y#2 ] // coby1_lt_zpby1_then_la1
//SEG16 [5] if((byte) 39<(byte) e#1) goto @2 [ x#1 e#1 cursor#1 y#2 ] -- coby1_lt_zpby1_then_la1
lda #39
cmp 5
bcc B2
//SEG17 [6] phi from @1 to @3
B3_from_B1:
// (byte) y#4 = (byte) y#2 // register copy zp byte:6
// (byte) e#5 = (byte) e#1 // register copy zp byte:5
// (byte*) cursor#5 = (byte*) cursor#1 // register copy zp ptr byte:2
//SEG18 [6] phi (byte) y#4 = (byte) y#2 -- register_copy
//SEG19 [6] phi (byte) e#5 = (byte) e#1 -- register_copy
//SEG20 [6] phi (byte*) cursor#5 = (byte*) cursor#1 -- register_copy
//SEG21 @3
B3:
// [7] if((byte) x#1<(byte) 40) goto @1 [ cursor#5 x#1 e#5 y#4 ] // zpby1_lt_coby1_then_la1
//SEG22 [7] if((byte) x#1<(byte) 40) goto @1 [ cursor#5 x#1 e#5 y#4 ] -- zpby1_lt_coby1_then_la1
lda 4
cmp #40
bcc B1_from_B3
//SEG23 @END
BEND:
//SEG24 @2
B2:
// [8] (byte) y#1 ← (byte) y#2 + (byte) 1 [ x#1 e#1 cursor#1 y#1 ] // zpby1=zpby1_plus_1
//SEG25 [8] (byte) y#1 ← (byte) y#2 + (byte) 1 [ x#1 e#1 cursor#1 y#1 ] -- zpby1=zpby1_plus_1
inc 6
// [9] (byte*) cursor#2 ← (byte*) cursor#1 + (byte) 40 [ x#1 e#1 cursor#2 y#1 ] // zpptrby1=zpptrby1_plus_coby1
//SEG26 [9] (byte*) cursor#2 ← (byte*) cursor#1 + (byte) 40 [ x#1 e#1 cursor#2 y#1 ] -- zpptrby1=zpptrby1_plus_coby1
lda 2
clc
adc #40
@ -1350,15 +1376,16 @@ B2:
bcc !+
inc 2+1
!:
// [10] (byte) e#2 ← (byte) e#1 - (byte) 39 [ x#1 cursor#2 e#2 y#1 ] // zpby1=zpby1_minus_coby1
//SEG27 [10] (byte) e#2 ← (byte) e#1 - (byte) 39 [ x#1 cursor#2 e#2 y#1 ] -- zpby1=zpby1_minus_coby1
lda 5
sec
sbc #39
sta 5
//SEG28 [6] phi from @2 to @3
B3_from_B2:
// (byte) y#4 = (byte) y#1 // register copy zp byte:6
// (byte) e#5 = (byte) e#2 // register copy zp byte:5
// (byte*) cursor#5 = (byte*) cursor#2 // register copy zp ptr byte:2
//SEG29 [6] phi (byte) y#4 = (byte) y#1 -- register_copy
//SEG30 [6] phi (byte) e#5 = (byte) e#2 -- register_copy
//SEG31 [6] phi (byte*) cursor#5 = (byte*) cursor#2 -- register_copy
jmp B3
FINAL SYMBOL TABLE
@ -1399,62 +1426,70 @@ zp byte:5 [ e#3 e#5 e#1 e#2 ]
zp byte:6 [ y#2 y#4 y#1 ]
FINAL CODE
//SEG0 @BEGIN
BBEGIN:
//SEG1 [0] phi from @BEGIN to @1
B1_from_BBEGIN:
// (byte) y#2 = (byte) 0 // zpby1=coby1
//SEG2 [0] phi (byte) y#2 = (byte) 0 -- zpby1=coby1
lda #0
sta 6
// (byte) e#3 = (byte) 12 // zpby1=coby1
//SEG3 [0] phi (byte) e#3 = (byte) 12 -- zpby1=coby1
lda #12
sta 5
// (byte) x#2 = (byte) 0 // zpby1=coby1
//SEG4 [0] phi (byte) x#2 = (byte) 0 -- zpby1=coby1
lda #0
sta 4
// (byte*) cursor#3 = (word) 1024 // zpptrby1=cowo1
//SEG5 [0] phi (byte*) cursor#3 = (word) 1024 -- zpptrby1=cowo1
lda #<1024
sta 2
lda #>1024
sta 2+1
//SEG6 [0] phi from @3 to @1
B1_from_B3:
// (byte) y#2 = (byte) y#4 // register copy zp byte:6
// (byte) e#3 = (byte) e#5 // register copy zp byte:5
// (byte) x#2 = (byte) x#1 // register copy zp byte:4
// (byte*) cursor#3 = (byte*) cursor#5 // register copy zp ptr byte:2
//SEG7 [0] phi (byte) y#2 = (byte) y#4 -- register_copy
//SEG8 [0] phi (byte) e#3 = (byte) e#5 -- register_copy
//SEG9 [0] phi (byte) x#2 = (byte) x#1 -- register_copy
//SEG10 [0] phi (byte*) cursor#3 = (byte*) cursor#5 -- register_copy
//SEG11 @1
B1:
// [1] *((byte*) cursor#3) ← (byte) 81 [ cursor#3 x#2 e#3 y#2 ] // _star_zpptrby1=coby1
//SEG12 [1] *((byte*) cursor#3) ← (byte) 81 [ cursor#3 x#2 e#3 y#2 ] -- _star_zpptrby1=coby1
ldy #0
lda #81
sta (2),y
// [2] (byte) x#1 ← (byte) x#2 + (byte) 1 [ x#1 cursor#3 e#3 y#2 ] // zpby1=zpby1_plus_1
//SEG13 [2] (byte) x#1 ← (byte) x#2 + (byte) 1 [ x#1 cursor#3 e#3 y#2 ] -- zpby1=zpby1_plus_1
inc 4
// [3] (byte*) cursor#1 ← (byte*) cursor#3 + (byte) 1 [ x#1 e#3 cursor#1 y#2 ] // zpptrby1=zpptrby1_plus_1
//SEG14 [3] (byte*) cursor#1 ← (byte*) cursor#3 + (byte) 1 [ x#1 e#3 cursor#1 y#2 ] -- zpptrby1=zpptrby1_plus_1
inc 2
bne !+
inc 2+1
!:
// [4] (byte) e#1 ← (byte) e#3 + (byte) 24 [ x#1 e#1 cursor#1 y#2 ] // zpby1=zpby1_plus_coby1
//SEG15 [4] (byte) e#1 ← (byte) e#3 + (byte) 24 [ x#1 e#1 cursor#1 y#2 ] -- zpby1=zpby1_plus_coby1
lda 5
clc
adc #24
sta 5
// [5] if((byte) 39<(byte) e#1) goto @2 [ x#1 e#1 cursor#1 y#2 ] // coby1_lt_zpby1_then_la1
//SEG16 [5] if((byte) 39<(byte) e#1) goto @2 [ x#1 e#1 cursor#1 y#2 ] -- coby1_lt_zpby1_then_la1
lda #39
cmp 5
bcc B2
//SEG17 [6] phi from @1 to @3
B3_from_B1:
// (byte) y#4 = (byte) y#2 // register copy zp byte:6
// (byte) e#5 = (byte) e#1 // register copy zp byte:5
// (byte*) cursor#5 = (byte*) cursor#1 // register copy zp ptr byte:2
//SEG18 [6] phi (byte) y#4 = (byte) y#2 -- register_copy
//SEG19 [6] phi (byte) e#5 = (byte) e#1 -- register_copy
//SEG20 [6] phi (byte*) cursor#5 = (byte*) cursor#1 -- register_copy
//SEG21 @3
B3:
// [7] if((byte) x#1<(byte) 40) goto @1 [ cursor#5 x#1 e#5 y#4 ] // zpby1_lt_coby1_then_la1
//SEG22 [7] if((byte) x#1<(byte) 40) goto @1 [ cursor#5 x#1 e#5 y#4 ] -- zpby1_lt_coby1_then_la1
lda 4
cmp #40
bcc B1_from_B3
//SEG23 @END
BEND:
//SEG24 @2
B2:
// [8] (byte) y#1 ← (byte) y#2 + (byte) 1 [ x#1 e#1 cursor#1 y#1 ] // zpby1=zpby1_plus_1
//SEG25 [8] (byte) y#1 ← (byte) y#2 + (byte) 1 [ x#1 e#1 cursor#1 y#1 ] -- zpby1=zpby1_plus_1
inc 6
// [9] (byte*) cursor#2 ← (byte*) cursor#1 + (byte) 40 [ x#1 e#1 cursor#2 y#1 ] // zpptrby1=zpptrby1_plus_coby1
//SEG26 [9] (byte*) cursor#2 ← (byte*) cursor#1 + (byte) 40 [ x#1 e#1 cursor#2 y#1 ] -- zpptrby1=zpptrby1_plus_coby1
lda 2
clc
adc #40
@ -1462,14 +1497,15 @@ B2:
bcc !+
inc 2+1
!:
// [10] (byte) e#2 ← (byte) e#1 - (byte) 39 [ x#1 cursor#2 e#2 y#1 ] // zpby1=zpby1_minus_coby1
//SEG27 [10] (byte) e#2 ← (byte) e#1 - (byte) 39 [ x#1 cursor#2 e#2 y#1 ] -- zpby1=zpby1_minus_coby1
lda 5
sec
sbc #39
sta 5
//SEG28 [6] phi from @2 to @3
B3_from_B2:
// (byte) y#4 = (byte) y#1 // register copy zp byte:6
// (byte) e#5 = (byte) e#2 // register copy zp byte:5
// (byte*) cursor#5 = (byte*) cursor#2 // register copy zp ptr byte:2
//SEG29 [6] phi (byte) y#4 = (byte) y#1 -- register_copy
//SEG30 [6] phi (byte) e#5 = (byte) e#2 -- register_copy
//SEG31 [6] phi (byte*) cursor#5 = (byte*) cursor#2 -- register_copy
jmp B3

View File

@ -466,132 +466,147 @@ zp byte:5 [ $4 ]
Coalescing zero page register [ zp byte:3 [ $1 ] ] with [ zp byte:5 [ $4 ] ]
INITIAL ASM
//SEG0 @BEGIN
BBEGIN:
// [0] *((word) 4352) ← (byte) 0 [ ] // _star_cowo1=coby2
//SEG1 [0] *((word) 4352) ← (byte) 0 [ ] -- _star_cowo1=coby2
lda #0
sta 4352
// [1] *((word) 4353) ← (byte) 1 [ ] // _star_cowo1=coby2
//SEG2 [1] *((word) 4353) ← (byte) 1 [ ] -- _star_cowo1=coby2
lda #1
sta 4353
//SEG3 [2] phi from @BEGIN to @1
B1_from_BBEGIN:
// (byte) i#2 = (byte) 0 // zpby1=coby1
//SEG4 [2] phi (byte) i#2 = (byte) 0 -- zpby1=coby1
lda #0
sta 2
jmp B1
//SEG5 [2] phi from @1 to @1
B1_from_B1:
// (byte) i#2 = (byte) i#1 // register copy zp byte:2
//SEG6 [2] phi (byte) i#2 = (byte) i#1 -- register_copy
jmp B1
//SEG7 @1
B1:
// [3] (byte~) $1 ← (word) 4352 *idx (byte) i#2 [ i#2 $1 ] // zpby1=cowo1_staridx_zpby2
//SEG8 [3] (byte~) $1 ← (word) 4352 *idx (byte) i#2 [ i#2 $1 ] -- zpby1=cowo1_staridx_zpby2
ldx 2
lda 4352,x
sta 3
// [4] (byte~) $3 ← (word) 4353 *idx (byte) i#2 [ i#2 $1 $3 ] // zpby1=cowo1_staridx_zpby2
//SEG9 [4] (byte~) $3 ← (word) 4353 *idx (byte) i#2 [ i#2 $1 $3 ] -- zpby1=cowo1_staridx_zpby2
ldx 2
lda 4353,x
sta 4
// [5] (byte~) $4 ← (byte~) $1 + (byte~) $3 [ i#2 $4 ] // zpby1=zpby2_plus_zpby3
//SEG10 [5] (byte~) $4 ← (byte~) $1 + (byte~) $3 [ i#2 $4 ] -- zpby1=zpby2_plus_zpby3
lda 3
clc
adc 4
sta 5
// [6] *((word) 4354 + (byte) i#2) ← (byte~) $4 [ i#2 ] // cowo1_staridx_zpby1=zpby2
//SEG11 [6] *((word) 4354 + (byte) i#2) ← (byte~) $4 [ i#2 ] -- cowo1_staridx_zpby1=zpby2
lda 5
ldx 2
sta 4354,x
// [7] (byte) i#1 ← (byte) i#2 + (byte) 1 [ i#1 ] // zpby1=zpby1_plus_1
//SEG12 [7] (byte) i#1 ← (byte) i#2 + (byte) 1 [ i#1 ] -- zpby1=zpby1_plus_1
inc 2
// [8] if((byte) i#1<(byte) 15) goto @1 [ i#1 ] // zpby1_lt_coby1_then_la1
//SEG13 [8] if((byte) i#1<(byte) 15) goto @1 [ i#1 ] -- zpby1_lt_coby1_then_la1
lda 2
cmp #15
bcc B1_from_B1
jmp BEND
//SEG14 @END
BEND:
Removing instruction jmp B1
Removing instruction jmp BEND
Succesful ASM optimization Pass5NextJumpElimination
ASSEMBLER
//SEG0 @BEGIN
BBEGIN:
// [0] *((word) 4352) ← (byte) 0 [ ] // _star_cowo1=coby2
//SEG1 [0] *((word) 4352) ← (byte) 0 [ ] -- _star_cowo1=coby2
lda #0
sta 4352
// [1] *((word) 4353) ← (byte) 1 [ ] // _star_cowo1=coby2
//SEG2 [1] *((word) 4353) ← (byte) 1 [ ] -- _star_cowo1=coby2
lda #1
sta 4353
//SEG3 [2] phi from @BEGIN to @1
B1_from_BBEGIN:
// (byte) i#2 = (byte) 0 // zpby1=coby1
//SEG4 [2] phi (byte) i#2 = (byte) 0 -- zpby1=coby1
lda #0
sta 2
jmp B1
//SEG5 [2] phi from @1 to @1
B1_from_B1:
// (byte) i#2 = (byte) i#1 // register copy zp byte:2
//SEG6 [2] phi (byte) i#2 = (byte) i#1 -- register_copy
//SEG7 @1
B1:
// [3] (byte~) $1 ← (word) 4352 *idx (byte) i#2 [ i#2 $1 ] // zpby1=cowo1_staridx_zpby2
//SEG8 [3] (byte~) $1 ← (word) 4352 *idx (byte) i#2 [ i#2 $1 ] -- zpby1=cowo1_staridx_zpby2
ldx 2
lda 4352,x
sta 3
// [4] (byte~) $3 ← (word) 4353 *idx (byte) i#2 [ i#2 $1 $3 ] // zpby1=cowo1_staridx_zpby2
//SEG9 [4] (byte~) $3 ← (word) 4353 *idx (byte) i#2 [ i#2 $1 $3 ] -- zpby1=cowo1_staridx_zpby2
ldx 2
lda 4353,x
sta 4
// [5] (byte~) $4 ← (byte~) $1 + (byte~) $3 [ i#2 $4 ] // zpby1=zpby2_plus_zpby3
//SEG10 [5] (byte~) $4 ← (byte~) $1 + (byte~) $3 [ i#2 $4 ] -- zpby1=zpby2_plus_zpby3
lda 3
clc
adc 4
sta 5
// [6] *((word) 4354 + (byte) i#2) ← (byte~) $4 [ i#2 ] // cowo1_staridx_zpby1=zpby2
//SEG11 [6] *((word) 4354 + (byte) i#2) ← (byte~) $4 [ i#2 ] -- cowo1_staridx_zpby1=zpby2
lda 5
ldx 2
sta 4354,x
// [7] (byte) i#1 ← (byte) i#2 + (byte) 1 [ i#1 ] // zpby1=zpby1_plus_1
//SEG12 [7] (byte) i#1 ← (byte) i#2 + (byte) 1 [ i#1 ] -- zpby1=zpby1_plus_1
inc 2
// [8] if((byte) i#1<(byte) 15) goto @1 [ i#1 ] // zpby1_lt_coby1_then_la1
//SEG13 [8] if((byte) i#1<(byte) 15) goto @1 [ i#1 ] -- zpby1_lt_coby1_then_la1
lda 2
cmp #15
bcc B1_from_B1
//SEG14 @END
BEND:
Removing instruction jmp B1
Succesful ASM optimization Pass5NextJumpElimination
ASSEMBLER
//SEG0 @BEGIN
BBEGIN:
// [0] *((word) 4352) ← (byte) 0 [ ] // _star_cowo1=coby2
//SEG1 [0] *((word) 4352) ← (byte) 0 [ ] -- _star_cowo1=coby2
lda #0
sta 4352
// [1] *((word) 4353) ← (byte) 1 [ ] // _star_cowo1=coby2
//SEG2 [1] *((word) 4353) ← (byte) 1 [ ] -- _star_cowo1=coby2
lda #1
sta 4353
//SEG3 [2] phi from @BEGIN to @1
B1_from_BBEGIN:
// (byte) i#2 = (byte) 0 // zpby1=coby1
//SEG4 [2] phi (byte) i#2 = (byte) 0 -- zpby1=coby1
lda #0
sta 2
//SEG5 [2] phi from @1 to @1
B1_from_B1:
// (byte) i#2 = (byte) i#1 // register copy zp byte:2
//SEG6 [2] phi (byte) i#2 = (byte) i#1 -- register_copy
//SEG7 @1
B1:
// [3] (byte~) $1 ← (word) 4352 *idx (byte) i#2 [ i#2 $1 ] // zpby1=cowo1_staridx_zpby2
//SEG8 [3] (byte~) $1 ← (word) 4352 *idx (byte) i#2 [ i#2 $1 ] -- zpby1=cowo1_staridx_zpby2
ldx 2
lda 4352,x
sta 3
// [4] (byte~) $3 ← (word) 4353 *idx (byte) i#2 [ i#2 $1 $3 ] // zpby1=cowo1_staridx_zpby2
//SEG9 [4] (byte~) $3 ← (word) 4353 *idx (byte) i#2 [ i#2 $1 $3 ] -- zpby1=cowo1_staridx_zpby2
ldx 2
lda 4353,x
sta 4
// [5] (byte~) $4 ← (byte~) $1 + (byte~) $3 [ i#2 $4 ] // zpby1=zpby2_plus_zpby3
//SEG10 [5] (byte~) $4 ← (byte~) $1 + (byte~) $3 [ i#2 $4 ] -- zpby1=zpby2_plus_zpby3
lda 3
clc
adc 4
sta 5
// [6] *((word) 4354 + (byte) i#2) ← (byte~) $4 [ i#2 ] // cowo1_staridx_zpby1=zpby2
//SEG11 [6] *((word) 4354 + (byte) i#2) ← (byte~) $4 [ i#2 ] -- cowo1_staridx_zpby1=zpby2
lda 5
ldx 2
sta 4354,x
// [7] (byte) i#1 ← (byte) i#2 + (byte) 1 [ i#1 ] // zpby1=zpby1_plus_1
//SEG12 [7] (byte) i#1 ← (byte) i#2 + (byte) 1 [ i#1 ] -- zpby1=zpby1_plus_1
inc 2
// [8] if((byte) i#1<(byte) 15) goto @1 [ i#1 ] // zpby1_lt_coby1_then_la1
//SEG13 [8] if((byte) i#1<(byte) 15) goto @1 [ i#1 ] -- zpby1_lt_coby1_then_la1
lda 2
cmp #15
bcc B1_from_B1
//SEG14 @END
BEND:
FINAL SYMBOL TABLE
@ -611,42 +626,47 @@ zp byte:3 [ $1 $4 ]
zp byte:4 [ $3 ]
FINAL CODE
//SEG0 @BEGIN
BBEGIN:
// [0] *((word) 4352) ← (byte) 0 [ ] // _star_cowo1=coby2
//SEG1 [0] *((word) 4352) ← (byte) 0 [ ] -- _star_cowo1=coby2
lda #0
sta 4352
// [1] *((word) 4353) ← (byte) 1 [ ] // _star_cowo1=coby2
//SEG2 [1] *((word) 4353) ← (byte) 1 [ ] -- _star_cowo1=coby2
lda #1
sta 4353
//SEG3 [2] phi from @BEGIN to @1
B1_from_BBEGIN:
// (byte) i#2 = (byte) 0 // zpby1=coby1
//SEG4 [2] phi (byte) i#2 = (byte) 0 -- zpby1=coby1
lda #0
sta 2
//SEG5 [2] phi from @1 to @1
B1_from_B1:
// (byte) i#2 = (byte) i#1 // register copy zp byte:2
//SEG6 [2] phi (byte) i#2 = (byte) i#1 -- register_copy
//SEG7 @1
B1:
// [3] (byte~) $1 ← (word) 4352 *idx (byte) i#2 [ i#2 $1 ] // zpby1=cowo1_staridx_zpby2
//SEG8 [3] (byte~) $1 ← (word) 4352 *idx (byte) i#2 [ i#2 $1 ] -- zpby1=cowo1_staridx_zpby2
ldx 2
lda 4352,x
sta 3
// [4] (byte~) $3 ← (word) 4353 *idx (byte) i#2 [ i#2 $1 $3 ] // zpby1=cowo1_staridx_zpby2
//SEG9 [4] (byte~) $3 ← (word) 4353 *idx (byte) i#2 [ i#2 $1 $3 ] -- zpby1=cowo1_staridx_zpby2
ldx 2
lda 4353,x
sta 4
// [5] (byte~) $4 ← (byte~) $1 + (byte~) $3 [ i#2 $4 ] // zpby1=zpby2_plus_zpby3
//SEG10 [5] (byte~) $4 ← (byte~) $1 + (byte~) $3 [ i#2 $4 ] -- zpby1=zpby2_plus_zpby3
lda 3
clc
adc 4
sta 5
// [6] *((word) 4354 + (byte) i#2) ← (byte~) $4 [ i#2 ] // cowo1_staridx_zpby1=zpby2
//SEG11 [6] *((word) 4354 + (byte) i#2) ← (byte~) $4 [ i#2 ] -- cowo1_staridx_zpby1=zpby2
lda 5
ldx 2
sta 4354,x
// [7] (byte) i#1 ← (byte) i#2 + (byte) 1 [ i#1 ] // zpby1=zpby1_plus_1
//SEG12 [7] (byte) i#1 ← (byte) i#2 + (byte) 1 [ i#1 ] -- zpby1=zpby1_plus_1
inc 2
// [8] if((byte) i#1<(byte) 15) goto @1 [ i#1 ] // zpby1_lt_coby1_then_la1
//SEG13 [8] if((byte) i#1<(byte) 15) goto @1 [ i#1 ] -- zpby1_lt_coby1_then_la1
lda 2
cmp #15
bcc B1_from_B1
//SEG14 @END
BEND:

File diff suppressed because it is too large Load Diff

View File

@ -383,9 +383,9 @@ zp byte:3 [ s#2 s#4 s#1 ]
Uplifting max weight 49.5 live range equivalence class zp byte:3 [ s#2 s#4 s#1 ]
Uplift to reg byte a resulted in clobber.
Register Cycles: reg byte x 28
Register Cycles: reg byte x 29
Uplift to reg byte x succesfull.
Register Cycles: reg byte y 28
Register Cycles: reg byte y 29
Uplift to reg byte y succesfull.
REGISTER UPLIFTING
(byte) i
@ -400,45 +400,54 @@ zp byte:2 [ i#2 i#1 ]
zp byte:3 [ s#2 s#4 s#1 ]
INITIAL ASM
//SEG0 @BEGIN
BBEGIN:
//SEG1 [0] phi from @BEGIN to @1
B1_from_BBEGIN:
// (byte) s#2 = (byte) 0 // zpby1=coby1
//SEG2 [0] phi (byte) s#2 = (byte) 0 -- zpby1=coby1
lda #0
sta 3
// (byte) i#2 = (byte) 10 // zpby1=coby1
//SEG3 [0] phi (byte) i#2 = (byte) 10 -- zpby1=coby1
lda #10
sta 2
jmp B1
//SEG4 [0] phi from @3 to @1
B1_from_B3:
// (byte) s#2 = (byte) s#4 // register copy zp byte:3
// (byte) i#2 = (byte) i#1 // register copy zp byte:2
//SEG5 [0] phi (byte) s#2 = (byte) s#4 -- register_copy
//SEG6 [0] phi (byte) i#2 = (byte) i#1 -- register_copy
jmp B1
//SEG7 @1
B1:
// [1] if((byte) i#2>(byte) 5) goto @2 [ i#2 s#2 ] // zpby1_gt_coby1_then_la1
//SEG8 [1] if((byte) i#2>(byte) 5) goto @2 [ i#2 s#2 ] -- zpby1_gt_coby1_then_la1
lda 2
cmp #5
beq !+
bcs B2
!:
//SEG9 [2] phi from @1 to @3
B3_from_B1:
// (byte) s#4 = (byte) s#2 // register copy zp byte:3
//SEG10 [2] phi (byte) s#4 = (byte) s#2 -- register_copy
jmp B3
//SEG11 @3
B3:
// [3] (byte) i#1 ← -- (byte) i#2 [ i#1 s#4 ] // zpby1=_dec_zpby1
//SEG12 [3] (byte) i#1 ← -- (byte) i#2 [ i#1 s#4 ] -- zpby1=_dec_zpby1
dec 2
// [4] if((byte) i#1>(byte) 0) goto @1 [ i#1 s#4 ] // zpby1_gt_0_then_la1
//SEG13 [4] if((byte) i#1>(byte) 0) goto @1 [ i#1 s#4 ] -- zpby1_gt_0_then_la1
lda 2
bne B1_from_B3
jmp BEND
//SEG14 @END
BEND:
//SEG15 @2
B2:
// [5] (byte) s#1 ← (byte) s#2 + (byte) i#2 [ i#2 s#1 ] // zpby1=zpby1_plus_zpby2
//SEG16 [5] (byte) s#1 ← (byte) s#2 + (byte) i#2 [ i#2 s#1 ] -- zpby1=zpby1_plus_zpby2
lda 3
clc
adc 2
sta 3
//SEG17 [2] phi from @2 to @3
B3_from_B2:
// (byte) s#4 = (byte) s#1 // register copy zp byte:3
//SEG18 [2] phi (byte) s#4 = (byte) s#1 -- register_copy
jmp B3
Removing instruction jmp B1
@ -446,82 +455,100 @@ Removing instruction jmp B3
Removing instruction jmp BEND
Succesful ASM optimization Pass5NextJumpElimination
ASSEMBLER
//SEG0 @BEGIN
BBEGIN:
//SEG1 [0] phi from @BEGIN to @1
B1_from_BBEGIN:
// (byte) s#2 = (byte) 0 // zpby1=coby1
//SEG2 [0] phi (byte) s#2 = (byte) 0 -- zpby1=coby1
lda #0
sta 3
// (byte) i#2 = (byte) 10 // zpby1=coby1
//SEG3 [0] phi (byte) i#2 = (byte) 10 -- zpby1=coby1
lda #10
sta 2
jmp B1
//SEG4 [0] phi from @3 to @1
B1_from_B3:
// (byte) s#2 = (byte) s#4 // register copy zp byte:3
// (byte) i#2 = (byte) i#1 // register copy zp byte:2
//SEG5 [0] phi (byte) s#2 = (byte) s#4 -- register_copy
//SEG6 [0] phi (byte) i#2 = (byte) i#1 -- register_copy
//SEG7 @1
B1:
// [1] if((byte) i#2>(byte) 5) goto @2 [ i#2 s#2 ] // zpby1_gt_coby1_then_la1
//SEG8 [1] if((byte) i#2>(byte) 5) goto @2 [ i#2 s#2 ] -- zpby1_gt_coby1_then_la1
lda 2
cmp #5
beq !+
bcs B2
!:
//SEG9 [2] phi from @1 to @3
B3_from_B1:
// (byte) s#4 = (byte) s#2 // register copy zp byte:3
//SEG10 [2] phi (byte) s#4 = (byte) s#2 -- register_copy
//SEG11 @3
B3:
// [3] (byte) i#1 ← -- (byte) i#2 [ i#1 s#4 ] // zpby1=_dec_zpby1
//SEG12 [3] (byte) i#1 ← -- (byte) i#2 [ i#1 s#4 ] -- zpby1=_dec_zpby1
dec 2
// [4] if((byte) i#1>(byte) 0) goto @1 [ i#1 s#4 ] // zpby1_gt_0_then_la1
//SEG13 [4] if((byte) i#1>(byte) 0) goto @1 [ i#1 s#4 ] -- zpby1_gt_0_then_la1
lda 2
bne B1_from_B3
//SEG14 @END
BEND:
//SEG15 @2
B2:
// [5] (byte) s#1 ← (byte) s#2 + (byte) i#2 [ i#2 s#1 ] // zpby1=zpby1_plus_zpby2
//SEG16 [5] (byte) s#1 ← (byte) s#2 + (byte) i#2 [ i#2 s#1 ] -- zpby1=zpby1_plus_zpby2
lda 3
clc
adc 2
sta 3
//SEG17 [2] phi from @2 to @3
B3_from_B2:
// (byte) s#4 = (byte) s#1 // register copy zp byte:3
//SEG18 [2] phi (byte) s#4 = (byte) s#1 -- register_copy
jmp B3
Removing instruction jmp B1
Succesful ASM optimization Pass5NextJumpElimination
ASSEMBLER
//SEG0 @BEGIN
BBEGIN:
//SEG1 [0] phi from @BEGIN to @1
B1_from_BBEGIN:
// (byte) s#2 = (byte) 0 // zpby1=coby1
//SEG2 [0] phi (byte) s#2 = (byte) 0 -- zpby1=coby1
lda #0
sta 3
// (byte) i#2 = (byte) 10 // zpby1=coby1
//SEG3 [0] phi (byte) i#2 = (byte) 10 -- zpby1=coby1
lda #10
sta 2
//SEG4 [0] phi from @3 to @1
B1_from_B3:
// (byte) s#2 = (byte) s#4 // register copy zp byte:3
// (byte) i#2 = (byte) i#1 // register copy zp byte:2
//SEG5 [0] phi (byte) s#2 = (byte) s#4 -- register_copy
//SEG6 [0] phi (byte) i#2 = (byte) i#1 -- register_copy
//SEG7 @1
B1:
// [1] if((byte) i#2>(byte) 5) goto @2 [ i#2 s#2 ] // zpby1_gt_coby1_then_la1
//SEG8 [1] if((byte) i#2>(byte) 5) goto @2 [ i#2 s#2 ] -- zpby1_gt_coby1_then_la1
lda 2
cmp #5
beq !+
bcs B2
!:
//SEG9 [2] phi from @1 to @3
B3_from_B1:
// (byte) s#4 = (byte) s#2 // register copy zp byte:3
//SEG10 [2] phi (byte) s#4 = (byte) s#2 -- register_copy
//SEG11 @3
B3:
// [3] (byte) i#1 ← -- (byte) i#2 [ i#1 s#4 ] // zpby1=_dec_zpby1
//SEG12 [3] (byte) i#1 ← -- (byte) i#2 [ i#1 s#4 ] -- zpby1=_dec_zpby1
dec 2
// [4] if((byte) i#1>(byte) 0) goto @1 [ i#1 s#4 ] // zpby1_gt_0_then_la1
//SEG13 [4] if((byte) i#1>(byte) 0) goto @1 [ i#1 s#4 ] -- zpby1_gt_0_then_la1
lda 2
bne B1_from_B3
//SEG14 @END
BEND:
//SEG15 @2
B2:
// [5] (byte) s#1 ← (byte) s#2 + (byte) i#2 [ i#2 s#1 ] // zpby1=zpby1_plus_zpby2
//SEG16 [5] (byte) s#1 ← (byte) s#2 + (byte) i#2 [ i#2 s#1 ] -- zpby1=zpby1_plus_zpby2
lda 3
clc
adc 2
sta 3
//SEG17 [2] phi from @2 to @3
B3_from_B2:
// (byte) s#4 = (byte) s#1 // register copy zp byte:3
//SEG18 [2] phi (byte) s#4 = (byte) s#1 -- register_copy
jmp B3
FINAL SYMBOL TABLE
@ -542,40 +569,49 @@ zp byte:2 [ i#2 i#1 ]
zp byte:3 [ s#2 s#4 s#1 ]
FINAL CODE
//SEG0 @BEGIN
BBEGIN:
//SEG1 [0] phi from @BEGIN to @1
B1_from_BBEGIN:
// (byte) s#2 = (byte) 0 // zpby1=coby1
//SEG2 [0] phi (byte) s#2 = (byte) 0 -- zpby1=coby1
lda #0
sta 3
// (byte) i#2 = (byte) 10 // zpby1=coby1
//SEG3 [0] phi (byte) i#2 = (byte) 10 -- zpby1=coby1
lda #10
sta 2
//SEG4 [0] phi from @3 to @1
B1_from_B3:
// (byte) s#2 = (byte) s#4 // register copy zp byte:3
// (byte) i#2 = (byte) i#1 // register copy zp byte:2
//SEG5 [0] phi (byte) s#2 = (byte) s#4 -- register_copy
//SEG6 [0] phi (byte) i#2 = (byte) i#1 -- register_copy
//SEG7 @1
B1:
// [1] if((byte) i#2>(byte) 5) goto @2 [ i#2 s#2 ] // zpby1_gt_coby1_then_la1
//SEG8 [1] if((byte) i#2>(byte) 5) goto @2 [ i#2 s#2 ] -- zpby1_gt_coby1_then_la1
lda 2
cmp #5
beq !+
bcs B2
!:
//SEG9 [2] phi from @1 to @3
B3_from_B1:
// (byte) s#4 = (byte) s#2 // register copy zp byte:3
//SEG10 [2] phi (byte) s#4 = (byte) s#2 -- register_copy
//SEG11 @3
B3:
// [3] (byte) i#1 ← -- (byte) i#2 [ i#1 s#4 ] // zpby1=_dec_zpby1
//SEG12 [3] (byte) i#1 ← -- (byte) i#2 [ i#1 s#4 ] -- zpby1=_dec_zpby1
dec 2
// [4] if((byte) i#1>(byte) 0) goto @1 [ i#1 s#4 ] // zpby1_gt_0_then_la1
//SEG13 [4] if((byte) i#1>(byte) 0) goto @1 [ i#1 s#4 ] -- zpby1_gt_0_then_la1
lda 2
bne B1_from_B3
//SEG14 @END
BEND:
//SEG15 @2
B2:
// [5] (byte) s#1 ← (byte) s#2 + (byte) i#2 [ i#2 s#1 ] // zpby1=zpby1_plus_zpby2
//SEG16 [5] (byte) s#1 ← (byte) s#2 + (byte) i#2 [ i#2 s#1 ] -- zpby1=zpby1_plus_zpby2
lda 3
clc
adc 2
sta 3
//SEG17 [2] phi from @2 to @3
B3_from_B2:
// (byte) s#4 = (byte) s#1 // register copy zp byte:3
//SEG18 [2] phi (byte) s#4 = (byte) s#1 -- register_copy
jmp B3

View File

@ -753,51 +753,68 @@ zp byte:2 [ main::i#2 main::i#1 ]
zp byte:3 [ nest::j#2 nest::j#1 ]
INITIAL ASM
//SEG0 @BEGIN
BBEGIN:
//SEG1 [0] call main param-assignment [ ]
jsr main
jmp BEND
//SEG2 @END
BEND:
//SEG3 main
main:
//SEG4 [1] phi from main to main::@1
main__B1_from_main:
// (byte) main::i#2 = (byte) 100 // zpby1=coby1
//SEG5 [1] phi (byte) main::i#2 = (byte) 100 -- zpby1=coby1
lda #100
sta 2
jmp main__B1
//SEG6 [1] phi from main::@3 to main::@1
main__B1_from_B3:
// (byte) main::i#2 = (byte) main::i#1 // register copy zp byte:2
//SEG7 [1] phi (byte) main::i#2 = (byte) main::i#1 -- register_copy
jmp main__B1
//SEG8 main::@1
main__B1:
//SEG9 [2] call nest param-assignment [ main::i#2 ]
jsr nest
jmp main__B3
//SEG10 main::@3
main__B3:
// [3] (byte) main::i#1 ← -- (byte) main::i#2 [ main::i#1 ] // zpby1=_dec_zpby1
//SEG11 [3] (byte) main::i#1 ← -- (byte) main::i#2 [ main::i#1 ] -- zpby1=_dec_zpby1
dec 2
// [4] if((byte) main::i#1>(byte) 0) goto main::@1 [ main::i#1 ] // zpby1_gt_0_then_la1
//SEG12 [4] if((byte) main::i#1>(byte) 0) goto main::@1 [ main::i#1 ] -- zpby1_gt_0_then_la1
lda 2
bne main__B1_from_B3
jmp main__Breturn
//SEG13 main::@return
main__Breturn:
//SEG14 [5] return [ ]
rts
//SEG15 nest
nest:
//SEG16 [6] phi from nest to nest::@1
nest__B1_from_nest:
// (byte) nest::j#2 = (byte) 100 // zpby1=coby1
//SEG17 [6] phi (byte) nest::j#2 = (byte) 100 -- zpby1=coby1
lda #100
sta 3
jmp nest__B1
//SEG18 [6] phi from nest::@1 to nest::@1
nest__B1_from_B1:
// (byte) nest::j#2 = (byte) nest::j#1 // register copy zp byte:3
//SEG19 [6] phi (byte) nest::j#2 = (byte) nest::j#1 -- register_copy
jmp nest__B1
//SEG20 nest::@1
nest__B1:
// [7] *((word) 1024) ← (byte) nest::j#2 [ main::i#2 nest::j#2 ] // _star_cowo1=zpby1
//SEG21 [7] *((word) 1024) ← (byte) nest::j#2 [ main::i#2 nest::j#2 ] -- _star_cowo1=zpby1
lda 3
sta 1024
// [8] (byte) nest::j#1 ← -- (byte) nest::j#2 [ main::i#2 nest::j#1 ] // zpby1=_dec_zpby1
//SEG22 [8] (byte) nest::j#1 ← -- (byte) nest::j#2 [ main::i#2 nest::j#1 ] -- zpby1=_dec_zpby1
dec 3
// [9] if((byte) nest::j#1>(byte) 0) goto nest::@1 [ main::i#2 nest::j#1 ] // zpby1_gt_0_then_la1
//SEG23 [9] if((byte) nest::j#1>(byte) 0) goto nest::@1 [ main::i#2 nest::j#1 ] -- zpby1_gt_0_then_la1
lda 3
bne nest__B1_from_B1
jmp nest__Breturn
//SEG24 nest::@return
nest__Breturn:
//SEG25 [10] return [ main::i#2 ]
rts
Removing instruction jmp BEND
@ -808,88 +825,122 @@ Removing instruction jmp nest__B1
Removing instruction jmp nest__Breturn
Succesful ASM optimization Pass5NextJumpElimination
ASSEMBLER
//SEG0 @BEGIN
BBEGIN:
//SEG1 [0] call main param-assignment [ ]
jsr main
//SEG2 @END
BEND:
//SEG3 main
main:
//SEG4 [1] phi from main to main::@1
main__B1_from_main:
// (byte) main::i#2 = (byte) 100 // zpby1=coby1
//SEG5 [1] phi (byte) main::i#2 = (byte) 100 -- zpby1=coby1
lda #100
sta 2
jmp main__B1
//SEG6 [1] phi from main::@3 to main::@1
main__B1_from_B3:
// (byte) main::i#2 = (byte) main::i#1 // register copy zp byte:2
//SEG7 [1] phi (byte) main::i#2 = (byte) main::i#1 -- register_copy
//SEG8 main::@1
main__B1:
//SEG9 [2] call nest param-assignment [ main::i#2 ]
jsr nest
//SEG10 main::@3
main__B3:
// [3] (byte) main::i#1 ← -- (byte) main::i#2 [ main::i#1 ] // zpby1=_dec_zpby1
//SEG11 [3] (byte) main::i#1 ← -- (byte) main::i#2 [ main::i#1 ] -- zpby1=_dec_zpby1
dec 2
// [4] if((byte) main::i#1>(byte) 0) goto main::@1 [ main::i#1 ] // zpby1_gt_0_then_la1
//SEG12 [4] if((byte) main::i#1>(byte) 0) goto main::@1 [ main::i#1 ] -- zpby1_gt_0_then_la1
lda 2
bne main__B1_from_B3
//SEG13 main::@return
main__Breturn:
//SEG14 [5] return [ ]
rts
//SEG15 nest
nest:
//SEG16 [6] phi from nest to nest::@1
nest__B1_from_nest:
// (byte) nest::j#2 = (byte) 100 // zpby1=coby1
//SEG17 [6] phi (byte) nest::j#2 = (byte) 100 -- zpby1=coby1
lda #100
sta 3
jmp nest__B1
//SEG18 [6] phi from nest::@1 to nest::@1
nest__B1_from_B1:
// (byte) nest::j#2 = (byte) nest::j#1 // register copy zp byte:3
//SEG19 [6] phi (byte) nest::j#2 = (byte) nest::j#1 -- register_copy
//SEG20 nest::@1
nest__B1:
// [7] *((word) 1024) ← (byte) nest::j#2 [ main::i#2 nest::j#2 ] // _star_cowo1=zpby1
//SEG21 [7] *((word) 1024) ← (byte) nest::j#2 [ main::i#2 nest::j#2 ] -- _star_cowo1=zpby1
lda 3
sta 1024
// [8] (byte) nest::j#1 ← -- (byte) nest::j#2 [ main::i#2 nest::j#1 ] // zpby1=_dec_zpby1
//SEG22 [8] (byte) nest::j#1 ← -- (byte) nest::j#2 [ main::i#2 nest::j#1 ] -- zpby1=_dec_zpby1
dec 3
// [9] if((byte) nest::j#1>(byte) 0) goto nest::@1 [ main::i#2 nest::j#1 ] // zpby1_gt_0_then_la1
//SEG23 [9] if((byte) nest::j#1>(byte) 0) goto nest::@1 [ main::i#2 nest::j#1 ] -- zpby1_gt_0_then_la1
lda 3
bne nest__B1_from_B1
//SEG24 nest::@return
nest__Breturn:
//SEG25 [10] return [ main::i#2 ]
rts
Removing instruction jmp main__B1
Removing instruction jmp nest__B1
Succesful ASM optimization Pass5NextJumpElimination
ASSEMBLER
//SEG0 @BEGIN
BBEGIN:
//SEG1 [0] call main param-assignment [ ]
jsr main
//SEG2 @END
BEND:
//SEG3 main
main:
//SEG4 [1] phi from main to main::@1
main__B1_from_main:
// (byte) main::i#2 = (byte) 100 // zpby1=coby1
//SEG5 [1] phi (byte) main::i#2 = (byte) 100 -- zpby1=coby1
lda #100
sta 2
//SEG6 [1] phi from main::@3 to main::@1
main__B1_from_B3:
// (byte) main::i#2 = (byte) main::i#1 // register copy zp byte:2
//SEG7 [1] phi (byte) main::i#2 = (byte) main::i#1 -- register_copy
//SEG8 main::@1
main__B1:
//SEG9 [2] call nest param-assignment [ main::i#2 ]
jsr nest
//SEG10 main::@3
main__B3:
// [3] (byte) main::i#1 ← -- (byte) main::i#2 [ main::i#1 ] // zpby1=_dec_zpby1
//SEG11 [3] (byte) main::i#1 ← -- (byte) main::i#2 [ main::i#1 ] -- zpby1=_dec_zpby1
dec 2
// [4] if((byte) main::i#1>(byte) 0) goto main::@1 [ main::i#1 ] // zpby1_gt_0_then_la1
//SEG12 [4] if((byte) main::i#1>(byte) 0) goto main::@1 [ main::i#1 ] -- zpby1_gt_0_then_la1
lda 2
bne main__B1_from_B3
//SEG13 main::@return
main__Breturn:
//SEG14 [5] return [ ]
rts
//SEG15 nest
nest:
//SEG16 [6] phi from nest to nest::@1
nest__B1_from_nest:
// (byte) nest::j#2 = (byte) 100 // zpby1=coby1
//SEG17 [6] phi (byte) nest::j#2 = (byte) 100 -- zpby1=coby1
lda #100
sta 3
//SEG18 [6] phi from nest::@1 to nest::@1
nest__B1_from_B1:
// (byte) nest::j#2 = (byte) nest::j#1 // register copy zp byte:3
//SEG19 [6] phi (byte) nest::j#2 = (byte) nest::j#1 -- register_copy
//SEG20 nest::@1
nest__B1:
// [7] *((word) 1024) ← (byte) nest::j#2 [ main::i#2 nest::j#2 ] // _star_cowo1=zpby1
//SEG21 [7] *((word) 1024) ← (byte) nest::j#2 [ main::i#2 nest::j#2 ] -- _star_cowo1=zpby1
lda 3
sta 1024
// [8] (byte) nest::j#1 ← -- (byte) nest::j#2 [ main::i#2 nest::j#1 ] // zpby1=_dec_zpby1
//SEG22 [8] (byte) nest::j#1 ← -- (byte) nest::j#2 [ main::i#2 nest::j#1 ] -- zpby1=_dec_zpby1
dec 3
// [9] if((byte) nest::j#1>(byte) 0) goto nest::@1 [ main::i#2 nest::j#1 ] // zpby1_gt_0_then_la1
//SEG23 [9] if((byte) nest::j#1>(byte) 0) goto nest::@1 [ main::i#2 nest::j#1 ] -- zpby1_gt_0_then_la1
lda 3
bne nest__B1_from_B1
//SEG24 nest::@return
nest__Breturn:
//SEG25 [10] return [ main::i#2 ]
rts
FINAL SYMBOL TABLE
@ -914,42 +965,59 @@ zp byte:2 [ main::i#2 main::i#1 ]
zp byte:3 [ nest::j#2 nest::j#1 ]
FINAL CODE
//SEG0 @BEGIN
BBEGIN:
//SEG1 [0] call main param-assignment [ ]
jsr main
//SEG2 @END
BEND:
//SEG3 main
main:
//SEG4 [1] phi from main to main::@1
main__B1_from_main:
// (byte) main::i#2 = (byte) 100 // zpby1=coby1
//SEG5 [1] phi (byte) main::i#2 = (byte) 100 -- zpby1=coby1
lda #100
sta 2
//SEG6 [1] phi from main::@3 to main::@1
main__B1_from_B3:
// (byte) main::i#2 = (byte) main::i#1 // register copy zp byte:2
//SEG7 [1] phi (byte) main::i#2 = (byte) main::i#1 -- register_copy
//SEG8 main::@1
main__B1:
//SEG9 [2] call nest param-assignment [ main::i#2 ]
jsr nest
//SEG10 main::@3
main__B3:
// [3] (byte) main::i#1 ← -- (byte) main::i#2 [ main::i#1 ] // zpby1=_dec_zpby1
//SEG11 [3] (byte) main::i#1 ← -- (byte) main::i#2 [ main::i#1 ] -- zpby1=_dec_zpby1
dec 2
// [4] if((byte) main::i#1>(byte) 0) goto main::@1 [ main::i#1 ] // zpby1_gt_0_then_la1
//SEG12 [4] if((byte) main::i#1>(byte) 0) goto main::@1 [ main::i#1 ] -- zpby1_gt_0_then_la1
lda 2
bne main__B1_from_B3
//SEG13 main::@return
main__Breturn:
//SEG14 [5] return [ ]
rts
//SEG15 nest
nest:
//SEG16 [6] phi from nest to nest::@1
nest__B1_from_nest:
// (byte) nest::j#2 = (byte) 100 // zpby1=coby1
//SEG17 [6] phi (byte) nest::j#2 = (byte) 100 -- zpby1=coby1
lda #100
sta 3
//SEG18 [6] phi from nest::@1 to nest::@1
nest__B1_from_B1:
// (byte) nest::j#2 = (byte) nest::j#1 // register copy zp byte:3
//SEG19 [6] phi (byte) nest::j#2 = (byte) nest::j#1 -- register_copy
//SEG20 nest::@1
nest__B1:
// [7] *((word) 1024) ← (byte) nest::j#2 [ main::i#2 nest::j#2 ] // _star_cowo1=zpby1
//SEG21 [7] *((word) 1024) ← (byte) nest::j#2 [ main::i#2 nest::j#2 ] -- _star_cowo1=zpby1
lda 3
sta 1024
// [8] (byte) nest::j#1 ← -- (byte) nest::j#2 [ main::i#2 nest::j#1 ] // zpby1=_dec_zpby1
//SEG22 [8] (byte) nest::j#1 ← -- (byte) nest::j#2 [ main::i#2 nest::j#1 ] -- zpby1=_dec_zpby1
dec 3
// [9] if((byte) nest::j#1>(byte) 0) goto nest::@1 [ main::i#2 nest::j#1 ] // zpby1_gt_0_then_la1
//SEG23 [9] if((byte) nest::j#1>(byte) 0) goto nest::@1 [ main::i#2 nest::j#1 ] -- zpby1_gt_0_then_la1
lda 3
bne nest__B1_from_B1
//SEG24 nest::@return
nest__Breturn:
//SEG25 [10] return [ main::i#2 ]
rts

View File

@ -1881,120 +1881,157 @@ zp byte:6 [ nest2::i#2 nest2::i#1 ]
zp byte:7 [ nest2::j#2 nest2::j#1 ]
INITIAL ASM
//SEG0 @BEGIN
BBEGIN:
//SEG1 [0] call main param-assignment [ ]
jsr main
jmp BEND
//SEG2 @END
BEND:
//SEG3 main
main:
//SEG4 [1] phi from main to main::@1
main__B1_from_main:
// (byte) main::i#2 = (byte) 100 // zpby1=coby1
//SEG5 [1] phi (byte) main::i#2 = (byte) 100 -- zpby1=coby1
lda #100
sta 2
jmp main__B1
//SEG6 [1] phi from main::@3 to main::@1
main__B1_from_B3:
// (byte) main::i#2 = (byte) main::i#1 // register copy zp byte:2
//SEG7 [1] phi (byte) main::i#2 = (byte) main::i#1 -- register_copy
jmp main__B1
//SEG8 main::@1
main__B1:
//SEG9 [2] phi from main::@1 to main::@2
main__B2_from_B1:
// (byte) main::j#2 = (byte) 100 // zpby1=coby1
//SEG10 [2] phi (byte) main::j#2 = (byte) 100 -- zpby1=coby1
lda #100
sta 3
jmp main__B2
//SEG11 [2] phi from main::@5 to main::@2
main__B2_from_B5:
// (byte) main::j#2 = (byte) main::j#1 // register copy zp byte:3
//SEG12 [2] phi (byte) main::j#2 = (byte) main::j#1 -- register_copy
jmp main__B2
//SEG13 main::@2
main__B2:
//SEG14 [3] call nest1 param-assignment [ main::j#2 main::i#2 ]
jsr nest1
jmp main__B5
//SEG15 main::@5
main__B5:
// [4] (byte) main::j#1 ← -- (byte) main::j#2 [ main::j#1 main::i#2 ] // zpby1=_dec_zpby1
//SEG16 [4] (byte) main::j#1 ← -- (byte) main::j#2 [ main::j#1 main::i#2 ] -- zpby1=_dec_zpby1
dec 3
// [5] if((byte) main::j#1>(byte) 0) goto main::@2 [ main::j#1 main::i#2 ] // zpby1_gt_0_then_la1
//SEG17 [5] if((byte) main::j#1>(byte) 0) goto main::@2 [ main::j#1 main::i#2 ] -- zpby1_gt_0_then_la1
lda 3
bne main__B2_from_B5
jmp main__B3
//SEG18 main::@3
main__B3:
// [6] (byte) main::i#1 ← -- (byte) main::i#2 [ main::i#1 ] // zpby1=_dec_zpby1
//SEG19 [6] (byte) main::i#1 ← -- (byte) main::i#2 [ main::i#1 ] -- zpby1=_dec_zpby1
dec 2
// [7] if((byte) main::i#1>(byte) 0) goto main::@1 [ main::i#1 ] // zpby1_gt_0_then_la1
//SEG20 [7] if((byte) main::i#1>(byte) 0) goto main::@1 [ main::i#1 ] -- zpby1_gt_0_then_la1
lda 2
bne main__B1_from_B3
jmp main__Breturn
//SEG21 main::@return
main__Breturn:
//SEG22 [8] return [ ]
rts
//SEG23 nest1
nest1:
//SEG24 [9] phi from nest1 to nest1::@1
nest1__B1_from_nest1:
// (byte) nest1::i#2 = (byte) 100 // zpby1=coby1
//SEG25 [9] phi (byte) nest1::i#2 = (byte) 100 -- zpby1=coby1
lda #100
sta 4
jmp nest1__B1
//SEG26 [9] phi from nest1::@3 to nest1::@1
nest1__B1_from_B3:
// (byte) nest1::i#2 = (byte) nest1::i#1 // register copy zp byte:4
//SEG27 [9] phi (byte) nest1::i#2 = (byte) nest1::i#1 -- register_copy
jmp nest1__B1
//SEG28 nest1::@1
nest1__B1:
//SEG29 [10] phi from nest1::@1 to nest1::@2
nest1__B2_from_B1:
// (byte) nest1::j#2 = (byte) 100 // zpby1=coby1
//SEG30 [10] phi (byte) nest1::j#2 = (byte) 100 -- zpby1=coby1
lda #100
sta 5
jmp nest1__B2
//SEG31 [10] phi from nest1::@5 to nest1::@2
nest1__B2_from_B5:
// (byte) nest1::j#2 = (byte) nest1::j#1 // register copy zp byte:5
//SEG32 [10] phi (byte) nest1::j#2 = (byte) nest1::j#1 -- register_copy
jmp nest1__B2
//SEG33 nest1::@2
nest1__B2:
//SEG34 [11] call nest2 param-assignment [ main::j#2 main::i#2 nest1::j#2 nest1::i#2 ]
jsr nest2
jmp nest1__B5
//SEG35 nest1::@5
nest1__B5:
// [12] (byte) nest1::j#1 ← -- (byte) nest1::j#2 [ main::j#2 main::i#2 nest1::j#1 nest1::i#2 ] // zpby1=_dec_zpby1
//SEG36 [12] (byte) nest1::j#1 ← -- (byte) nest1::j#2 [ main::j#2 main::i#2 nest1::j#1 nest1::i#2 ] -- zpby1=_dec_zpby1
dec 5
// [13] if((byte) nest1::j#1>(byte) 0) goto nest1::@2 [ main::j#2 main::i#2 nest1::j#1 nest1::i#2 ] // zpby1_gt_0_then_la1
//SEG37 [13] if((byte) nest1::j#1>(byte) 0) goto nest1::@2 [ main::j#2 main::i#2 nest1::j#1 nest1::i#2 ] -- zpby1_gt_0_then_la1
lda 5
bne nest1__B2_from_B5
jmp nest1__B3
//SEG38 nest1::@3
nest1__B3:
// [14] (byte) nest1::i#1 ← -- (byte) nest1::i#2 [ main::j#2 main::i#2 nest1::i#1 ] // zpby1=_dec_zpby1
//SEG39 [14] (byte) nest1::i#1 ← -- (byte) nest1::i#2 [ main::j#2 main::i#2 nest1::i#1 ] -- zpby1=_dec_zpby1
dec 4
// [15] if((byte) nest1::i#1>(byte) 0) goto nest1::@1 [ main::j#2 main::i#2 nest1::i#1 ] // zpby1_gt_0_then_la1
//SEG40 [15] if((byte) nest1::i#1>(byte) 0) goto nest1::@1 [ main::j#2 main::i#2 nest1::i#1 ] -- zpby1_gt_0_then_la1
lda 4
bne nest1__B1_from_B3
jmp nest1__Breturn
//SEG41 nest1::@return
nest1__Breturn:
//SEG42 [16] return [ main::j#2 main::i#2 ]
rts
//SEG43 nest2
nest2:
//SEG44 [17] phi from nest2 to nest2::@1
nest2__B1_from_nest2:
// (byte) nest2::i#2 = (byte) 100 // zpby1=coby1
//SEG45 [17] phi (byte) nest2::i#2 = (byte) 100 -- zpby1=coby1
lda #100
sta 6
jmp nest2__B1
//SEG46 [17] phi from nest2::@3 to nest2::@1
nest2__B1_from_B3:
// (byte) nest2::i#2 = (byte) nest2::i#1 // register copy zp byte:6
//SEG47 [17] phi (byte) nest2::i#2 = (byte) nest2::i#1 -- register_copy
jmp nest2__B1
//SEG48 nest2::@1
nest2__B1:
//SEG49 [18] phi from nest2::@1 to nest2::@2
nest2__B2_from_B1:
// (byte) nest2::j#2 = (byte) 100 // zpby1=coby1
//SEG50 [18] phi (byte) nest2::j#2 = (byte) 100 -- zpby1=coby1
lda #100
sta 7
jmp nest2__B2
//SEG51 [18] phi from nest2::@2 to nest2::@2
nest2__B2_from_B2:
// (byte) nest2::j#2 = (byte) nest2::j#1 // register copy zp byte:7
//SEG52 [18] phi (byte) nest2::j#2 = (byte) nest2::j#1 -- register_copy
jmp nest2__B2
//SEG53 nest2::@2
nest2__B2:
// [19] *((word) 1024) ← (byte) nest2::j#2 [ main::j#2 main::i#2 nest1::j#2 nest1::i#2 nest2::j#2 nest2::i#2 ] // _star_cowo1=zpby1
//SEG54 [19] *((word) 1024) ← (byte) nest2::j#2 [ main::j#2 main::i#2 nest1::j#2 nest1::i#2 nest2::j#2 nest2::i#2 ] -- _star_cowo1=zpby1
lda 7
sta 1024
// [20] (byte) nest2::j#1 ← -- (byte) nest2::j#2 [ main::j#2 main::i#2 nest1::j#2 nest1::i#2 nest2::j#1 nest2::i#2 ] // zpby1=_dec_zpby1
//SEG55 [20] (byte) nest2::j#1 ← -- (byte) nest2::j#2 [ main::j#2 main::i#2 nest1::j#2 nest1::i#2 nest2::j#1 nest2::i#2 ] -- zpby1=_dec_zpby1
dec 7
// [21] if((byte) nest2::j#1>(byte) 0) goto nest2::@2 [ main::j#2 main::i#2 nest1::j#2 nest1::i#2 nest2::j#1 nest2::i#2 ] // zpby1_gt_0_then_la1
//SEG56 [21] if((byte) nest2::j#1>(byte) 0) goto nest2::@2 [ main::j#2 main::i#2 nest1::j#2 nest1::i#2 nest2::j#1 nest2::i#2 ] -- zpby1_gt_0_then_la1
lda 7
bne nest2__B2_from_B2
jmp nest2__B3
//SEG57 nest2::@3
nest2__B3:
// [22] (byte) nest2::i#1 ← -- (byte) nest2::i#2 [ main::j#2 main::i#2 nest1::j#2 nest1::i#2 nest2::i#1 ] // zpby1=_dec_zpby1
//SEG58 [22] (byte) nest2::i#1 ← -- (byte) nest2::i#2 [ main::j#2 main::i#2 nest1::j#2 nest1::i#2 nest2::i#1 ] -- zpby1=_dec_zpby1
dec 6
// [23] if((byte) nest2::i#1>(byte) 0) goto nest2::@1 [ main::j#2 main::i#2 nest1::j#2 nest1::i#2 nest2::i#1 ] // zpby1_gt_0_then_la1
//SEG59 [23] if((byte) nest2::i#1>(byte) 0) goto nest2::@1 [ main::j#2 main::i#2 nest1::j#2 nest1::i#2 nest2::i#1 ] -- zpby1_gt_0_then_la1
lda 6
bne nest2__B1_from_B3
jmp nest2__Breturn
//SEG60 nest2::@return
nest2__Breturn:
//SEG61 [24] return [ main::j#2 main::i#2 nest1::j#2 nest1::i#2 ]
rts
Removing instruction jmp BEND
@ -2014,105 +2051,142 @@ Removing instruction jmp nest2__B3
Removing instruction jmp nest2__Breturn
Succesful ASM optimization Pass5NextJumpElimination
ASSEMBLER
//SEG0 @BEGIN
BBEGIN:
//SEG1 [0] call main param-assignment [ ]
jsr main
//SEG2 @END
BEND:
//SEG3 main
main:
//SEG4 [1] phi from main to main::@1
main__B1_from_main:
// (byte) main::i#2 = (byte) 100 // zpby1=coby1
//SEG5 [1] phi (byte) main::i#2 = (byte) 100 -- zpby1=coby1
lda #100
sta 2
jmp main__B1
//SEG6 [1] phi from main::@3 to main::@1
main__B1_from_B3:
// (byte) main::i#2 = (byte) main::i#1 // register copy zp byte:2
//SEG7 [1] phi (byte) main::i#2 = (byte) main::i#1 -- register_copy
//SEG8 main::@1
main__B1:
//SEG9 [2] phi from main::@1 to main::@2
main__B2_from_B1:
// (byte) main::j#2 = (byte) 100 // zpby1=coby1
//SEG10 [2] phi (byte) main::j#2 = (byte) 100 -- zpby1=coby1
lda #100
sta 3
jmp main__B2
//SEG11 [2] phi from main::@5 to main::@2
main__B2_from_B5:
// (byte) main::j#2 = (byte) main::j#1 // register copy zp byte:3
//SEG12 [2] phi (byte) main::j#2 = (byte) main::j#1 -- register_copy
//SEG13 main::@2
main__B2:
//SEG14 [3] call nest1 param-assignment [ main::j#2 main::i#2 ]
jsr nest1
//SEG15 main::@5
main__B5:
// [4] (byte) main::j#1 ← -- (byte) main::j#2 [ main::j#1 main::i#2 ] // zpby1=_dec_zpby1
//SEG16 [4] (byte) main::j#1 ← -- (byte) main::j#2 [ main::j#1 main::i#2 ] -- zpby1=_dec_zpby1
dec 3
// [5] if((byte) main::j#1>(byte) 0) goto main::@2 [ main::j#1 main::i#2 ] // zpby1_gt_0_then_la1
//SEG17 [5] if((byte) main::j#1>(byte) 0) goto main::@2 [ main::j#1 main::i#2 ] -- zpby1_gt_0_then_la1
lda 3
bne main__B2_from_B5
//SEG18 main::@3
main__B3:
// [6] (byte) main::i#1 ← -- (byte) main::i#2 [ main::i#1 ] // zpby1=_dec_zpby1
//SEG19 [6] (byte) main::i#1 ← -- (byte) main::i#2 [ main::i#1 ] -- zpby1=_dec_zpby1
dec 2
// [7] if((byte) main::i#1>(byte) 0) goto main::@1 [ main::i#1 ] // zpby1_gt_0_then_la1
//SEG20 [7] if((byte) main::i#1>(byte) 0) goto main::@1 [ main::i#1 ] -- zpby1_gt_0_then_la1
lda 2
bne main__B1_from_B3
//SEG21 main::@return
main__Breturn:
//SEG22 [8] return [ ]
rts
//SEG23 nest1
nest1:
//SEG24 [9] phi from nest1 to nest1::@1
nest1__B1_from_nest1:
// (byte) nest1::i#2 = (byte) 100 // zpby1=coby1
//SEG25 [9] phi (byte) nest1::i#2 = (byte) 100 -- zpby1=coby1
lda #100
sta 4
jmp nest1__B1
//SEG26 [9] phi from nest1::@3 to nest1::@1
nest1__B1_from_B3:
// (byte) nest1::i#2 = (byte) nest1::i#1 // register copy zp byte:4
//SEG27 [9] phi (byte) nest1::i#2 = (byte) nest1::i#1 -- register_copy
//SEG28 nest1::@1
nest1__B1:
//SEG29 [10] phi from nest1::@1 to nest1::@2
nest1__B2_from_B1:
// (byte) nest1::j#2 = (byte) 100 // zpby1=coby1
//SEG30 [10] phi (byte) nest1::j#2 = (byte) 100 -- zpby1=coby1
lda #100
sta 5
jmp nest1__B2
//SEG31 [10] phi from nest1::@5 to nest1::@2
nest1__B2_from_B5:
// (byte) nest1::j#2 = (byte) nest1::j#1 // register copy zp byte:5
//SEG32 [10] phi (byte) nest1::j#2 = (byte) nest1::j#1 -- register_copy
//SEG33 nest1::@2
nest1__B2:
//SEG34 [11] call nest2 param-assignment [ main::j#2 main::i#2 nest1::j#2 nest1::i#2 ]
jsr nest2
//SEG35 nest1::@5
nest1__B5:
// [12] (byte) nest1::j#1 ← -- (byte) nest1::j#2 [ main::j#2 main::i#2 nest1::j#1 nest1::i#2 ] // zpby1=_dec_zpby1
//SEG36 [12] (byte) nest1::j#1 ← -- (byte) nest1::j#2 [ main::j#2 main::i#2 nest1::j#1 nest1::i#2 ] -- zpby1=_dec_zpby1
dec 5
// [13] if((byte) nest1::j#1>(byte) 0) goto nest1::@2 [ main::j#2 main::i#2 nest1::j#1 nest1::i#2 ] // zpby1_gt_0_then_la1
//SEG37 [13] if((byte) nest1::j#1>(byte) 0) goto nest1::@2 [ main::j#2 main::i#2 nest1::j#1 nest1::i#2 ] -- zpby1_gt_0_then_la1
lda 5
bne nest1__B2_from_B5
//SEG38 nest1::@3
nest1__B3:
// [14] (byte) nest1::i#1 ← -- (byte) nest1::i#2 [ main::j#2 main::i#2 nest1::i#1 ] // zpby1=_dec_zpby1
//SEG39 [14] (byte) nest1::i#1 ← -- (byte) nest1::i#2 [ main::j#2 main::i#2 nest1::i#1 ] -- zpby1=_dec_zpby1
dec 4
// [15] if((byte) nest1::i#1>(byte) 0) goto nest1::@1 [ main::j#2 main::i#2 nest1::i#1 ] // zpby1_gt_0_then_la1
//SEG40 [15] if((byte) nest1::i#1>(byte) 0) goto nest1::@1 [ main::j#2 main::i#2 nest1::i#1 ] -- zpby1_gt_0_then_la1
lda 4
bne nest1__B1_from_B3
//SEG41 nest1::@return
nest1__Breturn:
//SEG42 [16] return [ main::j#2 main::i#2 ]
rts
//SEG43 nest2
nest2:
//SEG44 [17] phi from nest2 to nest2::@1
nest2__B1_from_nest2:
// (byte) nest2::i#2 = (byte) 100 // zpby1=coby1
//SEG45 [17] phi (byte) nest2::i#2 = (byte) 100 -- zpby1=coby1
lda #100
sta 6
jmp nest2__B1
//SEG46 [17] phi from nest2::@3 to nest2::@1
nest2__B1_from_B3:
// (byte) nest2::i#2 = (byte) nest2::i#1 // register copy zp byte:6
//SEG47 [17] phi (byte) nest2::i#2 = (byte) nest2::i#1 -- register_copy
//SEG48 nest2::@1
nest2__B1:
//SEG49 [18] phi from nest2::@1 to nest2::@2
nest2__B2_from_B1:
// (byte) nest2::j#2 = (byte) 100 // zpby1=coby1
//SEG50 [18] phi (byte) nest2::j#2 = (byte) 100 -- zpby1=coby1
lda #100
sta 7
jmp nest2__B2
//SEG51 [18] phi from nest2::@2 to nest2::@2
nest2__B2_from_B2:
// (byte) nest2::j#2 = (byte) nest2::j#1 // register copy zp byte:7
//SEG52 [18] phi (byte) nest2::j#2 = (byte) nest2::j#1 -- register_copy
//SEG53 nest2::@2
nest2__B2:
// [19] *((word) 1024) ← (byte) nest2::j#2 [ main::j#2 main::i#2 nest1::j#2 nest1::i#2 nest2::j#2 nest2::i#2 ] // _star_cowo1=zpby1
//SEG54 [19] *((word) 1024) ← (byte) nest2::j#2 [ main::j#2 main::i#2 nest1::j#2 nest1::i#2 nest2::j#2 nest2::i#2 ] -- _star_cowo1=zpby1
lda 7
sta 1024
// [20] (byte) nest2::j#1 ← -- (byte) nest2::j#2 [ main::j#2 main::i#2 nest1::j#2 nest1::i#2 nest2::j#1 nest2::i#2 ] // zpby1=_dec_zpby1
//SEG55 [20] (byte) nest2::j#1 ← -- (byte) nest2::j#2 [ main::j#2 main::i#2 nest1::j#2 nest1::i#2 nest2::j#1 nest2::i#2 ] -- zpby1=_dec_zpby1
dec 7
// [21] if((byte) nest2::j#1>(byte) 0) goto nest2::@2 [ main::j#2 main::i#2 nest1::j#2 nest1::i#2 nest2::j#1 nest2::i#2 ] // zpby1_gt_0_then_la1
//SEG56 [21] if((byte) nest2::j#1>(byte) 0) goto nest2::@2 [ main::j#2 main::i#2 nest1::j#2 nest1::i#2 nest2::j#1 nest2::i#2 ] -- zpby1_gt_0_then_la1
lda 7
bne nest2__B2_from_B2
//SEG57 nest2::@3
nest2__B3:
// [22] (byte) nest2::i#1 ← -- (byte) nest2::i#2 [ main::j#2 main::i#2 nest1::j#2 nest1::i#2 nest2::i#1 ] // zpby1=_dec_zpby1
//SEG58 [22] (byte) nest2::i#1 ← -- (byte) nest2::i#2 [ main::j#2 main::i#2 nest1::j#2 nest1::i#2 nest2::i#1 ] -- zpby1=_dec_zpby1
dec 6
// [23] if((byte) nest2::i#1>(byte) 0) goto nest2::@1 [ main::j#2 main::i#2 nest1::j#2 nest1::i#2 nest2::i#1 ] // zpby1_gt_0_then_la1
//SEG59 [23] if((byte) nest2::i#1>(byte) 0) goto nest2::@1 [ main::j#2 main::i#2 nest1::j#2 nest1::i#2 nest2::i#1 ] -- zpby1_gt_0_then_la1
lda 6
bne nest2__B1_from_B3
//SEG60 nest2::@return
nest2__Breturn:
//SEG61 [24] return [ main::j#2 main::i#2 nest1::j#2 nest1::i#2 ]
rts
Removing instruction jmp main__B1
@ -2123,99 +2197,136 @@ Removing instruction jmp nest2__B1
Removing instruction jmp nest2__B2
Succesful ASM optimization Pass5NextJumpElimination
ASSEMBLER
//SEG0 @BEGIN
BBEGIN:
//SEG1 [0] call main param-assignment [ ]
jsr main
//SEG2 @END
BEND:
//SEG3 main
main:
//SEG4 [1] phi from main to main::@1
main__B1_from_main:
// (byte) main::i#2 = (byte) 100 // zpby1=coby1
//SEG5 [1] phi (byte) main::i#2 = (byte) 100 -- zpby1=coby1
lda #100
sta 2
//SEG6 [1] phi from main::@3 to main::@1
main__B1_from_B3:
// (byte) main::i#2 = (byte) main::i#1 // register copy zp byte:2
//SEG7 [1] phi (byte) main::i#2 = (byte) main::i#1 -- register_copy
//SEG8 main::@1
main__B1:
//SEG9 [2] phi from main::@1 to main::@2
main__B2_from_B1:
// (byte) main::j#2 = (byte) 100 // zpby1=coby1
//SEG10 [2] phi (byte) main::j#2 = (byte) 100 -- zpby1=coby1
lda #100
sta 3
//SEG11 [2] phi from main::@5 to main::@2
main__B2_from_B5:
// (byte) main::j#2 = (byte) main::j#1 // register copy zp byte:3
//SEG12 [2] phi (byte) main::j#2 = (byte) main::j#1 -- register_copy
//SEG13 main::@2
main__B2:
//SEG14 [3] call nest1 param-assignment [ main::j#2 main::i#2 ]
jsr nest1
//SEG15 main::@5
main__B5:
// [4] (byte) main::j#1 ← -- (byte) main::j#2 [ main::j#1 main::i#2 ] // zpby1=_dec_zpby1
//SEG16 [4] (byte) main::j#1 ← -- (byte) main::j#2 [ main::j#1 main::i#2 ] -- zpby1=_dec_zpby1
dec 3
// [5] if((byte) main::j#1>(byte) 0) goto main::@2 [ main::j#1 main::i#2 ] // zpby1_gt_0_then_la1
//SEG17 [5] if((byte) main::j#1>(byte) 0) goto main::@2 [ main::j#1 main::i#2 ] -- zpby1_gt_0_then_la1
lda 3
bne main__B2_from_B5
//SEG18 main::@3
main__B3:
// [6] (byte) main::i#1 ← -- (byte) main::i#2 [ main::i#1 ] // zpby1=_dec_zpby1
//SEG19 [6] (byte) main::i#1 ← -- (byte) main::i#2 [ main::i#1 ] -- zpby1=_dec_zpby1
dec 2
// [7] if((byte) main::i#1>(byte) 0) goto main::@1 [ main::i#1 ] // zpby1_gt_0_then_la1
//SEG20 [7] if((byte) main::i#1>(byte) 0) goto main::@1 [ main::i#1 ] -- zpby1_gt_0_then_la1
lda 2
bne main__B1_from_B3
//SEG21 main::@return
main__Breturn:
//SEG22 [8] return [ ]
rts
//SEG23 nest1
nest1:
//SEG24 [9] phi from nest1 to nest1::@1
nest1__B1_from_nest1:
// (byte) nest1::i#2 = (byte) 100 // zpby1=coby1
//SEG25 [9] phi (byte) nest1::i#2 = (byte) 100 -- zpby1=coby1
lda #100
sta 4
//SEG26 [9] phi from nest1::@3 to nest1::@1
nest1__B1_from_B3:
// (byte) nest1::i#2 = (byte) nest1::i#1 // register copy zp byte:4
//SEG27 [9] phi (byte) nest1::i#2 = (byte) nest1::i#1 -- register_copy
//SEG28 nest1::@1
nest1__B1:
//SEG29 [10] phi from nest1::@1 to nest1::@2
nest1__B2_from_B1:
// (byte) nest1::j#2 = (byte) 100 // zpby1=coby1
//SEG30 [10] phi (byte) nest1::j#2 = (byte) 100 -- zpby1=coby1
lda #100
sta 5
//SEG31 [10] phi from nest1::@5 to nest1::@2
nest1__B2_from_B5:
// (byte) nest1::j#2 = (byte) nest1::j#1 // register copy zp byte:5
//SEG32 [10] phi (byte) nest1::j#2 = (byte) nest1::j#1 -- register_copy
//SEG33 nest1::@2
nest1__B2:
//SEG34 [11] call nest2 param-assignment [ main::j#2 main::i#2 nest1::j#2 nest1::i#2 ]
jsr nest2
//SEG35 nest1::@5
nest1__B5:
// [12] (byte) nest1::j#1 ← -- (byte) nest1::j#2 [ main::j#2 main::i#2 nest1::j#1 nest1::i#2 ] // zpby1=_dec_zpby1
//SEG36 [12] (byte) nest1::j#1 ← -- (byte) nest1::j#2 [ main::j#2 main::i#2 nest1::j#1 nest1::i#2 ] -- zpby1=_dec_zpby1
dec 5
// [13] if((byte) nest1::j#1>(byte) 0) goto nest1::@2 [ main::j#2 main::i#2 nest1::j#1 nest1::i#2 ] // zpby1_gt_0_then_la1
//SEG37 [13] if((byte) nest1::j#1>(byte) 0) goto nest1::@2 [ main::j#2 main::i#2 nest1::j#1 nest1::i#2 ] -- zpby1_gt_0_then_la1
lda 5
bne nest1__B2_from_B5
//SEG38 nest1::@3
nest1__B3:
// [14] (byte) nest1::i#1 ← -- (byte) nest1::i#2 [ main::j#2 main::i#2 nest1::i#1 ] // zpby1=_dec_zpby1
//SEG39 [14] (byte) nest1::i#1 ← -- (byte) nest1::i#2 [ main::j#2 main::i#2 nest1::i#1 ] -- zpby1=_dec_zpby1
dec 4
// [15] if((byte) nest1::i#1>(byte) 0) goto nest1::@1 [ main::j#2 main::i#2 nest1::i#1 ] // zpby1_gt_0_then_la1
//SEG40 [15] if((byte) nest1::i#1>(byte) 0) goto nest1::@1 [ main::j#2 main::i#2 nest1::i#1 ] -- zpby1_gt_0_then_la1
lda 4
bne nest1__B1_from_B3
//SEG41 nest1::@return
nest1__Breturn:
//SEG42 [16] return [ main::j#2 main::i#2 ]
rts
//SEG43 nest2
nest2:
//SEG44 [17] phi from nest2 to nest2::@1
nest2__B1_from_nest2:
// (byte) nest2::i#2 = (byte) 100 // zpby1=coby1
//SEG45 [17] phi (byte) nest2::i#2 = (byte) 100 -- zpby1=coby1
lda #100
sta 6
//SEG46 [17] phi from nest2::@3 to nest2::@1
nest2__B1_from_B3:
// (byte) nest2::i#2 = (byte) nest2::i#1 // register copy zp byte:6
//SEG47 [17] phi (byte) nest2::i#2 = (byte) nest2::i#1 -- register_copy
//SEG48 nest2::@1
nest2__B1:
//SEG49 [18] phi from nest2::@1 to nest2::@2
nest2__B2_from_B1:
// (byte) nest2::j#2 = (byte) 100 // zpby1=coby1
//SEG50 [18] phi (byte) nest2::j#2 = (byte) 100 -- zpby1=coby1
lda #100
sta 7
//SEG51 [18] phi from nest2::@2 to nest2::@2
nest2__B2_from_B2:
// (byte) nest2::j#2 = (byte) nest2::j#1 // register copy zp byte:7
//SEG52 [18] phi (byte) nest2::j#2 = (byte) nest2::j#1 -- register_copy
//SEG53 nest2::@2
nest2__B2:
// [19] *((word) 1024) ← (byte) nest2::j#2 [ main::j#2 main::i#2 nest1::j#2 nest1::i#2 nest2::j#2 nest2::i#2 ] // _star_cowo1=zpby1
//SEG54 [19] *((word) 1024) ← (byte) nest2::j#2 [ main::j#2 main::i#2 nest1::j#2 nest1::i#2 nest2::j#2 nest2::i#2 ] -- _star_cowo1=zpby1
lda 7
sta 1024
// [20] (byte) nest2::j#1 ← -- (byte) nest2::j#2 [ main::j#2 main::i#2 nest1::j#2 nest1::i#2 nest2::j#1 nest2::i#2 ] // zpby1=_dec_zpby1
//SEG55 [20] (byte) nest2::j#1 ← -- (byte) nest2::j#2 [ main::j#2 main::i#2 nest1::j#2 nest1::i#2 nest2::j#1 nest2::i#2 ] -- zpby1=_dec_zpby1
dec 7
// [21] if((byte) nest2::j#1>(byte) 0) goto nest2::@2 [ main::j#2 main::i#2 nest1::j#2 nest1::i#2 nest2::j#1 nest2::i#2 ] // zpby1_gt_0_then_la1
//SEG56 [21] if((byte) nest2::j#1>(byte) 0) goto nest2::@2 [ main::j#2 main::i#2 nest1::j#2 nest1::i#2 nest2::j#1 nest2::i#2 ] -- zpby1_gt_0_then_la1
lda 7
bne nest2__B2_from_B2
//SEG57 nest2::@3
nest2__B3:
// [22] (byte) nest2::i#1 ← -- (byte) nest2::i#2 [ main::j#2 main::i#2 nest1::j#2 nest1::i#2 nest2::i#1 ] // zpby1=_dec_zpby1
//SEG58 [22] (byte) nest2::i#1 ← -- (byte) nest2::i#2 [ main::j#2 main::i#2 nest1::j#2 nest1::i#2 nest2::i#1 ] -- zpby1=_dec_zpby1
dec 6
// [23] if((byte) nest2::i#1>(byte) 0) goto nest2::@1 [ main::j#2 main::i#2 nest1::j#2 nest1::i#2 nest2::i#1 ] // zpby1_gt_0_then_la1
//SEG59 [23] if((byte) nest2::i#1>(byte) 0) goto nest2::@1 [ main::j#2 main::i#2 nest1::j#2 nest1::i#2 nest2::i#1 ] -- zpby1_gt_0_then_la1
lda 6
bne nest2__B1_from_B3
//SEG60 nest2::@return
nest2__Breturn:
//SEG61 [24] return [ main::j#2 main::i#2 nest1::j#2 nest1::i#2 ]
rts
FINAL SYMBOL TABLE
@ -2266,98 +2377,135 @@ zp byte:6 [ nest2::i#2 nest2::i#1 ]
zp byte:7 [ nest2::j#2 nest2::j#1 ]
FINAL CODE
//SEG0 @BEGIN
BBEGIN:
//SEG1 [0] call main param-assignment [ ]
jsr main
//SEG2 @END
BEND:
//SEG3 main
main:
//SEG4 [1] phi from main to main::@1
main__B1_from_main:
// (byte) main::i#2 = (byte) 100 // zpby1=coby1
//SEG5 [1] phi (byte) main::i#2 = (byte) 100 -- zpby1=coby1
lda #100
sta 2
//SEG6 [1] phi from main::@3 to main::@1
main__B1_from_B3:
// (byte) main::i#2 = (byte) main::i#1 // register copy zp byte:2
//SEG7 [1] phi (byte) main::i#2 = (byte) main::i#1 -- register_copy
//SEG8 main::@1
main__B1:
//SEG9 [2] phi from main::@1 to main::@2
main__B2_from_B1:
// (byte) main::j#2 = (byte) 100 // zpby1=coby1
//SEG10 [2] phi (byte) main::j#2 = (byte) 100 -- zpby1=coby1
lda #100
sta 3
//SEG11 [2] phi from main::@5 to main::@2
main__B2_from_B5:
// (byte) main::j#2 = (byte) main::j#1 // register copy zp byte:3
//SEG12 [2] phi (byte) main::j#2 = (byte) main::j#1 -- register_copy
//SEG13 main::@2
main__B2:
//SEG14 [3] call nest1 param-assignment [ main::j#2 main::i#2 ]
jsr nest1
//SEG15 main::@5
main__B5:
// [4] (byte) main::j#1 ← -- (byte) main::j#2 [ main::j#1 main::i#2 ] // zpby1=_dec_zpby1
//SEG16 [4] (byte) main::j#1 ← -- (byte) main::j#2 [ main::j#1 main::i#2 ] -- zpby1=_dec_zpby1
dec 3
// [5] if((byte) main::j#1>(byte) 0) goto main::@2 [ main::j#1 main::i#2 ] // zpby1_gt_0_then_la1
//SEG17 [5] if((byte) main::j#1>(byte) 0) goto main::@2 [ main::j#1 main::i#2 ] -- zpby1_gt_0_then_la1
lda 3
bne main__B2_from_B5
//SEG18 main::@3
main__B3:
// [6] (byte) main::i#1 ← -- (byte) main::i#2 [ main::i#1 ] // zpby1=_dec_zpby1
//SEG19 [6] (byte) main::i#1 ← -- (byte) main::i#2 [ main::i#1 ] -- zpby1=_dec_zpby1
dec 2
// [7] if((byte) main::i#1>(byte) 0) goto main::@1 [ main::i#1 ] // zpby1_gt_0_then_la1
//SEG20 [7] if((byte) main::i#1>(byte) 0) goto main::@1 [ main::i#1 ] -- zpby1_gt_0_then_la1
lda 2
bne main__B1_from_B3
//SEG21 main::@return
main__Breturn:
//SEG22 [8] return [ ]
rts
//SEG23 nest1
nest1:
//SEG24 [9] phi from nest1 to nest1::@1
nest1__B1_from_nest1:
// (byte) nest1::i#2 = (byte) 100 // zpby1=coby1
//SEG25 [9] phi (byte) nest1::i#2 = (byte) 100 -- zpby1=coby1
lda #100
sta 4
//SEG26 [9] phi from nest1::@3 to nest1::@1
nest1__B1_from_B3:
// (byte) nest1::i#2 = (byte) nest1::i#1 // register copy zp byte:4
//SEG27 [9] phi (byte) nest1::i#2 = (byte) nest1::i#1 -- register_copy
//SEG28 nest1::@1
nest1__B1:
//SEG29 [10] phi from nest1::@1 to nest1::@2
nest1__B2_from_B1:
// (byte) nest1::j#2 = (byte) 100 // zpby1=coby1
//SEG30 [10] phi (byte) nest1::j#2 = (byte) 100 -- zpby1=coby1
lda #100
sta 5
//SEG31 [10] phi from nest1::@5 to nest1::@2
nest1__B2_from_B5:
// (byte) nest1::j#2 = (byte) nest1::j#1 // register copy zp byte:5
//SEG32 [10] phi (byte) nest1::j#2 = (byte) nest1::j#1 -- register_copy
//SEG33 nest1::@2
nest1__B2:
//SEG34 [11] call nest2 param-assignment [ main::j#2 main::i#2 nest1::j#2 nest1::i#2 ]
jsr nest2
//SEG35 nest1::@5
nest1__B5:
// [12] (byte) nest1::j#1 ← -- (byte) nest1::j#2 [ main::j#2 main::i#2 nest1::j#1 nest1::i#2 ] // zpby1=_dec_zpby1
//SEG36 [12] (byte) nest1::j#1 ← -- (byte) nest1::j#2 [ main::j#2 main::i#2 nest1::j#1 nest1::i#2 ] -- zpby1=_dec_zpby1
dec 5
// [13] if((byte) nest1::j#1>(byte) 0) goto nest1::@2 [ main::j#2 main::i#2 nest1::j#1 nest1::i#2 ] // zpby1_gt_0_then_la1
//SEG37 [13] if((byte) nest1::j#1>(byte) 0) goto nest1::@2 [ main::j#2 main::i#2 nest1::j#1 nest1::i#2 ] -- zpby1_gt_0_then_la1
lda 5
bne nest1__B2_from_B5
//SEG38 nest1::@3
nest1__B3:
// [14] (byte) nest1::i#1 ← -- (byte) nest1::i#2 [ main::j#2 main::i#2 nest1::i#1 ] // zpby1=_dec_zpby1
//SEG39 [14] (byte) nest1::i#1 ← -- (byte) nest1::i#2 [ main::j#2 main::i#2 nest1::i#1 ] -- zpby1=_dec_zpby1
dec 4
// [15] if((byte) nest1::i#1>(byte) 0) goto nest1::@1 [ main::j#2 main::i#2 nest1::i#1 ] // zpby1_gt_0_then_la1
//SEG40 [15] if((byte) nest1::i#1>(byte) 0) goto nest1::@1 [ main::j#2 main::i#2 nest1::i#1 ] -- zpby1_gt_0_then_la1
lda 4
bne nest1__B1_from_B3
//SEG41 nest1::@return
nest1__Breturn:
//SEG42 [16] return [ main::j#2 main::i#2 ]
rts
//SEG43 nest2
nest2:
//SEG44 [17] phi from nest2 to nest2::@1
nest2__B1_from_nest2:
// (byte) nest2::i#2 = (byte) 100 // zpby1=coby1
//SEG45 [17] phi (byte) nest2::i#2 = (byte) 100 -- zpby1=coby1
lda #100
sta 6
//SEG46 [17] phi from nest2::@3 to nest2::@1
nest2__B1_from_B3:
// (byte) nest2::i#2 = (byte) nest2::i#1 // register copy zp byte:6
//SEG47 [17] phi (byte) nest2::i#2 = (byte) nest2::i#1 -- register_copy
//SEG48 nest2::@1
nest2__B1:
//SEG49 [18] phi from nest2::@1 to nest2::@2
nest2__B2_from_B1:
// (byte) nest2::j#2 = (byte) 100 // zpby1=coby1
//SEG50 [18] phi (byte) nest2::j#2 = (byte) 100 -- zpby1=coby1
lda #100
sta 7
//SEG51 [18] phi from nest2::@2 to nest2::@2
nest2__B2_from_B2:
// (byte) nest2::j#2 = (byte) nest2::j#1 // register copy zp byte:7
//SEG52 [18] phi (byte) nest2::j#2 = (byte) nest2::j#1 -- register_copy
//SEG53 nest2::@2
nest2__B2:
// [19] *((word) 1024) ← (byte) nest2::j#2 [ main::j#2 main::i#2 nest1::j#2 nest1::i#2 nest2::j#2 nest2::i#2 ] // _star_cowo1=zpby1
//SEG54 [19] *((word) 1024) ← (byte) nest2::j#2 [ main::j#2 main::i#2 nest1::j#2 nest1::i#2 nest2::j#2 nest2::i#2 ] -- _star_cowo1=zpby1
lda 7
sta 1024
// [20] (byte) nest2::j#1 ← -- (byte) nest2::j#2 [ main::j#2 main::i#2 nest1::j#2 nest1::i#2 nest2::j#1 nest2::i#2 ] // zpby1=_dec_zpby1
//SEG55 [20] (byte) nest2::j#1 ← -- (byte) nest2::j#2 [ main::j#2 main::i#2 nest1::j#2 nest1::i#2 nest2::j#1 nest2::i#2 ] -- zpby1=_dec_zpby1
dec 7
// [21] if((byte) nest2::j#1>(byte) 0) goto nest2::@2 [ main::j#2 main::i#2 nest1::j#2 nest1::i#2 nest2::j#1 nest2::i#2 ] // zpby1_gt_0_then_la1
//SEG56 [21] if((byte) nest2::j#1>(byte) 0) goto nest2::@2 [ main::j#2 main::i#2 nest1::j#2 nest1::i#2 nest2::j#1 nest2::i#2 ] -- zpby1_gt_0_then_la1
lda 7
bne nest2__B2_from_B2
//SEG57 nest2::@3
nest2__B3:
// [22] (byte) nest2::i#1 ← -- (byte) nest2::i#2 [ main::j#2 main::i#2 nest1::j#2 nest1::i#2 nest2::i#1 ] // zpby1=_dec_zpby1
//SEG58 [22] (byte) nest2::i#1 ← -- (byte) nest2::i#2 [ main::j#2 main::i#2 nest1::j#2 nest1::i#2 nest2::i#1 ] -- zpby1=_dec_zpby1
dec 6
// [23] if((byte) nest2::i#1>(byte) 0) goto nest2::@1 [ main::j#2 main::i#2 nest1::j#2 nest1::i#2 nest2::i#1 ] // zpby1_gt_0_then_la1
//SEG59 [23] if((byte) nest2::i#1>(byte) 0) goto nest2::@1 [ main::j#2 main::i#2 nest1::j#2 nest1::i#2 nest2::i#1 ] -- zpby1_gt_0_then_la1
lda 6
bne nest2__B1_from_B3
//SEG60 nest2::@return
nest2__Breturn:
//SEG61 [24] return [ main::j#2 main::i#2 nest1::j#2 nest1::i#2 ]
rts

View File

@ -537,9 +537,9 @@ zp byte:3 [ main::s#3 main::s#1 main::s#2 ]
Uplifting max weight 55.0 live range equivalence class zp byte:3 [ main::s#3 main::s#1 main::s#2 ]
Uplift to reg byte a resulted in clobber.
Register Cycles: reg byte x 23
Register Cycles: reg byte x 24
Uplift to reg byte x succesfull.
Register Cycles: reg byte y 23
Register Cycles: reg byte y 24
Uplift to reg byte y succesfull.
REGISTER UPLIFTING
(void()) main()
@ -555,49 +555,62 @@ zp byte:2 [ main::i#2 main::i#1 ]
zp byte:3 [ main::s#3 main::s#1 main::s#2 ]
INITIAL ASM
//SEG0 @BEGIN
BBEGIN:
//SEG1 [0] call main param-assignment [ ]
jsr main
jmp BEND
//SEG2 @END
BEND:
//SEG3 main
main:
//SEG4 [1] phi from main to main::@1
main__B1_from_main:
// (byte) main::s#3 = (byte) 0 // zpby1=coby1
//SEG5 [1] phi (byte) main::s#3 = (byte) 0 -- zpby1=coby1
lda #0
sta 3
// (byte) main::i#2 = (byte) 100 // zpby1=coby1
//SEG6 [1] phi (byte) main::i#2 = (byte) 100 -- zpby1=coby1
lda #100
sta 2
jmp main__B1
//SEG7 main::@1
main__B1:
// [2] (byte) main::i#1 ← -- (byte) main::i#2 [ main::i#1 main::s#3 ] // zpby1=_dec_zpby1
//SEG8 [2] (byte) main::i#1 ← -- (byte) main::i#2 [ main::i#1 main::s#3 ] -- zpby1=_dec_zpby1
dec 2
// [3] if((byte) main::i#1>(byte) 0) goto main::@2 [ main::i#1 main::s#3 ] // zpby1_gt_0_then_la1
//SEG9 [3] if((byte) main::i#1>(byte) 0) goto main::@2 [ main::i#1 main::s#3 ] -- zpby1_gt_0_then_la1
lda 2
bne main__B2
jmp main__Breturn
//SEG10 main::@return
main__Breturn:
//SEG11 [4] return [ ]
rts
//SEG12 main::@2
main__B2:
// [5] if((byte) main::i#1>(byte) 50) goto main::@4 [ main::i#1 main::s#3 ] // zpby1_gt_coby1_then_la1
//SEG13 [5] if((byte) main::i#1>(byte) 50) goto main::@4 [ main::i#1 main::s#3 ] -- zpby1_gt_coby1_then_la1
lda 2
cmp #50
beq !+
bcs main__B4
!:
jmp main__B5
//SEG14 main::@5
main__B5:
// [6] (byte) main::s#2 ← -- (byte) main::s#3 [ main::i#1 main::s#2 ] // zpby1=_dec_zpby1
//SEG15 [6] (byte) main::s#2 ← -- (byte) main::s#3 [ main::i#1 main::s#2 ] -- zpby1=_dec_zpby1
dec 3
//SEG16 [1] phi from main::@5 to main::@1
main__B1_from_B5:
// (byte) main::s#3 = (byte) main::s#2 // register copy zp byte:3
// (byte) main::i#2 = (byte) main::i#1 // register copy zp byte:2
//SEG17 [1] phi (byte) main::s#3 = (byte) main::s#2 -- register_copy
//SEG18 [1] phi (byte) main::i#2 = (byte) main::i#1 -- register_copy
jmp main__B1
//SEG19 main::@4
main__B4:
// [7] (byte) main::s#1 ← ++ (byte) main::s#3 [ main::i#1 main::s#1 ] // zpby1=_inc_zpby1
//SEG20 [7] (byte) main::s#1 ← ++ (byte) main::s#3 [ main::i#1 main::s#1 ] -- zpby1=_inc_zpby1
inc 3
//SEG21 [1] phi from main::@4 to main::@1
main__B1_from_B4:
// (byte) main::s#3 = (byte) main::s#1 // register copy zp byte:3
// (byte) main::i#2 = (byte) main::i#1 // register copy zp byte:2
//SEG22 [1] phi (byte) main::s#3 = (byte) main::s#1 -- register_copy
//SEG23 [1] phi (byte) main::i#2 = (byte) main::i#1 -- register_copy
jmp main__B1
Removing instruction jmp BEND
@ -606,45 +619,58 @@ Removing instruction jmp main__Breturn
Removing instruction jmp main__B5
Succesful ASM optimization Pass5NextJumpElimination
ASSEMBLER
//SEG0 @BEGIN
BBEGIN:
//SEG1 [0] call main param-assignment [ ]
jsr main
//SEG2 @END
BEND:
//SEG3 main
main:
//SEG4 [1] phi from main to main::@1
main__B1_from_main:
// (byte) main::s#3 = (byte) 0 // zpby1=coby1
//SEG5 [1] phi (byte) main::s#3 = (byte) 0 -- zpby1=coby1
lda #0
sta 3
// (byte) main::i#2 = (byte) 100 // zpby1=coby1
//SEG6 [1] phi (byte) main::i#2 = (byte) 100 -- zpby1=coby1
lda #100
sta 2
//SEG7 main::@1
main__B1:
// [2] (byte) main::i#1 ← -- (byte) main::i#2 [ main::i#1 main::s#3 ] // zpby1=_dec_zpby1
//SEG8 [2] (byte) main::i#1 ← -- (byte) main::i#2 [ main::i#1 main::s#3 ] -- zpby1=_dec_zpby1
dec 2
// [3] if((byte) main::i#1>(byte) 0) goto main::@2 [ main::i#1 main::s#3 ] // zpby1_gt_0_then_la1
//SEG9 [3] if((byte) main::i#1>(byte) 0) goto main::@2 [ main::i#1 main::s#3 ] -- zpby1_gt_0_then_la1
lda 2
bne main__B2
//SEG10 main::@return
main__Breturn:
//SEG11 [4] return [ ]
rts
//SEG12 main::@2
main__B2:
// [5] if((byte) main::i#1>(byte) 50) goto main::@4 [ main::i#1 main::s#3 ] // zpby1_gt_coby1_then_la1
//SEG13 [5] if((byte) main::i#1>(byte) 50) goto main::@4 [ main::i#1 main::s#3 ] -- zpby1_gt_coby1_then_la1
lda 2
cmp #50
beq !+
bcs main__B4
!:
//SEG14 main::@5
main__B5:
// [6] (byte) main::s#2 ← -- (byte) main::s#3 [ main::i#1 main::s#2 ] // zpby1=_dec_zpby1
//SEG15 [6] (byte) main::s#2 ← -- (byte) main::s#3 [ main::i#1 main::s#2 ] -- zpby1=_dec_zpby1
dec 3
//SEG16 [1] phi from main::@5 to main::@1
main__B1_from_B5:
// (byte) main::s#3 = (byte) main::s#2 // register copy zp byte:3
// (byte) main::i#2 = (byte) main::i#1 // register copy zp byte:2
//SEG17 [1] phi (byte) main::s#3 = (byte) main::s#2 -- register_copy
//SEG18 [1] phi (byte) main::i#2 = (byte) main::i#1 -- register_copy
jmp main__B1
//SEG19 main::@4
main__B4:
// [7] (byte) main::s#1 ← ++ (byte) main::s#3 [ main::i#1 main::s#1 ] // zpby1=_inc_zpby1
//SEG20 [7] (byte) main::s#1 ← ++ (byte) main::s#3 [ main::i#1 main::s#1 ] -- zpby1=_inc_zpby1
inc 3
//SEG21 [1] phi from main::@4 to main::@1
main__B1_from_B4:
// (byte) main::s#3 = (byte) main::s#1 // register copy zp byte:3
// (byte) main::i#2 = (byte) main::i#1 // register copy zp byte:2
//SEG22 [1] phi (byte) main::s#3 = (byte) main::s#1 -- register_copy
//SEG23 [1] phi (byte) main::i#2 = (byte) main::i#1 -- register_copy
jmp main__B1
FINAL SYMBOL TABLE
@ -668,44 +694,57 @@ zp byte:2 [ main::i#2 main::i#1 ]
zp byte:3 [ main::s#3 main::s#1 main::s#2 ]
FINAL CODE
//SEG0 @BEGIN
BBEGIN:
//SEG1 [0] call main param-assignment [ ]
jsr main
//SEG2 @END
BEND:
//SEG3 main
main:
//SEG4 [1] phi from main to main::@1
main__B1_from_main:
// (byte) main::s#3 = (byte) 0 // zpby1=coby1
//SEG5 [1] phi (byte) main::s#3 = (byte) 0 -- zpby1=coby1
lda #0
sta 3
// (byte) main::i#2 = (byte) 100 // zpby1=coby1
//SEG6 [1] phi (byte) main::i#2 = (byte) 100 -- zpby1=coby1
lda #100
sta 2
//SEG7 main::@1
main__B1:
// [2] (byte) main::i#1 ← -- (byte) main::i#2 [ main::i#1 main::s#3 ] // zpby1=_dec_zpby1
//SEG8 [2] (byte) main::i#1 ← -- (byte) main::i#2 [ main::i#1 main::s#3 ] -- zpby1=_dec_zpby1
dec 2
// [3] if((byte) main::i#1>(byte) 0) goto main::@2 [ main::i#1 main::s#3 ] // zpby1_gt_0_then_la1
//SEG9 [3] if((byte) main::i#1>(byte) 0) goto main::@2 [ main::i#1 main::s#3 ] -- zpby1_gt_0_then_la1
lda 2
bne main__B2
//SEG10 main::@return
main__Breturn:
//SEG11 [4] return [ ]
rts
//SEG12 main::@2
main__B2:
// [5] if((byte) main::i#1>(byte) 50) goto main::@4 [ main::i#1 main::s#3 ] // zpby1_gt_coby1_then_la1
//SEG13 [5] if((byte) main::i#1>(byte) 50) goto main::@4 [ main::i#1 main::s#3 ] -- zpby1_gt_coby1_then_la1
lda 2
cmp #50
beq !+
bcs main__B4
!:
//SEG14 main::@5
main__B5:
// [6] (byte) main::s#2 ← -- (byte) main::s#3 [ main::i#1 main::s#2 ] // zpby1=_dec_zpby1
//SEG15 [6] (byte) main::s#2 ← -- (byte) main::s#3 [ main::i#1 main::s#2 ] -- zpby1=_dec_zpby1
dec 3
//SEG16 [1] phi from main::@5 to main::@1
main__B1_from_B5:
// (byte) main::s#3 = (byte) main::s#2 // register copy zp byte:3
// (byte) main::i#2 = (byte) main::i#1 // register copy zp byte:2
//SEG17 [1] phi (byte) main::s#3 = (byte) main::s#2 -- register_copy
//SEG18 [1] phi (byte) main::i#2 = (byte) main::i#1 -- register_copy
jmp main__B1
//SEG19 main::@4
main__B4:
// [7] (byte) main::s#1 ← ++ (byte) main::s#3 [ main::i#1 main::s#1 ] // zpby1=_inc_zpby1
//SEG20 [7] (byte) main::s#1 ← ++ (byte) main::s#3 [ main::i#1 main::s#1 ] -- zpby1=_inc_zpby1
inc 3
//SEG21 [1] phi from main::@4 to main::@1
main__B1_from_B4:
// (byte) main::s#3 = (byte) main::s#1 // register copy zp byte:3
// (byte) main::i#2 = (byte) main::i#1 // register copy zp byte:2
//SEG22 [1] phi (byte) main::s#3 = (byte) main::s#1 -- register_copy
//SEG23 [1] phi (byte) main::i#2 = (byte) main::i#1 -- register_copy
jmp main__B1

View File

@ -326,90 +326,105 @@ zp byte:2 [ i#2 i#1 ]
zp byte:3 [ $1 ]
INITIAL ASM
//SEG0 @BEGIN
BBEGIN:
//SEG1 [0] phi from @BEGIN to @1
B1_from_BBEGIN:
// (byte) i#2 = (byte) 5 // zpby1=coby1
//SEG2 [0] phi (byte) i#2 = (byte) 5 -- zpby1=coby1
lda #5
sta 2
jmp B1
//SEG3 [0] phi from @1 to @1
B1_from_B1:
// (byte) i#2 = (byte) i#1 // register copy zp byte:2
//SEG4 [0] phi (byte) i#2 = (byte) i#1 -- register_copy
jmp B1
//SEG5 @1
B1:
// [1] (byte~) $1 ← (byte) i#2 + (byte) 4 [ i#2 $1 ] // zpby1=zpby2_plus_coby1
//SEG6 [1] (byte~) $1 ← (byte) i#2 + (byte) 4 [ i#2 $1 ] -- zpby1=zpby2_plus_coby1
lda 2
clc
adc #4
sta 3
// [2] *((word) 4352 + (byte) i#2) ← (byte~) $1 [ i#2 ] // cowo1_staridx_zpby1=zpby2
//SEG7 [2] *((word) 4352 + (byte) i#2) ← (byte~) $1 [ i#2 ] -- cowo1_staridx_zpby1=zpby2
lda 3
ldx 2
sta 4352,x
// [3] (byte) i#1 ← (byte) i#2 + (byte) 1 [ i#1 ] // zpby1=zpby1_plus_1
//SEG8 [3] (byte) i#1 ← (byte) i#2 + (byte) 1 [ i#1 ] -- zpby1=zpby1_plus_1
inc 2
// [4] if((byte) i#1<(byte) 10) goto @1 [ i#1 ] // zpby1_lt_coby1_then_la1
//SEG9 [4] if((byte) i#1<(byte) 10) goto @1 [ i#1 ] -- zpby1_lt_coby1_then_la1
lda 2
cmp #10
bcc B1_from_B1
jmp BEND
//SEG10 @END
BEND:
Removing instruction jmp B1
Removing instruction jmp BEND
Succesful ASM optimization Pass5NextJumpElimination
ASSEMBLER
//SEG0 @BEGIN
BBEGIN:
//SEG1 [0] phi from @BEGIN to @1
B1_from_BBEGIN:
// (byte) i#2 = (byte) 5 // zpby1=coby1
//SEG2 [0] phi (byte) i#2 = (byte) 5 -- zpby1=coby1
lda #5
sta 2
jmp B1
//SEG3 [0] phi from @1 to @1
B1_from_B1:
// (byte) i#2 = (byte) i#1 // register copy zp byte:2
//SEG4 [0] phi (byte) i#2 = (byte) i#1 -- register_copy
//SEG5 @1
B1:
// [1] (byte~) $1 ← (byte) i#2 + (byte) 4 [ i#2 $1 ] // zpby1=zpby2_plus_coby1
//SEG6 [1] (byte~) $1 ← (byte) i#2 + (byte) 4 [ i#2 $1 ] -- zpby1=zpby2_plus_coby1
lda 2
clc
adc #4
sta 3
// [2] *((word) 4352 + (byte) i#2) ← (byte~) $1 [ i#2 ] // cowo1_staridx_zpby1=zpby2
//SEG7 [2] *((word) 4352 + (byte) i#2) ← (byte~) $1 [ i#2 ] -- cowo1_staridx_zpby1=zpby2
lda 3
ldx 2
sta 4352,x
// [3] (byte) i#1 ← (byte) i#2 + (byte) 1 [ i#1 ] // zpby1=zpby1_plus_1
//SEG8 [3] (byte) i#1 ← (byte) i#2 + (byte) 1 [ i#1 ] -- zpby1=zpby1_plus_1
inc 2
// [4] if((byte) i#1<(byte) 10) goto @1 [ i#1 ] // zpby1_lt_coby1_then_la1
//SEG9 [4] if((byte) i#1<(byte) 10) goto @1 [ i#1 ] -- zpby1_lt_coby1_then_la1
lda 2
cmp #10
bcc B1_from_B1
//SEG10 @END
BEND:
Removing instruction jmp B1
Succesful ASM optimization Pass5NextJumpElimination
ASSEMBLER
//SEG0 @BEGIN
BBEGIN:
//SEG1 [0] phi from @BEGIN to @1
B1_from_BBEGIN:
// (byte) i#2 = (byte) 5 // zpby1=coby1
//SEG2 [0] phi (byte) i#2 = (byte) 5 -- zpby1=coby1
lda #5
sta 2
//SEG3 [0] phi from @1 to @1
B1_from_B1:
// (byte) i#2 = (byte) i#1 // register copy zp byte:2
//SEG4 [0] phi (byte) i#2 = (byte) i#1 -- register_copy
//SEG5 @1
B1:
// [1] (byte~) $1 ← (byte) i#2 + (byte) 4 [ i#2 $1 ] // zpby1=zpby2_plus_coby1
//SEG6 [1] (byte~) $1 ← (byte) i#2 + (byte) 4 [ i#2 $1 ] -- zpby1=zpby2_plus_coby1
lda 2
clc
adc #4
sta 3
// [2] *((word) 4352 + (byte) i#2) ← (byte~) $1 [ i#2 ] // cowo1_staridx_zpby1=zpby2
//SEG7 [2] *((word) 4352 + (byte) i#2) ← (byte~) $1 [ i#2 ] -- cowo1_staridx_zpby1=zpby2
lda 3
ldx 2
sta 4352,x
// [3] (byte) i#1 ← (byte) i#2 + (byte) 1 [ i#1 ] // zpby1=zpby1_plus_1
//SEG8 [3] (byte) i#1 ← (byte) i#2 + (byte) 1 [ i#1 ] -- zpby1=zpby1_plus_1
inc 2
// [4] if((byte) i#1<(byte) 10) goto @1 [ i#1 ] // zpby1_lt_coby1_then_la1
//SEG9 [4] if((byte) i#1<(byte) 10) goto @1 [ i#1 ] -- zpby1_lt_coby1_then_la1
lda 2
cmp #10
bcc B1_from_B1
//SEG10 @END
BEND:
FINAL SYMBOL TABLE
@ -426,28 +441,33 @@ zp byte:2 [ i#2 i#1 ]
zp byte:3 [ $1 ]
FINAL CODE
//SEG0 @BEGIN
BBEGIN:
//SEG1 [0] phi from @BEGIN to @1
B1_from_BBEGIN:
// (byte) i#2 = (byte) 5 // zpby1=coby1
//SEG2 [0] phi (byte) i#2 = (byte) 5 -- zpby1=coby1
lda #5
sta 2
//SEG3 [0] phi from @1 to @1
B1_from_B1:
// (byte) i#2 = (byte) i#1 // register copy zp byte:2
//SEG4 [0] phi (byte) i#2 = (byte) i#1 -- register_copy
//SEG5 @1
B1:
// [1] (byte~) $1 ← (byte) i#2 + (byte) 4 [ i#2 $1 ] // zpby1=zpby2_plus_coby1
//SEG6 [1] (byte~) $1 ← (byte) i#2 + (byte) 4 [ i#2 $1 ] -- zpby1=zpby2_plus_coby1
lda 2
clc
adc #4
sta 3
// [2] *((word) 4352 + (byte) i#2) ← (byte~) $1 [ i#2 ] // cowo1_staridx_zpby1=zpby2
//SEG7 [2] *((word) 4352 + (byte) i#2) ← (byte~) $1 [ i#2 ] -- cowo1_staridx_zpby1=zpby2
lda 3
ldx 2
sta 4352,x
// [3] (byte) i#1 ← (byte) i#2 + (byte) 1 [ i#1 ] // zpby1=zpby1_plus_1
//SEG8 [3] (byte) i#1 ← (byte) i#2 + (byte) 1 [ i#1 ] -- zpby1=zpby1_plus_1
inc 2
// [4] if((byte) i#1<(byte) 10) goto @1 [ i#1 ] // zpby1_lt_coby1_then_la1
//SEG9 [4] if((byte) i#1<(byte) 10) goto @1 [ i#1 ] -- zpby1_lt_coby1_then_la1
lda 2
cmp #10
bcc B1_from_B1
//SEG10 @END
BEND:

View File

@ -1947,153 +1947,194 @@ Coalescing zero page register [ zp byte:2 [ lvaluevar::i#2 lvaluevar::i#1 rvalue
Coalescing zero page register [ zp byte:2 [ lvaluevar::i#2 lvaluevar::i#1 rvaluevar::i#2 rvaluevar::i#1 rvalue::i#2 rvalue::i#1 lvalue::i#2 lvalue::i#1 rvaluevar::b#0 rvalue::b#0 rvalue::b#1 ] ] with [ zp byte:13 [ rvalue::b#2 ] ]
Coalescing zero page register [ zp ptr byte:3 [ lvaluevar::screen#2 lvaluevar::screen#1 ] ] with [ zp ptr byte:6 [ rvaluevar::screen#2 rvaluevar::screen#1 ] ]
INITIAL ASM
//SEG0 @BEGIN
BBEGIN:
//SEG1 [0] call main param-assignment [ ]
jsr main
jmp BEND
//SEG2 @END
BEND:
//SEG3 main
main:
//SEG4 [1] call lvalue param-assignment [ ]
jsr lvalue
jmp main__B1
//SEG5 main::@1
main__B1:
//SEG6 [2] call rvalue param-assignment [ ]
jsr rvalue
jmp main__B2
//SEG7 main::@2
main__B2:
//SEG8 [3] call rvaluevar param-assignment [ ]
jsr rvaluevar
jmp main__B3
//SEG9 main::@3
main__B3:
//SEG10 [4] call lvaluevar param-assignment [ ]
jsr lvaluevar
jmp main__Breturn
//SEG11 main::@return
main__Breturn:
//SEG12 [5] return [ ]
rts
//SEG13 lvaluevar
lvaluevar:
//SEG14 [6] phi from lvaluevar to lvaluevar::@1
lvaluevar__B1_from_lvaluevar:
// (byte*) lvaluevar::screen#2 = (word) 1024 // zpptrby1=cowo1
//SEG15 [6] phi (byte*) lvaluevar::screen#2 = (word) 1024 -- zpptrby1=cowo1
lda #<1024
sta 3
lda #>1024
sta 3+1
// (byte) lvaluevar::i#2 = (byte) 2 // zpby1=coby1
//SEG16 [6] phi (byte) lvaluevar::i#2 = (byte) 2 -- zpby1=coby1
lda #2
sta 2
jmp lvaluevar__B1
//SEG17 lvaluevar::@1
lvaluevar__B1:
// [7] if((byte) lvaluevar::i#2<(byte) 10) goto lvaluevar::@2 [ lvaluevar::i#2 lvaluevar::screen#2 ] // zpby1_lt_coby1_then_la1
//SEG18 [7] if((byte) lvaluevar::i#2<(byte) 10) goto lvaluevar::@2 [ lvaluevar::i#2 lvaluevar::screen#2 ] -- zpby1_lt_coby1_then_la1
lda 2
cmp #10
bcc lvaluevar__B2
jmp lvaluevar__Breturn
//SEG19 lvaluevar::@return
lvaluevar__Breturn:
//SEG20 [8] return [ ]
rts
//SEG21 lvaluevar::@2
lvaluevar__B2:
// [9] *((byte*) lvaluevar::screen#2) ← (byte) 4 [ lvaluevar::i#2 lvaluevar::screen#2 ] // _star_zpptrby1=coby1
//SEG22 [9] *((byte*) lvaluevar::screen#2) ← (byte) 4 [ lvaluevar::i#2 lvaluevar::screen#2 ] -- _star_zpptrby1=coby1
ldy #0
lda #4
sta (3),y
// [10] (byte*) lvaluevar::screen#1 ← ++ (byte*) lvaluevar::screen#2 [ lvaluevar::screen#1 lvaluevar::i#2 ] // zpptrby1=_inc_zpptrby1
//SEG23 [10] (byte*) lvaluevar::screen#1 ← ++ (byte*) lvaluevar::screen#2 [ lvaluevar::screen#1 lvaluevar::i#2 ] -- zpptrby1=_inc_zpptrby1
inc 3
bne !+
inc 3+1
!:
// [11] (byte) lvaluevar::i#1 ← ++ (byte) lvaluevar::i#2 [ lvaluevar::i#1 lvaluevar::screen#1 ] // zpby1=_inc_zpby1
//SEG24 [11] (byte) lvaluevar::i#1 ← ++ (byte) lvaluevar::i#2 [ lvaluevar::i#1 lvaluevar::screen#1 ] -- zpby1=_inc_zpby1
inc 2
//SEG25 [6] phi from lvaluevar::@2 to lvaluevar::@1
lvaluevar__B1_from_B2:
// (byte*) lvaluevar::screen#2 = (byte*) lvaluevar::screen#1 // register copy zp ptr byte:3
// (byte) lvaluevar::i#2 = (byte) lvaluevar::i#1 // register copy zp byte:2
//SEG26 [6] phi (byte*) lvaluevar::screen#2 = (byte*) lvaluevar::screen#1 -- register_copy
//SEG27 [6] phi (byte) lvaluevar::i#2 = (byte) lvaluevar::i#1 -- register_copy
jmp lvaluevar__B1
//SEG28 rvaluevar
rvaluevar:
//SEG29 [12] phi from rvaluevar to rvaluevar::@1
rvaluevar__B1_from_rvaluevar:
// (byte*) rvaluevar::screen#2 = (word) 1024 // zpptrby1=cowo1
//SEG30 [12] phi (byte*) rvaluevar::screen#2 = (word) 1024 -- zpptrby1=cowo1
lda #<1024
sta 6
lda #>1024
sta 6+1
// (byte) rvaluevar::i#2 = (byte) 2 // zpby1=coby1
//SEG31 [12] phi (byte) rvaluevar::i#2 = (byte) 2 -- zpby1=coby1
lda #2
sta 5
jmp rvaluevar__B1
//SEG32 rvaluevar::@1
rvaluevar__B1:
// [13] if((byte) rvaluevar::i#2<(byte) 10) goto rvaluevar::@2 [ rvaluevar::i#2 rvaluevar::screen#2 ] // zpby1_lt_coby1_then_la1
//SEG33 [13] if((byte) rvaluevar::i#2<(byte) 10) goto rvaluevar::@2 [ rvaluevar::i#2 rvaluevar::screen#2 ] -- zpby1_lt_coby1_then_la1
lda 5
cmp #10
bcc rvaluevar__B2
jmp rvaluevar__Breturn
//SEG34 rvaluevar::@return
rvaluevar__Breturn:
//SEG35 [14] return [ ]
rts
//SEG36 rvaluevar::@2
rvaluevar__B2:
// [15] (byte) rvaluevar::b#0 ← * (byte*) rvaluevar::screen#2 [ rvaluevar::i#2 rvaluevar::screen#2 ] // zpby1=_star_zpptrby1
//SEG37 [15] (byte) rvaluevar::b#0 ← * (byte*) rvaluevar::screen#2 [ rvaluevar::i#2 rvaluevar::screen#2 ] -- zpby1=_star_zpptrby1
ldy #0
lda (6),y
sta 10
// [16] (byte*) rvaluevar::screen#1 ← ++ (byte*) rvaluevar::screen#2 [ rvaluevar::screen#1 rvaluevar::i#2 ] // zpptrby1=_inc_zpptrby1
//SEG38 [16] (byte*) rvaluevar::screen#1 ← ++ (byte*) rvaluevar::screen#2 [ rvaluevar::screen#1 rvaluevar::i#2 ] -- zpptrby1=_inc_zpptrby1
inc 6
bne !+
inc 6+1
!:
// [17] (byte) rvaluevar::i#1 ← ++ (byte) rvaluevar::i#2 [ rvaluevar::i#1 rvaluevar::screen#1 ] // zpby1=_inc_zpby1
//SEG39 [17] (byte) rvaluevar::i#1 ← ++ (byte) rvaluevar::i#2 [ rvaluevar::i#1 rvaluevar::screen#1 ] -- zpby1=_inc_zpby1
inc 5
//SEG40 [12] phi from rvaluevar::@2 to rvaluevar::@1
rvaluevar__B1_from_B2:
// (byte*) rvaluevar::screen#2 = (byte*) rvaluevar::screen#1 // register copy zp ptr byte:6
// (byte) rvaluevar::i#2 = (byte) rvaluevar::i#1 // register copy zp byte:5
//SEG41 [12] phi (byte*) rvaluevar::screen#2 = (byte*) rvaluevar::screen#1 -- register_copy
//SEG42 [12] phi (byte) rvaluevar::i#2 = (byte) rvaluevar::i#1 -- register_copy
jmp rvaluevar__B1
//SEG43 rvalue
rvalue:
// [18] (byte) rvalue::b#0 ← * (word) 1024 [ ] // zpby1=_star_cowo1
//SEG44 [18] (byte) rvalue::b#0 ← * (word) 1024 [ ] -- zpby1=_star_cowo1
lda 1024
sta 11
// [19] (byte) rvalue::b#1 ← * (word) 1025 [ ] // zpby1=_star_cowo1
//SEG45 [19] (byte) rvalue::b#1 ← * (word) 1025 [ ] -- zpby1=_star_cowo1
lda 1025
sta 12
//SEG46 [20] phi from rvalue to rvalue::@1
rvalue__B1_from_rvalue:
// (byte) rvalue::i#2 = (byte) 2 // zpby1=coby1
//SEG47 [20] phi (byte) rvalue::i#2 = (byte) 2 -- zpby1=coby1
lda #2
sta 8
jmp rvalue__B1
//SEG48 rvalue::@1
rvalue__B1:
// [21] if((byte) rvalue::i#2<(byte) 10) goto rvalue::@2 [ rvalue::i#2 ] // zpby1_lt_coby1_then_la1
//SEG49 [21] if((byte) rvalue::i#2<(byte) 10) goto rvalue::@2 [ rvalue::i#2 ] -- zpby1_lt_coby1_then_la1
lda 8
cmp #10
bcc rvalue__B2
jmp rvalue__Breturn
//SEG50 rvalue::@return
rvalue__Breturn:
//SEG51 [22] return [ ]
rts
//SEG52 rvalue::@2
rvalue__B2:
// [23] (byte) rvalue::b#2 ← (word) 1024 *idx (byte) rvalue::i#2 [ rvalue::i#2 ] // zpby1=cowo1_staridx_zpby2
//SEG53 [23] (byte) rvalue::b#2 ← (word) 1024 *idx (byte) rvalue::i#2 [ rvalue::i#2 ] -- zpby1=cowo1_staridx_zpby2
ldx 8
lda 1024,x
sta 13
// [24] (byte) rvalue::i#1 ← ++ (byte) rvalue::i#2 [ rvalue::i#1 ] // zpby1=_inc_zpby1
//SEG54 [24] (byte) rvalue::i#1 ← ++ (byte) rvalue::i#2 [ rvalue::i#1 ] -- zpby1=_inc_zpby1
inc 8
//SEG55 [20] phi from rvalue::@2 to rvalue::@1
rvalue__B1_from_B2:
// (byte) rvalue::i#2 = (byte) rvalue::i#1 // register copy zp byte:8
//SEG56 [20] phi (byte) rvalue::i#2 = (byte) rvalue::i#1 -- register_copy
jmp rvalue__B1
//SEG57 lvalue
lvalue:
// [25] *((word) 1024) ← (byte) 1 [ ] // _star_cowo1=coby2
//SEG58 [25] *((word) 1024) ← (byte) 1 [ ] -- _star_cowo1=coby2
lda #1
sta 1024
// [26] *((word) 1025) ← (byte) 2 [ ] // _star_cowo1=coby2
//SEG59 [26] *((word) 1025) ← (byte) 2 [ ] -- _star_cowo1=coby2
lda #2
sta 1025
//SEG60 [27] phi from lvalue to lvalue::@1
lvalue__B1_from_lvalue:
// (byte) lvalue::i#2 = (byte) 2 // zpby1=coby1
//SEG61 [27] phi (byte) lvalue::i#2 = (byte) 2 -- zpby1=coby1
lda #2
sta 9
jmp lvalue__B1
//SEG62 lvalue::@1
lvalue__B1:
// [28] if((byte) lvalue::i#2<(byte) 10) goto lvalue::@2 [ lvalue::i#2 ] // zpby1_lt_coby1_then_la1
//SEG63 [28] if((byte) lvalue::i#2<(byte) 10) goto lvalue::@2 [ lvalue::i#2 ] -- zpby1_lt_coby1_then_la1
lda 9
cmp #10
bcc lvalue__B2
jmp lvalue__Breturn
//SEG64 lvalue::@return
lvalue__Breturn:
//SEG65 [29] return [ ]
rts
//SEG66 lvalue::@2
lvalue__B2:
// [30] *((word) 1024 + (byte) lvalue::i#2) ← (byte) 3 [ lvalue::i#2 ] // cowo1_staridx_zpby1=coby2
//SEG67 [30] *((word) 1024 + (byte) lvalue::i#2) ← (byte) 3 [ lvalue::i#2 ] -- cowo1_staridx_zpby1=coby2
lda #3
ldx 9
sta 1024,x
// [31] (byte) lvalue::i#1 ← ++ (byte) lvalue::i#2 [ lvalue::i#1 ] // zpby1=_inc_zpby1
//SEG68 [31] (byte) lvalue::i#1 ← ++ (byte) lvalue::i#2 [ lvalue::i#1 ] -- zpby1=_inc_zpby1
inc 9
//SEG69 [27] phi from lvalue::@2 to lvalue::@1
lvalue__B1_from_B2:
// (byte) lvalue::i#2 = (byte) lvalue::i#1 // register copy zp byte:9
//SEG70 [27] phi (byte) lvalue::i#2 = (byte) lvalue::i#1 -- register_copy
jmp lvalue__B1
Removing instruction jmp BEND
@ -2111,140 +2152,181 @@ Removing instruction jmp lvalue__B1
Removing instruction jmp lvalue__Breturn
Succesful ASM optimization Pass5NextJumpElimination
ASSEMBLER
//SEG0 @BEGIN
BBEGIN:
//SEG1 [0] call main param-assignment [ ]
jsr main
//SEG2 @END
BEND:
//SEG3 main
main:
//SEG4 [1] call lvalue param-assignment [ ]
jsr lvalue
//SEG5 main::@1
main__B1:
//SEG6 [2] call rvalue param-assignment [ ]
jsr rvalue
//SEG7 main::@2
main__B2:
//SEG8 [3] call rvaluevar param-assignment [ ]
jsr rvaluevar
//SEG9 main::@3
main__B3:
//SEG10 [4] call lvaluevar param-assignment [ ]
jsr lvaluevar
//SEG11 main::@return
main__Breturn:
//SEG12 [5] return [ ]
rts
//SEG13 lvaluevar
lvaluevar:
//SEG14 [6] phi from lvaluevar to lvaluevar::@1
lvaluevar__B1_from_lvaluevar:
// (byte*) lvaluevar::screen#2 = (word) 1024 // zpptrby1=cowo1
//SEG15 [6] phi (byte*) lvaluevar::screen#2 = (word) 1024 -- zpptrby1=cowo1
lda #<1024
sta 3
lda #>1024
sta 3+1
// (byte) lvaluevar::i#2 = (byte) 2 // zpby1=coby1
//SEG16 [6] phi (byte) lvaluevar::i#2 = (byte) 2 -- zpby1=coby1
lda #2
sta 2
//SEG17 lvaluevar::@1
lvaluevar__B1:
// [7] if((byte) lvaluevar::i#2<(byte) 10) goto lvaluevar::@2 [ lvaluevar::i#2 lvaluevar::screen#2 ] // zpby1_lt_coby1_then_la1
//SEG18 [7] if((byte) lvaluevar::i#2<(byte) 10) goto lvaluevar::@2 [ lvaluevar::i#2 lvaluevar::screen#2 ] -- zpby1_lt_coby1_then_la1
lda 2
cmp #10
bcc lvaluevar__B2
//SEG19 lvaluevar::@return
lvaluevar__Breturn:
//SEG20 [8] return [ ]
rts
//SEG21 lvaluevar::@2
lvaluevar__B2:
// [9] *((byte*) lvaluevar::screen#2) ← (byte) 4 [ lvaluevar::i#2 lvaluevar::screen#2 ] // _star_zpptrby1=coby1
//SEG22 [9] *((byte*) lvaluevar::screen#2) ← (byte) 4 [ lvaluevar::i#2 lvaluevar::screen#2 ] -- _star_zpptrby1=coby1
ldy #0
lda #4
sta (3),y
// [10] (byte*) lvaluevar::screen#1 ← ++ (byte*) lvaluevar::screen#2 [ lvaluevar::screen#1 lvaluevar::i#2 ] // zpptrby1=_inc_zpptrby1
//SEG23 [10] (byte*) lvaluevar::screen#1 ← ++ (byte*) lvaluevar::screen#2 [ lvaluevar::screen#1 lvaluevar::i#2 ] -- zpptrby1=_inc_zpptrby1
inc 3
bne !+
inc 3+1
!:
// [11] (byte) lvaluevar::i#1 ← ++ (byte) lvaluevar::i#2 [ lvaluevar::i#1 lvaluevar::screen#1 ] // zpby1=_inc_zpby1
//SEG24 [11] (byte) lvaluevar::i#1 ← ++ (byte) lvaluevar::i#2 [ lvaluevar::i#1 lvaluevar::screen#1 ] -- zpby1=_inc_zpby1
inc 2
//SEG25 [6] phi from lvaluevar::@2 to lvaluevar::@1
lvaluevar__B1_from_B2:
// (byte*) lvaluevar::screen#2 = (byte*) lvaluevar::screen#1 // register copy zp ptr byte:3
// (byte) lvaluevar::i#2 = (byte) lvaluevar::i#1 // register copy zp byte:2
//SEG26 [6] phi (byte*) lvaluevar::screen#2 = (byte*) lvaluevar::screen#1 -- register_copy
//SEG27 [6] phi (byte) lvaluevar::i#2 = (byte) lvaluevar::i#1 -- register_copy
jmp lvaluevar__B1
//SEG28 rvaluevar
rvaluevar:
//SEG29 [12] phi from rvaluevar to rvaluevar::@1
rvaluevar__B1_from_rvaluevar:
// (byte*) rvaluevar::screen#2 = (word) 1024 // zpptrby1=cowo1
//SEG30 [12] phi (byte*) rvaluevar::screen#2 = (word) 1024 -- zpptrby1=cowo1
lda #<1024
sta 6
lda #>1024
sta 6+1
// (byte) rvaluevar::i#2 = (byte) 2 // zpby1=coby1
//SEG31 [12] phi (byte) rvaluevar::i#2 = (byte) 2 -- zpby1=coby1
lda #2
sta 5
//SEG32 rvaluevar::@1
rvaluevar__B1:
// [13] if((byte) rvaluevar::i#2<(byte) 10) goto rvaluevar::@2 [ rvaluevar::i#2 rvaluevar::screen#2 ] // zpby1_lt_coby1_then_la1
//SEG33 [13] if((byte) rvaluevar::i#2<(byte) 10) goto rvaluevar::@2 [ rvaluevar::i#2 rvaluevar::screen#2 ] -- zpby1_lt_coby1_then_la1
lda 5
cmp #10
bcc rvaluevar__B2
//SEG34 rvaluevar::@return
rvaluevar__Breturn:
//SEG35 [14] return [ ]
rts
//SEG36 rvaluevar::@2
rvaluevar__B2:
// [15] (byte) rvaluevar::b#0 ← * (byte*) rvaluevar::screen#2 [ rvaluevar::i#2 rvaluevar::screen#2 ] // zpby1=_star_zpptrby1
//SEG37 [15] (byte) rvaluevar::b#0 ← * (byte*) rvaluevar::screen#2 [ rvaluevar::i#2 rvaluevar::screen#2 ] -- zpby1=_star_zpptrby1
ldy #0
lda (6),y
sta 10
// [16] (byte*) rvaluevar::screen#1 ← ++ (byte*) rvaluevar::screen#2 [ rvaluevar::screen#1 rvaluevar::i#2 ] // zpptrby1=_inc_zpptrby1
//SEG38 [16] (byte*) rvaluevar::screen#1 ← ++ (byte*) rvaluevar::screen#2 [ rvaluevar::screen#1 rvaluevar::i#2 ] -- zpptrby1=_inc_zpptrby1
inc 6
bne !+
inc 6+1
!:
// [17] (byte) rvaluevar::i#1 ← ++ (byte) rvaluevar::i#2 [ rvaluevar::i#1 rvaluevar::screen#1 ] // zpby1=_inc_zpby1
//SEG39 [17] (byte) rvaluevar::i#1 ← ++ (byte) rvaluevar::i#2 [ rvaluevar::i#1 rvaluevar::screen#1 ] -- zpby1=_inc_zpby1
inc 5
//SEG40 [12] phi from rvaluevar::@2 to rvaluevar::@1
rvaluevar__B1_from_B2:
// (byte*) rvaluevar::screen#2 = (byte*) rvaluevar::screen#1 // register copy zp ptr byte:6
// (byte) rvaluevar::i#2 = (byte) rvaluevar::i#1 // register copy zp byte:5
//SEG41 [12] phi (byte*) rvaluevar::screen#2 = (byte*) rvaluevar::screen#1 -- register_copy
//SEG42 [12] phi (byte) rvaluevar::i#2 = (byte) rvaluevar::i#1 -- register_copy
jmp rvaluevar__B1
//SEG43 rvalue
rvalue:
// [18] (byte) rvalue::b#0 ← * (word) 1024 [ ] // zpby1=_star_cowo1
//SEG44 [18] (byte) rvalue::b#0 ← * (word) 1024 [ ] -- zpby1=_star_cowo1
lda 1024
sta 11
// [19] (byte) rvalue::b#1 ← * (word) 1025 [ ] // zpby1=_star_cowo1
//SEG45 [19] (byte) rvalue::b#1 ← * (word) 1025 [ ] -- zpby1=_star_cowo1
lda 1025
sta 12
//SEG46 [20] phi from rvalue to rvalue::@1
rvalue__B1_from_rvalue:
// (byte) rvalue::i#2 = (byte) 2 // zpby1=coby1
//SEG47 [20] phi (byte) rvalue::i#2 = (byte) 2 -- zpby1=coby1
lda #2
sta 8
//SEG48 rvalue::@1
rvalue__B1:
// [21] if((byte) rvalue::i#2<(byte) 10) goto rvalue::@2 [ rvalue::i#2 ] // zpby1_lt_coby1_then_la1
//SEG49 [21] if((byte) rvalue::i#2<(byte) 10) goto rvalue::@2 [ rvalue::i#2 ] -- zpby1_lt_coby1_then_la1
lda 8
cmp #10
bcc rvalue__B2
//SEG50 rvalue::@return
rvalue__Breturn:
//SEG51 [22] return [ ]
rts
//SEG52 rvalue::@2
rvalue__B2:
// [23] (byte) rvalue::b#2 ← (word) 1024 *idx (byte) rvalue::i#2 [ rvalue::i#2 ] // zpby1=cowo1_staridx_zpby2
//SEG53 [23] (byte) rvalue::b#2 ← (word) 1024 *idx (byte) rvalue::i#2 [ rvalue::i#2 ] -- zpby1=cowo1_staridx_zpby2
ldx 8
lda 1024,x
sta 13
// [24] (byte) rvalue::i#1 ← ++ (byte) rvalue::i#2 [ rvalue::i#1 ] // zpby1=_inc_zpby1
//SEG54 [24] (byte) rvalue::i#1 ← ++ (byte) rvalue::i#2 [ rvalue::i#1 ] -- zpby1=_inc_zpby1
inc 8
//SEG55 [20] phi from rvalue::@2 to rvalue::@1
rvalue__B1_from_B2:
// (byte) rvalue::i#2 = (byte) rvalue::i#1 // register copy zp byte:8
//SEG56 [20] phi (byte) rvalue::i#2 = (byte) rvalue::i#1 -- register_copy
jmp rvalue__B1
//SEG57 lvalue
lvalue:
// [25] *((word) 1024) ← (byte) 1 [ ] // _star_cowo1=coby2
//SEG58 [25] *((word) 1024) ← (byte) 1 [ ] -- _star_cowo1=coby2
lda #1
sta 1024
// [26] *((word) 1025) ← (byte) 2 [ ] // _star_cowo1=coby2
//SEG59 [26] *((word) 1025) ← (byte) 2 [ ] -- _star_cowo1=coby2
lda #2
sta 1025
//SEG60 [27] phi from lvalue to lvalue::@1
lvalue__B1_from_lvalue:
// (byte) lvalue::i#2 = (byte) 2 // zpby1=coby1
//SEG61 [27] phi (byte) lvalue::i#2 = (byte) 2 -- zpby1=coby1
lda #2
sta 9
//SEG62 lvalue::@1
lvalue__B1:
// [28] if((byte) lvalue::i#2<(byte) 10) goto lvalue::@2 [ lvalue::i#2 ] // zpby1_lt_coby1_then_la1
//SEG63 [28] if((byte) lvalue::i#2<(byte) 10) goto lvalue::@2 [ lvalue::i#2 ] -- zpby1_lt_coby1_then_la1
lda 9
cmp #10
bcc lvalue__B2
//SEG64 lvalue::@return
lvalue__Breturn:
//SEG65 [29] return [ ]
rts
//SEG66 lvalue::@2
lvalue__B2:
// [30] *((word) 1024 + (byte) lvalue::i#2) ← (byte) 3 [ lvalue::i#2 ] // cowo1_staridx_zpby1=coby2
//SEG67 [30] *((word) 1024 + (byte) lvalue::i#2) ← (byte) 3 [ lvalue::i#2 ] -- cowo1_staridx_zpby1=coby2
lda #3
ldx 9
sta 1024,x
// [31] (byte) lvalue::i#1 ← ++ (byte) lvalue::i#2 [ lvalue::i#1 ] // zpby1=_inc_zpby1
//SEG68 [31] (byte) lvalue::i#1 ← ++ (byte) lvalue::i#2 [ lvalue::i#1 ] -- zpby1=_inc_zpby1
inc 9
//SEG69 [27] phi from lvalue::@2 to lvalue::@1
lvalue__B1_from_B2:
// (byte) lvalue::i#2 = (byte) lvalue::i#1 // register copy zp byte:9
//SEG70 [27] phi (byte) lvalue::i#2 = (byte) lvalue::i#1 -- register_copy
jmp lvalue__B1
FINAL SYMBOL TABLE
@ -2303,139 +2385,180 @@ zp byte:2 [ lvaluevar::i#2 lvaluevar::i#1 rvaluevar::i#2 rvaluevar::i#1 rvalue::
zp ptr byte:3 [ lvaluevar::screen#2 lvaluevar::screen#1 rvaluevar::screen#2 rvaluevar::screen#1 ]
FINAL CODE
//SEG0 @BEGIN
BBEGIN:
//SEG1 [0] call main param-assignment [ ]
jsr main
//SEG2 @END
BEND:
//SEG3 main
main:
//SEG4 [1] call lvalue param-assignment [ ]
jsr lvalue
//SEG5 main::@1
main__B1:
//SEG6 [2] call rvalue param-assignment [ ]
jsr rvalue
//SEG7 main::@2
main__B2:
//SEG8 [3] call rvaluevar param-assignment [ ]
jsr rvaluevar
//SEG9 main::@3
main__B3:
//SEG10 [4] call lvaluevar param-assignment [ ]
jsr lvaluevar
//SEG11 main::@return
main__Breturn:
//SEG12 [5] return [ ]
rts
//SEG13 lvaluevar
lvaluevar:
//SEG14 [6] phi from lvaluevar to lvaluevar::@1
lvaluevar__B1_from_lvaluevar:
// (byte*) lvaluevar::screen#2 = (word) 1024 // zpptrby1=cowo1
//SEG15 [6] phi (byte*) lvaluevar::screen#2 = (word) 1024 -- zpptrby1=cowo1
lda #<1024
sta 3
lda #>1024
sta 3+1
// (byte) lvaluevar::i#2 = (byte) 2 // zpby1=coby1
//SEG16 [6] phi (byte) lvaluevar::i#2 = (byte) 2 -- zpby1=coby1
lda #2
sta 2
//SEG17 lvaluevar::@1
lvaluevar__B1:
// [7] if((byte) lvaluevar::i#2<(byte) 10) goto lvaluevar::@2 [ lvaluevar::i#2 lvaluevar::screen#2 ] // zpby1_lt_coby1_then_la1
//SEG18 [7] if((byte) lvaluevar::i#2<(byte) 10) goto lvaluevar::@2 [ lvaluevar::i#2 lvaluevar::screen#2 ] -- zpby1_lt_coby1_then_la1
lda 2
cmp #10
bcc lvaluevar__B2
//SEG19 lvaluevar::@return
lvaluevar__Breturn:
//SEG20 [8] return [ ]
rts
//SEG21 lvaluevar::@2
lvaluevar__B2:
// [9] *((byte*) lvaluevar::screen#2) ← (byte) 4 [ lvaluevar::i#2 lvaluevar::screen#2 ] // _star_zpptrby1=coby1
//SEG22 [9] *((byte*) lvaluevar::screen#2) ← (byte) 4 [ lvaluevar::i#2 lvaluevar::screen#2 ] -- _star_zpptrby1=coby1
ldy #0
lda #4
sta (3),y
// [10] (byte*) lvaluevar::screen#1 ← ++ (byte*) lvaluevar::screen#2 [ lvaluevar::screen#1 lvaluevar::i#2 ] // zpptrby1=_inc_zpptrby1
//SEG23 [10] (byte*) lvaluevar::screen#1 ← ++ (byte*) lvaluevar::screen#2 [ lvaluevar::screen#1 lvaluevar::i#2 ] -- zpptrby1=_inc_zpptrby1
inc 3
bne !+
inc 3+1
!:
// [11] (byte) lvaluevar::i#1 ← ++ (byte) lvaluevar::i#2 [ lvaluevar::i#1 lvaluevar::screen#1 ] // zpby1=_inc_zpby1
//SEG24 [11] (byte) lvaluevar::i#1 ← ++ (byte) lvaluevar::i#2 [ lvaluevar::i#1 lvaluevar::screen#1 ] -- zpby1=_inc_zpby1
inc 2
//SEG25 [6] phi from lvaluevar::@2 to lvaluevar::@1
lvaluevar__B1_from_B2:
// (byte*) lvaluevar::screen#2 = (byte*) lvaluevar::screen#1 // register copy zp ptr byte:3
// (byte) lvaluevar::i#2 = (byte) lvaluevar::i#1 // register copy zp byte:2
//SEG26 [6] phi (byte*) lvaluevar::screen#2 = (byte*) lvaluevar::screen#1 -- register_copy
//SEG27 [6] phi (byte) lvaluevar::i#2 = (byte) lvaluevar::i#1 -- register_copy
jmp lvaluevar__B1
//SEG28 rvaluevar
rvaluevar:
//SEG29 [12] phi from rvaluevar to rvaluevar::@1
rvaluevar__B1_from_rvaluevar:
// (byte*) rvaluevar::screen#2 = (word) 1024 // zpptrby1=cowo1
//SEG30 [12] phi (byte*) rvaluevar::screen#2 = (word) 1024 -- zpptrby1=cowo1
lda #<1024
sta 6
lda #>1024
sta 6+1
// (byte) rvaluevar::i#2 = (byte) 2 // zpby1=coby1
//SEG31 [12] phi (byte) rvaluevar::i#2 = (byte) 2 -- zpby1=coby1
lda #2
sta 5
//SEG32 rvaluevar::@1
rvaluevar__B1:
// [13] if((byte) rvaluevar::i#2<(byte) 10) goto rvaluevar::@2 [ rvaluevar::i#2 rvaluevar::screen#2 ] // zpby1_lt_coby1_then_la1
//SEG33 [13] if((byte) rvaluevar::i#2<(byte) 10) goto rvaluevar::@2 [ rvaluevar::i#2 rvaluevar::screen#2 ] -- zpby1_lt_coby1_then_la1
lda 5
cmp #10
bcc rvaluevar__B2
//SEG34 rvaluevar::@return
rvaluevar__Breturn:
//SEG35 [14] return [ ]
rts
//SEG36 rvaluevar::@2
rvaluevar__B2:
// [15] (byte) rvaluevar::b#0 ← * (byte*) rvaluevar::screen#2 [ rvaluevar::i#2 rvaluevar::screen#2 ] // zpby1=_star_zpptrby1
//SEG37 [15] (byte) rvaluevar::b#0 ← * (byte*) rvaluevar::screen#2 [ rvaluevar::i#2 rvaluevar::screen#2 ] -- zpby1=_star_zpptrby1
ldy #0
lda (6),y
sta 10
// [16] (byte*) rvaluevar::screen#1 ← ++ (byte*) rvaluevar::screen#2 [ rvaluevar::screen#1 rvaluevar::i#2 ] // zpptrby1=_inc_zpptrby1
//SEG38 [16] (byte*) rvaluevar::screen#1 ← ++ (byte*) rvaluevar::screen#2 [ rvaluevar::screen#1 rvaluevar::i#2 ] -- zpptrby1=_inc_zpptrby1
inc 6
bne !+
inc 6+1
!:
// [17] (byte) rvaluevar::i#1 ← ++ (byte) rvaluevar::i#2 [ rvaluevar::i#1 rvaluevar::screen#1 ] // zpby1=_inc_zpby1
//SEG39 [17] (byte) rvaluevar::i#1 ← ++ (byte) rvaluevar::i#2 [ rvaluevar::i#1 rvaluevar::screen#1 ] -- zpby1=_inc_zpby1
inc 5
//SEG40 [12] phi from rvaluevar::@2 to rvaluevar::@1
rvaluevar__B1_from_B2:
// (byte*) rvaluevar::screen#2 = (byte*) rvaluevar::screen#1 // register copy zp ptr byte:6
// (byte) rvaluevar::i#2 = (byte) rvaluevar::i#1 // register copy zp byte:5
//SEG41 [12] phi (byte*) rvaluevar::screen#2 = (byte*) rvaluevar::screen#1 -- register_copy
//SEG42 [12] phi (byte) rvaluevar::i#2 = (byte) rvaluevar::i#1 -- register_copy
jmp rvaluevar__B1
//SEG43 rvalue
rvalue:
// [18] (byte) rvalue::b#0 ← * (word) 1024 [ ] // zpby1=_star_cowo1
//SEG44 [18] (byte) rvalue::b#0 ← * (word) 1024 [ ] -- zpby1=_star_cowo1
lda 1024
sta 11
// [19] (byte) rvalue::b#1 ← * (word) 1025 [ ] // zpby1=_star_cowo1
//SEG45 [19] (byte) rvalue::b#1 ← * (word) 1025 [ ] -- zpby1=_star_cowo1
lda 1025
sta 12
//SEG46 [20] phi from rvalue to rvalue::@1
rvalue__B1_from_rvalue:
// (byte) rvalue::i#2 = (byte) 2 // zpby1=coby1
//SEG47 [20] phi (byte) rvalue::i#2 = (byte) 2 -- zpby1=coby1
lda #2
sta 8
//SEG48 rvalue::@1
rvalue__B1:
// [21] if((byte) rvalue::i#2<(byte) 10) goto rvalue::@2 [ rvalue::i#2 ] // zpby1_lt_coby1_then_la1
//SEG49 [21] if((byte) rvalue::i#2<(byte) 10) goto rvalue::@2 [ rvalue::i#2 ] -- zpby1_lt_coby1_then_la1
lda 8
cmp #10
bcc rvalue__B2
//SEG50 rvalue::@return
rvalue__Breturn:
//SEG51 [22] return [ ]
rts
//SEG52 rvalue::@2
rvalue__B2:
// [23] (byte) rvalue::b#2 ← (word) 1024 *idx (byte) rvalue::i#2 [ rvalue::i#2 ] // zpby1=cowo1_staridx_zpby2
//SEG53 [23] (byte) rvalue::b#2 ← (word) 1024 *idx (byte) rvalue::i#2 [ rvalue::i#2 ] -- zpby1=cowo1_staridx_zpby2
ldx 8
lda 1024,x
sta 13
// [24] (byte) rvalue::i#1 ← ++ (byte) rvalue::i#2 [ rvalue::i#1 ] // zpby1=_inc_zpby1
//SEG54 [24] (byte) rvalue::i#1 ← ++ (byte) rvalue::i#2 [ rvalue::i#1 ] -- zpby1=_inc_zpby1
inc 8
//SEG55 [20] phi from rvalue::@2 to rvalue::@1
rvalue__B1_from_B2:
// (byte) rvalue::i#2 = (byte) rvalue::i#1 // register copy zp byte:8
//SEG56 [20] phi (byte) rvalue::i#2 = (byte) rvalue::i#1 -- register_copy
jmp rvalue__B1
//SEG57 lvalue
lvalue:
// [25] *((word) 1024) ← (byte) 1 [ ] // _star_cowo1=coby2
//SEG58 [25] *((word) 1024) ← (byte) 1 [ ] -- _star_cowo1=coby2
lda #1
sta 1024
// [26] *((word) 1025) ← (byte) 2 [ ] // _star_cowo1=coby2
//SEG59 [26] *((word) 1025) ← (byte) 2 [ ] -- _star_cowo1=coby2
lda #2
sta 1025
//SEG60 [27] phi from lvalue to lvalue::@1
lvalue__B1_from_lvalue:
// (byte) lvalue::i#2 = (byte) 2 // zpby1=coby1
//SEG61 [27] phi (byte) lvalue::i#2 = (byte) 2 -- zpby1=coby1
lda #2
sta 9
//SEG62 lvalue::@1
lvalue__B1:
// [28] if((byte) lvalue::i#2<(byte) 10) goto lvalue::@2 [ lvalue::i#2 ] // zpby1_lt_coby1_then_la1
//SEG63 [28] if((byte) lvalue::i#2<(byte) 10) goto lvalue::@2 [ lvalue::i#2 ] -- zpby1_lt_coby1_then_la1
lda 9
cmp #10
bcc lvalue__B2
//SEG64 lvalue::@return
lvalue__Breturn:
//SEG65 [29] return [ ]
rts
//SEG66 lvalue::@2
lvalue__B2:
// [30] *((word) 1024 + (byte) lvalue::i#2) ← (byte) 3 [ lvalue::i#2 ] // cowo1_staridx_zpby1=coby2
//SEG67 [30] *((word) 1024 + (byte) lvalue::i#2) ← (byte) 3 [ lvalue::i#2 ] -- cowo1_staridx_zpby1=coby2
lda #3
ldx 9
sta 1024,x
// [31] (byte) lvalue::i#1 ← ++ (byte) lvalue::i#2 [ lvalue::i#1 ] // zpby1=_inc_zpby1
//SEG68 [31] (byte) lvalue::i#1 ← ++ (byte) lvalue::i#2 [ lvalue::i#1 ] -- zpby1=_inc_zpby1
inc 9
//SEG69 [27] phi from lvalue::@2 to lvalue::@1
lvalue__B1_from_B2:
// (byte) lvalue::i#2 = (byte) lvalue::i#1 // register copy zp byte:9
//SEG70 [27] phi (byte) lvalue::i#2 = (byte) lvalue::i#1 -- register_copy
jmp lvalue__B1

View File

@ -426,48 +426,59 @@ Coalescing zero page register [ zp byte:2 [ sum::a#2 ] ] with [ zp byte:5 [ s2#0
Coalescing zero page register [ zp byte:2 [ sum::a#2 s2#0 ] ] with [ zp byte:6 [ s3#0 ] ]
Coalescing zero page register [ zp byte:2 [ sum::a#2 s2#0 s3#0 ] ] with [ zp byte:7 [ sum::return#0 ] ]
INITIAL ASM
//SEG0 @BEGIN
BBEGIN:
//SEG1 [0] call sum param-assignment [ sum::return#0 s1#0 ]
//SEG2 [5] phi from @BEGIN to sum
sum_from_BBEGIN:
// (byte) sum::b#2 = (byte) 2 // zpby1=coby1
//SEG3 [5] phi (byte) sum::b#2 = (byte) 2 -- zpby1=coby1
lda #2
sta 3
// (byte) sum::a#2 = (byte) 1 // zpby1=coby1
//SEG4 [5] phi (byte) sum::a#2 = (byte) 1 -- zpby1=coby1
lda #1
sta 2
jsr sum
jmp B2
//SEG5 @2
B2:
// [1] (byte) s1#0 ← (byte) sum::return#0 [ sum::return#0 s1#0 ] // zpby1=zpby2
//SEG6 [1] (byte) s1#0 ← (byte) sum::return#0 [ sum::return#0 s1#0 ] -- zpby1=zpby2
lda 7
sta 4
//SEG7 [2] call sum param-assignment [ sum::return#0 s1#0 ]
//SEG8 [5] phi from @2 to sum
sum_from_B2:
// (byte) sum::b#2 = (byte) 13 // zpby1=coby1
//SEG9 [5] phi (byte) sum::b#2 = (byte) 13 -- zpby1=coby1
lda #13
sta 3
// (byte) sum::a#2 = (byte) 9 // zpby1=coby1
//SEG10 [5] phi (byte) sum::a#2 = (byte) 9 -- zpby1=coby1
lda #9
sta 2
jsr sum
jmp B3
//SEG11 @3
B3:
// [3] (byte) s2#0 ← (byte) sum::return#0 [ s1#0 s2#0 ] // zpby1=zpby2
//SEG12 [3] (byte) s2#0 ← (byte) sum::return#0 [ s1#0 s2#0 ] -- zpby1=zpby2
lda 7
sta 5
// [4] (byte) s3#0 ← (byte) s1#0 + (byte) s2#0 [ ] // zpby1=zpby2_plus_zpby3
//SEG13 [4] (byte) s3#0 ← (byte) s1#0 + (byte) s2#0 [ ] -- zpby1=zpby2_plus_zpby3
lda 4
clc
adc 5
sta 6
jmp BEND
//SEG14 @END
BEND:
//SEG15 sum
sum:
// [6] (byte) sum::return#0 ← (byte) sum::a#2 + (byte) sum::b#2 [ sum::return#0 s1#0 ] // zpby1=zpby2_plus_zpby3
//SEG16 [6] (byte) sum::return#0 ← (byte) sum::a#2 + (byte) sum::b#2 [ sum::return#0 s1#0 ] -- zpby1=zpby2_plus_zpby3
lda 2
clc
adc 3
sta 7
jmp sum__Breturn
//SEG17 sum::@return
sum__Breturn:
//SEG18 [7] return [ sum::return#0 s1#0 ]
rts
Removing instruction jmp B2
@ -476,44 +487,55 @@ Removing instruction jmp BEND
Removing instruction jmp sum__Breturn
Succesful ASM optimization Pass5NextJumpElimination
ASSEMBLER
//SEG0 @BEGIN
BBEGIN:
//SEG1 [0] call sum param-assignment [ sum::return#0 s1#0 ]
//SEG2 [5] phi from @BEGIN to sum
sum_from_BBEGIN:
// (byte) sum::b#2 = (byte) 2 // zpby1=coby1
//SEG3 [5] phi (byte) sum::b#2 = (byte) 2 -- zpby1=coby1
lda #2
sta 3
// (byte) sum::a#2 = (byte) 1 // zpby1=coby1
//SEG4 [5] phi (byte) sum::a#2 = (byte) 1 -- zpby1=coby1
lda #1
sta 2
jsr sum
//SEG5 @2
B2:
// [1] (byte) s1#0 ← (byte) sum::return#0 [ sum::return#0 s1#0 ] // zpby1=zpby2
//SEG6 [1] (byte) s1#0 ← (byte) sum::return#0 [ sum::return#0 s1#0 ] -- zpby1=zpby2
lda 7
sta 4
//SEG7 [2] call sum param-assignment [ sum::return#0 s1#0 ]
//SEG8 [5] phi from @2 to sum
sum_from_B2:
// (byte) sum::b#2 = (byte) 13 // zpby1=coby1
//SEG9 [5] phi (byte) sum::b#2 = (byte) 13 -- zpby1=coby1
lda #13
sta 3
// (byte) sum::a#2 = (byte) 9 // zpby1=coby1
//SEG10 [5] phi (byte) sum::a#2 = (byte) 9 -- zpby1=coby1
lda #9
sta 2
jsr sum
//SEG11 @3
B3:
// [3] (byte) s2#0 ← (byte) sum::return#0 [ s1#0 s2#0 ] // zpby1=zpby2
//SEG12 [3] (byte) s2#0 ← (byte) sum::return#0 [ s1#0 s2#0 ] -- zpby1=zpby2
lda 7
sta 5
// [4] (byte) s3#0 ← (byte) s1#0 + (byte) s2#0 [ ] // zpby1=zpby2_plus_zpby3
//SEG13 [4] (byte) s3#0 ← (byte) s1#0 + (byte) s2#0 [ ] -- zpby1=zpby2_plus_zpby3
lda 4
clc
adc 5
sta 6
//SEG14 @END
BEND:
//SEG15 sum
sum:
// [6] (byte) sum::return#0 ← (byte) sum::a#2 + (byte) sum::b#2 [ sum::return#0 s1#0 ] // zpby1=zpby2_plus_zpby3
//SEG16 [6] (byte) sum::return#0 ← (byte) sum::a#2 + (byte) sum::b#2 [ sum::return#0 s1#0 ] -- zpby1=zpby2_plus_zpby3
lda 2
clc
adc 3
sta 7
//SEG17 sum::@return
sum__Breturn:
//SEG18 [7] return [ sum::return#0 s1#0 ]
rts
FINAL SYMBOL TABLE
@ -541,43 +563,54 @@ zp byte:3 [ sum::b#2 ]
zp byte:4 [ s1#0 ]
FINAL CODE
//SEG0 @BEGIN
BBEGIN:
//SEG1 [0] call sum param-assignment [ sum::return#0 s1#0 ]
//SEG2 [5] phi from @BEGIN to sum
sum_from_BBEGIN:
// (byte) sum::b#2 = (byte) 2 // zpby1=coby1
//SEG3 [5] phi (byte) sum::b#2 = (byte) 2 -- zpby1=coby1
lda #2
sta 3
// (byte) sum::a#2 = (byte) 1 // zpby1=coby1
//SEG4 [5] phi (byte) sum::a#2 = (byte) 1 -- zpby1=coby1
lda #1
sta 2
jsr sum
//SEG5 @2
B2:
// [1] (byte) s1#0 ← (byte) sum::return#0 [ sum::return#0 s1#0 ] // zpby1=zpby2
//SEG6 [1] (byte) s1#0 ← (byte) sum::return#0 [ sum::return#0 s1#0 ] -- zpby1=zpby2
lda 7
sta 4
//SEG7 [2] call sum param-assignment [ sum::return#0 s1#0 ]
//SEG8 [5] phi from @2 to sum
sum_from_B2:
// (byte) sum::b#2 = (byte) 13 // zpby1=coby1
//SEG9 [5] phi (byte) sum::b#2 = (byte) 13 -- zpby1=coby1
lda #13
sta 3
// (byte) sum::a#2 = (byte) 9 // zpby1=coby1
//SEG10 [5] phi (byte) sum::a#2 = (byte) 9 -- zpby1=coby1
lda #9
sta 2
jsr sum
//SEG11 @3
B3:
// [3] (byte) s2#0 ← (byte) sum::return#0 [ s1#0 s2#0 ] // zpby1=zpby2
//SEG12 [3] (byte) s2#0 ← (byte) sum::return#0 [ s1#0 s2#0 ] -- zpby1=zpby2
lda 7
sta 5
// [4] (byte) s3#0 ← (byte) s1#0 + (byte) s2#0 [ ] // zpby1=zpby2_plus_zpby3
//SEG13 [4] (byte) s3#0 ← (byte) s1#0 + (byte) s2#0 [ ] -- zpby1=zpby2_plus_zpby3
lda 4
clc
adc 5
sta 6
//SEG14 @END
BEND:
//SEG15 sum
sum:
// [6] (byte) sum::return#0 ← (byte) sum::a#2 + (byte) sum::b#2 [ sum::return#0 s1#0 ] // zpby1=zpby2_plus_zpby3
//SEG16 [6] (byte) sum::return#0 ← (byte) sum::a#2 + (byte) sum::b#2 [ sum::return#0 s1#0 ] -- zpby1=zpby2_plus_zpby3
lda 2
clc
adc 3
sta 7
//SEG17 sum::@return
sum__Breturn:
//SEG18 [7] return [ sum::return#0 s1#0 ]
rts

View File

@ -213,30 +213,42 @@ REGISTER UPLIFTING
INITIAL ASM
//SEG0 @BEGIN
BBEGIN:
//SEG1 [0] call main param-assignment [ ]
jsr main
jmp BEND
//SEG2 @END
BEND:
//SEG3 main
main:
// [1] *((word) 1024) ← (byte) 1 [ ] // _star_cowo1=coby2
//SEG4 [1] *((word) 1024) ← (byte) 1 [ ] -- _star_cowo1=coby2
lda #1
sta 1024
jmp main__Breturn
//SEG5 main::@return
main__Breturn:
//SEG6 [2] return [ ]
rts
Removing instruction jmp BEND
Removing instruction jmp main__Breturn
Succesful ASM optimization Pass5NextJumpElimination
ASSEMBLER
//SEG0 @BEGIN
BBEGIN:
//SEG1 [0] call main param-assignment [ ]
jsr main
//SEG2 @END
BEND:
//SEG3 main
main:
// [1] *((word) 1024) ← (byte) 1 [ ] // _star_cowo1=coby2
//SEG4 [1] *((word) 1024) ← (byte) 1 [ ] -- _star_cowo1=coby2
lda #1
sta 1024
//SEG5 main::@return
main__Breturn:
//SEG6 [2] return [ ]
rts
FINAL SYMBOL TABLE
@ -248,13 +260,19 @@ FINAL SYMBOL TABLE
FINAL CODE
//SEG0 @BEGIN
BBEGIN:
//SEG1 [0] call main param-assignment [ ]
jsr main
//SEG2 @END
BEND:
//SEG3 main
main:
// [1] *((word) 1024) ← (byte) 1 [ ] // _star_cowo1=coby2
//SEG4 [1] *((word) 1024) ← (byte) 1 [ ] -- _star_cowo1=coby2
lda #1
sta 1024
//SEG5 main::@return
main__Breturn:
//SEG6 [2] return [ ]
rts