mirror of
https://gitlab.com/camelot/kickc.git
synced 2025-02-21 07:29:14 +00:00
Redundant and unused label elimination in ASM.
This commit is contained in:
parent
5f27eba623
commit
9c8372b989
@ -38,14 +38,16 @@ public class Compiler {
|
||||
}
|
||||
|
||||
public void pass6OptimizeAsm(Program program) {
|
||||
CompileLog log = program.getLog();
|
||||
List<Pass5AsmOptimization> pass5Optimizations = new ArrayList<>();
|
||||
pass5Optimizations.add(new Pass5NextJumpElimination(program, log));
|
||||
pass5Optimizations.add(new Pass5UnnecesaryLoadElimination(program, log));
|
||||
List<Pass6AsmOptimization> pass6Optimizations = new ArrayList<>();
|
||||
pass6Optimizations.add(new Pass6NextJumpElimination(program));
|
||||
pass6Optimizations.add(new Pass6UnnecesaryLoadElimination(program));
|
||||
pass6Optimizations.add(new Pass6RedundantLabelElimination(program));
|
||||
pass6Optimizations.add(new Pass6UnusedLabelElimination(program));
|
||||
boolean asmOptimized = true;
|
||||
CompileLog log = program.getLog();
|
||||
while (asmOptimized) {
|
||||
asmOptimized = false;
|
||||
for (Pass5AsmOptimization optimization : pass5Optimizations) {
|
||||
for (Pass6AsmOptimization optimization : pass6Optimizations) {
|
||||
boolean stepOptimized = optimization.optimize();
|
||||
if (stepOptimized) {
|
||||
log.append("Succesful ASM optimization " + optimization.getClass().getSimpleName());
|
||||
|
@ -51,4 +51,8 @@ public class AsmInstruction implements AsmLine {
|
||||
public void setIndex(int index) {
|
||||
this.index = index;
|
||||
}
|
||||
|
||||
public void setParameter(String parameter) {
|
||||
this.parameter = parameter;
|
||||
}
|
||||
}
|
||||
|
@ -327,7 +327,7 @@ public class AsmInstructionSet {
|
||||
add(0xfd, "sbc", abx, 4.5);
|
||||
add(0xfe, "inc", abx, 7.0);
|
||||
add(0xff, "isc", abx, 7.0);
|
||||
List<String> jumps = Arrays.asList("jmp", "beq", "bne", "bcc", "bcs", "bvs", "bvc", "bmi", "bpl");
|
||||
List<String> jumps = Arrays.asList("jmp", "beq", "bne", "bcc", "bcs", "bvs", "bvc", "bmi", "bpl", "jsr");
|
||||
for (AsmInstructionType instruction : instructions) {
|
||||
if(jumps.contains(instruction.getMnemnonic())) {
|
||||
instruction.setJump(true);
|
||||
|
@ -46,7 +46,8 @@ public class AsmInstructionType {
|
||||
}
|
||||
|
||||
/**
|
||||
* Tells if the instruction is a jump or a branch (and the parameter is therefore a label or destination address)
|
||||
* Tells if the instruction is a jump or a branch (and the parameter is therefore a label or destination address).
|
||||
*
|
||||
* @return true if the instruction is a jump/branch
|
||||
*/
|
||||
public boolean isJump() {
|
||||
|
@ -14,14 +14,12 @@ import java.util.List;
|
||||
* Optimization performed on Assembler Code (Asm Code).
|
||||
* Optimizations are performed repeatedly until none of them yield any result
|
||||
**/
|
||||
public abstract class Pass5AsmOptimization {
|
||||
public abstract class Pass6AsmOptimization {
|
||||
|
||||
protected CompileLog log;
|
||||
private Program program;
|
||||
|
||||
public Pass5AsmOptimization(Program program, CompileLog log) {
|
||||
public Pass6AsmOptimization(Program program) {
|
||||
this.program = program;
|
||||
this.log = log;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -36,7 +34,7 @@ public abstract class Pass5AsmOptimization {
|
||||
}
|
||||
|
||||
public CompileLog getLog() {
|
||||
return log;
|
||||
return program.getLog();
|
||||
}
|
||||
|
||||
public void remove(List<AsmLine> remove) {
|
||||
@ -45,7 +43,7 @@ public abstract class Pass5AsmOptimization {
|
||||
for (Iterator<AsmLine> iterator = segment.getLines().iterator(); iterator.hasNext(); ) {
|
||||
AsmLine line = iterator.next();
|
||||
if (remove.contains(line)) {
|
||||
log.append("Removing instruction " + line.getAsm());
|
||||
getLog().append("Removing instruction " + line.getAsm());
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
@ -1,6 +1,5 @@
|
||||
package dk.camelot64.kickc.passes;
|
||||
|
||||
import dk.camelot64.kickc.CompileLog;
|
||||
import dk.camelot64.kickc.asm.*;
|
||||
import dk.camelot64.kickc.icl.Program;
|
||||
|
||||
@ -10,10 +9,10 @@ import java.util.List;
|
||||
/**
|
||||
* Optimize assembler code by removing jumps to labels immediately following the jump
|
||||
*/
|
||||
public class Pass5NextJumpElimination extends Pass5AsmOptimization {
|
||||
public class Pass6NextJumpElimination extends Pass6AsmOptimization {
|
||||
|
||||
public Pass5NextJumpElimination(Program program, CompileLog log) {
|
||||
super(program, log);
|
||||
public Pass6NextJumpElimination(Program program) {
|
||||
super(program);
|
||||
}
|
||||
|
||||
public boolean optimize() {
|
||||
@ -31,7 +30,7 @@ public class Pass5NextJumpElimination extends Pass5AsmOptimization {
|
||||
if (line instanceof AsmInstruction) {
|
||||
candidate = null;
|
||||
AsmInstruction instruction = (AsmInstruction) line;
|
||||
if (instruction.getType().isJump()) {
|
||||
if (instruction.getType().isJump() && !instruction.getType().getMnemnonic().equals("jsr")) {
|
||||
candidate = instruction;
|
||||
}
|
||||
}
|
@ -0,0 +1,148 @@
|
||||
package dk.camelot64.kickc.passes;
|
||||
|
||||
import dk.camelot64.kickc.asm.*;
|
||||
import dk.camelot64.kickc.icl.Program;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Optimize assembler code by removing all unused labels
|
||||
*/
|
||||
public class Pass6RedundantLabelElimination extends Pass6AsmOptimization {
|
||||
|
||||
public Pass6RedundantLabelElimination(Program program) {
|
||||
super(program);
|
||||
}
|
||||
|
||||
public boolean optimize() {
|
||||
|
||||
List<RedundantLabels> redundantLabelSet = findRedundantLabels();
|
||||
|
||||
List<AsmLine> removeLines = new ArrayList<>();
|
||||
String currentScope = "";
|
||||
for (AsmSegment segment : getAsmProgram().getSegments()) {
|
||||
for (AsmLine line : segment.getLines()) {
|
||||
if(line instanceof AsmScopeBegin) {
|
||||
currentScope = ((AsmScopeBegin) line).getLabel();
|
||||
} else if(line instanceof AsmScopeEnd) {
|
||||
currentScope = "";
|
||||
} else if (line instanceof AsmInstruction) {
|
||||
AsmInstruction instruction = (AsmInstruction) line;
|
||||
if (instruction.getType().isJump()) {
|
||||
String labelStr = instruction.getParameter();
|
||||
if (!labelStr.contains("!")) {
|
||||
// If redundant - Replace with the shortest
|
||||
for (RedundantLabels redundantLabels : redundantLabelSet) {
|
||||
if (redundantLabels.getScope().equals(currentScope) && redundantLabels.isRedundant(labelStr)) {
|
||||
getLog().append("Replacing label "+labelStr+" with "+redundantLabels.getKeep());
|
||||
instruction.setParameter(redundantLabels.getKeep());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if(line instanceof AsmLabel) {
|
||||
AsmLabel label = (AsmLabel) line;
|
||||
String labelStr = label.getLabel();
|
||||
if(!labelStr.contains("!")) {
|
||||
for (RedundantLabels redundantLabels : redundantLabelSet) {
|
||||
if(redundantLabels.getScope().equals(currentScope) && redundantLabels.isRedundant(labelStr)) {
|
||||
removeLines.add(label);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
remove(removeLines);
|
||||
return removeLines.size() > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Find all redundant labels in the ASM
|
||||
*
|
||||
* @return List with all redundant labels
|
||||
*/
|
||||
private List<RedundantLabels> findRedundantLabels() {
|
||||
List<RedundantLabels> redundantLabelSet = new ArrayList<>();
|
||||
RedundantLabels current = null;
|
||||
String currentScope = "";
|
||||
for (AsmSegment segment : getAsmProgram().getSegments()) {
|
||||
for (AsmLine line : segment.getLines()) {
|
||||
boolean handled = false;
|
||||
if(line instanceof AsmScopeBegin) {
|
||||
currentScope = ((AsmScopeBegin) line).getLabel();
|
||||
} else if(line instanceof AsmScopeEnd) {
|
||||
currentScope = "";
|
||||
} else if(line instanceof AsmLabel) {
|
||||
AsmLabel label = (AsmLabel) line;
|
||||
String labelStr = label.getLabel();
|
||||
if(!labelStr.contains("!")) {
|
||||
if(current==null) {
|
||||
current = new RedundantLabels(currentScope, labelStr);
|
||||
} else {
|
||||
current.add(labelStr);
|
||||
}
|
||||
handled = true;
|
||||
}
|
||||
}
|
||||
if(!handled) {
|
||||
if(current!=null && current.size()>1) {
|
||||
redundantLabelSet.add(current);
|
||||
}
|
||||
current = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
return redundantLabelSet;
|
||||
}
|
||||
|
||||
|
||||
private static class RedundantLabels {
|
||||
|
||||
private String scope;
|
||||
|
||||
private String keep;
|
||||
|
||||
private Set<String> redundant;
|
||||
|
||||
public RedundantLabels(String scope, String label) {
|
||||
this.scope = scope;
|
||||
this.keep = label;
|
||||
this.redundant = new LinkedHashSet<>();
|
||||
}
|
||||
|
||||
public void add(String label) {
|
||||
if (keep.length() < label.length()) {
|
||||
redundant.add(label);
|
||||
} else {
|
||||
redundant.add(keep);
|
||||
keep = label;
|
||||
}
|
||||
}
|
||||
|
||||
public int size() {
|
||||
return redundant.size()+1;
|
||||
}
|
||||
|
||||
public String getScope() {
|
||||
return scope;
|
||||
}
|
||||
|
||||
public String getKeep() {
|
||||
return keep;
|
||||
}
|
||||
|
||||
public boolean isRedundant(String labelStr) {
|
||||
return redundant.contains(labelStr);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
@ -1,8 +1,6 @@
|
||||
package dk.camelot64.kickc.passes;
|
||||
|
||||
import dk.camelot64.kickc.CompileLog;
|
||||
import dk.camelot64.kickc.asm.*;
|
||||
import dk.camelot64.kickc.asm.AsmProgramStaticRegisterValues;
|
||||
import dk.camelot64.kickc.icl.Program;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@ -11,10 +9,10 @@ import java.util.List;
|
||||
/**
|
||||
* Maps out register values entering all instructions. Removes unnecessary loads / clears / sets
|
||||
*/
|
||||
public class Pass5UnnecesaryLoadElimination extends Pass5AsmOptimization {
|
||||
public class Pass6UnnecesaryLoadElimination extends Pass6AsmOptimization {
|
||||
|
||||
public Pass5UnnecesaryLoadElimination(Program program, CompileLog log) {
|
||||
super(program, log);
|
||||
public Pass6UnnecesaryLoadElimination(Program program) {
|
||||
super(program);
|
||||
}
|
||||
|
||||
@Override
|
@ -0,0 +1,58 @@
|
||||
package dk.camelot64.kickc.passes;
|
||||
|
||||
import dk.camelot64.kickc.CompileLog;
|
||||
import dk.camelot64.kickc.asm.*;
|
||||
import dk.camelot64.kickc.icl.Program;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Optimize assembler code by removing all unused labels
|
||||
*/
|
||||
public class Pass6UnusedLabelElimination extends Pass6AsmOptimization {
|
||||
|
||||
public Pass6UnusedLabelElimination(Program program) {
|
||||
super(program);
|
||||
}
|
||||
|
||||
public boolean optimize() {
|
||||
Set<String> usedLabels = new LinkedHashSet<>();
|
||||
String currentScope = "";
|
||||
for (AsmSegment segment : getAsmProgram().getSegments()) {
|
||||
for (AsmLine line : segment.getLines()) {
|
||||
if(line instanceof AsmScopeBegin) {
|
||||
currentScope = ((AsmScopeBegin) line).getLabel();
|
||||
} else if(line instanceof AsmScopeEnd) {
|
||||
currentScope = "";
|
||||
} else if(line instanceof AsmInstruction) {
|
||||
AsmInstruction instruction = (AsmInstruction) line;
|
||||
if(instruction.getType().isJump()) {
|
||||
String labelStr = currentScope+"::"+instruction.getParameter();
|
||||
usedLabels.add(labelStr);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
List<AsmLine> removeLines = new ArrayList<>();
|
||||
for (AsmSegment segment : getAsmProgram().getSegments()) {
|
||||
for (AsmLine line : segment.getLines()) {
|
||||
if(line instanceof AsmScopeBegin) {
|
||||
currentScope = ((AsmScopeBegin) line).getLabel();
|
||||
} else if(line instanceof AsmScopeEnd) {
|
||||
currentScope = "";
|
||||
} else if(line instanceof AsmLabel) {
|
||||
AsmLabel label = (AsmLabel) line;
|
||||
String labelStr = currentScope+"::"+label.getLabel();
|
||||
if(!labelStr.contains("!") && !usedLabels.contains(labelStr)) {
|
||||
removeLines.add(label);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
remove(removeLines);
|
||||
return removeLines.size() > 0;
|
||||
}
|
||||
}
|
@ -1,5 +1,3 @@
|
||||
bbegin:
|
||||
b1_from_bbegin:
|
||||
lda #$0
|
||||
sta $5
|
||||
ldx #$c
|
||||
@ -9,7 +7,6 @@ b1_from_bbegin:
|
||||
sta $2
|
||||
lda #>$400
|
||||
sta $2+$1
|
||||
b1_from_b3:
|
||||
b1:
|
||||
ldy #$0
|
||||
lda #$51
|
||||
@ -25,12 +22,10 @@ b1:
|
||||
tax
|
||||
cpx #$27
|
||||
bcs b2
|
||||
b3_from_b1:
|
||||
b3:
|
||||
lda $4
|
||||
cmp #$28
|
||||
bcc b1_from_b3
|
||||
bend:
|
||||
bcc b1
|
||||
b2:
|
||||
inc $5
|
||||
lda $2
|
||||
@ -44,5 +39,4 @@ b2:
|
||||
sec
|
||||
sbc #$27
|
||||
tax
|
||||
b3_from_b2:
|
||||
jmp b3
|
||||
|
@ -1201,7 +1201,7 @@ Re-allocated ZP register from zp byte:6 to zp byte:5
|
||||
Removing instruction jmp b1
|
||||
Removing instruction jmp b3
|
||||
Removing instruction jmp bend
|
||||
Succesful ASM optimization Pass5NextJumpElimination
|
||||
Succesful ASM optimization Pass6NextJumpElimination
|
||||
ASSEMBLER
|
||||
//SEG0 @begin
|
||||
bbegin:
|
||||
@ -1285,13 +1285,16 @@ b3_from_b2:
|
||||
//SEG31 [6] phi (byte*) cursor#5 = (byte*) cursor#2 -- register_copy
|
||||
jmp b3
|
||||
|
||||
Removing instruction jmp b1
|
||||
Succesful ASM optimization Pass5NextJumpElimination
|
||||
Replacing label b1_from_b3 with b1
|
||||
Removing instruction b1_from_bbegin:
|
||||
Removing instruction b1_from_b3:
|
||||
Removing instruction b3_from_b1:
|
||||
Removing instruction bend:
|
||||
Succesful ASM optimization Pass6RedundantLabelElimination
|
||||
ASSEMBLER
|
||||
//SEG0 @begin
|
||||
bbegin:
|
||||
//SEG1 [0] phi from @begin to @1
|
||||
b1_from_bbegin:
|
||||
//SEG2 [0] phi (byte) y#2 = (byte) 0 -- zpby1=coby1
|
||||
lda #$0
|
||||
sta $5
|
||||
@ -1305,8 +1308,8 @@ b1_from_bbegin:
|
||||
sta $2
|
||||
lda #>$400
|
||||
sta $2+$1
|
||||
jmp b1
|
||||
//SEG6 [0] phi from @3 to @1
|
||||
b1_from_b3:
|
||||
//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
|
||||
@ -1333,7 +1336,6 @@ b1:
|
||||
cpx #$27
|
||||
bcs b2
|
||||
//SEG17 [6] phi from @1 to @3
|
||||
b3_from_b1:
|
||||
//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
|
||||
@ -1342,9 +1344,8 @@ b3:
|
||||
//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 #$28
|
||||
bcc b1_from_b3
|
||||
bcc b1
|
||||
//SEG23 @end
|
||||
bend:
|
||||
//SEG24 @2
|
||||
b2:
|
||||
//SEG25 [8] (byte) y#1 ← (byte) y#2 + (byte) 1 [ x#1 e#1 cursor#1 y#1 ] -- zpby1=zpby1_plus_1
|
||||
@ -1369,6 +1370,164 @@ b3_from_b2:
|
||||
//SEG31 [6] phi (byte*) cursor#5 = (byte*) cursor#2 -- register_copy
|
||||
jmp b3
|
||||
|
||||
Removing instruction bbegin:
|
||||
Removing instruction b3_from_b2:
|
||||
Succesful ASM optimization Pass6UnusedLabelElimination
|
||||
ASSEMBLER
|
||||
//SEG0 @begin
|
||||
//SEG1 [0] phi from @begin to @1
|
||||
//SEG2 [0] phi (byte) y#2 = (byte) 0 -- zpby1=coby1
|
||||
lda #$0
|
||||
sta $5
|
||||
//SEG3 [0] phi (byte) e#3 = (byte) 12 -- xby=coby1
|
||||
ldx #$c
|
||||
//SEG4 [0] phi (byte) x#2 = (byte) 0 -- zpby1=coby1
|
||||
lda #$0
|
||||
sta $4
|
||||
//SEG5 [0] phi (byte*) cursor#3 = (word) 1024 -- zpptrby1=cowo1
|
||||
lda #<$400
|
||||
sta $2
|
||||
lda #>$400
|
||||
sta $2+$1
|
||||
jmp b1
|
||||
//SEG6 [0] phi from @3 to @1
|
||||
//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:
|
||||
//SEG12 [1] *((byte*) cursor#3) ← (byte) 81 [ cursor#3 x#2 e#3 y#2 ] -- _star_zpptrby1=coby1
|
||||
ldy #$0
|
||||
lda #$51
|
||||
sta ($2),y
|
||||
//SEG13 [2] (byte) x#1 ← (byte) x#2 + (byte) 1 [ x#1 cursor#3 e#3 y#2 ] -- zpby1=zpby1_plus_1
|
||||
inc $4
|
||||
//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
|
||||
!:
|
||||
//SEG15 [4] (byte) e#1 ← (byte) e#3 + (byte) 24 [ x#1 e#1 cursor#1 y#2 ] -- xby=xby_plus_coby1
|
||||
txa
|
||||
clc
|
||||
adc #$18
|
||||
tax
|
||||
//SEG16 [5] if((byte) 39<(byte) e#1) goto @2 [ x#1 e#1 cursor#1 y#2 ] -- coby1_lt_xby_then_la1
|
||||
cpx #$27
|
||||
bcs b2
|
||||
//SEG17 [6] phi from @1 to @3
|
||||
//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:
|
||||
//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 #$28
|
||||
bcc b1
|
||||
//SEG23 @end
|
||||
//SEG24 @2
|
||||
b2:
|
||||
//SEG25 [8] (byte) y#1 ← (byte) y#2 + (byte) 1 [ x#1 e#1 cursor#1 y#1 ] -- zpby1=zpby1_plus_1
|
||||
inc $5
|
||||
//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 #$28
|
||||
sta $2
|
||||
bcc !+
|
||||
inc $2+$1
|
||||
!:
|
||||
//SEG27 [10] (byte) e#2 ← (byte) e#1 - (byte) 39 [ x#1 cursor#2 e#2 y#1 ] -- xby=xby_minus_coby1
|
||||
txa
|
||||
sec
|
||||
sbc #$27
|
||||
tax
|
||||
//SEG28 [6] phi from @2 to @3
|
||||
//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 Pass6NextJumpElimination
|
||||
ASSEMBLER
|
||||
//SEG0 @begin
|
||||
//SEG1 [0] phi from @begin to @1
|
||||
//SEG2 [0] phi (byte) y#2 = (byte) 0 -- zpby1=coby1
|
||||
lda #$0
|
||||
sta $5
|
||||
//SEG3 [0] phi (byte) e#3 = (byte) 12 -- xby=coby1
|
||||
ldx #$c
|
||||
//SEG4 [0] phi (byte) x#2 = (byte) 0 -- zpby1=coby1
|
||||
lda #$0
|
||||
sta $4
|
||||
//SEG5 [0] phi (byte*) cursor#3 = (word) 1024 -- zpptrby1=cowo1
|
||||
lda #<$400
|
||||
sta $2
|
||||
lda #>$400
|
||||
sta $2+$1
|
||||
//SEG6 [0] phi from @3 to @1
|
||||
//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:
|
||||
//SEG12 [1] *((byte*) cursor#3) ← (byte) 81 [ cursor#3 x#2 e#3 y#2 ] -- _star_zpptrby1=coby1
|
||||
ldy #$0
|
||||
lda #$51
|
||||
sta ($2),y
|
||||
//SEG13 [2] (byte) x#1 ← (byte) x#2 + (byte) 1 [ x#1 cursor#3 e#3 y#2 ] -- zpby1=zpby1_plus_1
|
||||
inc $4
|
||||
//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
|
||||
!:
|
||||
//SEG15 [4] (byte) e#1 ← (byte) e#3 + (byte) 24 [ x#1 e#1 cursor#1 y#2 ] -- xby=xby_plus_coby1
|
||||
txa
|
||||
clc
|
||||
adc #$18
|
||||
tax
|
||||
//SEG16 [5] if((byte) 39<(byte) e#1) goto @2 [ x#1 e#1 cursor#1 y#2 ] -- coby1_lt_xby_then_la1
|
||||
cpx #$27
|
||||
bcs b2
|
||||
//SEG17 [6] phi from @1 to @3
|
||||
//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:
|
||||
//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 #$28
|
||||
bcc b1
|
||||
//SEG23 @end
|
||||
//SEG24 @2
|
||||
b2:
|
||||
//SEG25 [8] (byte) y#1 ← (byte) y#2 + (byte) 1 [ x#1 e#1 cursor#1 y#1 ] -- zpby1=zpby1_plus_1
|
||||
inc $5
|
||||
//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 #$28
|
||||
sta $2
|
||||
bcc !+
|
||||
inc $2+$1
|
||||
!:
|
||||
//SEG27 [10] (byte) e#2 ← (byte) e#1 - (byte) 39 [ x#1 cursor#2 e#2 y#1 ] -- xby=xby_minus_coby1
|
||||
txa
|
||||
sec
|
||||
sbc #$27
|
||||
tax
|
||||
//SEG28 [6] phi from @2 to @3
|
||||
//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
|
||||
(label) @1
|
||||
(label) @2
|
||||
@ -1408,9 +1567,7 @@ zp byte:5 [ y#2 y#4 y#1 ]
|
||||
|
||||
FINAL CODE
|
||||
//SEG0 @begin
|
||||
bbegin:
|
||||
//SEG1 [0] phi from @begin to @1
|
||||
b1_from_bbegin:
|
||||
//SEG2 [0] phi (byte) y#2 = (byte) 0 -- zpby1=coby1
|
||||
lda #$0
|
||||
sta $5
|
||||
@ -1425,7 +1582,6 @@ b1_from_bbegin:
|
||||
lda #>$400
|
||||
sta $2+$1
|
||||
//SEG6 [0] phi from @3 to @1
|
||||
b1_from_b3:
|
||||
//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
|
||||
@ -1452,7 +1608,6 @@ b1:
|
||||
cpx #$27
|
||||
bcs b2
|
||||
//SEG17 [6] phi from @1 to @3
|
||||
b3_from_b1:
|
||||
//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
|
||||
@ -1461,9 +1616,8 @@ b3:
|
||||
//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 #$28
|
||||
bcc b1_from_b3
|
||||
bcc b1
|
||||
//SEG23 @end
|
||||
bend:
|
||||
//SEG24 @2
|
||||
b2:
|
||||
//SEG25 [8] (byte) y#1 ← (byte) y#2 + (byte) 1 [ x#1 e#1 cursor#1 y#1 ] -- zpby1=zpby1_plus_1
|
||||
@ -1482,7 +1636,6 @@ b2:
|
||||
sbc #$27
|
||||
tax
|
||||
//SEG28 [6] phi from @2 to @3
|
||||
b3_from_b2:
|
||||
//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
|
||||
|
@ -1,14 +1,10 @@
|
||||
bbegin:
|
||||
jsr main
|
||||
bend:
|
||||
main: {
|
||||
lda #$0
|
||||
sta $1100
|
||||
lda #$1
|
||||
sta $1101
|
||||
b1_from_main:
|
||||
ldx #$0
|
||||
b1_from_b1:
|
||||
b1:
|
||||
lda $1100,x
|
||||
clc
|
||||
@ -16,7 +12,6 @@ main: {
|
||||
sta $1102,x
|
||||
inx
|
||||
cpx #$f
|
||||
bcc b1_from_b1
|
||||
breturn:
|
||||
bcc b1
|
||||
rts
|
||||
}
|
||||
|
@ -693,7 +693,7 @@ MISSING FRAGMENTS
|
||||
Removing instruction jmp bend
|
||||
Removing instruction jmp b1
|
||||
Removing instruction jmp breturn
|
||||
Succesful ASM optimization Pass5NextJumpElimination
|
||||
Succesful ASM optimization Pass6NextJumpElimination
|
||||
ASSEMBLER
|
||||
//SEG0 @begin
|
||||
bbegin:
|
||||
@ -739,8 +739,9 @@ main: {
|
||||
rts
|
||||
}
|
||||
|
||||
Removing instruction jmp b1
|
||||
Succesful ASM optimization Pass5NextJumpElimination
|
||||
Replacing label b1_from_b1 with b1
|
||||
Removing instruction b1_from_b1:
|
||||
Succesful ASM optimization Pass6RedundantLabelElimination
|
||||
ASSEMBLER
|
||||
//SEG0 @begin
|
||||
bbegin:
|
||||
@ -760,8 +761,8 @@ main: {
|
||||
b1_from_main:
|
||||
//SEG7 [3] phi (byte) main::i#2 = (byte) 0 -- xby=coby1
|
||||
ldx #$0
|
||||
jmp b1
|
||||
//SEG8 [3] phi from main::@1 to main::@1
|
||||
b1_from_b1:
|
||||
//SEG9 [3] phi (byte) main::i#2 = (byte) main::i#1 -- register_copy
|
||||
//SEG10 main::@1
|
||||
b1:
|
||||
@ -778,13 +779,99 @@ main: {
|
||||
inx
|
||||
//SEG16 [9] if((byte) main::i#1<(byte) 15) goto main::@1 [ main::i#1 ] -- xby_lt_coby1_then_la1
|
||||
cpx #$f
|
||||
bcc b1_from_b1
|
||||
bcc b1
|
||||
//SEG17 main::@return
|
||||
breturn:
|
||||
//SEG18 [10] return [ ]
|
||||
rts
|
||||
}
|
||||
|
||||
Removing instruction bbegin:
|
||||
Removing instruction bend:
|
||||
Removing instruction b1_from_main:
|
||||
Removing instruction breturn:
|
||||
Succesful ASM optimization Pass6UnusedLabelElimination
|
||||
ASSEMBLER
|
||||
//SEG0 @begin
|
||||
//SEG1 [0] call main param-assignment [ ]
|
||||
jsr main
|
||||
//SEG2 @end
|
||||
//SEG3 main
|
||||
main: {
|
||||
//SEG4 [1] *((word) 4352) ← (byte) 0 [ ] -- _star_cowo1=coby2
|
||||
lda #$0
|
||||
sta $1100
|
||||
//SEG5 [2] *((word) 4353) ← (byte) 1 [ ] -- _star_cowo1=coby2
|
||||
lda #$1
|
||||
sta $1101
|
||||
//SEG6 [3] phi from main to main::@1
|
||||
//SEG7 [3] phi (byte) main::i#2 = (byte) 0 -- xby=coby1
|
||||
ldx #$0
|
||||
jmp b1
|
||||
//SEG8 [3] phi from main::@1 to main::@1
|
||||
//SEG9 [3] phi (byte) main::i#2 = (byte) main::i#1 -- register_copy
|
||||
//SEG10 main::@1
|
||||
b1:
|
||||
//SEG11 [4] (byte~) main::$1 ← (word) 4352 *idx (byte) main::i#2 [ main::i#2 main::$1 ] -- aby=cowo1_staridx_xby
|
||||
lda $1100,x
|
||||
//SEG12 [5] (byte~) main::$3 ← (word) 4353 *idx (byte) main::i#2 [ main::i#2 main::$1 main::$3 ]
|
||||
// [5] main::$3 ← 4353 *idx main::i#2 // ALU
|
||||
//SEG13 [6] (byte~) main::$4 ← (byte~) main::$1 + (byte~) main::$3 [ main::i#2 main::$4 ] -- aby=aby_plus_cowo1_staridx_xby
|
||||
clc
|
||||
adc $1101,x
|
||||
//SEG14 [7] *((word) 4354 + (byte) main::i#2) ← (byte~) main::$4 [ main::i#2 ] -- cowo1_staridx_xby=aby
|
||||
sta $1102,x
|
||||
//SEG15 [8] (byte) main::i#1 ← ++ (byte) main::i#2 [ main::i#1 ] -- xby=_inc_xby
|
||||
inx
|
||||
//SEG16 [9] if((byte) main::i#1<(byte) 15) goto main::@1 [ main::i#1 ] -- xby_lt_coby1_then_la1
|
||||
cpx #$f
|
||||
bcc b1
|
||||
//SEG17 main::@return
|
||||
//SEG18 [10] return [ ]
|
||||
rts
|
||||
}
|
||||
|
||||
Removing instruction jmp b1
|
||||
Succesful ASM optimization Pass6NextJumpElimination
|
||||
ASSEMBLER
|
||||
//SEG0 @begin
|
||||
//SEG1 [0] call main param-assignment [ ]
|
||||
jsr main
|
||||
//SEG2 @end
|
||||
//SEG3 main
|
||||
main: {
|
||||
//SEG4 [1] *((word) 4352) ← (byte) 0 [ ] -- _star_cowo1=coby2
|
||||
lda #$0
|
||||
sta $1100
|
||||
//SEG5 [2] *((word) 4353) ← (byte) 1 [ ] -- _star_cowo1=coby2
|
||||
lda #$1
|
||||
sta $1101
|
||||
//SEG6 [3] phi from main to main::@1
|
||||
//SEG7 [3] phi (byte) main::i#2 = (byte) 0 -- xby=coby1
|
||||
ldx #$0
|
||||
//SEG8 [3] phi from main::@1 to main::@1
|
||||
//SEG9 [3] phi (byte) main::i#2 = (byte) main::i#1 -- register_copy
|
||||
//SEG10 main::@1
|
||||
b1:
|
||||
//SEG11 [4] (byte~) main::$1 ← (word) 4352 *idx (byte) main::i#2 [ main::i#2 main::$1 ] -- aby=cowo1_staridx_xby
|
||||
lda $1100,x
|
||||
//SEG12 [5] (byte~) main::$3 ← (word) 4353 *idx (byte) main::i#2 [ main::i#2 main::$1 main::$3 ]
|
||||
// [5] main::$3 ← 4353 *idx main::i#2 // ALU
|
||||
//SEG13 [6] (byte~) main::$4 ← (byte~) main::$1 + (byte~) main::$3 [ main::i#2 main::$4 ] -- aby=aby_plus_cowo1_staridx_xby
|
||||
clc
|
||||
adc $1101,x
|
||||
//SEG14 [7] *((word) 4354 + (byte) main::i#2) ← (byte~) main::$4 [ main::i#2 ] -- cowo1_staridx_xby=aby
|
||||
sta $1102,x
|
||||
//SEG15 [8] (byte) main::i#1 ← ++ (byte) main::i#2 [ main::i#1 ] -- xby=_inc_xby
|
||||
inx
|
||||
//SEG16 [9] if((byte) main::i#1<(byte) 15) goto main::@1 [ main::i#1 ] -- xby_lt_coby1_then_la1
|
||||
cpx #$f
|
||||
bcc b1
|
||||
//SEG17 main::@return
|
||||
//SEG18 [10] return [ ]
|
||||
rts
|
||||
}
|
||||
|
||||
FINAL SYMBOL TABLE
|
||||
(label) @begin
|
||||
(label) @end
|
||||
@ -806,11 +893,9 @@ reg byte a [ main::$4 ]
|
||||
|
||||
FINAL CODE
|
||||
//SEG0 @begin
|
||||
bbegin:
|
||||
//SEG1 [0] call main param-assignment [ ]
|
||||
jsr main
|
||||
//SEG2 @end
|
||||
bend:
|
||||
//SEG3 main
|
||||
main: {
|
||||
//SEG4 [1] *((word) 4352) ← (byte) 0 [ ] -- _star_cowo1=coby2
|
||||
@ -820,11 +905,9 @@ main: {
|
||||
lda #$1
|
||||
sta $1101
|
||||
//SEG6 [3] phi from main to main::@1
|
||||
b1_from_main:
|
||||
//SEG7 [3] phi (byte) main::i#2 = (byte) 0 -- xby=coby1
|
||||
ldx #$0
|
||||
//SEG8 [3] phi from main::@1 to main::@1
|
||||
b1_from_b1:
|
||||
//SEG9 [3] phi (byte) main::i#2 = (byte) main::i#1 -- register_copy
|
||||
//SEG10 main::@1
|
||||
b1:
|
||||
@ -841,9 +924,8 @@ main: {
|
||||
inx
|
||||
//SEG16 [9] if((byte) main::i#1<(byte) 15) goto main::@1 [ main::i#1 ] -- xby_lt_coby1_then_la1
|
||||
cpx #$f
|
||||
bcc b1_from_b1
|
||||
bcc b1
|
||||
//SEG17 main::@return
|
||||
breturn:
|
||||
//SEG18 [10] return [ ]
|
||||
rts
|
||||
}
|
||||
|
@ -1,38 +1,27 @@
|
||||
bbegin:
|
||||
jsr main
|
||||
bend:
|
||||
main: {
|
||||
jsr prepare
|
||||
b3_from_main:
|
||||
ldx #$19
|
||||
jmp b3
|
||||
b3_from_b11:
|
||||
ldx #$19
|
||||
b3_from_b3:
|
||||
b3_from_b6:
|
||||
b3:
|
||||
lda $d012
|
||||
cmp #$fe
|
||||
bne b3_from_b3
|
||||
bne b3
|
||||
b4:
|
||||
lda $d012
|
||||
cmp #$ff
|
||||
bne b4
|
||||
b6:
|
||||
dex
|
||||
cpx #$0
|
||||
bne b3_from_b6
|
||||
b7:
|
||||
bne b3
|
||||
jsr flip
|
||||
b10:
|
||||
jsr plot
|
||||
b11:
|
||||
jmp b3_from_b11
|
||||
breturn:
|
||||
rts
|
||||
}
|
||||
plot: {
|
||||
b1_from_plot:
|
||||
lda #$10
|
||||
sta $4
|
||||
lda #<$4d4
|
||||
@ -40,19 +29,15 @@ plot: {
|
||||
lda #>$4d4
|
||||
sta $2+$1
|
||||
ldx #$0
|
||||
b1_from_b3:
|
||||
b1:
|
||||
b2_from_b1:
|
||||
ldy #$0
|
||||
b2_from_b2:
|
||||
b2:
|
||||
lda $1000,x
|
||||
sta ($2),y
|
||||
inx
|
||||
iny
|
||||
cpy #$10
|
||||
bcc b2_from_b2
|
||||
b3:
|
||||
bcc b2
|
||||
lda $2
|
||||
clc
|
||||
adc #$28
|
||||
@ -62,22 +47,17 @@ plot: {
|
||||
!:
|
||||
dec $4
|
||||
lda $4
|
||||
bne b1_from_b3
|
||||
breturn:
|
||||
bne b1
|
||||
rts
|
||||
}
|
||||
flip: {
|
||||
b1_from_flip:
|
||||
lda #$10
|
||||
sta $4
|
||||
ldy #$f
|
||||
ldx #$0
|
||||
b1_from_b4:
|
||||
b1:
|
||||
b2_from_b1:
|
||||
lda #$10
|
||||
sta $5
|
||||
b2_from_b2:
|
||||
b2:
|
||||
lda $1000,x
|
||||
sta $1100,y
|
||||
@ -88,34 +68,27 @@ flip: {
|
||||
tay
|
||||
dec $5
|
||||
lda $5
|
||||
bne b2_from_b2
|
||||
b4:
|
||||
bne b2
|
||||
dey
|
||||
dec $4
|
||||
lda $4
|
||||
bne b1_from_b4
|
||||
b3_from_b4:
|
||||
bne b1
|
||||
ldx #$0
|
||||
b3_from_b3:
|
||||
b3:
|
||||
lda $1100,x
|
||||
sta $1000,x
|
||||
inx
|
||||
cpx #$0
|
||||
bne b3_from_b3
|
||||
breturn:
|
||||
bne b3
|
||||
rts
|
||||
}
|
||||
prepare: {
|
||||
b1_from_prepare:
|
||||
ldx #$0
|
||||
b1_from_b1:
|
||||
b1:
|
||||
txa
|
||||
sta $1000,x
|
||||
inx
|
||||
cpx #$0
|
||||
bne b1_from_b1
|
||||
breturn:
|
||||
bne b1
|
||||
rts
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,22 +1,16 @@
|
||||
bbegin:
|
||||
b1_from_bbegin:
|
||||
lda #$0
|
||||
ldx #$a
|
||||
b1_from_b3:
|
||||
b1:
|
||||
cpx #$5
|
||||
beq !+
|
||||
bcs b2
|
||||
!:
|
||||
b3_from_b1:
|
||||
b3:
|
||||
dex
|
||||
cpx #$0
|
||||
bne b1_from_b3
|
||||
bend:
|
||||
bne b1
|
||||
b2:
|
||||
stx $ff
|
||||
clc
|
||||
adc $ff
|
||||
b3_from_b2:
|
||||
jmp b3
|
||||
|
@ -442,7 +442,7 @@ Uplifting [] best 405 combination reg byte a [ s#2 s#4 s#1 ] reg byte x [ i#2 i#
|
||||
Removing instruction jmp b1
|
||||
Removing instruction jmp b3
|
||||
Removing instruction jmp bend
|
||||
Succesful ASM optimization Pass5NextJumpElimination
|
||||
Succesful ASM optimization Pass6NextJumpElimination
|
||||
ASSEMBLER
|
||||
//SEG0 @begin
|
||||
bbegin:
|
||||
@ -487,19 +487,22 @@ b3_from_b2:
|
||||
//SEG18 [2] phi (byte) s#4 = (byte) s#1 -- register_copy
|
||||
jmp b3
|
||||
|
||||
Removing instruction jmp b1
|
||||
Succesful ASM optimization Pass5NextJumpElimination
|
||||
Replacing label b1_from_b3 with b1
|
||||
Removing instruction b1_from_bbegin:
|
||||
Removing instruction b1_from_b3:
|
||||
Removing instruction b3_from_b1:
|
||||
Removing instruction bend:
|
||||
Succesful ASM optimization Pass6RedundantLabelElimination
|
||||
ASSEMBLER
|
||||
//SEG0 @begin
|
||||
bbegin:
|
||||
//SEG1 [0] phi from @begin to @1
|
||||
b1_from_bbegin:
|
||||
//SEG2 [0] phi (byte) s#2 = (byte) 0 -- aby=coby1
|
||||
lda #$0
|
||||
//SEG3 [0] phi (byte) i#2 = (byte) 10 -- xby=coby1
|
||||
ldx #$a
|
||||
jmp b1
|
||||
//SEG4 [0] phi from @3 to @1
|
||||
b1_from_b3:
|
||||
//SEG5 [0] phi (byte) s#2 = (byte) s#4 -- register_copy
|
||||
//SEG6 [0] phi (byte) i#2 = (byte) i#1 -- register_copy
|
||||
//SEG7 @1
|
||||
@ -510,7 +513,6 @@ b1:
|
||||
bcs b2
|
||||
!:
|
||||
//SEG9 [2] phi from @1 to @3
|
||||
b3_from_b1:
|
||||
//SEG10 [2] phi (byte) s#4 = (byte) s#2 -- register_copy
|
||||
//SEG11 @3
|
||||
b3:
|
||||
@ -518,9 +520,8 @@ b3:
|
||||
dex
|
||||
//SEG13 [4] if((byte) i#1>(byte) 0) goto @1 [ i#1 s#4 ] -- xby_gt_0_then_la1
|
||||
cpx #$0
|
||||
bne b1_from_b3
|
||||
bne b1
|
||||
//SEG14 @end
|
||||
bend:
|
||||
//SEG15 @2
|
||||
b2:
|
||||
//SEG16 [5] (byte) s#1 ← (byte) s#2 + (byte) i#2 [ i#2 s#1 ] -- aby=aby_plus_xby
|
||||
@ -532,6 +533,86 @@ b3_from_b2:
|
||||
//SEG18 [2] phi (byte) s#4 = (byte) s#1 -- register_copy
|
||||
jmp b3
|
||||
|
||||
Removing instruction bbegin:
|
||||
Removing instruction b3_from_b2:
|
||||
Succesful ASM optimization Pass6UnusedLabelElimination
|
||||
ASSEMBLER
|
||||
//SEG0 @begin
|
||||
//SEG1 [0] phi from @begin to @1
|
||||
//SEG2 [0] phi (byte) s#2 = (byte) 0 -- aby=coby1
|
||||
lda #$0
|
||||
//SEG3 [0] phi (byte) i#2 = (byte) 10 -- xby=coby1
|
||||
ldx #$a
|
||||
jmp b1
|
||||
//SEG4 [0] phi from @3 to @1
|
||||
//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:
|
||||
//SEG8 [1] if((byte) i#2>(byte) 5) goto @2 [ i#2 s#2 ] -- xby_gt_coby1_then_la1
|
||||
cpx #$5
|
||||
beq !+
|
||||
bcs b2
|
||||
!:
|
||||
//SEG9 [2] phi from @1 to @3
|
||||
//SEG10 [2] phi (byte) s#4 = (byte) s#2 -- register_copy
|
||||
//SEG11 @3
|
||||
b3:
|
||||
//SEG12 [3] (byte) i#1 ← -- (byte) i#2 [ i#1 s#4 ] -- xby=_dec_xby
|
||||
dex
|
||||
//SEG13 [4] if((byte) i#1>(byte) 0) goto @1 [ i#1 s#4 ] -- xby_gt_0_then_la1
|
||||
cpx #$0
|
||||
bne b1
|
||||
//SEG14 @end
|
||||
//SEG15 @2
|
||||
b2:
|
||||
//SEG16 [5] (byte) s#1 ← (byte) s#2 + (byte) i#2 [ i#2 s#1 ] -- aby=aby_plus_xby
|
||||
stx $ff
|
||||
clc
|
||||
adc $ff
|
||||
//SEG17 [2] phi from @2 to @3
|
||||
//SEG18 [2] phi (byte) s#4 = (byte) s#1 -- register_copy
|
||||
jmp b3
|
||||
|
||||
Removing instruction jmp b1
|
||||
Succesful ASM optimization Pass6NextJumpElimination
|
||||
ASSEMBLER
|
||||
//SEG0 @begin
|
||||
//SEG1 [0] phi from @begin to @1
|
||||
//SEG2 [0] phi (byte) s#2 = (byte) 0 -- aby=coby1
|
||||
lda #$0
|
||||
//SEG3 [0] phi (byte) i#2 = (byte) 10 -- xby=coby1
|
||||
ldx #$a
|
||||
//SEG4 [0] phi from @3 to @1
|
||||
//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:
|
||||
//SEG8 [1] if((byte) i#2>(byte) 5) goto @2 [ i#2 s#2 ] -- xby_gt_coby1_then_la1
|
||||
cpx #$5
|
||||
beq !+
|
||||
bcs b2
|
||||
!:
|
||||
//SEG9 [2] phi from @1 to @3
|
||||
//SEG10 [2] phi (byte) s#4 = (byte) s#2 -- register_copy
|
||||
//SEG11 @3
|
||||
b3:
|
||||
//SEG12 [3] (byte) i#1 ← -- (byte) i#2 [ i#1 s#4 ] -- xby=_dec_xby
|
||||
dex
|
||||
//SEG13 [4] if((byte) i#1>(byte) 0) goto @1 [ i#1 s#4 ] -- xby_gt_0_then_la1
|
||||
cpx #$0
|
||||
bne b1
|
||||
//SEG14 @end
|
||||
//SEG15 @2
|
||||
b2:
|
||||
//SEG16 [5] (byte) s#1 ← (byte) s#2 + (byte) i#2 [ i#2 s#1 ] -- aby=aby_plus_xby
|
||||
stx $ff
|
||||
clc
|
||||
adc $ff
|
||||
//SEG17 [2] phi from @2 to @3
|
||||
//SEG18 [2] phi (byte) s#4 = (byte) s#1 -- register_copy
|
||||
jmp b3
|
||||
|
||||
FINAL SYMBOL TABLE
|
||||
(label) @1
|
||||
(label) @2
|
||||
@ -551,15 +632,12 @@ reg byte a [ s#2 s#4 s#1 ]
|
||||
|
||||
FINAL CODE
|
||||
//SEG0 @begin
|
||||
bbegin:
|
||||
//SEG1 [0] phi from @begin to @1
|
||||
b1_from_bbegin:
|
||||
//SEG2 [0] phi (byte) s#2 = (byte) 0 -- aby=coby1
|
||||
lda #$0
|
||||
//SEG3 [0] phi (byte) i#2 = (byte) 10 -- xby=coby1
|
||||
ldx #$a
|
||||
//SEG4 [0] phi from @3 to @1
|
||||
b1_from_b3:
|
||||
//SEG5 [0] phi (byte) s#2 = (byte) s#4 -- register_copy
|
||||
//SEG6 [0] phi (byte) i#2 = (byte) i#1 -- register_copy
|
||||
//SEG7 @1
|
||||
@ -570,7 +648,6 @@ b1:
|
||||
bcs b2
|
||||
!:
|
||||
//SEG9 [2] phi from @1 to @3
|
||||
b3_from_b1:
|
||||
//SEG10 [2] phi (byte) s#4 = (byte) s#2 -- register_copy
|
||||
//SEG11 @3
|
||||
b3:
|
||||
@ -578,9 +655,8 @@ b3:
|
||||
dex
|
||||
//SEG13 [4] if((byte) i#1>(byte) 0) goto @1 [ i#1 s#4 ] -- xby_gt_0_then_la1
|
||||
cpx #$0
|
||||
bne b1_from_b3
|
||||
bne b1
|
||||
//SEG14 @end
|
||||
bend:
|
||||
//SEG15 @2
|
||||
b2:
|
||||
//SEG16 [5] (byte) s#1 ← (byte) s#2 + (byte) i#2 [ i#2 s#1 ] -- aby=aby_plus_xby
|
||||
@ -588,7 +664,6 @@ b2:
|
||||
clc
|
||||
adc $ff
|
||||
//SEG17 [2] phi from @2 to @3
|
||||
b3_from_b2:
|
||||
//SEG18 [2] phi (byte) s#4 = (byte) s#1 -- register_copy
|
||||
jmp b3
|
||||
|
||||
|
@ -1,28 +1,19 @@
|
||||
bbegin:
|
||||
jsr main
|
||||
bend:
|
||||
main: {
|
||||
b1_from_main:
|
||||
ldy #$64
|
||||
b1_from_b3:
|
||||
b1:
|
||||
jsr nest
|
||||
b3:
|
||||
dey
|
||||
cpy #$0
|
||||
bne b1_from_b3
|
||||
breturn:
|
||||
bne b1
|
||||
rts
|
||||
}
|
||||
nest: {
|
||||
b1_from_nest:
|
||||
ldx #$64
|
||||
b1_from_b1:
|
||||
b1:
|
||||
stx $400
|
||||
dex
|
||||
cpx #$0
|
||||
bne b1_from_b1
|
||||
breturn:
|
||||
bne b1
|
||||
rts
|
||||
}
|
||||
|
@ -820,7 +820,7 @@ Removing instruction jmp b3
|
||||
Removing instruction jmp breturn
|
||||
Removing instruction jmp b1
|
||||
Removing instruction jmp breturn
|
||||
Succesful ASM optimization Pass5NextJumpElimination
|
||||
Succesful ASM optimization Pass6NextJumpElimination
|
||||
ASSEMBLER
|
||||
//SEG0 @begin
|
||||
bbegin:
|
||||
@ -879,9 +879,11 @@ nest: {
|
||||
rts
|
||||
}
|
||||
|
||||
Removing instruction jmp b1
|
||||
Removing instruction jmp b1
|
||||
Succesful ASM optimization Pass5NextJumpElimination
|
||||
Replacing label b1_from_b3 with b1
|
||||
Replacing label b1_from_b1 with b1
|
||||
Removing instruction b1_from_b3:
|
||||
Removing instruction b1_from_b1:
|
||||
Succesful ASM optimization Pass6RedundantLabelElimination
|
||||
ASSEMBLER
|
||||
//SEG0 @begin
|
||||
bbegin:
|
||||
@ -895,8 +897,8 @@ main: {
|
||||
b1_from_main:
|
||||
//SEG5 [1] phi (byte) main::i#2 = (byte) 100 -- yby=coby1
|
||||
ldy #$64
|
||||
jmp b1
|
||||
//SEG6 [1] phi from main::@3 to main::@1
|
||||
b1_from_b3:
|
||||
//SEG7 [1] phi (byte) main::i#2 = (byte) main::i#1 -- register_copy
|
||||
//SEG8 main::@1
|
||||
b1:
|
||||
@ -908,7 +910,7 @@ main: {
|
||||
dey
|
||||
//SEG12 [4] if((byte) main::i#1>(byte) 0) goto main::@1 [ main::i#1 ] -- yby_gt_0_then_la1
|
||||
cpy #$0
|
||||
bne b1_from_b3
|
||||
bne b1
|
||||
//SEG13 main::@return
|
||||
breturn:
|
||||
//SEG14 [5] return [ ]
|
||||
@ -920,8 +922,8 @@ nest: {
|
||||
b1_from_nest:
|
||||
//SEG17 [6] phi (byte) nest::j#2 = (byte) 100 -- xby=coby1
|
||||
ldx #$64
|
||||
jmp b1
|
||||
//SEG18 [6] phi from nest::@1 to nest::@1
|
||||
b1_from_b1:
|
||||
//SEG19 [6] phi (byte) nest::j#2 = (byte) nest::j#1 -- register_copy
|
||||
//SEG20 nest::@1
|
||||
b1:
|
||||
@ -931,13 +933,120 @@ nest: {
|
||||
dex
|
||||
//SEG23 [9] if((byte) nest::j#1>(byte) 0) goto nest::@1 [ main::i#2 nest::j#1 ] -- xby_gt_0_then_la1
|
||||
cpx #$0
|
||||
bne b1_from_b1
|
||||
bne b1
|
||||
//SEG24 nest::@return
|
||||
breturn:
|
||||
//SEG25 [10] return [ main::i#2 ]
|
||||
rts
|
||||
}
|
||||
|
||||
Removing instruction bbegin:
|
||||
Removing instruction bend:
|
||||
Removing instruction b1_from_main:
|
||||
Removing instruction b3:
|
||||
Removing instruction breturn:
|
||||
Removing instruction b1_from_nest:
|
||||
Removing instruction breturn:
|
||||
Succesful ASM optimization Pass6UnusedLabelElimination
|
||||
ASSEMBLER
|
||||
//SEG0 @begin
|
||||
//SEG1 [0] call main param-assignment [ ]
|
||||
jsr main
|
||||
//SEG2 @end
|
||||
//SEG3 main
|
||||
main: {
|
||||
//SEG4 [1] phi from main to main::@1
|
||||
//SEG5 [1] phi (byte) main::i#2 = (byte) 100 -- yby=coby1
|
||||
ldy #$64
|
||||
jmp b1
|
||||
//SEG6 [1] phi from main::@3 to main::@1
|
||||
//SEG7 [1] phi (byte) main::i#2 = (byte) main::i#1 -- register_copy
|
||||
//SEG8 main::@1
|
||||
b1:
|
||||
//SEG9 [2] call nest param-assignment [ main::i#2 ]
|
||||
jsr nest
|
||||
//SEG10 main::@3
|
||||
//SEG11 [3] (byte) main::i#1 ← -- (byte) main::i#2 [ main::i#1 ] -- yby=_dec_yby
|
||||
dey
|
||||
//SEG12 [4] if((byte) main::i#1>(byte) 0) goto main::@1 [ main::i#1 ] -- yby_gt_0_then_la1
|
||||
cpy #$0
|
||||
bne b1
|
||||
//SEG13 main::@return
|
||||
//SEG14 [5] return [ ]
|
||||
rts
|
||||
}
|
||||
//SEG15 nest
|
||||
nest: {
|
||||
//SEG16 [6] phi from nest to nest::@1
|
||||
//SEG17 [6] phi (byte) nest::j#2 = (byte) 100 -- xby=coby1
|
||||
ldx #$64
|
||||
jmp b1
|
||||
//SEG18 [6] phi from nest::@1 to nest::@1
|
||||
//SEG19 [6] phi (byte) nest::j#2 = (byte) nest::j#1 -- register_copy
|
||||
//SEG20 nest::@1
|
||||
b1:
|
||||
//SEG21 [7] *((word) 1024) ← (byte) nest::j#2 [ main::i#2 nest::j#2 ] -- _star_cowo1=xby
|
||||
stx $400
|
||||
//SEG22 [8] (byte) nest::j#1 ← -- (byte) nest::j#2 [ main::i#2 nest::j#1 ] -- xby=_dec_xby
|
||||
dex
|
||||
//SEG23 [9] if((byte) nest::j#1>(byte) 0) goto nest::@1 [ main::i#2 nest::j#1 ] -- xby_gt_0_then_la1
|
||||
cpx #$0
|
||||
bne b1
|
||||
//SEG24 nest::@return
|
||||
//SEG25 [10] return [ main::i#2 ]
|
||||
rts
|
||||
}
|
||||
|
||||
Removing instruction jmp b1
|
||||
Removing instruction jmp b1
|
||||
Succesful ASM optimization Pass6NextJumpElimination
|
||||
ASSEMBLER
|
||||
//SEG0 @begin
|
||||
//SEG1 [0] call main param-assignment [ ]
|
||||
jsr main
|
||||
//SEG2 @end
|
||||
//SEG3 main
|
||||
main: {
|
||||
//SEG4 [1] phi from main to main::@1
|
||||
//SEG5 [1] phi (byte) main::i#2 = (byte) 100 -- yby=coby1
|
||||
ldy #$64
|
||||
//SEG6 [1] phi from main::@3 to main::@1
|
||||
//SEG7 [1] phi (byte) main::i#2 = (byte) main::i#1 -- register_copy
|
||||
//SEG8 main::@1
|
||||
b1:
|
||||
//SEG9 [2] call nest param-assignment [ main::i#2 ]
|
||||
jsr nest
|
||||
//SEG10 main::@3
|
||||
//SEG11 [3] (byte) main::i#1 ← -- (byte) main::i#2 [ main::i#1 ] -- yby=_dec_yby
|
||||
dey
|
||||
//SEG12 [4] if((byte) main::i#1>(byte) 0) goto main::@1 [ main::i#1 ] -- yby_gt_0_then_la1
|
||||
cpy #$0
|
||||
bne b1
|
||||
//SEG13 main::@return
|
||||
//SEG14 [5] return [ ]
|
||||
rts
|
||||
}
|
||||
//SEG15 nest
|
||||
nest: {
|
||||
//SEG16 [6] phi from nest to nest::@1
|
||||
//SEG17 [6] phi (byte) nest::j#2 = (byte) 100 -- xby=coby1
|
||||
ldx #$64
|
||||
//SEG18 [6] phi from nest::@1 to nest::@1
|
||||
//SEG19 [6] phi (byte) nest::j#2 = (byte) nest::j#1 -- register_copy
|
||||
//SEG20 nest::@1
|
||||
b1:
|
||||
//SEG21 [7] *((word) 1024) ← (byte) nest::j#2 [ main::i#2 nest::j#2 ] -- _star_cowo1=xby
|
||||
stx $400
|
||||
//SEG22 [8] (byte) nest::j#1 ← -- (byte) nest::j#2 [ main::i#2 nest::j#1 ] -- xby=_dec_xby
|
||||
dex
|
||||
//SEG23 [9] if((byte) nest::j#1>(byte) 0) goto nest::@1 [ main::i#2 nest::j#1 ] -- xby_gt_0_then_la1
|
||||
cpx #$0
|
||||
bne b1
|
||||
//SEG24 nest::@return
|
||||
//SEG25 [10] return [ main::i#2 ]
|
||||
rts
|
||||
}
|
||||
|
||||
FINAL SYMBOL TABLE
|
||||
(label) @begin
|
||||
(label) @end
|
||||
@ -961,44 +1070,36 @@ reg byte x [ 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
|
||||
b1_from_main:
|
||||
//SEG5 [1] phi (byte) main::i#2 = (byte) 100 -- yby=coby1
|
||||
ldy #$64
|
||||
//SEG6 [1] phi from main::@3 to main::@1
|
||||
b1_from_b3:
|
||||
//SEG7 [1] phi (byte) main::i#2 = (byte) main::i#1 -- register_copy
|
||||
//SEG8 main::@1
|
||||
b1:
|
||||
//SEG9 [2] call nest param-assignment [ main::i#2 ]
|
||||
jsr nest
|
||||
//SEG10 main::@3
|
||||
b3:
|
||||
//SEG11 [3] (byte) main::i#1 ← -- (byte) main::i#2 [ main::i#1 ] -- yby=_dec_yby
|
||||
dey
|
||||
//SEG12 [4] if((byte) main::i#1>(byte) 0) goto main::@1 [ main::i#1 ] -- yby_gt_0_then_la1
|
||||
cpy #$0
|
||||
bne b1_from_b3
|
||||
bne b1
|
||||
//SEG13 main::@return
|
||||
breturn:
|
||||
//SEG14 [5] return [ ]
|
||||
rts
|
||||
}
|
||||
//SEG15 nest
|
||||
nest: {
|
||||
//SEG16 [6] phi from nest to nest::@1
|
||||
b1_from_nest:
|
||||
//SEG17 [6] phi (byte) nest::j#2 = (byte) 100 -- xby=coby1
|
||||
ldx #$64
|
||||
//SEG18 [6] phi from nest::@1 to nest::@1
|
||||
b1_from_b1:
|
||||
//SEG19 [6] phi (byte) nest::j#2 = (byte) nest::j#1 -- register_copy
|
||||
//SEG20 nest::@1
|
||||
b1:
|
||||
@ -1008,9 +1109,8 @@ nest: {
|
||||
dex
|
||||
//SEG23 [9] if((byte) nest::j#1>(byte) 0) goto nest::@1 [ main::i#2 nest::j#1 ] -- xby_gt_0_then_la1
|
||||
cpx #$0
|
||||
bne b1_from_b1
|
||||
bne b1
|
||||
//SEG24 nest::@return
|
||||
breturn:
|
||||
//SEG25 [10] return [ main::i#2 ]
|
||||
rts
|
||||
}
|
||||
|
@ -1,69 +1,47 @@
|
||||
bbegin:
|
||||
jsr main
|
||||
bend:
|
||||
main: {
|
||||
b1_from_main:
|
||||
lda #$64
|
||||
sta $2
|
||||
b1_from_b3:
|
||||
b1:
|
||||
b2_from_b1:
|
||||
lda #$64
|
||||
sta $3
|
||||
b2_from_b5:
|
||||
b2:
|
||||
jsr nest1
|
||||
b5:
|
||||
dec $3
|
||||
lda $3
|
||||
bne b2_from_b5
|
||||
b3:
|
||||
bne b2
|
||||
dec $2
|
||||
lda $2
|
||||
bne b1_from_b3
|
||||
breturn:
|
||||
bne b1
|
||||
rts
|
||||
}
|
||||
nest1: {
|
||||
b1_from_nest1:
|
||||
lda #$64
|
||||
sta $4
|
||||
b1_from_b3:
|
||||
b1:
|
||||
b2_from_b1:
|
||||
lda #$64
|
||||
b2_from_b5:
|
||||
b2:
|
||||
jsr nest2
|
||||
b5:
|
||||
sec
|
||||
sbc #$1
|
||||
cmp #$0
|
||||
bne b2_from_b5
|
||||
b3:
|
||||
bne b2
|
||||
dec $4
|
||||
lda $4
|
||||
bne b1_from_b3
|
||||
breturn:
|
||||
bne b1
|
||||
rts
|
||||
}
|
||||
nest2: {
|
||||
b1_from_nest2:
|
||||
ldx #$64
|
||||
b1_from_b3:
|
||||
b1:
|
||||
b2_from_b1:
|
||||
ldy #$64
|
||||
b2_from_b2:
|
||||
b2:
|
||||
sty $400
|
||||
dey
|
||||
cpy #$0
|
||||
bne b2_from_b2
|
||||
b3:
|
||||
bne b2
|
||||
dex
|
||||
cpx #$0
|
||||
bne b1_from_b3
|
||||
breturn:
|
||||
bne b1
|
||||
rts
|
||||
}
|
||||
|
@ -2118,7 +2118,7 @@ Removing instruction jmp b1
|
||||
Removing instruction jmp b2
|
||||
Removing instruction jmp b3
|
||||
Removing instruction jmp breturn
|
||||
Succesful ASM optimization Pass5NextJumpElimination
|
||||
Succesful ASM optimization Pass6NextJumpElimination
|
||||
ASSEMBLER
|
||||
//SEG0 @begin
|
||||
bbegin:
|
||||
@ -2258,13 +2258,22 @@ nest2: {
|
||||
rts
|
||||
}
|
||||
|
||||
Removing instruction jmp b1
|
||||
Removing instruction jmp b2
|
||||
Removing instruction jmp b1
|
||||
Removing instruction jmp b2
|
||||
Removing instruction jmp b1
|
||||
Removing instruction jmp b2
|
||||
Succesful ASM optimization Pass5NextJumpElimination
|
||||
Replacing label b2_from_b5 with b2
|
||||
Replacing label b1_from_b3 with b1
|
||||
Replacing label b2_from_b5 with b2
|
||||
Replacing label b1_from_b3 with b1
|
||||
Replacing label b2_from_b2 with b2
|
||||
Replacing label b1_from_b3 with b1
|
||||
Removing instruction b1_from_b3:
|
||||
Removing instruction b2_from_b1:
|
||||
Removing instruction b2_from_b5:
|
||||
Removing instruction b1_from_b3:
|
||||
Removing instruction b2_from_b1:
|
||||
Removing instruction b2_from_b5:
|
||||
Removing instruction b1_from_b3:
|
||||
Removing instruction b2_from_b1:
|
||||
Removing instruction b2_from_b2:
|
||||
Succesful ASM optimization Pass6RedundantLabelElimination
|
||||
ASSEMBLER
|
||||
//SEG0 @begin
|
||||
bbegin:
|
||||
@ -2279,18 +2288,17 @@ main: {
|
||||
//SEG5 [1] phi (byte) main::i#2 = (byte) 100 -- zpby1=coby1
|
||||
lda #$64
|
||||
sta $2
|
||||
jmp b1
|
||||
//SEG6 [1] phi from main::@3 to main::@1
|
||||
b1_from_b3:
|
||||
//SEG7 [1] phi (byte) main::i#2 = (byte) main::i#1 -- register_copy
|
||||
//SEG8 main::@1
|
||||
b1:
|
||||
//SEG9 [2] phi from main::@1 to main::@2
|
||||
b2_from_b1:
|
||||
//SEG10 [2] phi (byte) main::j#2 = (byte) 100 -- zpby1=coby1
|
||||
lda #$64
|
||||
sta $3
|
||||
jmp b2
|
||||
//SEG11 [2] phi from main::@5 to main::@2
|
||||
b2_from_b5:
|
||||
//SEG12 [2] phi (byte) main::j#2 = (byte) main::j#1 -- register_copy
|
||||
//SEG13 main::@2
|
||||
b2:
|
||||
@ -2302,14 +2310,14 @@ main: {
|
||||
dec $3
|
||||
//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 b2_from_b5
|
||||
bne b2
|
||||
//SEG18 main::@3
|
||||
b3:
|
||||
//SEG19 [6] (byte) main::i#1 ← -- (byte) main::i#2 [ main::i#1 ] -- zpby1=_dec_zpby1
|
||||
dec $2
|
||||
//SEG20 [7] if((byte) main::i#1>(byte) 0) goto main::@1 [ main::i#1 ] -- zpby1_gt_0_then_la1
|
||||
lda $2
|
||||
bne b1_from_b3
|
||||
bne b1
|
||||
//SEG21 main::@return
|
||||
breturn:
|
||||
//SEG22 [8] return [ ]
|
||||
@ -2322,17 +2330,16 @@ nest1: {
|
||||
//SEG25 [9] phi (byte) nest1::i#2 = (byte) 100 -- zpby1=coby1
|
||||
lda #$64
|
||||
sta $4
|
||||
jmp b1
|
||||
//SEG26 [9] phi from nest1::@3 to nest1::@1
|
||||
b1_from_b3:
|
||||
//SEG27 [9] phi (byte) nest1::i#2 = (byte) nest1::i#1 -- register_copy
|
||||
//SEG28 nest1::@1
|
||||
b1:
|
||||
//SEG29 [10] phi from nest1::@1 to nest1::@2
|
||||
b2_from_b1:
|
||||
//SEG30 [10] phi (byte) nest1::j#2 = (byte) 100 -- aby=coby1
|
||||
lda #$64
|
||||
jmp b2
|
||||
//SEG31 [10] phi from nest1::@5 to nest1::@2
|
||||
b2_from_b5:
|
||||
//SEG32 [10] phi (byte) nest1::j#2 = (byte) nest1::j#1 -- register_copy
|
||||
//SEG33 nest1::@2
|
||||
b2:
|
||||
@ -2345,14 +2352,14 @@ nest1: {
|
||||
sbc #$1
|
||||
//SEG37 [13] if((byte) nest1::j#1>(byte) 0) goto nest1::@2 [ main::j#2 main::i#2 nest1::j#1 nest1::i#2 ] -- aby_gt_0_then_la1
|
||||
cmp #$0
|
||||
bne b2_from_b5
|
||||
bne b2
|
||||
//SEG38 nest1::@3
|
||||
b3:
|
||||
//SEG39 [14] (byte) nest1::i#1 ← -- (byte) nest1::i#2 [ main::j#2 main::i#2 nest1::i#1 ] -- zpby1=_dec_zpby1
|
||||
dec $4
|
||||
//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 b1_from_b3
|
||||
bne b1
|
||||
//SEG41 nest1::@return
|
||||
breturn:
|
||||
//SEG42 [16] return [ main::j#2 main::i#2 ]
|
||||
@ -2364,17 +2371,16 @@ nest2: {
|
||||
b1_from_nest2:
|
||||
//SEG45 [17] phi (byte) nest2::i#2 = (byte) 100 -- xby=coby1
|
||||
ldx #$64
|
||||
jmp b1
|
||||
//SEG46 [17] phi from nest2::@3 to nest2::@1
|
||||
b1_from_b3:
|
||||
//SEG47 [17] phi (byte) nest2::i#2 = (byte) nest2::i#1 -- register_copy
|
||||
//SEG48 nest2::@1
|
||||
b1:
|
||||
//SEG49 [18] phi from nest2::@1 to nest2::@2
|
||||
b2_from_b1:
|
||||
//SEG50 [18] phi (byte) nest2::j#2 = (byte) 100 -- yby=coby1
|
||||
ldy #$64
|
||||
jmp b2
|
||||
//SEG51 [18] phi from nest2::@2 to nest2::@2
|
||||
b2_from_b2:
|
||||
//SEG52 [18] phi (byte) nest2::j#2 = (byte) nest2::j#1 -- register_copy
|
||||
//SEG53 nest2::@2
|
||||
b2:
|
||||
@ -2384,20 +2390,269 @@ nest2: {
|
||||
dey
|
||||
//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 ] -- yby_gt_0_then_la1
|
||||
cpy #$0
|
||||
bne b2_from_b2
|
||||
bne b2
|
||||
//SEG57 nest2::@3
|
||||
b3:
|
||||
//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 ] -- xby=_dec_xby
|
||||
dex
|
||||
//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 ] -- xby_gt_0_then_la1
|
||||
cpx #$0
|
||||
bne b1_from_b3
|
||||
bne b1
|
||||
//SEG60 nest2::@return
|
||||
breturn:
|
||||
//SEG61 [24] return [ main::j#2 main::i#2 nest1::j#2 nest1::i#2 ]
|
||||
rts
|
||||
}
|
||||
|
||||
Removing instruction bbegin:
|
||||
Removing instruction bend:
|
||||
Removing instruction b1_from_main:
|
||||
Removing instruction b5:
|
||||
Removing instruction b3:
|
||||
Removing instruction breturn:
|
||||
Removing instruction b1_from_nest1:
|
||||
Removing instruction b5:
|
||||
Removing instruction b3:
|
||||
Removing instruction breturn:
|
||||
Removing instruction b1_from_nest2:
|
||||
Removing instruction b3:
|
||||
Removing instruction breturn:
|
||||
Succesful ASM optimization Pass6UnusedLabelElimination
|
||||
ASSEMBLER
|
||||
//SEG0 @begin
|
||||
//SEG1 [0] call main param-assignment [ ]
|
||||
jsr main
|
||||
//SEG2 @end
|
||||
//SEG3 main
|
||||
main: {
|
||||
//SEG4 [1] phi from main to main::@1
|
||||
//SEG5 [1] phi (byte) main::i#2 = (byte) 100 -- zpby1=coby1
|
||||
lda #$64
|
||||
sta $2
|
||||
jmp b1
|
||||
//SEG6 [1] phi from main::@3 to main::@1
|
||||
//SEG7 [1] phi (byte) main::i#2 = (byte) main::i#1 -- register_copy
|
||||
//SEG8 main::@1
|
||||
b1:
|
||||
//SEG9 [2] phi from main::@1 to main::@2
|
||||
//SEG10 [2] phi (byte) main::j#2 = (byte) 100 -- zpby1=coby1
|
||||
lda #$64
|
||||
sta $3
|
||||
jmp b2
|
||||
//SEG11 [2] phi from main::@5 to main::@2
|
||||
//SEG12 [2] phi (byte) main::j#2 = (byte) main::j#1 -- register_copy
|
||||
//SEG13 main::@2
|
||||
b2:
|
||||
//SEG14 [3] call nest1 param-assignment [ main::j#2 main::i#2 ]
|
||||
jsr nest1
|
||||
//SEG15 main::@5
|
||||
//SEG16 [4] (byte) main::j#1 ← -- (byte) main::j#2 [ main::j#1 main::i#2 ] -- zpby1=_dec_zpby1
|
||||
dec $3
|
||||
//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 b2
|
||||
//SEG18 main::@3
|
||||
//SEG19 [6] (byte) main::i#1 ← -- (byte) main::i#2 [ main::i#1 ] -- zpby1=_dec_zpby1
|
||||
dec $2
|
||||
//SEG20 [7] if((byte) main::i#1>(byte) 0) goto main::@1 [ main::i#1 ] -- zpby1_gt_0_then_la1
|
||||
lda $2
|
||||
bne b1
|
||||
//SEG21 main::@return
|
||||
//SEG22 [8] return [ ]
|
||||
rts
|
||||
}
|
||||
//SEG23 nest1
|
||||
nest1: {
|
||||
//SEG24 [9] phi from nest1 to nest1::@1
|
||||
//SEG25 [9] phi (byte) nest1::i#2 = (byte) 100 -- zpby1=coby1
|
||||
lda #$64
|
||||
sta $4
|
||||
jmp b1
|
||||
//SEG26 [9] phi from nest1::@3 to nest1::@1
|
||||
//SEG27 [9] phi (byte) nest1::i#2 = (byte) nest1::i#1 -- register_copy
|
||||
//SEG28 nest1::@1
|
||||
b1:
|
||||
//SEG29 [10] phi from nest1::@1 to nest1::@2
|
||||
//SEG30 [10] phi (byte) nest1::j#2 = (byte) 100 -- aby=coby1
|
||||
lda #$64
|
||||
jmp b2
|
||||
//SEG31 [10] phi from nest1::@5 to nest1::@2
|
||||
//SEG32 [10] phi (byte) nest1::j#2 = (byte) nest1::j#1 -- register_copy
|
||||
//SEG33 nest1::@2
|
||||
b2:
|
||||
//SEG34 [11] call nest2 param-assignment [ main::j#2 main::i#2 nest1::j#2 nest1::i#2 ]
|
||||
jsr nest2
|
||||
//SEG35 nest1::@5
|
||||
//SEG36 [12] (byte) nest1::j#1 ← -- (byte) nest1::j#2 [ main::j#2 main::i#2 nest1::j#1 nest1::i#2 ] -- aby=_dec_aby
|
||||
sec
|
||||
sbc #$1
|
||||
//SEG37 [13] if((byte) nest1::j#1>(byte) 0) goto nest1::@2 [ main::j#2 main::i#2 nest1::j#1 nest1::i#2 ] -- aby_gt_0_then_la1
|
||||
cmp #$0
|
||||
bne b2
|
||||
//SEG38 nest1::@3
|
||||
//SEG39 [14] (byte) nest1::i#1 ← -- (byte) nest1::i#2 [ main::j#2 main::i#2 nest1::i#1 ] -- zpby1=_dec_zpby1
|
||||
dec $4
|
||||
//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 b1
|
||||
//SEG41 nest1::@return
|
||||
//SEG42 [16] return [ main::j#2 main::i#2 ]
|
||||
rts
|
||||
}
|
||||
//SEG43 nest2
|
||||
nest2: {
|
||||
//SEG44 [17] phi from nest2 to nest2::@1
|
||||
//SEG45 [17] phi (byte) nest2::i#2 = (byte) 100 -- xby=coby1
|
||||
ldx #$64
|
||||
jmp b1
|
||||
//SEG46 [17] phi from nest2::@3 to nest2::@1
|
||||
//SEG47 [17] phi (byte) nest2::i#2 = (byte) nest2::i#1 -- register_copy
|
||||
//SEG48 nest2::@1
|
||||
b1:
|
||||
//SEG49 [18] phi from nest2::@1 to nest2::@2
|
||||
//SEG50 [18] phi (byte) nest2::j#2 = (byte) 100 -- yby=coby1
|
||||
ldy #$64
|
||||
jmp b2
|
||||
//SEG51 [18] phi from nest2::@2 to nest2::@2
|
||||
//SEG52 [18] phi (byte) nest2::j#2 = (byte) nest2::j#1 -- register_copy
|
||||
//SEG53 nest2::@2
|
||||
b2:
|
||||
//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=yby
|
||||
sty $400
|
||||
//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 ] -- yby=_dec_yby
|
||||
dey
|
||||
//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 ] -- yby_gt_0_then_la1
|
||||
cpy #$0
|
||||
bne b2
|
||||
//SEG57 nest2::@3
|
||||
//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 ] -- xby=_dec_xby
|
||||
dex
|
||||
//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 ] -- xby_gt_0_then_la1
|
||||
cpx #$0
|
||||
bne b1
|
||||
//SEG60 nest2::@return
|
||||
//SEG61 [24] return [ main::j#2 main::i#2 nest1::j#2 nest1::i#2 ]
|
||||
rts
|
||||
}
|
||||
|
||||
Removing instruction jmp b1
|
||||
Removing instruction jmp b2
|
||||
Removing instruction jmp b1
|
||||
Removing instruction jmp b2
|
||||
Removing instruction jmp b1
|
||||
Removing instruction jmp b2
|
||||
Succesful ASM optimization Pass6NextJumpElimination
|
||||
ASSEMBLER
|
||||
//SEG0 @begin
|
||||
//SEG1 [0] call main param-assignment [ ]
|
||||
jsr main
|
||||
//SEG2 @end
|
||||
//SEG3 main
|
||||
main: {
|
||||
//SEG4 [1] phi from main to main::@1
|
||||
//SEG5 [1] phi (byte) main::i#2 = (byte) 100 -- zpby1=coby1
|
||||
lda #$64
|
||||
sta $2
|
||||
//SEG6 [1] phi from main::@3 to main::@1
|
||||
//SEG7 [1] phi (byte) main::i#2 = (byte) main::i#1 -- register_copy
|
||||
//SEG8 main::@1
|
||||
b1:
|
||||
//SEG9 [2] phi from main::@1 to main::@2
|
||||
//SEG10 [2] phi (byte) main::j#2 = (byte) 100 -- zpby1=coby1
|
||||
lda #$64
|
||||
sta $3
|
||||
//SEG11 [2] phi from main::@5 to main::@2
|
||||
//SEG12 [2] phi (byte) main::j#2 = (byte) main::j#1 -- register_copy
|
||||
//SEG13 main::@2
|
||||
b2:
|
||||
//SEG14 [3] call nest1 param-assignment [ main::j#2 main::i#2 ]
|
||||
jsr nest1
|
||||
//SEG15 main::@5
|
||||
//SEG16 [4] (byte) main::j#1 ← -- (byte) main::j#2 [ main::j#1 main::i#2 ] -- zpby1=_dec_zpby1
|
||||
dec $3
|
||||
//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 b2
|
||||
//SEG18 main::@3
|
||||
//SEG19 [6] (byte) main::i#1 ← -- (byte) main::i#2 [ main::i#1 ] -- zpby1=_dec_zpby1
|
||||
dec $2
|
||||
//SEG20 [7] if((byte) main::i#1>(byte) 0) goto main::@1 [ main::i#1 ] -- zpby1_gt_0_then_la1
|
||||
lda $2
|
||||
bne b1
|
||||
//SEG21 main::@return
|
||||
//SEG22 [8] return [ ]
|
||||
rts
|
||||
}
|
||||
//SEG23 nest1
|
||||
nest1: {
|
||||
//SEG24 [9] phi from nest1 to nest1::@1
|
||||
//SEG25 [9] phi (byte) nest1::i#2 = (byte) 100 -- zpby1=coby1
|
||||
lda #$64
|
||||
sta $4
|
||||
//SEG26 [9] phi from nest1::@3 to nest1::@1
|
||||
//SEG27 [9] phi (byte) nest1::i#2 = (byte) nest1::i#1 -- register_copy
|
||||
//SEG28 nest1::@1
|
||||
b1:
|
||||
//SEG29 [10] phi from nest1::@1 to nest1::@2
|
||||
//SEG30 [10] phi (byte) nest1::j#2 = (byte) 100 -- aby=coby1
|
||||
lda #$64
|
||||
//SEG31 [10] phi from nest1::@5 to nest1::@2
|
||||
//SEG32 [10] phi (byte) nest1::j#2 = (byte) nest1::j#1 -- register_copy
|
||||
//SEG33 nest1::@2
|
||||
b2:
|
||||
//SEG34 [11] call nest2 param-assignment [ main::j#2 main::i#2 nest1::j#2 nest1::i#2 ]
|
||||
jsr nest2
|
||||
//SEG35 nest1::@5
|
||||
//SEG36 [12] (byte) nest1::j#1 ← -- (byte) nest1::j#2 [ main::j#2 main::i#2 nest1::j#1 nest1::i#2 ] -- aby=_dec_aby
|
||||
sec
|
||||
sbc #$1
|
||||
//SEG37 [13] if((byte) nest1::j#1>(byte) 0) goto nest1::@2 [ main::j#2 main::i#2 nest1::j#1 nest1::i#2 ] -- aby_gt_0_then_la1
|
||||
cmp #$0
|
||||
bne b2
|
||||
//SEG38 nest1::@3
|
||||
//SEG39 [14] (byte) nest1::i#1 ← -- (byte) nest1::i#2 [ main::j#2 main::i#2 nest1::i#1 ] -- zpby1=_dec_zpby1
|
||||
dec $4
|
||||
//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 b1
|
||||
//SEG41 nest1::@return
|
||||
//SEG42 [16] return [ main::j#2 main::i#2 ]
|
||||
rts
|
||||
}
|
||||
//SEG43 nest2
|
||||
nest2: {
|
||||
//SEG44 [17] phi from nest2 to nest2::@1
|
||||
//SEG45 [17] phi (byte) nest2::i#2 = (byte) 100 -- xby=coby1
|
||||
ldx #$64
|
||||
//SEG46 [17] phi from nest2::@3 to nest2::@1
|
||||
//SEG47 [17] phi (byte) nest2::i#2 = (byte) nest2::i#1 -- register_copy
|
||||
//SEG48 nest2::@1
|
||||
b1:
|
||||
//SEG49 [18] phi from nest2::@1 to nest2::@2
|
||||
//SEG50 [18] phi (byte) nest2::j#2 = (byte) 100 -- yby=coby1
|
||||
ldy #$64
|
||||
//SEG51 [18] phi from nest2::@2 to nest2::@2
|
||||
//SEG52 [18] phi (byte) nest2::j#2 = (byte) nest2::j#1 -- register_copy
|
||||
//SEG53 nest2::@2
|
||||
b2:
|
||||
//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=yby
|
||||
sty $400
|
||||
//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 ] -- yby=_dec_yby
|
||||
dey
|
||||
//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 ] -- yby_gt_0_then_la1
|
||||
cpy #$0
|
||||
bne b2
|
||||
//SEG57 nest2::@3
|
||||
//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 ] -- xby=_dec_xby
|
||||
dex
|
||||
//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 ] -- xby_gt_0_then_la1
|
||||
cpx #$0
|
||||
bne b1
|
||||
//SEG60 nest2::@return
|
||||
//SEG61 [24] return [ main::j#2 main::i#2 nest1::j#2 nest1::i#2 ]
|
||||
rts
|
||||
}
|
||||
|
||||
FINAL SYMBOL TABLE
|
||||
(label) @begin
|
||||
(label) @end
|
||||
@ -2447,114 +2702,94 @@ reg byte y [ 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
|
||||
b1_from_main:
|
||||
//SEG5 [1] phi (byte) main::i#2 = (byte) 100 -- zpby1=coby1
|
||||
lda #$64
|
||||
sta $2
|
||||
//SEG6 [1] phi from main::@3 to main::@1
|
||||
b1_from_b3:
|
||||
//SEG7 [1] phi (byte) main::i#2 = (byte) main::i#1 -- register_copy
|
||||
//SEG8 main::@1
|
||||
b1:
|
||||
//SEG9 [2] phi from main::@1 to main::@2
|
||||
b2_from_b1:
|
||||
//SEG10 [2] phi (byte) main::j#2 = (byte) 100 -- zpby1=coby1
|
||||
lda #$64
|
||||
sta $3
|
||||
//SEG11 [2] phi from main::@5 to main::@2
|
||||
b2_from_b5:
|
||||
//SEG12 [2] phi (byte) main::j#2 = (byte) main::j#1 -- register_copy
|
||||
//SEG13 main::@2
|
||||
b2:
|
||||
//SEG14 [3] call nest1 param-assignment [ main::j#2 main::i#2 ]
|
||||
jsr nest1
|
||||
//SEG15 main::@5
|
||||
b5:
|
||||
//SEG16 [4] (byte) main::j#1 ← -- (byte) main::j#2 [ main::j#1 main::i#2 ] -- zpby1=_dec_zpby1
|
||||
dec $3
|
||||
//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 b2_from_b5
|
||||
bne b2
|
||||
//SEG18 main::@3
|
||||
b3:
|
||||
//SEG19 [6] (byte) main::i#1 ← -- (byte) main::i#2 [ main::i#1 ] -- zpby1=_dec_zpby1
|
||||
dec $2
|
||||
//SEG20 [7] if((byte) main::i#1>(byte) 0) goto main::@1 [ main::i#1 ] -- zpby1_gt_0_then_la1
|
||||
lda $2
|
||||
bne b1_from_b3
|
||||
bne b1
|
||||
//SEG21 main::@return
|
||||
breturn:
|
||||
//SEG22 [8] return [ ]
|
||||
rts
|
||||
}
|
||||
//SEG23 nest1
|
||||
nest1: {
|
||||
//SEG24 [9] phi from nest1 to nest1::@1
|
||||
b1_from_nest1:
|
||||
//SEG25 [9] phi (byte) nest1::i#2 = (byte) 100 -- zpby1=coby1
|
||||
lda #$64
|
||||
sta $4
|
||||
//SEG26 [9] phi from nest1::@3 to nest1::@1
|
||||
b1_from_b3:
|
||||
//SEG27 [9] phi (byte) nest1::i#2 = (byte) nest1::i#1 -- register_copy
|
||||
//SEG28 nest1::@1
|
||||
b1:
|
||||
//SEG29 [10] phi from nest1::@1 to nest1::@2
|
||||
b2_from_b1:
|
||||
//SEG30 [10] phi (byte) nest1::j#2 = (byte) 100 -- aby=coby1
|
||||
lda #$64
|
||||
//SEG31 [10] phi from nest1::@5 to nest1::@2
|
||||
b2_from_b5:
|
||||
//SEG32 [10] phi (byte) nest1::j#2 = (byte) nest1::j#1 -- register_copy
|
||||
//SEG33 nest1::@2
|
||||
b2:
|
||||
//SEG34 [11] call nest2 param-assignment [ main::j#2 main::i#2 nest1::j#2 nest1::i#2 ]
|
||||
jsr nest2
|
||||
//SEG35 nest1::@5
|
||||
b5:
|
||||
//SEG36 [12] (byte) nest1::j#1 ← -- (byte) nest1::j#2 [ main::j#2 main::i#2 nest1::j#1 nest1::i#2 ] -- aby=_dec_aby
|
||||
sec
|
||||
sbc #$1
|
||||
//SEG37 [13] if((byte) nest1::j#1>(byte) 0) goto nest1::@2 [ main::j#2 main::i#2 nest1::j#1 nest1::i#2 ] -- aby_gt_0_then_la1
|
||||
cmp #$0
|
||||
bne b2_from_b5
|
||||
bne b2
|
||||
//SEG38 nest1::@3
|
||||
b3:
|
||||
//SEG39 [14] (byte) nest1::i#1 ← -- (byte) nest1::i#2 [ main::j#2 main::i#2 nest1::i#1 ] -- zpby1=_dec_zpby1
|
||||
dec $4
|
||||
//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 b1_from_b3
|
||||
bne b1
|
||||
//SEG41 nest1::@return
|
||||
breturn:
|
||||
//SEG42 [16] return [ main::j#2 main::i#2 ]
|
||||
rts
|
||||
}
|
||||
//SEG43 nest2
|
||||
nest2: {
|
||||
//SEG44 [17] phi from nest2 to nest2::@1
|
||||
b1_from_nest2:
|
||||
//SEG45 [17] phi (byte) nest2::i#2 = (byte) 100 -- xby=coby1
|
||||
ldx #$64
|
||||
//SEG46 [17] phi from nest2::@3 to nest2::@1
|
||||
b1_from_b3:
|
||||
//SEG47 [17] phi (byte) nest2::i#2 = (byte) nest2::i#1 -- register_copy
|
||||
//SEG48 nest2::@1
|
||||
b1:
|
||||
//SEG49 [18] phi from nest2::@1 to nest2::@2
|
||||
b2_from_b1:
|
||||
//SEG50 [18] phi (byte) nest2::j#2 = (byte) 100 -- yby=coby1
|
||||
ldy #$64
|
||||
//SEG51 [18] phi from nest2::@2 to nest2::@2
|
||||
b2_from_b2:
|
||||
//SEG52 [18] phi (byte) nest2::j#2 = (byte) nest2::j#1 -- register_copy
|
||||
//SEG53 nest2::@2
|
||||
b2:
|
||||
@ -2564,16 +2799,14 @@ nest2: {
|
||||
dey
|
||||
//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 ] -- yby_gt_0_then_la1
|
||||
cpy #$0
|
||||
bne b2_from_b2
|
||||
bne b2
|
||||
//SEG57 nest2::@3
|
||||
b3:
|
||||
//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 ] -- xby=_dec_xby
|
||||
dex
|
||||
//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 ] -- xby_gt_0_then_la1
|
||||
cpx #$0
|
||||
bne b1_from_b3
|
||||
bne b1
|
||||
//SEG60 nest2::@return
|
||||
breturn:
|
||||
//SEG61 [24] return [ main::j#2 main::i#2 nest1::j#2 nest1::i#2 ]
|
||||
rts
|
||||
}
|
||||
|
@ -1,27 +1,20 @@
|
||||
bbegin:
|
||||
jsr main
|
||||
bend:
|
||||
main: {
|
||||
b1_from_main:
|
||||
ldy #$0
|
||||
ldx #$64
|
||||
b1:
|
||||
dex
|
||||
cpx #$0
|
||||
bne b2
|
||||
breturn:
|
||||
rts
|
||||
b2:
|
||||
cpx #$32
|
||||
beq !+
|
||||
bcs b4
|
||||
!:
|
||||
b5:
|
||||
dey
|
||||
b1_from_b5:
|
||||
jmp b1
|
||||
b4:
|
||||
iny
|
||||
b1_from_b4:
|
||||
jmp b1
|
||||
}
|
||||
|
@ -608,7 +608,7 @@ Removing instruction jmp bend
|
||||
Removing instruction jmp b1
|
||||
Removing instruction jmp breturn
|
||||
Removing instruction jmp b5
|
||||
Succesful ASM optimization Pass5NextJumpElimination
|
||||
Succesful ASM optimization Pass6NextJumpElimination
|
||||
ASSEMBLER
|
||||
//SEG0 @begin
|
||||
bbegin:
|
||||
@ -662,6 +662,60 @@ main: {
|
||||
jmp b1
|
||||
}
|
||||
|
||||
Removing instruction bbegin:
|
||||
Removing instruction bend:
|
||||
Removing instruction b1_from_main:
|
||||
Removing instruction breturn:
|
||||
Removing instruction b5:
|
||||
Removing instruction b1_from_b5:
|
||||
Removing instruction b1_from_b4:
|
||||
Succesful ASM optimization Pass6UnusedLabelElimination
|
||||
ASSEMBLER
|
||||
//SEG0 @begin
|
||||
//SEG1 [0] call main param-assignment [ ]
|
||||
jsr main
|
||||
//SEG2 @end
|
||||
//SEG3 main
|
||||
main: {
|
||||
//SEG4 [1] phi from main to main::@1
|
||||
//SEG5 [1] phi (byte) main::s#3 = (byte) 0 -- yby=coby1
|
||||
ldy #$0
|
||||
//SEG6 [1] phi (byte) main::i#2 = (byte) 100 -- xby=coby1
|
||||
ldx #$64
|
||||
//SEG7 main::@1
|
||||
b1:
|
||||
//SEG8 [2] (byte) main::i#1 ← -- (byte) main::i#2 [ main::i#1 main::s#3 ] -- xby=_dec_xby
|
||||
dex
|
||||
//SEG9 [3] if((byte) main::i#1>(byte) 0) goto main::@2 [ main::i#1 main::s#3 ] -- xby_gt_0_then_la1
|
||||
cpx #$0
|
||||
bne b2
|
||||
//SEG10 main::@return
|
||||
//SEG11 [4] return [ ]
|
||||
rts
|
||||
//SEG12 main::@2
|
||||
b2:
|
||||
//SEG13 [5] if((byte) main::i#1>(byte) 50) goto main::@4 [ main::i#1 main::s#3 ] -- xby_gt_coby1_then_la1
|
||||
cpx #$32
|
||||
beq !+
|
||||
bcs b4
|
||||
!:
|
||||
//SEG14 main::@5
|
||||
//SEG15 [6] (byte) main::s#2 ← -- (byte) main::s#3 [ main::i#1 main::s#2 ] -- yby=_dec_yby
|
||||
dey
|
||||
//SEG16 [1] phi from main::@5 to main::@1
|
||||
//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 b1
|
||||
//SEG19 main::@4
|
||||
b4:
|
||||
//SEG20 [7] (byte) main::s#1 ← ++ (byte) main::s#3 [ main::i#1 main::s#1 ] -- yby=_inc_yby
|
||||
iny
|
||||
//SEG21 [1] phi from main::@4 to main::@1
|
||||
//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 b1
|
||||
}
|
||||
|
||||
FINAL SYMBOL TABLE
|
||||
(label) @begin
|
||||
(label) @end
|
||||
@ -684,15 +738,12 @@ reg byte y [ 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
|
||||
b1_from_main:
|
||||
//SEG5 [1] phi (byte) main::s#3 = (byte) 0 -- yby=coby1
|
||||
ldy #$0
|
||||
//SEG6 [1] phi (byte) main::i#2 = (byte) 100 -- xby=coby1
|
||||
@ -705,7 +756,6 @@ main: {
|
||||
cpx #$0
|
||||
bne b2
|
||||
//SEG10 main::@return
|
||||
breturn:
|
||||
//SEG11 [4] return [ ]
|
||||
rts
|
||||
//SEG12 main::@2
|
||||
@ -716,11 +766,9 @@ main: {
|
||||
bcs b4
|
||||
!:
|
||||
//SEG14 main::@5
|
||||
b5:
|
||||
//SEG15 [6] (byte) main::s#2 ← -- (byte) main::s#3 [ main::i#1 main::s#2 ] -- yby=_dec_yby
|
||||
dey
|
||||
//SEG16 [1] phi from main::@5 to main::@1
|
||||
b1_from_b5:
|
||||
//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 b1
|
||||
@ -729,7 +777,6 @@ main: {
|
||||
//SEG20 [7] (byte) main::s#1 ← ++ (byte) main::s#3 [ main::i#1 main::s#1 ] -- yby=_inc_yby
|
||||
iny
|
||||
//SEG21 [1] phi from main::@4 to main::@1
|
||||
b1_from_b4:
|
||||
//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 b1
|
||||
|
@ -1,7 +1,4 @@
|
||||
bbegin:
|
||||
b1_from_bbegin:
|
||||
ldx #$5
|
||||
b1_from_b1:
|
||||
b1:
|
||||
txa
|
||||
clc
|
||||
@ -9,5 +6,4 @@ b1:
|
||||
sta $1100,x
|
||||
inx
|
||||
cpx #$a
|
||||
bcc b1_from_b1
|
||||
bend:
|
||||
bcc b1
|
||||
|
@ -355,7 +355,7 @@ Uplift Scope [] 31.17: zp byte:2 [ i#2 i#1 ] 22: zp byte:3 [ $1 ]
|
||||
Uplifting [] best 285 combination reg byte x [ i#2 i#1 ] reg byte a [ $1 ]
|
||||
Removing instruction jmp b1
|
||||
Removing instruction jmp bend
|
||||
Succesful ASM optimization Pass5NextJumpElimination
|
||||
Succesful ASM optimization Pass6NextJumpElimination
|
||||
ASSEMBLER
|
||||
//SEG0 @begin
|
||||
bbegin:
|
||||
@ -383,17 +383,18 @@ b1:
|
||||
//SEG10 @end
|
||||
bend:
|
||||
|
||||
Removing instruction jmp b1
|
||||
Succesful ASM optimization Pass5NextJumpElimination
|
||||
Replacing label b1_from_b1 with b1
|
||||
Removing instruction b1_from_bbegin:
|
||||
Removing instruction b1_from_b1:
|
||||
Succesful ASM optimization Pass6RedundantLabelElimination
|
||||
ASSEMBLER
|
||||
//SEG0 @begin
|
||||
bbegin:
|
||||
//SEG1 [0] phi from @begin to @1
|
||||
b1_from_bbegin:
|
||||
//SEG2 [0] phi (byte) i#2 = (byte) 5 -- xby=coby1
|
||||
ldx #$5
|
||||
jmp b1
|
||||
//SEG3 [0] phi from @1 to @1
|
||||
b1_from_b1:
|
||||
//SEG4 [0] phi (byte) i#2 = (byte) i#1 -- register_copy
|
||||
//SEG5 @1
|
||||
b1:
|
||||
@ -407,10 +408,60 @@ b1:
|
||||
inx
|
||||
//SEG9 [4] if((byte) i#1<(byte) 10) goto @1 [ i#1 ] -- xby_lt_coby1_then_la1
|
||||
cpx #$a
|
||||
bcc b1_from_b1
|
||||
bcc b1
|
||||
//SEG10 @end
|
||||
bend:
|
||||
|
||||
Removing instruction bbegin:
|
||||
Removing instruction bend:
|
||||
Succesful ASM optimization Pass6UnusedLabelElimination
|
||||
ASSEMBLER
|
||||
//SEG0 @begin
|
||||
//SEG1 [0] phi from @begin to @1
|
||||
//SEG2 [0] phi (byte) i#2 = (byte) 5 -- xby=coby1
|
||||
ldx #$5
|
||||
jmp b1
|
||||
//SEG3 [0] phi from @1 to @1
|
||||
//SEG4 [0] phi (byte) i#2 = (byte) i#1 -- register_copy
|
||||
//SEG5 @1
|
||||
b1:
|
||||
//SEG6 [1] (byte~) $1 ← (byte) i#2 + (byte) 4 [ i#2 $1 ] -- aby=xby_plus_coby1
|
||||
txa
|
||||
clc
|
||||
adc #$4
|
||||
//SEG7 [2] *((word) 4352 + (byte) i#2) ← (byte~) $1 [ i#2 ] -- cowo1_staridx_xby=aby
|
||||
sta $1100,x
|
||||
//SEG8 [3] (byte) i#1 ← (byte) i#2 + (byte) 1 [ i#1 ] -- xby=xby_plus_1
|
||||
inx
|
||||
//SEG9 [4] if((byte) i#1<(byte) 10) goto @1 [ i#1 ] -- xby_lt_coby1_then_la1
|
||||
cpx #$a
|
||||
bcc b1
|
||||
//SEG10 @end
|
||||
|
||||
Removing instruction jmp b1
|
||||
Succesful ASM optimization Pass6NextJumpElimination
|
||||
ASSEMBLER
|
||||
//SEG0 @begin
|
||||
//SEG1 [0] phi from @begin to @1
|
||||
//SEG2 [0] phi (byte) i#2 = (byte) 5 -- xby=coby1
|
||||
ldx #$5
|
||||
//SEG3 [0] phi from @1 to @1
|
||||
//SEG4 [0] phi (byte) i#2 = (byte) i#1 -- register_copy
|
||||
//SEG5 @1
|
||||
b1:
|
||||
//SEG6 [1] (byte~) $1 ← (byte) i#2 + (byte) 4 [ i#2 $1 ] -- aby=xby_plus_coby1
|
||||
txa
|
||||
clc
|
||||
adc #$4
|
||||
//SEG7 [2] *((word) 4352 + (byte) i#2) ← (byte~) $1 [ i#2 ] -- cowo1_staridx_xby=aby
|
||||
sta $1100,x
|
||||
//SEG8 [3] (byte) i#1 ← (byte) i#2 + (byte) 1 [ i#1 ] -- xby=xby_plus_1
|
||||
inx
|
||||
//SEG9 [4] if((byte) i#1<(byte) 10) goto @1 [ i#1 ] -- xby_lt_coby1_then_la1
|
||||
cpx #$a
|
||||
bcc b1
|
||||
//SEG10 @end
|
||||
|
||||
FINAL SYMBOL TABLE
|
||||
(byte~) $1 reg byte a 22.0
|
||||
(label) @1
|
||||
@ -426,13 +477,10 @@ reg byte a [ $1 ]
|
||||
|
||||
FINAL CODE
|
||||
//SEG0 @begin
|
||||
bbegin:
|
||||
//SEG1 [0] phi from @begin to @1
|
||||
b1_from_bbegin:
|
||||
//SEG2 [0] phi (byte) i#2 = (byte) 5 -- xby=coby1
|
||||
ldx #$5
|
||||
//SEG3 [0] phi from @1 to @1
|
||||
b1_from_b1:
|
||||
//SEG4 [0] phi (byte) i#2 = (byte) i#1 -- register_copy
|
||||
//SEG5 @1
|
||||
b1:
|
||||
@ -446,7 +494,6 @@ b1:
|
||||
inx
|
||||
//SEG9 [4] if((byte) i#1<(byte) 10) goto @1 [ i#1 ] -- xby_lt_coby1_then_la1
|
||||
cpx #$a
|
||||
bcc b1_from_b1
|
||||
bcc b1
|
||||
//SEG10 @end
|
||||
bend:
|
||||
|
||||
|
@ -1,25 +1,17 @@
|
||||
bbegin:
|
||||
jsr main
|
||||
bend:
|
||||
main: {
|
||||
inccnt_from_main:
|
||||
ldy #$0
|
||||
ldx #$0
|
||||
jsr inccnt
|
||||
b1:
|
||||
sta $400
|
||||
inx
|
||||
inccnt_from_b1:
|
||||
jsr inccnt
|
||||
b2:
|
||||
sta $401
|
||||
breturn:
|
||||
rts
|
||||
}
|
||||
inccnt: {
|
||||
inx
|
||||
iny
|
||||
txa
|
||||
breturn:
|
||||
rts
|
||||
}
|
||||
|
@ -810,7 +810,7 @@ Removing instruction jmp b1
|
||||
Removing instruction jmp b2
|
||||
Removing instruction jmp breturn
|
||||
Removing instruction jmp breturn
|
||||
Succesful ASM optimization Pass5NextJumpElimination
|
||||
Succesful ASM optimization Pass6NextJumpElimination
|
||||
ASSEMBLER
|
||||
//SEG0 @begin
|
||||
bbegin:
|
||||
@ -867,6 +867,63 @@ inccnt: {
|
||||
rts
|
||||
}
|
||||
|
||||
Removing instruction bbegin:
|
||||
Removing instruction bend:
|
||||
Removing instruction inccnt_from_main:
|
||||
Removing instruction b1:
|
||||
Removing instruction inccnt_from_b1:
|
||||
Removing instruction b2:
|
||||
Removing instruction breturn:
|
||||
Removing instruction breturn:
|
||||
Succesful ASM optimization Pass6UnusedLabelElimination
|
||||
ASSEMBLER
|
||||
//SEG0 @begin
|
||||
//SEG1 [0] call main param-assignment [ ]
|
||||
jsr main
|
||||
//SEG2 @end
|
||||
//SEG3 main
|
||||
main: {
|
||||
//SEG4 [1] call inccnt param-assignment [ inccnt::return#0 cnt#1 cnt2#1 ]
|
||||
//SEG5 [9] phi from main to inccnt
|
||||
//SEG6 [9] phi (byte) cnt2#11 = (byte) 0 -- yby=coby1
|
||||
ldy #$0
|
||||
//SEG7 [9] phi (byte) cnt#12 = (byte) 0 -- xby=coby1
|
||||
ldx #$0
|
||||
jsr inccnt
|
||||
//SEG8 main::@1
|
||||
//SEG9 [2] (byte~) main::$0 ← (byte) inccnt::return#0 [ main::$0 cnt#1 cnt2#1 ]
|
||||
// (byte~) main::$0 = (byte) inccnt::return#0 // register copy reg byte a
|
||||
//SEG10 [3] *((word) 1024) ← (byte~) main::$0 [ cnt#1 cnt2#1 ] -- _star_cowo1=aby
|
||||
sta $400
|
||||
//SEG11 [4] (byte) cnt#3 ← ++ (byte) cnt#1 [ cnt#3 cnt2#1 ] -- xby=_inc_xby
|
||||
inx
|
||||
//SEG12 [5] call inccnt param-assignment [ inccnt::return#0 ]
|
||||
//SEG13 [9] phi from main::@1 to inccnt
|
||||
//SEG14 [9] phi (byte) cnt2#11 = (byte) cnt2#1 -- register_copy
|
||||
//SEG15 [9] phi (byte) cnt#12 = (byte) cnt#3 -- register_copy
|
||||
jsr inccnt
|
||||
//SEG16 main::@2
|
||||
//SEG17 [6] (byte~) main::$1 ← (byte) inccnt::return#0 [ main::$1 ]
|
||||
// (byte~) main::$1 = (byte) inccnt::return#0 // register copy reg byte a
|
||||
//SEG18 [7] *((word) 1025) ← (byte~) main::$1 [ ] -- _star_cowo1=aby
|
||||
sta $401
|
||||
//SEG19 main::@return
|
||||
//SEG20 [8] return [ ]
|
||||
rts
|
||||
}
|
||||
//SEG21 inccnt
|
||||
inccnt: {
|
||||
//SEG22 [10] (byte) cnt#1 ← ++ (byte) cnt#12 [ cnt#1 cnt2#11 ] -- xby=_inc_xby
|
||||
inx
|
||||
//SEG23 [11] (byte) cnt2#1 ← ++ (byte) cnt2#11 [ cnt#1 cnt2#1 ] -- yby=_inc_yby
|
||||
iny
|
||||
//SEG24 [12] (byte) inccnt::return#0 ← (byte) cnt#1 [ inccnt::return#0 cnt#1 cnt2#1 ] -- aby=xby
|
||||
txa
|
||||
//SEG25 inccnt::@return
|
||||
//SEG26 [13] return [ inccnt::return#0 cnt#1 cnt2#1 ]
|
||||
rts
|
||||
}
|
||||
|
||||
FINAL SYMBOL TABLE
|
||||
(label) @begin
|
||||
(label) @end
|
||||
@ -898,23 +955,19 @@ reg byte a [ inccnt::return#0 ]
|
||||
|
||||
FINAL CODE
|
||||
//SEG0 @begin
|
||||
bbegin:
|
||||
//SEG1 [0] call main param-assignment [ ]
|
||||
jsr main
|
||||
//SEG2 @end
|
||||
bend:
|
||||
//SEG3 main
|
||||
main: {
|
||||
//SEG4 [1] call inccnt param-assignment [ inccnt::return#0 cnt#1 cnt2#1 ]
|
||||
//SEG5 [9] phi from main to inccnt
|
||||
inccnt_from_main:
|
||||
//SEG6 [9] phi (byte) cnt2#11 = (byte) 0 -- yby=coby1
|
||||
ldy #$0
|
||||
//SEG7 [9] phi (byte) cnt#12 = (byte) 0 -- xby=coby1
|
||||
ldx #$0
|
||||
jsr inccnt
|
||||
//SEG8 main::@1
|
||||
b1:
|
||||
//SEG9 [2] (byte~) main::$0 ← (byte) inccnt::return#0 [ main::$0 cnt#1 cnt2#1 ]
|
||||
// (byte~) main::$0 = (byte) inccnt::return#0 // register copy reg byte a
|
||||
//SEG10 [3] *((word) 1024) ← (byte~) main::$0 [ cnt#1 cnt2#1 ] -- _star_cowo1=aby
|
||||
@ -923,18 +976,15 @@ main: {
|
||||
inx
|
||||
//SEG12 [5] call inccnt param-assignment [ inccnt::return#0 ]
|
||||
//SEG13 [9] phi from main::@1 to inccnt
|
||||
inccnt_from_b1:
|
||||
//SEG14 [9] phi (byte) cnt2#11 = (byte) cnt2#1 -- register_copy
|
||||
//SEG15 [9] phi (byte) cnt#12 = (byte) cnt#3 -- register_copy
|
||||
jsr inccnt
|
||||
//SEG16 main::@2
|
||||
b2:
|
||||
//SEG17 [6] (byte~) main::$1 ← (byte) inccnt::return#0 [ main::$1 ]
|
||||
// (byte~) main::$1 = (byte) inccnt::return#0 // register copy reg byte a
|
||||
//SEG18 [7] *((word) 1025) ← (byte~) main::$1 [ ] -- _star_cowo1=aby
|
||||
sta $401
|
||||
//SEG19 main::@return
|
||||
breturn:
|
||||
//SEG20 [8] return [ ]
|
||||
rts
|
||||
}
|
||||
@ -947,7 +997,6 @@ inccnt: {
|
||||
//SEG24 [12] (byte) inccnt::return#0 ← (byte) cnt#1 [ inccnt::return#0 cnt#1 cnt2#1 ] -- aby=xby
|
||||
txa
|
||||
//SEG25 inccnt::@return
|
||||
breturn:
|
||||
//SEG26 [13] return [ inccnt::return#0 cnt#1 cnt2#1 ]
|
||||
rts
|
||||
}
|
||||
|
@ -1,23 +1,15 @@
|
||||
bbegin:
|
||||
jsr main
|
||||
bend:
|
||||
main: {
|
||||
inccnt_from_main:
|
||||
ldx #$0
|
||||
jsr inccnt
|
||||
b1:
|
||||
stx $400
|
||||
inx
|
||||
inccnt_from_b1:
|
||||
jsr inccnt
|
||||
b2:
|
||||
inx
|
||||
stx $401
|
||||
breturn:
|
||||
rts
|
||||
}
|
||||
inccnt: {
|
||||
inx
|
||||
breturn:
|
||||
rts
|
||||
}
|
||||
|
@ -636,7 +636,7 @@ Removing instruction jmp b1
|
||||
Removing instruction jmp b2
|
||||
Removing instruction jmp breturn
|
||||
Removing instruction jmp breturn
|
||||
Succesful ASM optimization Pass5NextJumpElimination
|
||||
Succesful ASM optimization Pass6NextJumpElimination
|
||||
ASSEMBLER
|
||||
//SEG0 @begin
|
||||
bbegin:
|
||||
@ -684,6 +684,54 @@ inccnt: {
|
||||
rts
|
||||
}
|
||||
|
||||
Removing instruction bbegin:
|
||||
Removing instruction bend:
|
||||
Removing instruction inccnt_from_main:
|
||||
Removing instruction b1:
|
||||
Removing instruction inccnt_from_b1:
|
||||
Removing instruction b2:
|
||||
Removing instruction breturn:
|
||||
Removing instruction breturn:
|
||||
Succesful ASM optimization Pass6UnusedLabelElimination
|
||||
ASSEMBLER
|
||||
//SEG0 @begin
|
||||
//SEG1 [0] call main param-assignment [ ]
|
||||
jsr main
|
||||
//SEG2 @end
|
||||
//SEG3 main
|
||||
main: {
|
||||
//SEG4 [1] call inccnt param-assignment [ cnt#10 ]
|
||||
//SEG5 [8] phi from main to inccnt
|
||||
//SEG6 [8] phi (byte) cnt#13 = (byte) 0 -- xby=coby1
|
||||
ldx #$0
|
||||
jsr inccnt
|
||||
//SEG7 main::@1
|
||||
//SEG8 [2] *((word) 1024) ← (byte) cnt#10 [ cnt#10 ] -- _star_cowo1=xby
|
||||
stx $400
|
||||
//SEG9 [3] (byte) cnt#3 ← ++ (byte) cnt#10 [ cnt#3 ] -- xby=_inc_xby
|
||||
inx
|
||||
//SEG10 [4] call inccnt param-assignment [ cnt#10 ]
|
||||
//SEG11 [8] phi from main::@1 to inccnt
|
||||
//SEG12 [8] phi (byte) cnt#13 = (byte) cnt#3 -- register_copy
|
||||
jsr inccnt
|
||||
//SEG13 main::@2
|
||||
//SEG14 [5] (byte) cnt#1 ← ++ (byte) cnt#10 [ cnt#1 ] -- xby=_inc_xby
|
||||
inx
|
||||
//SEG15 [6] *((word) 1025) ← (byte) cnt#1 [ ] -- _star_cowo1=xby
|
||||
stx $401
|
||||
//SEG16 main::@return
|
||||
//SEG17 [7] return [ ]
|
||||
rts
|
||||
}
|
||||
//SEG18 inccnt
|
||||
inccnt: {
|
||||
//SEG19 [9] (byte) cnt#10 ← ++ (byte) cnt#13 [ cnt#10 ] -- xby=_inc_xby
|
||||
inx
|
||||
//SEG20 inccnt::@return
|
||||
//SEG21 [10] return [ cnt#10 ]
|
||||
rts
|
||||
}
|
||||
|
||||
FINAL SYMBOL TABLE
|
||||
(label) @begin
|
||||
(label) @end
|
||||
@ -706,38 +754,31 @@ reg byte x [ cnt#10 ]
|
||||
|
||||
FINAL CODE
|
||||
//SEG0 @begin
|
||||
bbegin:
|
||||
//SEG1 [0] call main param-assignment [ ]
|
||||
jsr main
|
||||
//SEG2 @end
|
||||
bend:
|
||||
//SEG3 main
|
||||
main: {
|
||||
//SEG4 [1] call inccnt param-assignment [ cnt#10 ]
|
||||
//SEG5 [8] phi from main to inccnt
|
||||
inccnt_from_main:
|
||||
//SEG6 [8] phi (byte) cnt#13 = (byte) 0 -- xby=coby1
|
||||
ldx #$0
|
||||
jsr inccnt
|
||||
//SEG7 main::@1
|
||||
b1:
|
||||
//SEG8 [2] *((word) 1024) ← (byte) cnt#10 [ cnt#10 ] -- _star_cowo1=xby
|
||||
stx $400
|
||||
//SEG9 [3] (byte) cnt#3 ← ++ (byte) cnt#10 [ cnt#3 ] -- xby=_inc_xby
|
||||
inx
|
||||
//SEG10 [4] call inccnt param-assignment [ cnt#10 ]
|
||||
//SEG11 [8] phi from main::@1 to inccnt
|
||||
inccnt_from_b1:
|
||||
//SEG12 [8] phi (byte) cnt#13 = (byte) cnt#3 -- register_copy
|
||||
jsr inccnt
|
||||
//SEG13 main::@2
|
||||
b2:
|
||||
//SEG14 [5] (byte) cnt#1 ← ++ (byte) cnt#10 [ cnt#1 ] -- xby=_inc_xby
|
||||
inx
|
||||
//SEG15 [6] *((word) 1025) ← (byte) cnt#1 [ ] -- _star_cowo1=xby
|
||||
stx $401
|
||||
//SEG16 main::@return
|
||||
breturn:
|
||||
//SEG17 [7] return [ ]
|
||||
rts
|
||||
}
|
||||
@ -746,7 +787,6 @@ inccnt: {
|
||||
//SEG19 [9] (byte) cnt#10 ← ++ (byte) cnt#13 [ cnt#10 ] -- xby=_inc_xby
|
||||
inx
|
||||
//SEG20 inccnt::@return
|
||||
breturn:
|
||||
//SEG21 [10] return [ cnt#10 ]
|
||||
rts
|
||||
}
|
||||
|
@ -1,19 +1,12 @@
|
||||
bbegin:
|
||||
jsr main
|
||||
bend:
|
||||
main: {
|
||||
jsr lvalue
|
||||
b1:
|
||||
jsr rvalue
|
||||
b2:
|
||||
jsr rvaluevar
|
||||
b3:
|
||||
jsr lvaluevar
|
||||
breturn:
|
||||
rts
|
||||
}
|
||||
lvaluevar: {
|
||||
b1_from_lvaluevar:
|
||||
lda #<$400
|
||||
sta $2
|
||||
lda #>$400
|
||||
@ -22,7 +15,6 @@ lvaluevar: {
|
||||
b1:
|
||||
cpx #$a
|
||||
bcc b2
|
||||
breturn:
|
||||
rts
|
||||
b2:
|
||||
ldy #$0
|
||||
@ -33,11 +25,9 @@ lvaluevar: {
|
||||
inc $2+$1
|
||||
!:
|
||||
inx
|
||||
b1_from_b2:
|
||||
jmp b1
|
||||
}
|
||||
rvaluevar: {
|
||||
b1_from_rvaluevar:
|
||||
lda #<$400
|
||||
sta $2
|
||||
lda #>$400
|
||||
@ -46,7 +36,6 @@ rvaluevar: {
|
||||
b1:
|
||||
cpx #$a
|
||||
bcc b2
|
||||
breturn:
|
||||
rts
|
||||
b2:
|
||||
ldy #$0
|
||||
@ -56,23 +45,19 @@ rvaluevar: {
|
||||
inc $2+$1
|
||||
!:
|
||||
inx
|
||||
b1_from_b2:
|
||||
jmp b1
|
||||
}
|
||||
rvalue: {
|
||||
lda $400
|
||||
lda $401
|
||||
b1_from_rvalue:
|
||||
ldx #$2
|
||||
b1:
|
||||
cpx #$a
|
||||
bcc b2
|
||||
breturn:
|
||||
rts
|
||||
b2:
|
||||
lda $400,x
|
||||
inx
|
||||
b1_from_b2:
|
||||
jmp b1
|
||||
}
|
||||
lvalue: {
|
||||
@ -80,17 +65,14 @@ lvalue: {
|
||||
sta $400
|
||||
lda #$2
|
||||
sta $401
|
||||
b1_from_lvalue:
|
||||
ldx #$2
|
||||
b1:
|
||||
cpx #$a
|
||||
bcc b2
|
||||
breturn:
|
||||
rts
|
||||
b2:
|
||||
lda #$3
|
||||
sta $400,x
|
||||
inx
|
||||
b1_from_b2:
|
||||
jmp b1
|
||||
}
|
||||
|
@ -2129,7 +2129,7 @@ Removing instruction jmp b1
|
||||
Removing instruction jmp breturn
|
||||
Removing instruction jmp b1
|
||||
Removing instruction jmp breturn
|
||||
Succesful ASM optimization Pass5NextJumpElimination
|
||||
Succesful ASM optimization Pass6NextJumpElimination
|
||||
ASSEMBLER
|
||||
//SEG0 @begin
|
||||
bbegin:
|
||||
@ -2299,6 +2299,176 @@ lvalue: {
|
||||
jmp b1
|
||||
}
|
||||
|
||||
Removing instruction bbegin:
|
||||
Removing instruction bend:
|
||||
Removing instruction b1:
|
||||
Removing instruction b2:
|
||||
Removing instruction b3:
|
||||
Removing instruction breturn:
|
||||
Removing instruction b1_from_lvaluevar:
|
||||
Removing instruction breturn:
|
||||
Removing instruction b1_from_b2:
|
||||
Removing instruction b1_from_rvaluevar:
|
||||
Removing instruction breturn:
|
||||
Removing instruction b1_from_b2:
|
||||
Removing instruction b1_from_rvalue:
|
||||
Removing instruction breturn:
|
||||
Removing instruction b1_from_b2:
|
||||
Removing instruction b1_from_lvalue:
|
||||
Removing instruction breturn:
|
||||
Removing instruction b1_from_b2:
|
||||
Succesful ASM optimization Pass6UnusedLabelElimination
|
||||
ASSEMBLER
|
||||
//SEG0 @begin
|
||||
//SEG1 [0] call main param-assignment [ ]
|
||||
jsr main
|
||||
//SEG2 @end
|
||||
//SEG3 main
|
||||
main: {
|
||||
//SEG4 [1] call lvalue param-assignment [ ]
|
||||
jsr lvalue
|
||||
//SEG5 main::@1
|
||||
//SEG6 [2] call rvalue param-assignment [ ]
|
||||
jsr rvalue
|
||||
//SEG7 main::@2
|
||||
//SEG8 [3] call rvaluevar param-assignment [ ]
|
||||
jsr rvaluevar
|
||||
//SEG9 main::@3
|
||||
//SEG10 [4] call lvaluevar param-assignment [ ]
|
||||
jsr lvaluevar
|
||||
//SEG11 main::@return
|
||||
//SEG12 [5] return [ ]
|
||||
rts
|
||||
}
|
||||
//SEG13 lvaluevar
|
||||
lvaluevar: {
|
||||
//SEG14 [6] phi from lvaluevar to lvaluevar::@1
|
||||
//SEG15 [6] phi (byte*) lvaluevar::screen#2 = (word) 1024 -- zpptrby1=cowo1
|
||||
lda #<$400
|
||||
sta $2
|
||||
lda #>$400
|
||||
sta $2+$1
|
||||
//SEG16 [6] phi (byte) lvaluevar::i#2 = (byte) 2 -- xby=coby1
|
||||
ldx #$2
|
||||
//SEG17 lvaluevar::@1
|
||||
b1:
|
||||
//SEG18 [7] if((byte) lvaluevar::i#2<(byte) 10) goto lvaluevar::@2 [ lvaluevar::i#2 lvaluevar::screen#2 ] -- xby_lt_coby1_then_la1
|
||||
cpx #$a
|
||||
bcc b2
|
||||
//SEG19 lvaluevar::@return
|
||||
//SEG20 [8] return [ ]
|
||||
rts
|
||||
//SEG21 lvaluevar::@2
|
||||
b2:
|
||||
//SEG22 [9] *((byte*) lvaluevar::screen#2) ← (byte) 4 [ lvaluevar::i#2 lvaluevar::screen#2 ] -- _star_zpptrby1=coby1
|
||||
ldy #$0
|
||||
lda #$4
|
||||
sta ($2),y
|
||||
//SEG23 [10] (byte*) lvaluevar::screen#1 ← ++ (byte*) lvaluevar::screen#2 [ lvaluevar::screen#1 lvaluevar::i#2 ] -- zpptrby1=_inc_zpptrby1
|
||||
inc $2
|
||||
bne !+
|
||||
inc $2+$1
|
||||
!:
|
||||
//SEG24 [11] (byte) lvaluevar::i#1 ← ++ (byte) lvaluevar::i#2 [ lvaluevar::i#1 lvaluevar::screen#1 ] -- xby=_inc_xby
|
||||
inx
|
||||
//SEG25 [6] phi from lvaluevar::@2 to lvaluevar::@1
|
||||
//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 b1
|
||||
}
|
||||
//SEG28 rvaluevar
|
||||
rvaluevar: {
|
||||
//SEG29 [12] phi from rvaluevar to rvaluevar::@1
|
||||
//SEG30 [12] phi (byte*) rvaluevar::screen#2 = (word) 1024 -- zpptrby1=cowo1
|
||||
lda #<$400
|
||||
sta $2
|
||||
lda #>$400
|
||||
sta $2+$1
|
||||
//SEG31 [12] phi (byte) rvaluevar::i#2 = (byte) 2 -- xby=coby1
|
||||
ldx #$2
|
||||
//SEG32 rvaluevar::@1
|
||||
b1:
|
||||
//SEG33 [13] if((byte) rvaluevar::i#2<(byte) 10) goto rvaluevar::@2 [ rvaluevar::i#2 rvaluevar::screen#2 ] -- xby_lt_coby1_then_la1
|
||||
cpx #$a
|
||||
bcc b2
|
||||
//SEG34 rvaluevar::@return
|
||||
//SEG35 [14] return [ ]
|
||||
rts
|
||||
//SEG36 rvaluevar::@2
|
||||
b2:
|
||||
//SEG37 [15] (byte) rvaluevar::b#0 ← * (byte*) rvaluevar::screen#2 [ rvaluevar::i#2 rvaluevar::screen#2 ] -- aby=_star_zpptrby1
|
||||
ldy #$0
|
||||
lda ($2),y
|
||||
//SEG38 [16] (byte*) rvaluevar::screen#1 ← ++ (byte*) rvaluevar::screen#2 [ rvaluevar::screen#1 rvaluevar::i#2 ] -- zpptrby1=_inc_zpptrby1
|
||||
inc $2
|
||||
bne !+
|
||||
inc $2+$1
|
||||
!:
|
||||
//SEG39 [17] (byte) rvaluevar::i#1 ← ++ (byte) rvaluevar::i#2 [ rvaluevar::i#1 rvaluevar::screen#1 ] -- xby=_inc_xby
|
||||
inx
|
||||
//SEG40 [12] phi from rvaluevar::@2 to rvaluevar::@1
|
||||
//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 b1
|
||||
}
|
||||
//SEG43 rvalue
|
||||
rvalue: {
|
||||
//SEG44 [18] (byte) rvalue::b#0 ← * (word) 1024 [ ] -- aby=_star_cowo1
|
||||
lda $400
|
||||
//SEG45 [19] (byte) rvalue::b#1 ← * (word) 1025 [ ] -- aby=_star_cowo1
|
||||
lda $401
|
||||
//SEG46 [20] phi from rvalue to rvalue::@1
|
||||
//SEG47 [20] phi (byte) rvalue::i#2 = (byte) 2 -- xby=coby1
|
||||
ldx #$2
|
||||
//SEG48 rvalue::@1
|
||||
b1:
|
||||
//SEG49 [21] if((byte) rvalue::i#2<(byte) 10) goto rvalue::@2 [ rvalue::i#2 ] -- xby_lt_coby1_then_la1
|
||||
cpx #$a
|
||||
bcc b2
|
||||
//SEG50 rvalue::@return
|
||||
//SEG51 [22] return [ ]
|
||||
rts
|
||||
//SEG52 rvalue::@2
|
||||
b2:
|
||||
//SEG53 [23] (byte) rvalue::b#2 ← (word) 1024 *idx (byte) rvalue::i#2 [ rvalue::i#2 ] -- aby=cowo1_staridx_xby
|
||||
lda $400,x
|
||||
//SEG54 [24] (byte) rvalue::i#1 ← ++ (byte) rvalue::i#2 [ rvalue::i#1 ] -- xby=_inc_xby
|
||||
inx
|
||||
//SEG55 [20] phi from rvalue::@2 to rvalue::@1
|
||||
//SEG56 [20] phi (byte) rvalue::i#2 = (byte) rvalue::i#1 -- register_copy
|
||||
jmp b1
|
||||
}
|
||||
//SEG57 lvalue
|
||||
lvalue: {
|
||||
//SEG58 [25] *((word) 1024) ← (byte) 1 [ ] -- _star_cowo1=coby2
|
||||
lda #$1
|
||||
sta $400
|
||||
//SEG59 [26] *((word) 1025) ← (byte) 2 [ ] -- _star_cowo1=coby2
|
||||
lda #$2
|
||||
sta $401
|
||||
//SEG60 [27] phi from lvalue to lvalue::@1
|
||||
//SEG61 [27] phi (byte) lvalue::i#2 = (byte) 2 -- xby=coby1
|
||||
ldx #$2
|
||||
//SEG62 lvalue::@1
|
||||
b1:
|
||||
//SEG63 [28] if((byte) lvalue::i#2<(byte) 10) goto lvalue::@2 [ lvalue::i#2 ] -- xby_lt_coby1_then_la1
|
||||
cpx #$a
|
||||
bcc b2
|
||||
//SEG64 lvalue::@return
|
||||
//SEG65 [29] return [ ]
|
||||
rts
|
||||
//SEG66 lvalue::@2
|
||||
b2:
|
||||
//SEG67 [30] *((word) 1024 + (byte) lvalue::i#2) ← (byte) 3 [ lvalue::i#2 ] -- cowo1_staridx_xby=coby2
|
||||
lda #$3
|
||||
sta $400,x
|
||||
//SEG68 [31] (byte) lvalue::i#1 ← ++ (byte) lvalue::i#2 [ lvalue::i#1 ] -- xby=_inc_xby
|
||||
inx
|
||||
//SEG69 [27] phi from lvalue::@2 to lvalue::@1
|
||||
//SEG70 [27] phi (byte) lvalue::i#2 = (byte) lvalue::i#1 -- register_copy
|
||||
jmp b1
|
||||
}
|
||||
|
||||
FINAL SYMBOL TABLE
|
||||
(label) @begin
|
||||
(label) @end
|
||||
@ -2363,36 +2533,29 @@ reg byte a [ rvalue::b#2 ]
|
||||
|
||||
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
|
||||
b1:
|
||||
//SEG6 [2] call rvalue param-assignment [ ]
|
||||
jsr rvalue
|
||||
//SEG7 main::@2
|
||||
b2:
|
||||
//SEG8 [3] call rvaluevar param-assignment [ ]
|
||||
jsr rvaluevar
|
||||
//SEG9 main::@3
|
||||
b3:
|
||||
//SEG10 [4] call lvaluevar param-assignment [ ]
|
||||
jsr lvaluevar
|
||||
//SEG11 main::@return
|
||||
breturn:
|
||||
//SEG12 [5] return [ ]
|
||||
rts
|
||||
}
|
||||
//SEG13 lvaluevar
|
||||
lvaluevar: {
|
||||
//SEG14 [6] phi from lvaluevar to lvaluevar::@1
|
||||
b1_from_lvaluevar:
|
||||
//SEG15 [6] phi (byte*) lvaluevar::screen#2 = (word) 1024 -- zpptrby1=cowo1
|
||||
lda #<$400
|
||||
sta $2
|
||||
@ -2406,7 +2569,6 @@ lvaluevar: {
|
||||
cpx #$a
|
||||
bcc b2
|
||||
//SEG19 lvaluevar::@return
|
||||
breturn:
|
||||
//SEG20 [8] return [ ]
|
||||
rts
|
||||
//SEG21 lvaluevar::@2
|
||||
@ -2423,7 +2585,6 @@ lvaluevar: {
|
||||
//SEG24 [11] (byte) lvaluevar::i#1 ← ++ (byte) lvaluevar::i#2 [ lvaluevar::i#1 lvaluevar::screen#1 ] -- xby=_inc_xby
|
||||
inx
|
||||
//SEG25 [6] phi from lvaluevar::@2 to lvaluevar::@1
|
||||
b1_from_b2:
|
||||
//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 b1
|
||||
@ -2431,7 +2592,6 @@ lvaluevar: {
|
||||
//SEG28 rvaluevar
|
||||
rvaluevar: {
|
||||
//SEG29 [12] phi from rvaluevar to rvaluevar::@1
|
||||
b1_from_rvaluevar:
|
||||
//SEG30 [12] phi (byte*) rvaluevar::screen#2 = (word) 1024 -- zpptrby1=cowo1
|
||||
lda #<$400
|
||||
sta $2
|
||||
@ -2445,7 +2605,6 @@ rvaluevar: {
|
||||
cpx #$a
|
||||
bcc b2
|
||||
//SEG34 rvaluevar::@return
|
||||
breturn:
|
||||
//SEG35 [14] return [ ]
|
||||
rts
|
||||
//SEG36 rvaluevar::@2
|
||||
@ -2461,7 +2620,6 @@ rvaluevar: {
|
||||
//SEG39 [17] (byte) rvaluevar::i#1 ← ++ (byte) rvaluevar::i#2 [ rvaluevar::i#1 rvaluevar::screen#1 ] -- xby=_inc_xby
|
||||
inx
|
||||
//SEG40 [12] phi from rvaluevar::@2 to rvaluevar::@1
|
||||
b1_from_b2:
|
||||
//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 b1
|
||||
@ -2473,7 +2631,6 @@ rvalue: {
|
||||
//SEG45 [19] (byte) rvalue::b#1 ← * (word) 1025 [ ] -- aby=_star_cowo1
|
||||
lda $401
|
||||
//SEG46 [20] phi from rvalue to rvalue::@1
|
||||
b1_from_rvalue:
|
||||
//SEG47 [20] phi (byte) rvalue::i#2 = (byte) 2 -- xby=coby1
|
||||
ldx #$2
|
||||
//SEG48 rvalue::@1
|
||||
@ -2482,7 +2639,6 @@ rvalue: {
|
||||
cpx #$a
|
||||
bcc b2
|
||||
//SEG50 rvalue::@return
|
||||
breturn:
|
||||
//SEG51 [22] return [ ]
|
||||
rts
|
||||
//SEG52 rvalue::@2
|
||||
@ -2492,7 +2648,6 @@ rvalue: {
|
||||
//SEG54 [24] (byte) rvalue::i#1 ← ++ (byte) rvalue::i#2 [ rvalue::i#1 ] -- xby=_inc_xby
|
||||
inx
|
||||
//SEG55 [20] phi from rvalue::@2 to rvalue::@1
|
||||
b1_from_b2:
|
||||
//SEG56 [20] phi (byte) rvalue::i#2 = (byte) rvalue::i#1 -- register_copy
|
||||
jmp b1
|
||||
}
|
||||
@ -2505,7 +2660,6 @@ lvalue: {
|
||||
lda #$2
|
||||
sta $401
|
||||
//SEG60 [27] phi from lvalue to lvalue::@1
|
||||
b1_from_lvalue:
|
||||
//SEG61 [27] phi (byte) lvalue::i#2 = (byte) 2 -- xby=coby1
|
||||
ldx #$2
|
||||
//SEG62 lvalue::@1
|
||||
@ -2514,7 +2668,6 @@ lvalue: {
|
||||
cpx #$a
|
||||
bcc b2
|
||||
//SEG64 lvalue::@return
|
||||
breturn:
|
||||
//SEG65 [29] return [ ]
|
||||
rts
|
||||
//SEG66 lvalue::@2
|
||||
@ -2525,7 +2678,6 @@ lvalue: {
|
||||
//SEG68 [31] (byte) lvalue::i#1 ← ++ (byte) lvalue::i#2 [ lvalue::i#1 ] -- xby=_inc_xby
|
||||
inx
|
||||
//SEG69 [27] phi from lvalue::@2 to lvalue::@1
|
||||
b1_from_b2:
|
||||
//SEG70 [27] phi (byte) lvalue::i#2 = (byte) lvalue::i#1 -- register_copy
|
||||
jmp b1
|
||||
}
|
||||
|
@ -1,17 +1,12 @@
|
||||
bbegin:
|
||||
jsr main
|
||||
bend:
|
||||
main: {
|
||||
b1_from_main:
|
||||
ldx #$2
|
||||
b1:
|
||||
cpx #$a
|
||||
bcc b2
|
||||
breturn:
|
||||
rts
|
||||
b2:
|
||||
lda $400,x
|
||||
inx
|
||||
b1_from_b2:
|
||||
jmp b1
|
||||
}
|
||||
|
@ -504,7 +504,7 @@ Uplifting [] best 235 combination
|
||||
Removing instruction jmp bend
|
||||
Removing instruction jmp b1
|
||||
Removing instruction jmp breturn
|
||||
Succesful ASM optimization Pass5NextJumpElimination
|
||||
Succesful ASM optimization Pass6NextJumpElimination
|
||||
ASSEMBLER
|
||||
//SEG0 @begin
|
||||
bbegin:
|
||||
@ -539,6 +539,41 @@ main: {
|
||||
jmp b1
|
||||
}
|
||||
|
||||
Removing instruction bbegin:
|
||||
Removing instruction bend:
|
||||
Removing instruction b1_from_main:
|
||||
Removing instruction breturn:
|
||||
Removing instruction b1_from_b2:
|
||||
Succesful ASM optimization Pass6UnusedLabelElimination
|
||||
ASSEMBLER
|
||||
//SEG0 @begin
|
||||
//SEG1 [0] call main param-assignment [ ]
|
||||
jsr main
|
||||
//SEG2 @end
|
||||
//SEG3 main
|
||||
main: {
|
||||
//SEG4 [1] phi from main to main::@1
|
||||
//SEG5 [1] phi (byte) main::i#2 = (byte) 2 -- xby=coby1
|
||||
ldx #$2
|
||||
//SEG6 main::@1
|
||||
b1:
|
||||
//SEG7 [2] if((byte) main::i#2<(byte) 10) goto main::@2 [ main::i#2 ] -- xby_lt_coby1_then_la1
|
||||
cpx #$a
|
||||
bcc b2
|
||||
//SEG8 main::@return
|
||||
//SEG9 [3] return [ ]
|
||||
rts
|
||||
//SEG10 main::@2
|
||||
b2:
|
||||
//SEG11 [4] (byte) main::b#0 ← (word) 1024 *idx (byte) main::i#2 [ main::i#2 ] -- aby=cowo1_staridx_xby
|
||||
lda $400,x
|
||||
//SEG12 [5] (byte) main::i#1 ← ++ (byte) main::i#2 [ main::i#1 ] -- xby=_inc_xby
|
||||
inx
|
||||
//SEG13 [1] phi from main::@2 to main::@1
|
||||
//SEG14 [1] phi (byte) main::i#2 = (byte) main::i#1 -- register_copy
|
||||
jmp b1
|
||||
}
|
||||
|
||||
FINAL SYMBOL TABLE
|
||||
(label) @begin
|
||||
(label) @end
|
||||
@ -558,15 +593,12 @@ reg byte a [ main::b#0 ]
|
||||
|
||||
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
|
||||
b1_from_main:
|
||||
//SEG5 [1] phi (byte) main::i#2 = (byte) 2 -- xby=coby1
|
||||
ldx #$2
|
||||
//SEG6 main::@1
|
||||
@ -575,7 +607,6 @@ main: {
|
||||
cpx #$a
|
||||
bcc b2
|
||||
//SEG8 main::@return
|
||||
breturn:
|
||||
//SEG9 [3] return [ ]
|
||||
rts
|
||||
//SEG10 main::@2
|
||||
@ -585,7 +616,6 @@ main: {
|
||||
//SEG12 [5] (byte) main::i#1 ← ++ (byte) main::i#2 [ main::i#1 ] -- xby=_inc_xby
|
||||
inx
|
||||
//SEG13 [1] phi from main::@2 to main::@1
|
||||
b1_from_b2:
|
||||
//SEG14 [1] phi (byte) main::i#2 = (byte) main::i#1 -- register_copy
|
||||
jmp b1
|
||||
}
|
||||
|
@ -1,32 +1,23 @@
|
||||
bbegin:
|
||||
sum_from_bbegin:
|
||||
lda #$2
|
||||
ldy #$1
|
||||
jsr sum
|
||||
b2:
|
||||
sta $2
|
||||
sum_from_b2:
|
||||
lda #$4
|
||||
ldy #$3
|
||||
jsr sum
|
||||
b3:
|
||||
tax
|
||||
sum_from_b3:
|
||||
lda #$d
|
||||
ldy #$9
|
||||
jsr sum
|
||||
b4:
|
||||
sta $3
|
||||
txa
|
||||
clc
|
||||
adc $2
|
||||
clc
|
||||
adc $3
|
||||
bend:
|
||||
sum: {
|
||||
sty $ff
|
||||
clc
|
||||
adc $ff
|
||||
breturn:
|
||||
rts
|
||||
}
|
||||
|
@ -597,7 +597,7 @@ Removing instruction jmp b3
|
||||
Removing instruction jmp b4
|
||||
Removing instruction jmp bend
|
||||
Removing instruction jmp breturn
|
||||
Succesful ASM optimization Pass5NextJumpElimination
|
||||
Succesful ASM optimization Pass6NextJumpElimination
|
||||
ASSEMBLER
|
||||
//SEG0 @begin
|
||||
bbegin:
|
||||
@ -658,45 +658,13 @@ sum: {
|
||||
rts
|
||||
}
|
||||
|
||||
FINAL SYMBOL TABLE
|
||||
(byte~) $3 reg byte a 4.0
|
||||
(label) @2
|
||||
(label) @3
|
||||
(label) @4
|
||||
(label) @begin
|
||||
(label) @end
|
||||
(byte) s1
|
||||
(byte) s1#0 zp byte:2 0.5
|
||||
(byte) s2
|
||||
(byte) s2#0 reg byte x 0.6666666666666666
|
||||
(byte) s3
|
||||
(byte) s3#0 zp byte:3 2.0
|
||||
(byte) s4
|
||||
(byte) s4#0 reg byte a Infinity
|
||||
(byte()) sum((byte) sum::a , (byte) sum::b)
|
||||
(label) sum::@return
|
||||
(byte) sum::a
|
||||
(byte) sum::a#3 reg byte y 2.0
|
||||
(byte) sum::b
|
||||
(byte) sum::b#3 reg byte a 2.0
|
||||
(byte) sum::return
|
||||
(byte) sum::return#0 reg byte a 1.6
|
||||
|
||||
reg byte y [ sum::a#3 ]
|
||||
reg byte a [ sum::b#3 ]
|
||||
zp byte:2 [ s1#0 ]
|
||||
reg byte x [ s2#0 ]
|
||||
zp byte:3 [ s3#0 ]
|
||||
reg byte a [ $3 ]
|
||||
reg byte a [ s4#0 ]
|
||||
reg byte a [ sum::return#0 ]
|
||||
|
||||
FINAL CODE
|
||||
Removing instruction sum_from_bbegin:
|
||||
Succesful ASM optimization Pass6RedundantLabelElimination
|
||||
ASSEMBLER
|
||||
//SEG0 @begin
|
||||
bbegin:
|
||||
//SEG1 [0] call sum param-assignment [ sum::return#0 ]
|
||||
//SEG2 [8] phi from @begin to sum
|
||||
sum_from_bbegin:
|
||||
//SEG3 [8] phi (byte) sum::b#3 = (byte) 2 -- aby=coby1
|
||||
lda #$2
|
||||
//SEG4 [8] phi (byte) sum::a#3 = (byte) 1 -- yby=coby1
|
||||
@ -751,3 +719,147 @@ sum: {
|
||||
rts
|
||||
}
|
||||
|
||||
Removing instruction bbegin:
|
||||
Removing instruction b2:
|
||||
Removing instruction sum_from_b2:
|
||||
Removing instruction b3:
|
||||
Removing instruction sum_from_b3:
|
||||
Removing instruction b4:
|
||||
Removing instruction bend:
|
||||
Removing instruction breturn:
|
||||
Succesful ASM optimization Pass6UnusedLabelElimination
|
||||
ASSEMBLER
|
||||
//SEG0 @begin
|
||||
//SEG1 [0] call sum param-assignment [ sum::return#0 ]
|
||||
//SEG2 [8] phi from @begin to sum
|
||||
//SEG3 [8] phi (byte) sum::b#3 = (byte) 2 -- aby=coby1
|
||||
lda #$2
|
||||
//SEG4 [8] phi (byte) sum::a#3 = (byte) 1 -- yby=coby1
|
||||
ldy #$1
|
||||
jsr sum
|
||||
//SEG5 @2
|
||||
//SEG6 [1] (byte) s1#0 ← (byte) sum::return#0 [ s1#0 ] -- zpby1=aby
|
||||
sta $2
|
||||
//SEG7 [2] call sum param-assignment [ sum::return#0 s1#0 ]
|
||||
//SEG8 [8] phi from @2 to sum
|
||||
//SEG9 [8] phi (byte) sum::b#3 = (byte) 4 -- aby=coby1
|
||||
lda #$4
|
||||
//SEG10 [8] phi (byte) sum::a#3 = (byte) 3 -- yby=coby1
|
||||
ldy #$3
|
||||
jsr sum
|
||||
//SEG11 @3
|
||||
//SEG12 [3] (byte) s2#0 ← (byte) sum::return#0 [ s1#0 s2#0 ] -- xby=aby
|
||||
tax
|
||||
//SEG13 [4] call sum param-assignment [ sum::return#0 s1#0 s2#0 ]
|
||||
//SEG14 [8] phi from @3 to sum
|
||||
//SEG15 [8] phi (byte) sum::b#3 = (byte) 13 -- aby=coby1
|
||||
lda #$d
|
||||
//SEG16 [8] phi (byte) sum::a#3 = (byte) 9 -- yby=coby1
|
||||
ldy #$9
|
||||
jsr sum
|
||||
//SEG17 @4
|
||||
//SEG18 [5] (byte) s3#0 ← (byte) sum::return#0 [ s1#0 s2#0 s3#0 ] -- zpby1=aby
|
||||
sta $3
|
||||
//SEG19 [6] (byte~) $3 ← (byte) s1#0 + (byte) s2#0 [ $3 s3#0 ] -- aby=zpby1_plus_xby
|
||||
txa
|
||||
clc
|
||||
adc $2
|
||||
//SEG20 [7] (byte) s4#0 ← (byte~) $3 + (byte) s3#0 [ ] -- aby=aby_plus_zpby1
|
||||
clc
|
||||
adc $3
|
||||
//SEG21 @end
|
||||
//SEG22 sum
|
||||
sum: {
|
||||
//SEG23 [9] (byte) sum::return#0 ← (byte) sum::a#3 + (byte) sum::b#3 [ sum::return#0 s1#0 s2#0 ] -- aby=yby_plus_aby
|
||||
sty $ff
|
||||
clc
|
||||
adc $ff
|
||||
//SEG24 sum::@return
|
||||
//SEG25 [10] return [ sum::return#0 s1#0 s2#0 ]
|
||||
rts
|
||||
}
|
||||
|
||||
FINAL SYMBOL TABLE
|
||||
(byte~) $3 reg byte a 4.0
|
||||
(label) @2
|
||||
(label) @3
|
||||
(label) @4
|
||||
(label) @begin
|
||||
(label) @end
|
||||
(byte) s1
|
||||
(byte) s1#0 zp byte:2 0.5
|
||||
(byte) s2
|
||||
(byte) s2#0 reg byte x 0.6666666666666666
|
||||
(byte) s3
|
||||
(byte) s3#0 zp byte:3 2.0
|
||||
(byte) s4
|
||||
(byte) s4#0 reg byte a Infinity
|
||||
(byte()) sum((byte) sum::a , (byte) sum::b)
|
||||
(label) sum::@return
|
||||
(byte) sum::a
|
||||
(byte) sum::a#3 reg byte y 2.0
|
||||
(byte) sum::b
|
||||
(byte) sum::b#3 reg byte a 2.0
|
||||
(byte) sum::return
|
||||
(byte) sum::return#0 reg byte a 1.6
|
||||
|
||||
reg byte y [ sum::a#3 ]
|
||||
reg byte a [ sum::b#3 ]
|
||||
zp byte:2 [ s1#0 ]
|
||||
reg byte x [ s2#0 ]
|
||||
zp byte:3 [ s3#0 ]
|
||||
reg byte a [ $3 ]
|
||||
reg byte a [ s4#0 ]
|
||||
reg byte a [ sum::return#0 ]
|
||||
|
||||
FINAL CODE
|
||||
//SEG0 @begin
|
||||
//SEG1 [0] call sum param-assignment [ sum::return#0 ]
|
||||
//SEG2 [8] phi from @begin to sum
|
||||
//SEG3 [8] phi (byte) sum::b#3 = (byte) 2 -- aby=coby1
|
||||
lda #$2
|
||||
//SEG4 [8] phi (byte) sum::a#3 = (byte) 1 -- yby=coby1
|
||||
ldy #$1
|
||||
jsr sum
|
||||
//SEG5 @2
|
||||
//SEG6 [1] (byte) s1#0 ← (byte) sum::return#0 [ s1#0 ] -- zpby1=aby
|
||||
sta $2
|
||||
//SEG7 [2] call sum param-assignment [ sum::return#0 s1#0 ]
|
||||
//SEG8 [8] phi from @2 to sum
|
||||
//SEG9 [8] phi (byte) sum::b#3 = (byte) 4 -- aby=coby1
|
||||
lda #$4
|
||||
//SEG10 [8] phi (byte) sum::a#3 = (byte) 3 -- yby=coby1
|
||||
ldy #$3
|
||||
jsr sum
|
||||
//SEG11 @3
|
||||
//SEG12 [3] (byte) s2#0 ← (byte) sum::return#0 [ s1#0 s2#0 ] -- xby=aby
|
||||
tax
|
||||
//SEG13 [4] call sum param-assignment [ sum::return#0 s1#0 s2#0 ]
|
||||
//SEG14 [8] phi from @3 to sum
|
||||
//SEG15 [8] phi (byte) sum::b#3 = (byte) 13 -- aby=coby1
|
||||
lda #$d
|
||||
//SEG16 [8] phi (byte) sum::a#3 = (byte) 9 -- yby=coby1
|
||||
ldy #$9
|
||||
jsr sum
|
||||
//SEG17 @4
|
||||
//SEG18 [5] (byte) s3#0 ← (byte) sum::return#0 [ s1#0 s2#0 s3#0 ] -- zpby1=aby
|
||||
sta $3
|
||||
//SEG19 [6] (byte~) $3 ← (byte) s1#0 + (byte) s2#0 [ $3 s3#0 ] -- aby=zpby1_plus_xby
|
||||
txa
|
||||
clc
|
||||
adc $2
|
||||
//SEG20 [7] (byte) s4#0 ← (byte~) $3 + (byte) s3#0 [ ] -- aby=aby_plus_zpby1
|
||||
clc
|
||||
adc $3
|
||||
//SEG21 @end
|
||||
//SEG22 sum
|
||||
sum: {
|
||||
//SEG23 [9] (byte) sum::return#0 ← (byte) sum::a#3 + (byte) sum::b#3 [ sum::return#0 s1#0 s2#0 ] -- aby=yby_plus_aby
|
||||
sty $ff
|
||||
clc
|
||||
adc $ff
|
||||
//SEG24 sum::@return
|
||||
//SEG25 [10] return [ sum::return#0 s1#0 s2#0 ]
|
||||
rts
|
||||
}
|
||||
|
||||
|
@ -1,9 +1,6 @@
|
||||
bbegin:
|
||||
jsr main
|
||||
bend:
|
||||
main: {
|
||||
lda #$1
|
||||
sta $400
|
||||
breturn:
|
||||
rts
|
||||
}
|
||||
|
@ -240,7 +240,7 @@ Uplifting [main] best 24 combination
|
||||
Uplifting [] best 24 combination
|
||||
Removing instruction jmp bend
|
||||
Removing instruction jmp breturn
|
||||
Succesful ASM optimization Pass5NextJumpElimination
|
||||
Succesful ASM optimization Pass6NextJumpElimination
|
||||
ASSEMBLER
|
||||
//SEG0 @begin
|
||||
bbegin:
|
||||
@ -259,6 +259,25 @@ main: {
|
||||
rts
|
||||
}
|
||||
|
||||
Removing instruction bbegin:
|
||||
Removing instruction bend:
|
||||
Removing instruction breturn:
|
||||
Succesful ASM optimization Pass6UnusedLabelElimination
|
||||
ASSEMBLER
|
||||
//SEG0 @begin
|
||||
//SEG1 [0] call main param-assignment [ ]
|
||||
jsr main
|
||||
//SEG2 @end
|
||||
//SEG3 main
|
||||
main: {
|
||||
//SEG4 [1] *((word) 1024) ← (byte) 1 [ ] -- _star_cowo1=coby2
|
||||
lda #$1
|
||||
sta $400
|
||||
//SEG5 main::@return
|
||||
//SEG6 [2] return [ ]
|
||||
rts
|
||||
}
|
||||
|
||||
FINAL SYMBOL TABLE
|
||||
(label) @begin
|
||||
(label) @end
|
||||
@ -269,18 +288,15 @@ FINAL SYMBOL TABLE
|
||||
|
||||
FINAL CODE
|
||||
//SEG0 @begin
|
||||
bbegin:
|
||||
//SEG1 [0] call main param-assignment [ ]
|
||||
jsr main
|
||||
//SEG2 @end
|
||||
bend:
|
||||
//SEG3 main
|
||||
main: {
|
||||
//SEG4 [1] *((word) 1024) ← (byte) 1 [ ] -- _star_cowo1=coby2
|
||||
lda #$1
|
||||
sta $400
|
||||
//SEG5 main::@return
|
||||
breturn:
|
||||
//SEG6 [2] return [ ]
|
||||
rts
|
||||
}
|
||||
|
@ -1,8 +1,5 @@
|
||||
bbegin:
|
||||
jsr main
|
||||
bend:
|
||||
main: {
|
||||
addpoint_from_main:
|
||||
lda #$1
|
||||
sta $2
|
||||
ldy #$5
|
||||
@ -10,50 +7,36 @@ main: {
|
||||
sta $8
|
||||
lda #$5
|
||||
jsr addpoint
|
||||
b3:
|
||||
addpoint_from_b3:
|
||||
lda #$2
|
||||
sta $2
|
||||
ldy #$8
|
||||
lda #$f
|
||||
jsr addpoint
|
||||
b4:
|
||||
addpoint_from_b4:
|
||||
lda #$3
|
||||
sta $2
|
||||
ldy #$e
|
||||
lda #$6
|
||||
jsr addpoint
|
||||
b5:
|
||||
addpoint_from_b5:
|
||||
lda #$4
|
||||
sta $2
|
||||
ldy #$2
|
||||
lda #$22
|
||||
jsr addpoint
|
||||
b6:
|
||||
addpoint_from_b6:
|
||||
lda #$5
|
||||
sta $2
|
||||
ldy #$11
|
||||
lda #$15
|
||||
jsr addpoint
|
||||
b7:
|
||||
addpoint_from_b7:
|
||||
lda #$7
|
||||
sta $2
|
||||
ldy #$16
|
||||
lda #$1f
|
||||
jsr addpoint
|
||||
b8:
|
||||
jsr initscreen
|
||||
b1:
|
||||
jsr render
|
||||
b10:
|
||||
jsr animate
|
||||
b11:
|
||||
jmp b1
|
||||
breturn:
|
||||
rts
|
||||
}
|
||||
animate: {
|
||||
@ -131,34 +114,28 @@ animate: {
|
||||
jmp b2
|
||||
}
|
||||
render: {
|
||||
b1_from_render:
|
||||
lda #<$d800
|
||||
sta $3
|
||||
lda #>$d800
|
||||
sta $3+$1
|
||||
lda #$0
|
||||
sta $2
|
||||
b1_from_b3:
|
||||
b1:
|
||||
b2_from_b1:
|
||||
lda #$0
|
||||
sta $5
|
||||
b2_from_b5:
|
||||
b2:
|
||||
lda $5
|
||||
sta $9
|
||||
lda $2
|
||||
sta $a
|
||||
jsr findcol
|
||||
b5:
|
||||
tya
|
||||
ldy $5
|
||||
sta ($3),y
|
||||
inc $5
|
||||
lda $5
|
||||
cmp #$28
|
||||
bcc b2_from_b5
|
||||
b3:
|
||||
bcc b2
|
||||
lda $3
|
||||
clc
|
||||
adc #$28
|
||||
@ -169,17 +146,14 @@ render: {
|
||||
inc $2
|
||||
lda $2
|
||||
cmp #$19
|
||||
bcc b1_from_b3
|
||||
breturn:
|
||||
bcc b1
|
||||
rts
|
||||
}
|
||||
findcol: {
|
||||
b1_from_findcol:
|
||||
ldy #$0
|
||||
lda #$ff
|
||||
sta $6
|
||||
ldx #$0
|
||||
b1_from_b13:
|
||||
b1:
|
||||
lda $1000,x
|
||||
sta $7
|
||||
@ -192,32 +166,26 @@ findcol: {
|
||||
lda $9
|
||||
cmp $7
|
||||
bcc b6
|
||||
b7:
|
||||
lda $9
|
||||
sec
|
||||
sbc $7
|
||||
sta $7
|
||||
b8_from_b7:
|
||||
b8:
|
||||
lda $a
|
||||
cmp $b
|
||||
bcc b9
|
||||
b10:
|
||||
lda $a
|
||||
sec
|
||||
sbc $b
|
||||
clc
|
||||
adc $7
|
||||
b11_from_b10:
|
||||
b11:
|
||||
cmp $6
|
||||
bcc b12
|
||||
b13_from_b11:
|
||||
b13:
|
||||
inx
|
||||
cpx $8
|
||||
bcc b1_from_b13
|
||||
breturn_from_b13:
|
||||
bcc b1
|
||||
jmp breturn
|
||||
breturn_from_b2:
|
||||
ldy #$0
|
||||
@ -226,7 +194,6 @@ findcol: {
|
||||
b12:
|
||||
ldy $1200,x
|
||||
sta $6
|
||||
b13_from_b12:
|
||||
jmp b13
|
||||
b9:
|
||||
lda $b
|
||||
@ -234,14 +201,12 @@ findcol: {
|
||||
sbc $a
|
||||
clc
|
||||
adc $7
|
||||
b11_from_b9:
|
||||
jmp b11
|
||||
b6:
|
||||
lda $7
|
||||
sec
|
||||
sbc $9
|
||||
sta $7
|
||||
b8_from_b6:
|
||||
jmp b8
|
||||
b2:
|
||||
lda $a
|
||||
@ -250,12 +215,10 @@ findcol: {
|
||||
jmp b3
|
||||
}
|
||||
initscreen: {
|
||||
b1_from_initscreen:
|
||||
lda #<$400
|
||||
sta $3
|
||||
lda #>$400
|
||||
sta $3+$1
|
||||
b1_from_b1:
|
||||
b1:
|
||||
ldy #$0
|
||||
lda #$e6
|
||||
@ -266,13 +229,12 @@ initscreen: {
|
||||
!:
|
||||
lda $3+$1
|
||||
cmp #>$7e8
|
||||
bcc b1_from_b1
|
||||
bcc b1
|
||||
bne !+
|
||||
lda $3
|
||||
cmp #<$7e8
|
||||
bcc b1_from_b1
|
||||
bcc b1
|
||||
!:
|
||||
breturn:
|
||||
rts
|
||||
}
|
||||
addpoint: {
|
||||
@ -285,6 +247,5 @@ addpoint: {
|
||||
ldx $8
|
||||
sta $1200,x
|
||||
inc $8
|
||||
breturn:
|
||||
rts
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user