1
0
mirror of https://gitlab.com/camelot/kickc.git synced 2024-08-03 01:29:04 +00:00

Optimizing ASM removing double jumps and unreachable code (after JMP/RTS). Closes #58. Closes #99.

This commit is contained in:
jespergravgaard 2017-11-30 00:27:11 +01:00
parent 6eb54c11a6
commit d9490718fa
32 changed files with 7476 additions and 103 deletions

View File

@ -297,6 +297,8 @@ public class Compiler {
pass5Optimizations.add(new Pass5UnnecesaryLoadElimination(program));
pass5Optimizations.add(new Pass5RedundantLabelElimination(program));
pass5Optimizations.add(new Pass5UnusedLabelElimination(program));
pass5Optimizations.add(new Pass5DoubleJumpElimination(program));
pass5Optimizations.add(new Pass5UnreachableCodeElimination(program));
boolean asmOptimized = true;
CompileLog log = program.getLog();
while (asmOptimized) {

View File

@ -11,7 +11,7 @@ public class AsmInstructionSet {
private static AsmInstructionSet set = new AsmInstructionSet();
public static AsmInstructionType getInstructionType(String mnemonic, AsmAddressingMode mode, String parameter, boolean isZp) {
public static AsmInstructionType getInstructionType(String mnemonic, AsmAddressingMode mode, boolean isZp) {
AsmInstructionType type = null;
if (AsmAddressingMode.ABS.equals(mode) && isZp) {
type = set.getType(mnemonic, AsmAddressingMode.ZP);
@ -31,19 +31,6 @@ public class AsmInstructionSet {
return type;
}
private static boolean isZp(String parameter) {
Number number = null;
if(parameter!=null) {
try {
number = NumberParser.parseLiteral(parameter);
} catch (NumberFormatException e) {
// ignore
}
}
return (number != null && number.intValue()<256 && number.intValue()>=0);
}
private List<AsmInstructionType> instructions;
/** Maps mnemonic_addressingmMode to the instruction type */

View File

@ -66,7 +66,7 @@ public class AsmProgram {
}
public void addInstruction(String mnemonic, AsmAddressingMode addressingMode, String parameter, boolean zp) {
AsmInstructionType instructionType = AsmInstructionSet.getInstructionType(mnemonic, addressingMode, parameter, zp);
AsmInstructionType instructionType = AsmInstructionSet.getInstructionType(mnemonic, addressingMode, zp);
addLine(new AsmInstruction(instructionType, parameter));
}

View File

@ -294,7 +294,6 @@ public class AsmFragment {
AsmInstructionType type = AsmInstructionSet.getInstructionType(
ctx.MNEMONIC().getText(),
AsmAddressingMode.NON,
null,
false);
instruction = new AsmInstruction(type, null);
} else {
@ -365,7 +364,6 @@ public class AsmFragment {
AsmInstructionType type = AsmInstructionSet.getInstructionType(
mnemonic,
addressingMode,
parameter.getParam(),
parameter.isZp());
if (type == null) {
throw new RuntimeException("Error in " + name + ".asm line " + ctx.getStart().getLine() + " - Instruction type unknown " + mnemonic + " " + addressingMode + " " + parameter);

View File

@ -0,0 +1,79 @@
package dk.camelot64.kickc.passes;
import dk.camelot64.kickc.asm.*;
import dk.camelot64.kickc.model.Program;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
/**
* Optimize assembler code by removing jumps to labels immediately following the jump
*/
public class Pass5DoubleJumpElimination extends Pass5AsmOptimization {
public Pass5DoubleJumpElimination(Program program) {
super(program);
}
public boolean optimize() {
boolean optimized = false;
// Find all labels immediately followed by a a jump
String currentScope = "";
String currentLabel = null;
Map<String, String> immediateJumps = new LinkedHashMap<>();
for (AsmSegment segment : getAsmProgram().getSegments()) {
for (AsmLine line : segment.getLines()) {
if (line instanceof AsmScopeBegin) {
currentScope = ((AsmScopeBegin) line).getLabel();
currentLabel = null;
} else if (line instanceof AsmScopeEnd) {
currentScope = "";
currentLabel = null;
} else if (line instanceof AsmLabel) {
currentLabel = ((AsmLabel) line).getLabel();
} else if (line instanceof AsmComment || line instanceof AsmConstant || line instanceof AsmLabelDecl) {
// ignore
} else if (line instanceof AsmBasicUpstart || line instanceof AsmDataNumeric || line instanceof AsmDataString || line instanceof AsmSetPc) {
currentLabel = null;
} else if (line instanceof AsmInstruction) {
if (currentLabel != null) {
AsmInstruction asmInstruction = (AsmInstruction) line;
AsmInstructionType jmpType = AsmInstructionSet.getInstructionType("jmp", AsmAddressingMode.ABS, false);
if (asmInstruction.getType().equals(jmpType)) {
immediateJumps.put(currentScope + "::" + currentLabel, asmInstruction.getParameter());
}
}
currentLabel = null;
} else {
throw new RuntimeException("ASM not handled " + line);
}
}
}
// Look through the code for double-jumps
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 asmInstruction = (AsmInstruction) line;
if (asmInstruction.getType().isJump()) {
String immediateJmpTarget = immediateJumps.get(currentScope + "::" + asmInstruction.getParameter());
if(immediateJmpTarget!=null) {
getLog().append("Skipping double jump to "+immediateJmpTarget+" in "+asmInstruction.toString());
asmInstruction.setParameter(immediateJmpTarget);
optimized = true;
}
}
}
}
}
return optimized;
}
}

View File

@ -3,7 +3,6 @@ package dk.camelot64.kickc.passes;
import dk.camelot64.kickc.asm.*;
import dk.camelot64.kickc.model.Program;
import java.util.ArrayList;
import java.util.List;
import java.util.ListIterator;
@ -38,11 +37,11 @@ public class Pass5UnnecesaryLoadElimination extends Pass5AsmOptimization {
modified = remove(lineIt);
} else if (AsmProgramStaticRegisterValues.matchImm(instructionValues.getX(), immValue)) {
getLog().append("Replacing instruction "+instruction+" with TXA");
instruction.setType(AsmInstructionSet.getInstructionType("txa", AsmAddressingMode.NON, null, false));
instruction.setType(AsmInstructionSet.getInstructionType("txa", AsmAddressingMode.NON, false));
instruction.setParameter(null);
} else if (AsmProgramStaticRegisterValues.matchImm(instructionValues.getY(), immValue)) {
getLog().append("Replacing instruction "+instruction+" with TYA");
instruction.setType(AsmInstructionSet.getInstructionType("tya", AsmAddressingMode.NON, null, false));
instruction.setType(AsmInstructionSet.getInstructionType("tya", AsmAddressingMode.NON, false));
instruction.setParameter(null);
}
}
@ -53,11 +52,11 @@ public class Pass5UnnecesaryLoadElimination extends Pass5AsmOptimization {
modified = remove(lineIt);
} else if (instructionValues.getxMem() != null && instructionValues.getxMem().equals(memValue)) {
getLog().append("Replacing instruction "+instruction+" with TXA");
instruction.setType(AsmInstructionSet.getInstructionType("txa", AsmAddressingMode.NON, null, false));
instruction.setType(AsmInstructionSet.getInstructionType("txa", AsmAddressingMode.NON, false));
instruction.setParameter(null);
} else if (instructionValues.getyMem() != null && instructionValues.getyMem().equals(memValue)) {
getLog().append("Replacing instruction "+instruction+" with TYA");
instruction.setType(AsmInstructionSet.getInstructionType("tya", AsmAddressingMode.NON, null, false));
instruction.setType(AsmInstructionSet.getInstructionType("tya", AsmAddressingMode.NON, false));
instruction.setParameter(null);
}
}
@ -68,7 +67,7 @@ public class Pass5UnnecesaryLoadElimination extends Pass5AsmOptimization {
modified = remove(lineIt);
} else if (AsmProgramStaticRegisterValues.matchImm(instructionValues.getA(), immValue)) {
getLog().append("Replacing instruction "+instruction+" with TAX");
instruction.setType(AsmInstructionSet.getInstructionType("tax", AsmAddressingMode.NON, null, false));
instruction.setType(AsmInstructionSet.getInstructionType("tax", AsmAddressingMode.NON, false));
instruction.setParameter(null);
}
}
@ -79,7 +78,7 @@ public class Pass5UnnecesaryLoadElimination extends Pass5AsmOptimization {
modified = remove(lineIt);
} else if (instructionValues.getaMem() != null && instructionValues.getaMem().equals(memValue)) {
getLog().append("Replacing instruction "+instruction+" with TAX");
instruction.setType(AsmInstructionSet.getInstructionType("tax", AsmAddressingMode.NON, null, false));
instruction.setType(AsmInstructionSet.getInstructionType("tax", AsmAddressingMode.NON, false));
instruction.setParameter(null);
}
}
@ -90,7 +89,7 @@ public class Pass5UnnecesaryLoadElimination extends Pass5AsmOptimization {
modified = remove(lineIt);
} else if (AsmProgramStaticRegisterValues.matchImm(instructionValues.getA(), immValue)) {
getLog().append("Replacing instruction "+instruction+" with TAY");
instruction.setType(AsmInstructionSet.getInstructionType("tay", AsmAddressingMode.NON, null, false));
instruction.setType(AsmInstructionSet.getInstructionType("tay", AsmAddressingMode.NON, false));
instruction.setParameter(null);
}
}
@ -101,7 +100,7 @@ public class Pass5UnnecesaryLoadElimination extends Pass5AsmOptimization {
modified = remove(lineIt);
} else if (instructionValues.getaMem() != null && instructionValues.getaMem().equals(memValue)) {
getLog().append("Replacing instruction "+instruction+" with TAY");
instruction.setType(AsmInstructionSet.getInstructionType("tay", AsmAddressingMode.NON, null, false));
instruction.setType(AsmInstructionSet.getInstructionType("tay", AsmAddressingMode.NON, false));
instruction.setParameter(null);
}
}

View File

@ -0,0 +1,51 @@
package dk.camelot64.kickc.passes;
import dk.camelot64.kickc.asm.AsmComment;
import dk.camelot64.kickc.asm.AsmInstruction;
import dk.camelot64.kickc.asm.AsmLine;
import dk.camelot64.kickc.asm.AsmSegment;
import dk.camelot64.kickc.model.Program;
import java.util.ListIterator;
/**
* Optimize assembler code by removing anything following an RTS or JMP (meaning they will never execute.) - until the next label/scope occurs.
* Such JMP's can occur when double JMP's are eliminated
*/
public class Pass5UnreachableCodeElimination extends Pass5AsmOptimization {
public Pass5UnreachableCodeElimination(Program program) {
super(program);
}
public boolean optimize() {
boolean optimized = false;
// Find RTS/JMP followed by code
boolean afterExit = false;
for (AsmSegment segment : getAsmProgram().getSegments()) {
ListIterator<AsmLine> lineIt = segment.getLines().listIterator();
while (lineIt.hasNext()) {
AsmLine line = lineIt.next();
if (line instanceof AsmInstruction) {
if (afterExit) {
getLog().append("Removing unreachable instruction "+line.toString());
lineIt.remove();
optimized = true;
} else {
AsmInstruction asmInstruction = (AsmInstruction) line;
if (asmInstruction.getType().getMnemnonic().equals("rts") || asmInstruction.getType().getMnemnonic().equals("jmp")) {
afterExit = true;
}
}
} else if(line instanceof AsmComment ) {
// ignore comments
} else {
afterExit = false;
}
}
}
return optimized;
}
}

View File

@ -39,7 +39,6 @@ main: {
b1:
jsr lines
jmp b1
rts
}
lines: {
.label _2 = 3
@ -386,7 +385,7 @@ init_plot_tables: {
lsr
tay
cpy #0
bne b10
bne b2
ldy #$80
b2:
inx
@ -421,8 +420,6 @@ init_plot_tables: {
cpx #0
bne b3
rts
b10:
jmp b2
}
init_screen: {
.label b = 8

File diff suppressed because it is too large Load Diff

View File

@ -44,7 +44,6 @@ main: {
jsr plots
dec BGCOL
jmp b2
rts
}
plots: {
.label i = 2
@ -110,7 +109,7 @@ init_plot_tables: {
lsr
tay
cpy #0
bne b10
bne b2
ldy #$80
b2:
inx
@ -145,8 +144,6 @@ init_plot_tables: {
cpx #0
bne b3
rts
b10:
jmp b2
}
init_screen: {
.label b = 3

File diff suppressed because it is too large Load Diff

View File

@ -17,7 +17,6 @@ main: {
b2:
jsr line
jmp b2
rts
}
line: {
.const x0 = 0

View File

@ -2456,6 +2456,118 @@ plot: {
rts
}
Removing unreachable instruction rts
Succesful ASM optimization Pass5AfterRtsElimination
ASSEMBLER
//SEG0 Basic Upstart
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
//SEG1 Global Constants & labels
.const plots = $1000
.const SCREEN = $400
//SEG2 @begin
//SEG3 [1] phi from @begin to @3 [phi:@begin->@3]
//SEG4 @3
//SEG5 [2] call main param-assignment [ ] ( )
//SEG6 [4] phi from @3 to main [phi:@3->main]
jsr main
//SEG7 [3] phi from @3 to @end [phi:@3->@end]
//SEG8 @end
//SEG9 main
main: {
//SEG10 [5] phi from main to main::@1 [phi:main->main::@1]
//SEG11 [5] phi (byte) main::i#2 = (byte/signed byte/word/signed word) 0 [phi:main->main::@1#0] -- xby=coby1
ldx #0
jmp b1
//SEG12 [5] phi from main::@1 to main::@1 [phi:main::@1->main::@1]
//SEG13 [5] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@1->main::@1#0] -- register_copy
//SEG14 main::@1
b1:
//SEG15 [6] *((const byte[]) plots#0 + (byte) main::i#2) ← (byte) main::i#2 [ main::i#2 ] ( main:2 [ main::i#2 ] ) -- cowo1_derefidx_xby=xby
txa
sta plots,x
//SEG16 [7] *((const byte*) SCREEN#0 + (byte) main::i#2) ← (byte/signed byte/word/signed word) 0 [ main::i#2 ] ( main:2 [ main::i#2 ] ) -- cowo1_derefidx_xby=coby2
lda #0
sta SCREEN,x
//SEG17 [8] (byte) main::i#1 ← ++ (byte) main::i#2 [ main::i#1 ] ( main:2 [ main::i#1 ] ) -- xby=_inc_xby
inx
//SEG18 [9] if((byte) main::i#1!=(byte/signed byte/word/signed word) 40) goto main::@1 [ main::i#1 ] ( main:2 [ main::i#1 ] ) -- xby_neq_coby1_then_la1
cpx #$28
bne b1
//SEG19 [10] phi from main::@1 main::@5 to main::@2 [phi:main::@1/main::@5->main::@2]
//SEG20 main::@2
b2:
//SEG21 [11] call line param-assignment [ ] ( main:2 [ ] )
jsr line
//SEG22 main::@5
//SEG23 [12] if(true) goto main::@2 [ ] ( main:2 [ ] ) -- true_then_la1
jmp b2
//SEG24 main::@return
//SEG25 [13] return [ ] ( main:2 [ ] )
}
//SEG26 line
line: {
.const x0 = 0
.const x1 = $a
.label x = 2
//SEG27 [14] if((const byte) line::x0#0>=(const byte) line::x1#0) goto line::@1 [ ] ( main:2::line:11 [ ] ) -- coby1_ge_coby2_then_la1
lda #x0
cmp #x1
bcs b1
//SEG28 [15] phi from line to line::@2 [phi:line->line::@2]
//SEG29 [15] phi (byte) line::x#2 = (const byte) line::x0#0 [phi:line->line::@2#0] -- zpby1=coby1
lda #x0
sta x
jmp b2
//SEG30 [15] phi from line::@8 to line::@2 [phi:line::@8->line::@2]
//SEG31 [15] phi (byte) line::x#2 = (byte) line::x#1 [phi:line::@8->line::@2#0] -- register_copy
//SEG32 line::@2
b2:
//SEG33 [16] (byte) plot::x#1 ← (byte) line::x#2 [ line::x#2 plot::x#1 ] ( main:2::line:11 [ line::x#2 plot::x#1 ] ) -- yby=zpby1
ldy x
//SEG34 [17] call plot param-assignment [ line::x#2 ] ( main:2::line:11 [ line::x#2 ] )
//SEG35 [23] phi from line::@2 to plot [phi:line::@2->plot]
//SEG36 [23] phi (byte) plot::x#2 = (byte) plot::x#1 [phi:line::@2->plot#0] -- register_copy
jsr plot
//SEG37 line::@8
//SEG38 [18] (byte) line::x#1 ← ++ (byte) line::x#2 [ line::x#1 ] ( main:2::line:11 [ line::x#1 ] ) -- zpby1=_inc_zpby1
inc x
//SEG39 [19] if((byte) line::x#1<=(const byte) line::x1#0) goto line::@2 [ line::x#1 ] ( main:2::line:11 [ line::x#1 ] ) -- zpby1_le_coby1_then_la1
lda x
cmp #x1
bcc b2
beq b2
//SEG40 line::@return
breturn:
//SEG41 [20] return [ ] ( main:2::line:11 [ ] )
rts
//SEG42 [21] phi from line to line::@1 [phi:line->line::@1]
//SEG43 line::@1
b1:
//SEG44 [22] call plot param-assignment [ ] ( main:2::line:11 [ ] )
//SEG45 [23] phi from line::@1 to plot [phi:line::@1->plot]
//SEG46 [23] phi (byte) plot::x#2 = (const byte) line::x0#0 [phi:line::@1->plot#0] -- yby=coby1
ldy #x0
jsr plot
jmp breturn
}
//SEG47 plot
plot: {
//SEG48 [24] (byte) plot::idx#0 ← (const byte[]) plots#0 *idx (byte) plot::x#2 [ plot::idx#0 ] ( main:2::line:11::plot:17 [ line::x#2 plot::idx#0 ] main:2::line:11::plot:22 [ plot::idx#0 ] ) -- xby=cowo1_derefidx_yby
ldx plots,y
//SEG49 [25] (byte~) plot::$1 ← (const byte*) SCREEN#0 *idx (byte) plot::idx#0 [ plot::idx#0 plot::$1 ] ( main:2::line:11::plot:17 [ line::x#2 plot::idx#0 plot::$1 ] main:2::line:11::plot:22 [ plot::idx#0 plot::$1 ] ) -- aby=cowo1_derefidx_xby
lda SCREEN,x
//SEG50 [26] (byte~) plot::$2 ← (byte~) plot::$1 + (byte/signed byte/word/signed word) 1 [ plot::idx#0 plot::$2 ] ( main:2::line:11::plot:17 [ line::x#2 plot::idx#0 plot::$2 ] main:2::line:11::plot:22 [ plot::idx#0 plot::$2 ] ) -- aby=aby_plus_1
clc
adc #1
//SEG51 [27] *((const byte*) SCREEN#0 + (byte) plot::idx#0) ← (byte~) plot::$2 [ ] ( main:2::line:11::plot:17 [ line::x#2 ] main:2::line:11::plot:22 [ ] ) -- cowo1_derefidx_xby=aby
sta SCREEN,x
//SEG52 plot::@return
//SEG53 [28] return [ ] ( main:2::line:11::plot:17 [ line::x#2 ] main:2::line:11::plot:22 [ ] )
rts
}
Removing instruction jmp b1
Removing instruction jmp b2
Succesful ASM optimization Pass5NextJumpElimination
@ -2505,7 +2617,6 @@ main: {
jmp b2
//SEG24 main::@return
//SEG25 [13] return [ ] ( main:2 [ ] )
rts
}
//SEG26 line
line: {
@ -2616,7 +2727,6 @@ main: {
jmp b2
//SEG24 main::@return
//SEG25 [13] return [ ] ( main:2 [ ] )
rts
}
//SEG26 line
line: {
@ -2769,7 +2879,6 @@ main: {
jmp b2
//SEG24 main::@return
//SEG25 [13] return [ ] ( main:2 [ ] )
rts
}
//SEG26 line
line: {

View File

@ -24,7 +24,6 @@ main: {
jsr flip
jsr plot
jmp b3_from_b11
rts
}
plot: {
.label line = 2

View File

@ -5504,6 +5504,467 @@ prepare: {
rts
}
Skipping double jump to b3 in bne b3_from_b3
Succesful ASM optimization Pass5DoubleJumpElimination
ASSEMBLER
//SEG0 Basic Upstart
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
//SEG1 Global Constants & labels
.const SCREEN = $400
.const buffer1 = $1000
.const buffer2 = $1100
.const RASTER = $d012
//SEG2 @begin
//SEG3 [1] phi from @begin to @4 [phi:@begin->@4]
//SEG4 @4
//SEG5 [2] call main param-assignment [ ] ( )
//SEG6 [4] phi from @4 to main [phi:@4->main]
jsr main
//SEG7 [3] phi from @4 to @end [phi:@4->@end]
//SEG8 @end
//SEG9 main
main: {
//SEG10 [5] call prepare param-assignment [ ] ( main:2 [ ] )
//SEG11 [47] phi from main to prepare [phi:main->prepare]
jsr prepare
//SEG12 [6] phi from main main::@11 to main::@3 [phi:main/main::@11->main::@3]
b3_from_b11:
//SEG13 [6] phi (byte) main::c#4 = (byte/signed byte/word/signed word) 25 [phi:main/main::@11->main::@3#0] -- xby=coby1
ldx #$19
jmp b3
//SEG14 [6] phi from main::@3 to main::@3 [phi:main::@3->main::@3]
b3_from_b3:
jmp b3
//SEG15 [6] phi from main::@6 to main::@3 [phi:main::@6->main::@3]
//SEG16 [6] phi (byte) main::c#4 = (byte) main::c#1 [phi:main::@6->main::@3#0] -- register_copy
//SEG17 main::@3
b3:
//SEG18 [7] if(*((const byte*) RASTER#0)!=(byte/word/signed word) 254) goto main::@3 [ main::c#4 ] ( main:2 [ main::c#4 ] ) -- _deref_cowo1_neq_coby2_then_la1
lda RASTER
cmp #$fe
bne b3
//SEG19 main::@4
b4:
//SEG20 [8] if(*((const byte*) RASTER#0)!=(byte/word/signed word) 255) goto main::@4 [ main::c#4 ] ( main:2 [ main::c#4 ] ) -- _deref_cowo1_neq_coby2_then_la1
lda RASTER
cmp #$ff
bne b4
//SEG21 main::@6
//SEG22 [9] (byte) main::c#1 ← -- (byte) main::c#4 [ main::c#1 ] ( main:2 [ main::c#1 ] ) -- xby=_dec_xby
dex
//SEG23 [10] if((byte) main::c#1!=(byte/signed byte/word/signed word) 0) goto main::@3 [ main::c#1 ] ( main:2 [ main::c#1 ] ) -- xby_neq_0_then_la1
cpx #0
bne b3
//SEG24 [11] phi from main::@6 to main::@7 [phi:main::@6->main::@7]
//SEG25 main::@7
//SEG26 [12] call flip param-assignment [ ] ( main:2 [ ] )
//SEG27 [29] phi from main::@7 to flip [phi:main::@7->flip]
jsr flip
//SEG28 [13] phi from main::@7 to main::@10 [phi:main::@7->main::@10]
//SEG29 main::@10
//SEG30 [14] call plot param-assignment [ ] ( main:2 [ ] )
//SEG31 [17] phi from main::@10 to plot [phi:main::@10->plot]
jsr plot
//SEG32 main::@11
//SEG33 [15] if(true) goto main::@3 [ ] ( main:2 [ ] ) -- true_then_la1
jmp b3_from_b11
//SEG34 main::@return
//SEG35 [16] return [ ] ( main:2 [ ] )
rts
}
//SEG36 plot
plot: {
.label line = 2
.label y = 4
//SEG37 [18] phi from plot to plot::@1 [phi:plot->plot::@1]
//SEG38 [18] phi (byte) plot::y#4 = (byte/signed byte/word/signed word) 16 [phi:plot->plot::@1#0] -- zpby1=coby1
lda #$10
sta y
//SEG39 [18] phi (byte*) plot::line#4 = (const byte[1000]) SCREEN#0+(byte/signed byte/word/signed word) 5*(byte/signed byte/word/signed word) 40+(byte/signed byte/word/signed word) 12 [phi:plot->plot::@1#1] -- zpptrby1=cowo1
lda #<SCREEN+5*$28+$c
sta line
lda #>SCREEN+5*$28+$c
sta line+1
//SEG40 [18] phi (byte) plot::i#3 = (byte/signed byte/word/signed word) 0 [phi:plot->plot::@1#2] -- xby=coby1
ldx #0
jmp b1
//SEG41 [18] phi from plot::@3 to plot::@1 [phi:plot::@3->plot::@1]
//SEG42 [18] phi (byte) plot::y#4 = (byte) plot::y#1 [phi:plot::@3->plot::@1#0] -- register_copy
//SEG43 [18] phi (byte*) plot::line#4 = (byte*) plot::line#1 [phi:plot::@3->plot::@1#1] -- register_copy
//SEG44 [18] phi (byte) plot::i#3 = (byte) plot::i#1 [phi:plot::@3->plot::@1#2] -- register_copy
//SEG45 plot::@1
b1:
//SEG46 [19] phi from plot::@1 to plot::@2 [phi:plot::@1->plot::@2]
//SEG47 [19] phi (byte) plot::x#2 = (byte/signed byte/word/signed word) 0 [phi:plot::@1->plot::@2#0] -- yby=coby1
ldy #0
//SEG48 [19] phi (byte) plot::i#2 = (byte) plot::i#3 [phi:plot::@1->plot::@2#1] -- register_copy
jmp b2
//SEG49 [19] phi from plot::@2 to plot::@2 [phi:plot::@2->plot::@2]
//SEG50 [19] phi (byte) plot::x#2 = (byte) plot::x#1 [phi:plot::@2->plot::@2#0] -- register_copy
//SEG51 [19] phi (byte) plot::i#2 = (byte) plot::i#1 [phi:plot::@2->plot::@2#1] -- register_copy
//SEG52 plot::@2
b2:
//SEG53 [20] (byte~) plot::$3 ← (const byte[256]) buffer1#0 *idx (byte) plot::i#2 [ plot::line#4 plot::y#4 plot::i#2 plot::x#2 plot::$3 ] ( main:2::plot:14 [ plot::line#4 plot::y#4 plot::i#2 plot::x#2 plot::$3 ] ) -- aby=cowo1_derefidx_xby
lda buffer1,x
//SEG54 [21] *((byte*) plot::line#4 + (byte) plot::x#2) ← (byte~) plot::$3 [ plot::line#4 plot::y#4 plot::i#2 plot::x#2 ] ( main:2::plot:14 [ plot::line#4 plot::y#4 plot::i#2 plot::x#2 ] ) -- zpptrby1_derefidx_yby=aby
sta (line),y
//SEG55 [22] (byte) plot::i#1 ← ++ (byte) plot::i#2 [ plot::line#4 plot::y#4 plot::i#1 plot::x#2 ] ( main:2::plot:14 [ plot::line#4 plot::y#4 plot::i#1 plot::x#2 ] ) -- xby=_inc_xby
inx
//SEG56 [23] (byte) plot::x#1 ← ++ (byte) plot::x#2 [ plot::line#4 plot::y#4 plot::i#1 plot::x#1 ] ( main:2::plot:14 [ plot::line#4 plot::y#4 plot::i#1 plot::x#1 ] ) -- yby=_inc_yby
iny
//SEG57 [24] if((byte) plot::x#1<(byte/signed byte/word/signed word) 16) goto plot::@2 [ plot::line#4 plot::y#4 plot::i#1 plot::x#1 ] ( main:2::plot:14 [ plot::line#4 plot::y#4 plot::i#1 plot::x#1 ] ) -- yby_lt_coby1_then_la1
cpy #$10
bcc b2
//SEG58 plot::@3
//SEG59 [25] (byte*) plot::line#1 ← (byte*) plot::line#4 + (byte/signed byte/word/signed word) 40 [ plot::y#4 plot::i#1 plot::line#1 ] ( main:2::plot:14 [ plot::y#4 plot::i#1 plot::line#1 ] ) -- zpptrby1=zpptrby1_plus_coby1
lda line
clc
adc #$28
sta line
bcc !+
inc line+1
!:
//SEG60 [26] (byte) plot::y#1 ← -- (byte) plot::y#4 [ plot::i#1 plot::line#1 plot::y#1 ] ( main:2::plot:14 [ plot::i#1 plot::line#1 plot::y#1 ] ) -- zpby1=_dec_zpby1
dec y
//SEG61 [27] if((byte) plot::y#1!=(byte/signed byte/word/signed word) 0) goto plot::@1 [ plot::i#1 plot::line#1 plot::y#1 ] ( main:2::plot:14 [ plot::i#1 plot::line#1 plot::y#1 ] ) -- zpby1_neq_0_then_la1
lda y
bne b1
//SEG62 plot::@return
//SEG63 [28] return [ ] ( main:2::plot:14 [ ] )
rts
}
//SEG64 flip
flip: {
.label c = 5
.label r = 4
//SEG65 [30] phi from flip to flip::@1 [phi:flip->flip::@1]
//SEG66 [30] phi (byte) flip::r#4 = (byte/signed byte/word/signed word) 16 [phi:flip->flip::@1#0] -- zpby1=coby1
lda #$10
sta r
//SEG67 [30] phi (byte) flip::dstIdx#5 = (byte/signed byte/word/signed word) 15 [phi:flip->flip::@1#1] -- yby=coby1
ldy #$f
//SEG68 [30] phi (byte) flip::srcIdx#3 = (byte/signed byte/word/signed word) 0 [phi:flip->flip::@1#2] -- xby=coby1
ldx #0
jmp b1
//SEG69 [30] phi from flip::@4 to flip::@1 [phi:flip::@4->flip::@1]
//SEG70 [30] phi (byte) flip::r#4 = (byte) flip::r#1 [phi:flip::@4->flip::@1#0] -- register_copy
//SEG71 [30] phi (byte) flip::dstIdx#5 = (byte) flip::dstIdx#2 [phi:flip::@4->flip::@1#1] -- register_copy
//SEG72 [30] phi (byte) flip::srcIdx#3 = (byte) flip::srcIdx#1 [phi:flip::@4->flip::@1#2] -- register_copy
//SEG73 flip::@1
b1:
//SEG74 [31] phi from flip::@1 to flip::@2 [phi:flip::@1->flip::@2]
//SEG75 [31] phi (byte) flip::c#2 = (byte/signed byte/word/signed word) 16 [phi:flip::@1->flip::@2#0] -- zpby1=coby1
lda #$10
sta c
//SEG76 [31] phi (byte) flip::dstIdx#3 = (byte) flip::dstIdx#5 [phi:flip::@1->flip::@2#1] -- register_copy
//SEG77 [31] phi (byte) flip::srcIdx#2 = (byte) flip::srcIdx#3 [phi:flip::@1->flip::@2#2] -- register_copy
jmp b2
//SEG78 [31] phi from flip::@2 to flip::@2 [phi:flip::@2->flip::@2]
//SEG79 [31] phi (byte) flip::c#2 = (byte) flip::c#1 [phi:flip::@2->flip::@2#0] -- register_copy
//SEG80 [31] phi (byte) flip::dstIdx#3 = (byte) flip::dstIdx#1 [phi:flip::@2->flip::@2#1] -- register_copy
//SEG81 [31] phi (byte) flip::srcIdx#2 = (byte) flip::srcIdx#1 [phi:flip::@2->flip::@2#2] -- register_copy
//SEG82 flip::@2
b2:
//SEG83 [32] (byte~) flip::$0 ← (const byte[256]) buffer1#0 *idx (byte) flip::srcIdx#2 [ flip::r#4 flip::srcIdx#2 flip::dstIdx#3 flip::c#2 flip::$0 ] ( main:2::flip:12 [ flip::r#4 flip::srcIdx#2 flip::dstIdx#3 flip::c#2 flip::$0 ] ) -- aby=cowo1_derefidx_xby
lda buffer1,x
//SEG84 [33] *((const byte[256]) buffer2#0 + (byte) flip::dstIdx#3) ← (byte~) flip::$0 [ flip::r#4 flip::srcIdx#2 flip::dstIdx#3 flip::c#2 ] ( main:2::flip:12 [ flip::r#4 flip::srcIdx#2 flip::dstIdx#3 flip::c#2 ] ) -- cowo1_derefidx_yby=aby
sta buffer2,y
//SEG85 [34] (byte) flip::srcIdx#1 ← ++ (byte) flip::srcIdx#2 [ flip::r#4 flip::srcIdx#1 flip::dstIdx#3 flip::c#2 ] ( main:2::flip:12 [ flip::r#4 flip::srcIdx#1 flip::dstIdx#3 flip::c#2 ] ) -- xby=_inc_xby
inx
//SEG86 [35] (byte) flip::dstIdx#1 ← (byte) flip::dstIdx#3 + (byte/signed byte/word/signed word) 16 [ flip::r#4 flip::srcIdx#1 flip::c#2 flip::dstIdx#1 ] ( main:2::flip:12 [ flip::r#4 flip::srcIdx#1 flip::c#2 flip::dstIdx#1 ] ) -- yby=yby_plus_coby1
tya
clc
adc #$10
tay
//SEG87 [36] (byte) flip::c#1 ← -- (byte) flip::c#2 [ flip::r#4 flip::srcIdx#1 flip::dstIdx#1 flip::c#1 ] ( main:2::flip:12 [ flip::r#4 flip::srcIdx#1 flip::dstIdx#1 flip::c#1 ] ) -- zpby1=_dec_zpby1
dec c
//SEG88 [37] if((byte) flip::c#1!=(byte/signed byte/word/signed word) 0) goto flip::@2 [ flip::r#4 flip::srcIdx#1 flip::dstIdx#1 flip::c#1 ] ( main:2::flip:12 [ flip::r#4 flip::srcIdx#1 flip::dstIdx#1 flip::c#1 ] ) -- zpby1_neq_0_then_la1
lda c
bne b2
//SEG89 flip::@4
//SEG90 [38] (byte) flip::dstIdx#2 ← -- (byte) flip::dstIdx#1 [ flip::r#4 flip::srcIdx#1 flip::dstIdx#2 ] ( main:2::flip:12 [ flip::r#4 flip::srcIdx#1 flip::dstIdx#2 ] ) -- yby=_dec_yby
dey
//SEG91 [39] (byte) flip::r#1 ← -- (byte) flip::r#4 [ flip::srcIdx#1 flip::dstIdx#2 flip::r#1 ] ( main:2::flip:12 [ flip::srcIdx#1 flip::dstIdx#2 flip::r#1 ] ) -- zpby1=_dec_zpby1
dec r
//SEG92 [40] if((byte) flip::r#1!=(byte/signed byte/word/signed word) 0) goto flip::@1 [ flip::srcIdx#1 flip::dstIdx#2 flip::r#1 ] ( main:2::flip:12 [ flip::srcIdx#1 flip::dstIdx#2 flip::r#1 ] ) -- zpby1_neq_0_then_la1
lda r
bne b1
//SEG93 [41] phi from flip::@4 to flip::@3 [phi:flip::@4->flip::@3]
//SEG94 [41] phi (byte) flip::i#2 = (byte/signed byte/word/signed word) 0 [phi:flip::@4->flip::@3#0] -- xby=coby1
ldx #0
jmp b3
//SEG95 [41] phi from flip::@3 to flip::@3 [phi:flip::@3->flip::@3]
//SEG96 [41] phi (byte) flip::i#2 = (byte) flip::i#1 [phi:flip::@3->flip::@3#0] -- register_copy
//SEG97 flip::@3
b3:
//SEG98 [42] (byte~) flip::$4 ← (const byte[256]) buffer2#0 *idx (byte) flip::i#2 [ flip::i#2 flip::$4 ] ( main:2::flip:12 [ flip::i#2 flip::$4 ] ) -- aby=cowo1_derefidx_xby
lda buffer2,x
//SEG99 [43] *((const byte[256]) buffer1#0 + (byte) flip::i#2) ← (byte~) flip::$4 [ flip::i#2 ] ( main:2::flip:12 [ flip::i#2 ] ) -- cowo1_derefidx_xby=aby
sta buffer1,x
//SEG100 [44] (byte) flip::i#1 ← ++ (byte) flip::i#2 [ flip::i#1 ] ( main:2::flip:12 [ flip::i#1 ] ) -- xby=_inc_xby
inx
//SEG101 [45] if((byte) flip::i#1!=(byte/signed byte/word/signed word) 0) goto flip::@3 [ flip::i#1 ] ( main:2::flip:12 [ flip::i#1 ] ) -- xby_neq_0_then_la1
cpx #0
bne b3
//SEG102 flip::@return
//SEG103 [46] return [ ] ( main:2::flip:12 [ ] )
rts
}
//SEG104 prepare
prepare: {
//SEG105 [48] phi from prepare to prepare::@1 [phi:prepare->prepare::@1]
//SEG106 [48] phi (byte) prepare::i#2 = (byte/signed byte/word/signed word) 0 [phi:prepare->prepare::@1#0] -- xby=coby1
ldx #0
jmp b1
//SEG107 [48] phi from prepare::@1 to prepare::@1 [phi:prepare::@1->prepare::@1]
//SEG108 [48] phi (byte) prepare::i#2 = (byte) prepare::i#1 [phi:prepare::@1->prepare::@1#0] -- register_copy
//SEG109 prepare::@1
b1:
//SEG110 [49] *((const byte[256]) buffer1#0 + (byte) prepare::i#2) ← (byte) prepare::i#2 [ prepare::i#2 ] ( main:2::prepare:5 [ prepare::i#2 ] ) -- cowo1_derefidx_xby=xby
txa
sta buffer1,x
//SEG111 [50] (byte) prepare::i#1 ← ++ (byte) prepare::i#2 [ prepare::i#1 ] ( main:2::prepare:5 [ prepare::i#1 ] ) -- xby=_inc_xby
inx
//SEG112 [51] if((byte) prepare::i#1!=(byte/signed byte/word/signed word) 0) goto prepare::@1 [ prepare::i#1 ] ( main:2::prepare:5 [ prepare::i#1 ] ) -- xby_neq_0_then_la1
cpx #0
bne b1
//SEG113 prepare::@return
//SEG114 [52] return [ ] ( main:2::prepare:5 [ ] )
rts
}
Removing unreachable instruction rts
Succesful ASM optimization Pass5AfterRtsElimination
ASSEMBLER
//SEG0 Basic Upstart
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
//SEG1 Global Constants & labels
.const SCREEN = $400
.const buffer1 = $1000
.const buffer2 = $1100
.const RASTER = $d012
//SEG2 @begin
//SEG3 [1] phi from @begin to @4 [phi:@begin->@4]
//SEG4 @4
//SEG5 [2] call main param-assignment [ ] ( )
//SEG6 [4] phi from @4 to main [phi:@4->main]
jsr main
//SEG7 [3] phi from @4 to @end [phi:@4->@end]
//SEG8 @end
//SEG9 main
main: {
//SEG10 [5] call prepare param-assignment [ ] ( main:2 [ ] )
//SEG11 [47] phi from main to prepare [phi:main->prepare]
jsr prepare
//SEG12 [6] phi from main main::@11 to main::@3 [phi:main/main::@11->main::@3]
b3_from_b11:
//SEG13 [6] phi (byte) main::c#4 = (byte/signed byte/word/signed word) 25 [phi:main/main::@11->main::@3#0] -- xby=coby1
ldx #$19
jmp b3
//SEG14 [6] phi from main::@3 to main::@3 [phi:main::@3->main::@3]
b3_from_b3:
jmp b3
//SEG15 [6] phi from main::@6 to main::@3 [phi:main::@6->main::@3]
//SEG16 [6] phi (byte) main::c#4 = (byte) main::c#1 [phi:main::@6->main::@3#0] -- register_copy
//SEG17 main::@3
b3:
//SEG18 [7] if(*((const byte*) RASTER#0)!=(byte/word/signed word) 254) goto main::@3 [ main::c#4 ] ( main:2 [ main::c#4 ] ) -- _deref_cowo1_neq_coby2_then_la1
lda RASTER
cmp #$fe
bne b3
//SEG19 main::@4
b4:
//SEG20 [8] if(*((const byte*) RASTER#0)!=(byte/word/signed word) 255) goto main::@4 [ main::c#4 ] ( main:2 [ main::c#4 ] ) -- _deref_cowo1_neq_coby2_then_la1
lda RASTER
cmp #$ff
bne b4
//SEG21 main::@6
//SEG22 [9] (byte) main::c#1 ← -- (byte) main::c#4 [ main::c#1 ] ( main:2 [ main::c#1 ] ) -- xby=_dec_xby
dex
//SEG23 [10] if((byte) main::c#1!=(byte/signed byte/word/signed word) 0) goto main::@3 [ main::c#1 ] ( main:2 [ main::c#1 ] ) -- xby_neq_0_then_la1
cpx #0
bne b3
//SEG24 [11] phi from main::@6 to main::@7 [phi:main::@6->main::@7]
//SEG25 main::@7
//SEG26 [12] call flip param-assignment [ ] ( main:2 [ ] )
//SEG27 [29] phi from main::@7 to flip [phi:main::@7->flip]
jsr flip
//SEG28 [13] phi from main::@7 to main::@10 [phi:main::@7->main::@10]
//SEG29 main::@10
//SEG30 [14] call plot param-assignment [ ] ( main:2 [ ] )
//SEG31 [17] phi from main::@10 to plot [phi:main::@10->plot]
jsr plot
//SEG32 main::@11
//SEG33 [15] if(true) goto main::@3 [ ] ( main:2 [ ] ) -- true_then_la1
jmp b3_from_b11
//SEG34 main::@return
//SEG35 [16] return [ ] ( main:2 [ ] )
}
//SEG36 plot
plot: {
.label line = 2
.label y = 4
//SEG37 [18] phi from plot to plot::@1 [phi:plot->plot::@1]
//SEG38 [18] phi (byte) plot::y#4 = (byte/signed byte/word/signed word) 16 [phi:plot->plot::@1#0] -- zpby1=coby1
lda #$10
sta y
//SEG39 [18] phi (byte*) plot::line#4 = (const byte[1000]) SCREEN#0+(byte/signed byte/word/signed word) 5*(byte/signed byte/word/signed word) 40+(byte/signed byte/word/signed word) 12 [phi:plot->plot::@1#1] -- zpptrby1=cowo1
lda #<SCREEN+5*$28+$c
sta line
lda #>SCREEN+5*$28+$c
sta line+1
//SEG40 [18] phi (byte) plot::i#3 = (byte/signed byte/word/signed word) 0 [phi:plot->plot::@1#2] -- xby=coby1
ldx #0
jmp b1
//SEG41 [18] phi from plot::@3 to plot::@1 [phi:plot::@3->plot::@1]
//SEG42 [18] phi (byte) plot::y#4 = (byte) plot::y#1 [phi:plot::@3->plot::@1#0] -- register_copy
//SEG43 [18] phi (byte*) plot::line#4 = (byte*) plot::line#1 [phi:plot::@3->plot::@1#1] -- register_copy
//SEG44 [18] phi (byte) plot::i#3 = (byte) plot::i#1 [phi:plot::@3->plot::@1#2] -- register_copy
//SEG45 plot::@1
b1:
//SEG46 [19] phi from plot::@1 to plot::@2 [phi:plot::@1->plot::@2]
//SEG47 [19] phi (byte) plot::x#2 = (byte/signed byte/word/signed word) 0 [phi:plot::@1->plot::@2#0] -- yby=coby1
ldy #0
//SEG48 [19] phi (byte) plot::i#2 = (byte) plot::i#3 [phi:plot::@1->plot::@2#1] -- register_copy
jmp b2
//SEG49 [19] phi from plot::@2 to plot::@2 [phi:plot::@2->plot::@2]
//SEG50 [19] phi (byte) plot::x#2 = (byte) plot::x#1 [phi:plot::@2->plot::@2#0] -- register_copy
//SEG51 [19] phi (byte) plot::i#2 = (byte) plot::i#1 [phi:plot::@2->plot::@2#1] -- register_copy
//SEG52 plot::@2
b2:
//SEG53 [20] (byte~) plot::$3 ← (const byte[256]) buffer1#0 *idx (byte) plot::i#2 [ plot::line#4 plot::y#4 plot::i#2 plot::x#2 plot::$3 ] ( main:2::plot:14 [ plot::line#4 plot::y#4 plot::i#2 plot::x#2 plot::$3 ] ) -- aby=cowo1_derefidx_xby
lda buffer1,x
//SEG54 [21] *((byte*) plot::line#4 + (byte) plot::x#2) ← (byte~) plot::$3 [ plot::line#4 plot::y#4 plot::i#2 plot::x#2 ] ( main:2::plot:14 [ plot::line#4 plot::y#4 plot::i#2 plot::x#2 ] ) -- zpptrby1_derefidx_yby=aby
sta (line),y
//SEG55 [22] (byte) plot::i#1 ← ++ (byte) plot::i#2 [ plot::line#4 plot::y#4 plot::i#1 plot::x#2 ] ( main:2::plot:14 [ plot::line#4 plot::y#4 plot::i#1 plot::x#2 ] ) -- xby=_inc_xby
inx
//SEG56 [23] (byte) plot::x#1 ← ++ (byte) plot::x#2 [ plot::line#4 plot::y#4 plot::i#1 plot::x#1 ] ( main:2::plot:14 [ plot::line#4 plot::y#4 plot::i#1 plot::x#1 ] ) -- yby=_inc_yby
iny
//SEG57 [24] if((byte) plot::x#1<(byte/signed byte/word/signed word) 16) goto plot::@2 [ plot::line#4 plot::y#4 plot::i#1 plot::x#1 ] ( main:2::plot:14 [ plot::line#4 plot::y#4 plot::i#1 plot::x#1 ] ) -- yby_lt_coby1_then_la1
cpy #$10
bcc b2
//SEG58 plot::@3
//SEG59 [25] (byte*) plot::line#1 ← (byte*) plot::line#4 + (byte/signed byte/word/signed word) 40 [ plot::y#4 plot::i#1 plot::line#1 ] ( main:2::plot:14 [ plot::y#4 plot::i#1 plot::line#1 ] ) -- zpptrby1=zpptrby1_plus_coby1
lda line
clc
adc #$28
sta line
bcc !+
inc line+1
!:
//SEG60 [26] (byte) plot::y#1 ← -- (byte) plot::y#4 [ plot::i#1 plot::line#1 plot::y#1 ] ( main:2::plot:14 [ plot::i#1 plot::line#1 plot::y#1 ] ) -- zpby1=_dec_zpby1
dec y
//SEG61 [27] if((byte) plot::y#1!=(byte/signed byte/word/signed word) 0) goto plot::@1 [ plot::i#1 plot::line#1 plot::y#1 ] ( main:2::plot:14 [ plot::i#1 plot::line#1 plot::y#1 ] ) -- zpby1_neq_0_then_la1
lda y
bne b1
//SEG62 plot::@return
//SEG63 [28] return [ ] ( main:2::plot:14 [ ] )
rts
}
//SEG64 flip
flip: {
.label c = 5
.label r = 4
//SEG65 [30] phi from flip to flip::@1 [phi:flip->flip::@1]
//SEG66 [30] phi (byte) flip::r#4 = (byte/signed byte/word/signed word) 16 [phi:flip->flip::@1#0] -- zpby1=coby1
lda #$10
sta r
//SEG67 [30] phi (byte) flip::dstIdx#5 = (byte/signed byte/word/signed word) 15 [phi:flip->flip::@1#1] -- yby=coby1
ldy #$f
//SEG68 [30] phi (byte) flip::srcIdx#3 = (byte/signed byte/word/signed word) 0 [phi:flip->flip::@1#2] -- xby=coby1
ldx #0
jmp b1
//SEG69 [30] phi from flip::@4 to flip::@1 [phi:flip::@4->flip::@1]
//SEG70 [30] phi (byte) flip::r#4 = (byte) flip::r#1 [phi:flip::@4->flip::@1#0] -- register_copy
//SEG71 [30] phi (byte) flip::dstIdx#5 = (byte) flip::dstIdx#2 [phi:flip::@4->flip::@1#1] -- register_copy
//SEG72 [30] phi (byte) flip::srcIdx#3 = (byte) flip::srcIdx#1 [phi:flip::@4->flip::@1#2] -- register_copy
//SEG73 flip::@1
b1:
//SEG74 [31] phi from flip::@1 to flip::@2 [phi:flip::@1->flip::@2]
//SEG75 [31] phi (byte) flip::c#2 = (byte/signed byte/word/signed word) 16 [phi:flip::@1->flip::@2#0] -- zpby1=coby1
lda #$10
sta c
//SEG76 [31] phi (byte) flip::dstIdx#3 = (byte) flip::dstIdx#5 [phi:flip::@1->flip::@2#1] -- register_copy
//SEG77 [31] phi (byte) flip::srcIdx#2 = (byte) flip::srcIdx#3 [phi:flip::@1->flip::@2#2] -- register_copy
jmp b2
//SEG78 [31] phi from flip::@2 to flip::@2 [phi:flip::@2->flip::@2]
//SEG79 [31] phi (byte) flip::c#2 = (byte) flip::c#1 [phi:flip::@2->flip::@2#0] -- register_copy
//SEG80 [31] phi (byte) flip::dstIdx#3 = (byte) flip::dstIdx#1 [phi:flip::@2->flip::@2#1] -- register_copy
//SEG81 [31] phi (byte) flip::srcIdx#2 = (byte) flip::srcIdx#1 [phi:flip::@2->flip::@2#2] -- register_copy
//SEG82 flip::@2
b2:
//SEG83 [32] (byte~) flip::$0 ← (const byte[256]) buffer1#0 *idx (byte) flip::srcIdx#2 [ flip::r#4 flip::srcIdx#2 flip::dstIdx#3 flip::c#2 flip::$0 ] ( main:2::flip:12 [ flip::r#4 flip::srcIdx#2 flip::dstIdx#3 flip::c#2 flip::$0 ] ) -- aby=cowo1_derefidx_xby
lda buffer1,x
//SEG84 [33] *((const byte[256]) buffer2#0 + (byte) flip::dstIdx#3) ← (byte~) flip::$0 [ flip::r#4 flip::srcIdx#2 flip::dstIdx#3 flip::c#2 ] ( main:2::flip:12 [ flip::r#4 flip::srcIdx#2 flip::dstIdx#3 flip::c#2 ] ) -- cowo1_derefidx_yby=aby
sta buffer2,y
//SEG85 [34] (byte) flip::srcIdx#1 ← ++ (byte) flip::srcIdx#2 [ flip::r#4 flip::srcIdx#1 flip::dstIdx#3 flip::c#2 ] ( main:2::flip:12 [ flip::r#4 flip::srcIdx#1 flip::dstIdx#3 flip::c#2 ] ) -- xby=_inc_xby
inx
//SEG86 [35] (byte) flip::dstIdx#1 ← (byte) flip::dstIdx#3 + (byte/signed byte/word/signed word) 16 [ flip::r#4 flip::srcIdx#1 flip::c#2 flip::dstIdx#1 ] ( main:2::flip:12 [ flip::r#4 flip::srcIdx#1 flip::c#2 flip::dstIdx#1 ] ) -- yby=yby_plus_coby1
tya
clc
adc #$10
tay
//SEG87 [36] (byte) flip::c#1 ← -- (byte) flip::c#2 [ flip::r#4 flip::srcIdx#1 flip::dstIdx#1 flip::c#1 ] ( main:2::flip:12 [ flip::r#4 flip::srcIdx#1 flip::dstIdx#1 flip::c#1 ] ) -- zpby1=_dec_zpby1
dec c
//SEG88 [37] if((byte) flip::c#1!=(byte/signed byte/word/signed word) 0) goto flip::@2 [ flip::r#4 flip::srcIdx#1 flip::dstIdx#1 flip::c#1 ] ( main:2::flip:12 [ flip::r#4 flip::srcIdx#1 flip::dstIdx#1 flip::c#1 ] ) -- zpby1_neq_0_then_la1
lda c
bne b2
//SEG89 flip::@4
//SEG90 [38] (byte) flip::dstIdx#2 ← -- (byte) flip::dstIdx#1 [ flip::r#4 flip::srcIdx#1 flip::dstIdx#2 ] ( main:2::flip:12 [ flip::r#4 flip::srcIdx#1 flip::dstIdx#2 ] ) -- yby=_dec_yby
dey
//SEG91 [39] (byte) flip::r#1 ← -- (byte) flip::r#4 [ flip::srcIdx#1 flip::dstIdx#2 flip::r#1 ] ( main:2::flip:12 [ flip::srcIdx#1 flip::dstIdx#2 flip::r#1 ] ) -- zpby1=_dec_zpby1
dec r
//SEG92 [40] if((byte) flip::r#1!=(byte/signed byte/word/signed word) 0) goto flip::@1 [ flip::srcIdx#1 flip::dstIdx#2 flip::r#1 ] ( main:2::flip:12 [ flip::srcIdx#1 flip::dstIdx#2 flip::r#1 ] ) -- zpby1_neq_0_then_la1
lda r
bne b1
//SEG93 [41] phi from flip::@4 to flip::@3 [phi:flip::@4->flip::@3]
//SEG94 [41] phi (byte) flip::i#2 = (byte/signed byte/word/signed word) 0 [phi:flip::@4->flip::@3#0] -- xby=coby1
ldx #0
jmp b3
//SEG95 [41] phi from flip::@3 to flip::@3 [phi:flip::@3->flip::@3]
//SEG96 [41] phi (byte) flip::i#2 = (byte) flip::i#1 [phi:flip::@3->flip::@3#0] -- register_copy
//SEG97 flip::@3
b3:
//SEG98 [42] (byte~) flip::$4 ← (const byte[256]) buffer2#0 *idx (byte) flip::i#2 [ flip::i#2 flip::$4 ] ( main:2::flip:12 [ flip::i#2 flip::$4 ] ) -- aby=cowo1_derefidx_xby
lda buffer2,x
//SEG99 [43] *((const byte[256]) buffer1#0 + (byte) flip::i#2) ← (byte~) flip::$4 [ flip::i#2 ] ( main:2::flip:12 [ flip::i#2 ] ) -- cowo1_derefidx_xby=aby
sta buffer1,x
//SEG100 [44] (byte) flip::i#1 ← ++ (byte) flip::i#2 [ flip::i#1 ] ( main:2::flip:12 [ flip::i#1 ] ) -- xby=_inc_xby
inx
//SEG101 [45] if((byte) flip::i#1!=(byte/signed byte/word/signed word) 0) goto flip::@3 [ flip::i#1 ] ( main:2::flip:12 [ flip::i#1 ] ) -- xby_neq_0_then_la1
cpx #0
bne b3
//SEG102 flip::@return
//SEG103 [46] return [ ] ( main:2::flip:12 [ ] )
rts
}
//SEG104 prepare
prepare: {
//SEG105 [48] phi from prepare to prepare::@1 [phi:prepare->prepare::@1]
//SEG106 [48] phi (byte) prepare::i#2 = (byte/signed byte/word/signed word) 0 [phi:prepare->prepare::@1#0] -- xby=coby1
ldx #0
jmp b1
//SEG107 [48] phi from prepare::@1 to prepare::@1 [phi:prepare::@1->prepare::@1]
//SEG108 [48] phi (byte) prepare::i#2 = (byte) prepare::i#1 [phi:prepare::@1->prepare::@1#0] -- register_copy
//SEG109 prepare::@1
b1:
//SEG110 [49] *((const byte[256]) buffer1#0 + (byte) prepare::i#2) ← (byte) prepare::i#2 [ prepare::i#2 ] ( main:2::prepare:5 [ prepare::i#2 ] ) -- cowo1_derefidx_xby=xby
txa
sta buffer1,x
//SEG111 [50] (byte) prepare::i#1 ← ++ (byte) prepare::i#2 [ prepare::i#1 ] ( main:2::prepare:5 [ prepare::i#1 ] ) -- xby=_inc_xby
inx
//SEG112 [51] if((byte) prepare::i#1!=(byte/signed byte/word/signed word) 0) goto prepare::@1 [ prepare::i#1 ] ( main:2::prepare:5 [ prepare::i#1 ] ) -- xby_neq_0_then_la1
cpx #0
bne b1
//SEG113 prepare::@return
//SEG114 [52] return [ ] ( main:2::prepare:5 [ ] )
rts
}
Removing instruction jmp b3
Removing instruction jmp b1
Removing instruction jmp b2
@ -5549,7 +6010,7 @@ main: {
//SEG18 [7] if(*((const byte*) RASTER#0)!=(byte/word/signed word) 254) goto main::@3 [ main::c#4 ] ( main:2 [ main::c#4 ] ) -- _deref_cowo1_neq_coby2_then_la1
lda RASTER
cmp #$fe
bne b3_from_b3
bne b3
//SEG19 main::@4
b4:
//SEG20 [8] if(*((const byte*) RASTER#0)!=(byte/word/signed word) 255) goto main::@4 [ main::c#4 ] ( main:2 [ main::c#4 ] ) -- _deref_cowo1_neq_coby2_then_la1
@ -5577,7 +6038,6 @@ main: {
jmp b3_from_b11
//SEG34 main::@return
//SEG35 [16] return [ ] ( main:2 [ ] )
rts
}
//SEG36 plot
plot: {
@ -5734,7 +6194,6 @@ prepare: {
rts
}
Replacing label b3_from_b3 with b3
Removing instruction b3_from_b3:
Succesful ASM optimization Pass5RedundantLabelElimination
ASSEMBLER
@ -5801,7 +6260,6 @@ main: {
jmp b3_from_b11
//SEG34 main::@return
//SEG35 [16] return [ ] ( main:2 [ ] )
rts
}
//SEG36 plot
plot: {
@ -6023,7 +6481,6 @@ main: {
jmp b3_from_b11
//SEG34 main::@return
//SEG35 [16] return [ ] ( main:2 [ ] )
rts
}
//SEG36 plot
plot: {
@ -6332,7 +6789,6 @@ main: {
jmp b3_from_b11
//SEG34 main::@return
//SEG35 [16] return [ ] ( main:2 [ ] )
rts
}
//SEG36 plot
plot: {

View File

@ -8,5 +8,4 @@ main: {
inc BGCOL
dec BGCOL
jmp b1
rts
}

View File

@ -573,6 +573,37 @@ main: {
rts
}
Removing unreachable instruction rts
Succesful ASM optimization Pass5AfterRtsElimination
ASSEMBLER
//SEG0 Basic Upstart
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
//SEG1 Global Constants & labels
.const BGCOL = $d020
//SEG2 @begin
//SEG3 [1] phi from @begin to @1 [phi:@begin->@1]
//SEG4 @1
//SEG5 [2] call main param-assignment [ ] ( )
//SEG6 [4] phi from @1 to main [phi:@1->main]
jsr main
//SEG7 [3] phi from @1 to @end [phi:@1->@end]
//SEG8 @end
//SEG9 main
main: {
//SEG10 main::@1
b1:
//SEG11 [5] *((const byte*) BGCOL#0) ← ++ *((const byte*) BGCOL#0) [ ] ( main:2 [ ] ) -- _deref_cowo1=_inc__deref_cowo1
inc BGCOL
//SEG12 [6] *((const byte*) BGCOL#0) ← -- *((const byte*) BGCOL#0) [ ] ( main:2 [ ] ) -- _deref_cowo1=_dec__deref_cowo1
dec BGCOL
//SEG13 [7] if(true) goto main::@1 [ ] ( main:2 [ ] ) -- true_then_la1
jmp b1
//SEG14 main::@return
//SEG15 [8] return [ ] ( main:2 [ ] )
}
FINAL SYMBOL TABLE
(label) @1
(label) @begin
@ -611,6 +642,5 @@ main: {
jmp b1
//SEG14 main::@return
//SEG15 [8] return [ ] ( main:2 [ ] )
rts
}

View File

@ -12,13 +12,11 @@ main: {
sta SCREEN,x
iny
cpy #8
bne b6
bne b2
ldy #0
b2:
inx
cpx #$65
bne b1
rts
b6:
jmp b2
}

View File

@ -1253,6 +1253,67 @@ main: {
jmp b2
}
Skipping double jump to b2 in bne b6
Succesful ASM optimization Pass5DoubleJumpElimination
ASSEMBLER
//SEG0 Basic Upstart
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
//SEG1 Global Constants & labels
.const SCREEN = $400
TXT: .byte 3, 1, $d, 5, $c, $f, $14, $20
//SEG2 @begin
//SEG3 [1] phi from @begin to @1 [phi:@begin->@1]
//SEG4 @1
//SEG5 [2] call main param-assignment [ ] ( )
//SEG6 [4] phi from @1 to main [phi:@1->main]
jsr main
//SEG7 [3] phi from @1 to @end [phi:@1->@end]
//SEG8 @end
//SEG9 main
main: {
//SEG10 [5] phi from main to main::@1 [phi:main->main::@1]
//SEG11 [5] phi (byte) main::i#2 = (byte/signed byte/word/signed word) 0 [phi:main->main::@1#0] -- xby=coby1
ldx #0
//SEG12 [5] phi (byte) main::j#3 = (byte/signed byte/word/signed word) 0 [phi:main->main::@1#1] -- yby=coby1
ldy #0
jmp b1
//SEG13 [5] phi from main::@2 to main::@1 [phi:main::@2->main::@1]
//SEG14 [5] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@2->main::@1#0] -- register_copy
//SEG15 [5] phi (byte) main::j#3 = (byte) main::j#4 [phi:main::@2->main::@1#1] -- register_copy
//SEG16 main::@1
b1:
//SEG17 [6] (byte~) main::$0 ← (const byte[]) TXT#0 *idx (byte) main::j#3 [ main::j#3 main::i#2 main::$0 ] ( main:2 [ main::j#3 main::i#2 main::$0 ] ) -- aby=cowo1_derefidx_yby
lda TXT,y
//SEG18 [7] *((const byte*) SCREEN#0 + (byte) main::i#2) ← (byte~) main::$0 [ main::j#3 main::i#2 ] ( main:2 [ main::j#3 main::i#2 ] ) -- cowo1_derefidx_xby=aby
sta SCREEN,x
//SEG19 [8] (byte) main::j#1 ← ++ (byte) main::j#3 [ main::i#2 main::j#1 ] ( main:2 [ main::i#2 main::j#1 ] ) -- yby=_inc_yby
iny
//SEG20 [9] if((byte) main::j#1!=(byte/signed byte/word/signed word) 8) goto main::@6 [ main::i#2 main::j#1 ] ( main:2 [ main::i#2 main::j#1 ] ) -- yby_neq_coby1_then_la1
cpy #8
bne b2
//SEG21 [10] phi from main::@1 to main::@2 [phi:main::@1->main::@2]
//SEG22 [10] phi (byte) main::j#4 = (byte/signed byte/word/signed word) 0 [phi:main::@1->main::@2#0] -- yby=coby1
ldy #0
//SEG23 main::@2
b2:
//SEG24 [11] (byte) main::i#1 ← ++ (byte) main::i#2 [ main::j#4 main::i#1 ] ( main:2 [ main::j#4 main::i#1 ] ) -- xby=_inc_xby
inx
//SEG25 [12] if((byte) main::i#1!=(byte/signed byte/word/signed word) 101) goto main::@1 [ main::j#4 main::i#1 ] ( main:2 [ main::j#4 main::i#1 ] ) -- xby_neq_coby1_then_la1
cpx #$65
bne b1
//SEG26 main::@return
//SEG27 [13] return [ ] ( main:2 [ ] )
rts
//SEG28 [14] phi from main::@1 to main::@6 [phi:main::@1->main::@6]
//SEG29 main::@6
b6:
//SEG30 [10] phi from main::@6 to main::@2 [phi:main::@6->main::@2]
//SEG31 [10] phi (byte) main::j#4 = (byte) main::j#1 [phi:main::@6->main::@2#0] -- register_copy
jmp b2
}
Removing instruction jmp b1
Succesful ASM optimization Pass5NextJumpElimination
ASSEMBLER
@ -1291,7 +1352,7 @@ main: {
iny
//SEG20 [9] if((byte) main::j#1!=(byte/signed byte/word/signed word) 8) goto main::@6 [ main::i#2 main::j#1 ] ( main:2 [ main::i#2 main::j#1 ] ) -- yby_neq_coby1_then_la1
cpy #8
bne b6
bne b2
//SEG21 [10] phi from main::@1 to main::@2 [phi:main::@1->main::@2]
//SEG22 [10] phi (byte) main::j#4 = (byte/signed byte/word/signed word) 0 [phi:main::@1->main::@2#0] -- yby=coby1
ldy #0
@ -1313,6 +1374,123 @@ main: {
jmp b2
}
Removing instruction b6:
Succesful ASM optimization Pass5UnusedLabelElimination
ASSEMBLER
//SEG0 Basic Upstart
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
//SEG1 Global Constants & labels
.const SCREEN = $400
TXT: .byte 3, 1, $d, 5, $c, $f, $14, $20
//SEG2 @begin
//SEG3 [1] phi from @begin to @1 [phi:@begin->@1]
//SEG4 @1
//SEG5 [2] call main param-assignment [ ] ( )
//SEG6 [4] phi from @1 to main [phi:@1->main]
jsr main
//SEG7 [3] phi from @1 to @end [phi:@1->@end]
//SEG8 @end
//SEG9 main
main: {
//SEG10 [5] phi from main to main::@1 [phi:main->main::@1]
//SEG11 [5] phi (byte) main::i#2 = (byte/signed byte/word/signed word) 0 [phi:main->main::@1#0] -- xby=coby1
ldx #0
//SEG12 [5] phi (byte) main::j#3 = (byte/signed byte/word/signed word) 0 [phi:main->main::@1#1] -- yby=coby1
ldy #0
//SEG13 [5] phi from main::@2 to main::@1 [phi:main::@2->main::@1]
//SEG14 [5] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@2->main::@1#0] -- register_copy
//SEG15 [5] phi (byte) main::j#3 = (byte) main::j#4 [phi:main::@2->main::@1#1] -- register_copy
//SEG16 main::@1
b1:
//SEG17 [6] (byte~) main::$0 ← (const byte[]) TXT#0 *idx (byte) main::j#3 [ main::j#3 main::i#2 main::$0 ] ( main:2 [ main::j#3 main::i#2 main::$0 ] ) -- aby=cowo1_derefidx_yby
lda TXT,y
//SEG18 [7] *((const byte*) SCREEN#0 + (byte) main::i#2) ← (byte~) main::$0 [ main::j#3 main::i#2 ] ( main:2 [ main::j#3 main::i#2 ] ) -- cowo1_derefidx_xby=aby
sta SCREEN,x
//SEG19 [8] (byte) main::j#1 ← ++ (byte) main::j#3 [ main::i#2 main::j#1 ] ( main:2 [ main::i#2 main::j#1 ] ) -- yby=_inc_yby
iny
//SEG20 [9] if((byte) main::j#1!=(byte/signed byte/word/signed word) 8) goto main::@6 [ main::i#2 main::j#1 ] ( main:2 [ main::i#2 main::j#1 ] ) -- yby_neq_coby1_then_la1
cpy #8
bne b2
//SEG21 [10] phi from main::@1 to main::@2 [phi:main::@1->main::@2]
//SEG22 [10] phi (byte) main::j#4 = (byte/signed byte/word/signed word) 0 [phi:main::@1->main::@2#0] -- yby=coby1
ldy #0
//SEG23 main::@2
b2:
//SEG24 [11] (byte) main::i#1 ← ++ (byte) main::i#2 [ main::j#4 main::i#1 ] ( main:2 [ main::j#4 main::i#1 ] ) -- xby=_inc_xby
inx
//SEG25 [12] if((byte) main::i#1!=(byte/signed byte/word/signed word) 101) goto main::@1 [ main::j#4 main::i#1 ] ( main:2 [ main::j#4 main::i#1 ] ) -- xby_neq_coby1_then_la1
cpx #$65
bne b1
//SEG26 main::@return
//SEG27 [13] return [ ] ( main:2 [ ] )
rts
//SEG28 [14] phi from main::@1 to main::@6 [phi:main::@1->main::@6]
//SEG29 main::@6
//SEG30 [10] phi from main::@6 to main::@2 [phi:main::@6->main::@2]
//SEG31 [10] phi (byte) main::j#4 = (byte) main::j#1 [phi:main::@6->main::@2#0] -- register_copy
jmp b2
}
Removing unreachable instruction jmp b2
Succesful ASM optimization Pass5AfterRtsElimination
ASSEMBLER
//SEG0 Basic Upstart
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
//SEG1 Global Constants & labels
.const SCREEN = $400
TXT: .byte 3, 1, $d, 5, $c, $f, $14, $20
//SEG2 @begin
//SEG3 [1] phi from @begin to @1 [phi:@begin->@1]
//SEG4 @1
//SEG5 [2] call main param-assignment [ ] ( )
//SEG6 [4] phi from @1 to main [phi:@1->main]
jsr main
//SEG7 [3] phi from @1 to @end [phi:@1->@end]
//SEG8 @end
//SEG9 main
main: {
//SEG10 [5] phi from main to main::@1 [phi:main->main::@1]
//SEG11 [5] phi (byte) main::i#2 = (byte/signed byte/word/signed word) 0 [phi:main->main::@1#0] -- xby=coby1
ldx #0
//SEG12 [5] phi (byte) main::j#3 = (byte/signed byte/word/signed word) 0 [phi:main->main::@1#1] -- yby=coby1
ldy #0
//SEG13 [5] phi from main::@2 to main::@1 [phi:main::@2->main::@1]
//SEG14 [5] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@2->main::@1#0] -- register_copy
//SEG15 [5] phi (byte) main::j#3 = (byte) main::j#4 [phi:main::@2->main::@1#1] -- register_copy
//SEG16 main::@1
b1:
//SEG17 [6] (byte~) main::$0 ← (const byte[]) TXT#0 *idx (byte) main::j#3 [ main::j#3 main::i#2 main::$0 ] ( main:2 [ main::j#3 main::i#2 main::$0 ] ) -- aby=cowo1_derefidx_yby
lda TXT,y
//SEG18 [7] *((const byte*) SCREEN#0 + (byte) main::i#2) ← (byte~) main::$0 [ main::j#3 main::i#2 ] ( main:2 [ main::j#3 main::i#2 ] ) -- cowo1_derefidx_xby=aby
sta SCREEN,x
//SEG19 [8] (byte) main::j#1 ← ++ (byte) main::j#3 [ main::i#2 main::j#1 ] ( main:2 [ main::i#2 main::j#1 ] ) -- yby=_inc_yby
iny
//SEG20 [9] if((byte) main::j#1!=(byte/signed byte/word/signed word) 8) goto main::@6 [ main::i#2 main::j#1 ] ( main:2 [ main::i#2 main::j#1 ] ) -- yby_neq_coby1_then_la1
cpy #8
bne b2
//SEG21 [10] phi from main::@1 to main::@2 [phi:main::@1->main::@2]
//SEG22 [10] phi (byte) main::j#4 = (byte/signed byte/word/signed word) 0 [phi:main::@1->main::@2#0] -- yby=coby1
ldy #0
//SEG23 main::@2
b2:
//SEG24 [11] (byte) main::i#1 ← ++ (byte) main::i#2 [ main::j#4 main::i#1 ] ( main:2 [ main::j#4 main::i#1 ] ) -- xby=_inc_xby
inx
//SEG25 [12] if((byte) main::i#1!=(byte/signed byte/word/signed word) 101) goto main::@1 [ main::j#4 main::i#1 ] ( main:2 [ main::j#4 main::i#1 ] ) -- xby_neq_coby1_then_la1
cpx #$65
bne b1
//SEG26 main::@return
//SEG27 [13] return [ ] ( main:2 [ ] )
rts
//SEG28 [14] phi from main::@1 to main::@6 [phi:main::@1->main::@6]
//SEG29 main::@6
//SEG30 [10] phi from main::@6 to main::@2 [phi:main::@6->main::@2]
//SEG31 [10] phi (byte) main::j#4 = (byte) main::j#1 [phi:main::@6->main::@2#0] -- register_copy
}
FINAL SYMBOL TABLE
(label) @1
(label) @begin
@ -1375,7 +1553,7 @@ main: {
iny
//SEG20 [9] if((byte) main::j#1!=(byte/signed byte/word/signed word) 8) goto main::@6 [ main::i#2 main::j#1 ] ( main:2 [ main::i#2 main::j#1 ] ) -- yby_neq_coby1_then_la1
cpy #8
bne b6
bne b2
//SEG21 [10] phi from main::@1 to main::@2 [phi:main::@1->main::@2]
//SEG22 [10] phi (byte) main::j#4 = (byte/signed byte/word/signed word) 0 [phi:main::@1->main::@2#0] -- yby=coby1
ldy #0
@ -1391,9 +1569,7 @@ main: {
rts
//SEG28 [14] phi from main::@1 to main::@6 [phi:main::@1->main::@6]
//SEG29 main::@6
b6:
//SEG30 [10] phi from main::@6 to main::@2 [phi:main::@6->main::@2]
//SEG31 [10] phi (byte) main::j#4 = (byte) main::j#1 [phi:main::@6->main::@2#0] -- register_copy
jmp b2
}

View File

@ -17,7 +17,7 @@ main: {
sta (cursor),y
inx
cpx #8
bne b6
bne b2
ldx #0
b2:
inc cursor
@ -33,6 +33,4 @@ main: {
bcc b1
!:
rts
b6:
jmp b2
}

View File

@ -1366,6 +1366,81 @@ main: {
jmp b2
}
Skipping double jump to b2 in bne b6
Succesful ASM optimization Pass5DoubleJumpElimination
ASSEMBLER
//SEG0 Basic Upstart
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
//SEG1 Global Constants & labels
.const SCREEN = $400
TEXT: .text "camelot "
//SEG2 @begin
//SEG3 [1] phi from @begin to @1 [phi:@begin->@1]
//SEG4 @1
//SEG5 [2] call main param-assignment [ ] ( )
//SEG6 [4] phi from @1 to main [phi:@1->main]
jsr main
//SEG7 [3] phi from @1 to @end [phi:@1->@end]
//SEG8 @end
//SEG9 main
main: {
.label cursor = 2
//SEG10 [5] phi from main to main::@1 [phi:main->main::@1]
//SEG11 [5] phi (byte*) main::cursor#2 = (const byte*) SCREEN#0 [phi:main->main::@1#0] -- zpptrby1=cowo1
lda #<SCREEN
sta cursor
lda #>SCREEN
sta cursor+1
//SEG12 [5] phi (byte) main::i#3 = (byte/signed byte/word/signed word) 0 [phi:main->main::@1#1] -- xby=coby1
ldx #0
jmp b1
//SEG13 [5] phi from main::@2 to main::@1 [phi:main::@2->main::@1]
//SEG14 [5] phi (byte*) main::cursor#2 = (byte*) main::cursor#1 [phi:main::@2->main::@1#0] -- register_copy
//SEG15 [5] phi (byte) main::i#3 = (byte) main::i#4 [phi:main::@2->main::@1#1] -- register_copy
//SEG16 main::@1
b1:
//SEG17 [6] (byte~) main::$0 ← (const byte[]) TEXT#0 *idx (byte) main::i#3 [ main::i#3 main::cursor#2 main::$0 ] ( main:2 [ main::i#3 main::cursor#2 main::$0 ] ) -- aby=cowo1_derefidx_xby
lda TEXT,x
//SEG18 [7] *((byte*) main::cursor#2) ← (byte~) main::$0 [ main::i#3 main::cursor#2 ] ( main:2 [ main::i#3 main::cursor#2 ] ) -- _deref_zpptrby1=aby
ldy #0
sta (cursor),y
//SEG19 [8] (byte) main::i#1 ← ++ (byte) main::i#3 [ main::cursor#2 main::i#1 ] ( main:2 [ main::cursor#2 main::i#1 ] ) -- xby=_inc_xby
inx
//SEG20 [9] if((byte) main::i#1!=(byte/signed byte/word/signed word) 8) goto main::@6 [ main::cursor#2 main::i#1 ] ( main:2 [ main::cursor#2 main::i#1 ] ) -- xby_neq_coby1_then_la1
cpx #8
bne b2
//SEG21 [10] phi from main::@1 to main::@2 [phi:main::@1->main::@2]
//SEG22 [10] phi (byte) main::i#4 = (byte/signed byte/word/signed word) 0 [phi:main::@1->main::@2#0] -- xby=coby1
ldx #0
//SEG23 main::@2
b2:
//SEG24 [11] (byte*) main::cursor#1 ← ++ (byte*) main::cursor#2 [ main::i#4 main::cursor#1 ] ( main:2 [ main::i#4 main::cursor#1 ] ) -- zpptrby1=_inc_zpptrby1
inc cursor
bne !+
inc cursor+1
!:
//SEG25 [12] if((byte*) main::cursor#1<(const byte*) SCREEN#0+(word/signed word) 1000) goto main::@1 [ main::i#4 main::cursor#1 ] ( main:2 [ main::i#4 main::cursor#1 ] ) -- zpptrby1_lt_cowo1_then_la1
lda cursor+1
cmp #>SCREEN+$3e8
bcc b1
bne !+
lda cursor
cmp #<SCREEN+$3e8
bcc b1
!:
//SEG26 main::@return
//SEG27 [13] return [ ] ( main:2 [ ] )
rts
//SEG28 [14] phi from main::@1 to main::@6 [phi:main::@1->main::@6]
//SEG29 main::@6
b6:
//SEG30 [10] phi from main::@6 to main::@2 [phi:main::@6->main::@2]
//SEG31 [10] phi (byte) main::i#4 = (byte) main::i#1 [phi:main::@6->main::@2#0] -- register_copy
jmp b2
}
Removing instruction jmp b1
Succesful ASM optimization Pass5NextJumpElimination
ASSEMBLER
@ -1409,7 +1484,7 @@ main: {
inx
//SEG20 [9] if((byte) main::i#1!=(byte/signed byte/word/signed word) 8) goto main::@6 [ main::cursor#2 main::i#1 ] ( main:2 [ main::cursor#2 main::i#1 ] ) -- xby_neq_coby1_then_la1
cpx #8
bne b6
bne b2
//SEG21 [10] phi from main::@1 to main::@2 [phi:main::@1->main::@2]
//SEG22 [10] phi (byte) main::i#4 = (byte/signed byte/word/signed word) 0 [phi:main::@1->main::@2#0] -- xby=coby1
ldx #0
@ -1440,6 +1515,151 @@ main: {
jmp b2
}
Removing instruction b6:
Succesful ASM optimization Pass5UnusedLabelElimination
ASSEMBLER
//SEG0 Basic Upstart
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
//SEG1 Global Constants & labels
.const SCREEN = $400
TEXT: .text "camelot "
//SEG2 @begin
//SEG3 [1] phi from @begin to @1 [phi:@begin->@1]
//SEG4 @1
//SEG5 [2] call main param-assignment [ ] ( )
//SEG6 [4] phi from @1 to main [phi:@1->main]
jsr main
//SEG7 [3] phi from @1 to @end [phi:@1->@end]
//SEG8 @end
//SEG9 main
main: {
.label cursor = 2
//SEG10 [5] phi from main to main::@1 [phi:main->main::@1]
//SEG11 [5] phi (byte*) main::cursor#2 = (const byte*) SCREEN#0 [phi:main->main::@1#0] -- zpptrby1=cowo1
lda #<SCREEN
sta cursor
lda #>SCREEN
sta cursor+1
//SEG12 [5] phi (byte) main::i#3 = (byte/signed byte/word/signed word) 0 [phi:main->main::@1#1] -- xby=coby1
ldx #0
//SEG13 [5] phi from main::@2 to main::@1 [phi:main::@2->main::@1]
//SEG14 [5] phi (byte*) main::cursor#2 = (byte*) main::cursor#1 [phi:main::@2->main::@1#0] -- register_copy
//SEG15 [5] phi (byte) main::i#3 = (byte) main::i#4 [phi:main::@2->main::@1#1] -- register_copy
//SEG16 main::@1
b1:
//SEG17 [6] (byte~) main::$0 ← (const byte[]) TEXT#0 *idx (byte) main::i#3 [ main::i#3 main::cursor#2 main::$0 ] ( main:2 [ main::i#3 main::cursor#2 main::$0 ] ) -- aby=cowo1_derefidx_xby
lda TEXT,x
//SEG18 [7] *((byte*) main::cursor#2) ← (byte~) main::$0 [ main::i#3 main::cursor#2 ] ( main:2 [ main::i#3 main::cursor#2 ] ) -- _deref_zpptrby1=aby
ldy #0
sta (cursor),y
//SEG19 [8] (byte) main::i#1 ← ++ (byte) main::i#3 [ main::cursor#2 main::i#1 ] ( main:2 [ main::cursor#2 main::i#1 ] ) -- xby=_inc_xby
inx
//SEG20 [9] if((byte) main::i#1!=(byte/signed byte/word/signed word) 8) goto main::@6 [ main::cursor#2 main::i#1 ] ( main:2 [ main::cursor#2 main::i#1 ] ) -- xby_neq_coby1_then_la1
cpx #8
bne b2
//SEG21 [10] phi from main::@1 to main::@2 [phi:main::@1->main::@2]
//SEG22 [10] phi (byte) main::i#4 = (byte/signed byte/word/signed word) 0 [phi:main::@1->main::@2#0] -- xby=coby1
ldx #0
//SEG23 main::@2
b2:
//SEG24 [11] (byte*) main::cursor#1 ← ++ (byte*) main::cursor#2 [ main::i#4 main::cursor#1 ] ( main:2 [ main::i#4 main::cursor#1 ] ) -- zpptrby1=_inc_zpptrby1
inc cursor
bne !+
inc cursor+1
!:
//SEG25 [12] if((byte*) main::cursor#1<(const byte*) SCREEN#0+(word/signed word) 1000) goto main::@1 [ main::i#4 main::cursor#1 ] ( main:2 [ main::i#4 main::cursor#1 ] ) -- zpptrby1_lt_cowo1_then_la1
lda cursor+1
cmp #>SCREEN+$3e8
bcc b1
bne !+
lda cursor
cmp #<SCREEN+$3e8
bcc b1
!:
//SEG26 main::@return
//SEG27 [13] return [ ] ( main:2 [ ] )
rts
//SEG28 [14] phi from main::@1 to main::@6 [phi:main::@1->main::@6]
//SEG29 main::@6
//SEG30 [10] phi from main::@6 to main::@2 [phi:main::@6->main::@2]
//SEG31 [10] phi (byte) main::i#4 = (byte) main::i#1 [phi:main::@6->main::@2#0] -- register_copy
jmp b2
}
Removing unreachable instruction jmp b2
Succesful ASM optimization Pass5AfterRtsElimination
ASSEMBLER
//SEG0 Basic Upstart
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
//SEG1 Global Constants & labels
.const SCREEN = $400
TEXT: .text "camelot "
//SEG2 @begin
//SEG3 [1] phi from @begin to @1 [phi:@begin->@1]
//SEG4 @1
//SEG5 [2] call main param-assignment [ ] ( )
//SEG6 [4] phi from @1 to main [phi:@1->main]
jsr main
//SEG7 [3] phi from @1 to @end [phi:@1->@end]
//SEG8 @end
//SEG9 main
main: {
.label cursor = 2
//SEG10 [5] phi from main to main::@1 [phi:main->main::@1]
//SEG11 [5] phi (byte*) main::cursor#2 = (const byte*) SCREEN#0 [phi:main->main::@1#0] -- zpptrby1=cowo1
lda #<SCREEN
sta cursor
lda #>SCREEN
sta cursor+1
//SEG12 [5] phi (byte) main::i#3 = (byte/signed byte/word/signed word) 0 [phi:main->main::@1#1] -- xby=coby1
ldx #0
//SEG13 [5] phi from main::@2 to main::@1 [phi:main::@2->main::@1]
//SEG14 [5] phi (byte*) main::cursor#2 = (byte*) main::cursor#1 [phi:main::@2->main::@1#0] -- register_copy
//SEG15 [5] phi (byte) main::i#3 = (byte) main::i#4 [phi:main::@2->main::@1#1] -- register_copy
//SEG16 main::@1
b1:
//SEG17 [6] (byte~) main::$0 ← (const byte[]) TEXT#0 *idx (byte) main::i#3 [ main::i#3 main::cursor#2 main::$0 ] ( main:2 [ main::i#3 main::cursor#2 main::$0 ] ) -- aby=cowo1_derefidx_xby
lda TEXT,x
//SEG18 [7] *((byte*) main::cursor#2) ← (byte~) main::$0 [ main::i#3 main::cursor#2 ] ( main:2 [ main::i#3 main::cursor#2 ] ) -- _deref_zpptrby1=aby
ldy #0
sta (cursor),y
//SEG19 [8] (byte) main::i#1 ← ++ (byte) main::i#3 [ main::cursor#2 main::i#1 ] ( main:2 [ main::cursor#2 main::i#1 ] ) -- xby=_inc_xby
inx
//SEG20 [9] if((byte) main::i#1!=(byte/signed byte/word/signed word) 8) goto main::@6 [ main::cursor#2 main::i#1 ] ( main:2 [ main::cursor#2 main::i#1 ] ) -- xby_neq_coby1_then_la1
cpx #8
bne b2
//SEG21 [10] phi from main::@1 to main::@2 [phi:main::@1->main::@2]
//SEG22 [10] phi (byte) main::i#4 = (byte/signed byte/word/signed word) 0 [phi:main::@1->main::@2#0] -- xby=coby1
ldx #0
//SEG23 main::@2
b2:
//SEG24 [11] (byte*) main::cursor#1 ← ++ (byte*) main::cursor#2 [ main::i#4 main::cursor#1 ] ( main:2 [ main::i#4 main::cursor#1 ] ) -- zpptrby1=_inc_zpptrby1
inc cursor
bne !+
inc cursor+1
!:
//SEG25 [12] if((byte*) main::cursor#1<(const byte*) SCREEN#0+(word/signed word) 1000) goto main::@1 [ main::i#4 main::cursor#1 ] ( main:2 [ main::i#4 main::cursor#1 ] ) -- zpptrby1_lt_cowo1_then_la1
lda cursor+1
cmp #>SCREEN+$3e8
bcc b1
bne !+
lda cursor
cmp #<SCREEN+$3e8
bcc b1
!:
//SEG26 main::@return
//SEG27 [13] return [ ] ( main:2 [ ] )
rts
//SEG28 [14] phi from main::@1 to main::@6 [phi:main::@1->main::@6]
//SEG29 main::@6
//SEG30 [10] phi from main::@6 to main::@2 [phi:main::@6->main::@2]
//SEG31 [10] phi (byte) main::i#4 = (byte) main::i#1 [phi:main::@6->main::@2#0] -- register_copy
}
FINAL SYMBOL TABLE
(label) @1
(label) @begin
@ -1507,7 +1727,7 @@ main: {
inx
//SEG20 [9] if((byte) main::i#1!=(byte/signed byte/word/signed word) 8) goto main::@6 [ main::cursor#2 main::i#1 ] ( main:2 [ main::cursor#2 main::i#1 ] ) -- xby_neq_coby1_then_la1
cpx #8
bne b6
bne b2
//SEG21 [10] phi from main::@1 to main::@2 [phi:main::@1->main::@2]
//SEG22 [10] phi (byte) main::i#4 = (byte/signed byte/word/signed word) 0 [phi:main::@1->main::@2#0] -- xby=coby1
ldx #0
@ -1532,9 +1752,7 @@ main: {
rts
//SEG28 [14] phi from main::@1 to main::@6 [phi:main::@1->main::@6]
//SEG29 main::@6
b6:
//SEG30 [10] phi from main::@6 to main::@2 [phi:main::@6->main::@2]
//SEG31 [10] phi (byte) main::i#4 = (byte) main::i#1 [phi:main::@6->main::@2#0] -- register_copy
jmp b2
}

View File

@ -15,9 +15,8 @@ main: {
bcc b4
beq b4
iny
b1_from_b8:
jmp b1
b4:
dey
jmp b1_from_b8
jmp b1
}

View File

@ -994,6 +994,113 @@ main: {
jmp b1_from_b8
}
Skipping double jump to b1 in jmp b1_from_b8
Succesful ASM optimization Pass5DoubleJumpElimination
ASSEMBLER
//SEG0 Basic Upstart
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
//SEG1 Global Constants & labels
//SEG2 @begin
//SEG3 [1] phi from @begin to @1 [phi:@begin->@1]
//SEG4 @1
//SEG5 [2] call main param-assignment [ ] ( )
//SEG6 [4] phi from @1 to main [phi:@1->main]
jsr main
//SEG7 [3] phi from @1 to @end [phi:@1->@end]
//SEG8 @end
//SEG9 main
main: {
//SEG10 [5] phi from main to main::@1 [phi:main->main::@1]
//SEG11 [5] phi (byte) main::s#3 = (byte/signed byte/word/signed word) 0 [phi:main->main::@1#0] -- yby=coby1
ldy #0
//SEG12 [5] phi (byte) main::i#2 = (byte/signed byte/word/signed word) 100 [phi:main->main::@1#1] -- xby=coby1
ldx #$64
//SEG13 main::@1
b1:
//SEG14 [6] (byte) main::i#1 ← -- (byte) main::i#2 [ main::s#3 main::i#1 ] ( main:2 [ main::s#3 main::i#1 ] ) -- xby=_dec_xby
dex
//SEG15 [7] if((byte) main::i#1>(byte/signed byte/word/signed word) 0) goto main::@2 [ main::s#3 main::i#1 ] ( main:2 [ main::s#3 main::i#1 ] ) -- xby_gt_0_then_la1
cpx #0
bne b2
//SEG16 main::@return
//SEG17 [8] return [ ] ( main:2 [ ] )
rts
//SEG18 main::@2
b2:
//SEG19 [9] if((byte) main::i#1<=(byte/signed byte/word/signed word) 50) goto main::@4 [ main::s#3 main::i#1 ] ( main:2 [ main::s#3 main::i#1 ] ) -- xby_le_coby1_then_la1
cpx #$32
bcc b4
beq b4
//SEG20 main::@8
//SEG21 [10] (byte) main::s#2 ← ++ (byte) main::s#3 [ main::i#1 main::s#2 ] ( main:2 [ main::i#1 main::s#2 ] ) -- yby=_inc_yby
iny
//SEG22 [5] phi from main::@4 main::@8 to main::@1 [phi:main::@4/main::@8->main::@1]
b1_from_b8:
//SEG23 [5] phi (byte) main::s#3 = (byte) main::s#1 [phi:main::@4/main::@8->main::@1#0] -- register_copy
//SEG24 [5] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@4/main::@8->main::@1#1] -- register_copy
jmp b1
//SEG25 main::@4
b4:
//SEG26 [11] (byte) main::s#1 ← -- (byte) main::s#3 [ main::i#1 main::s#1 ] ( main:2 [ main::i#1 main::s#1 ] ) -- yby=_dec_yby
dey
jmp b1
}
Removing instruction b1_from_b8:
Succesful ASM optimization Pass5UnusedLabelElimination
ASSEMBLER
//SEG0 Basic Upstart
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
//SEG1 Global Constants & labels
//SEG2 @begin
//SEG3 [1] phi from @begin to @1 [phi:@begin->@1]
//SEG4 @1
//SEG5 [2] call main param-assignment [ ] ( )
//SEG6 [4] phi from @1 to main [phi:@1->main]
jsr main
//SEG7 [3] phi from @1 to @end [phi:@1->@end]
//SEG8 @end
//SEG9 main
main: {
//SEG10 [5] phi from main to main::@1 [phi:main->main::@1]
//SEG11 [5] phi (byte) main::s#3 = (byte/signed byte/word/signed word) 0 [phi:main->main::@1#0] -- yby=coby1
ldy #0
//SEG12 [5] phi (byte) main::i#2 = (byte/signed byte/word/signed word) 100 [phi:main->main::@1#1] -- xby=coby1
ldx #$64
//SEG13 main::@1
b1:
//SEG14 [6] (byte) main::i#1 ← -- (byte) main::i#2 [ main::s#3 main::i#1 ] ( main:2 [ main::s#3 main::i#1 ] ) -- xby=_dec_xby
dex
//SEG15 [7] if((byte) main::i#1>(byte/signed byte/word/signed word) 0) goto main::@2 [ main::s#3 main::i#1 ] ( main:2 [ main::s#3 main::i#1 ] ) -- xby_gt_0_then_la1
cpx #0
bne b2
//SEG16 main::@return
//SEG17 [8] return [ ] ( main:2 [ ] )
rts
//SEG18 main::@2
b2:
//SEG19 [9] if((byte) main::i#1<=(byte/signed byte/word/signed word) 50) goto main::@4 [ main::s#3 main::i#1 ] ( main:2 [ main::s#3 main::i#1 ] ) -- xby_le_coby1_then_la1
cpx #$32
bcc b4
beq b4
//SEG20 main::@8
//SEG21 [10] (byte) main::s#2 ← ++ (byte) main::s#3 [ main::i#1 main::s#2 ] ( main:2 [ main::i#1 main::s#2 ] ) -- yby=_inc_yby
iny
//SEG22 [5] phi from main::@4 main::@8 to main::@1 [phi:main::@4/main::@8->main::@1]
//SEG23 [5] phi (byte) main::s#3 = (byte) main::s#1 [phi:main::@4/main::@8->main::@1#0] -- register_copy
//SEG24 [5] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@4/main::@8->main::@1#1] -- register_copy
jmp b1
//SEG25 main::@4
b4:
//SEG26 [11] (byte) main::s#1 ← -- (byte) main::s#3 [ main::i#1 main::s#1 ] ( main:2 [ main::i#1 main::s#1 ] ) -- yby=_dec_yby
dey
jmp b1
}
FINAL SYMBOL TABLE
(label) @1
(label) @begin
@ -1056,7 +1163,6 @@ main: {
//SEG21 [10] (byte) main::s#2 ← ++ (byte) main::s#3 [ main::i#1 main::s#2 ] ( main:2 [ main::i#1 main::s#2 ] ) -- yby=_inc_yby
iny
//SEG22 [5] phi from main::@4 main::@8 to main::@1 [phi:main::@4/main::@8->main::@1]
b1_from_b8:
//SEG23 [5] phi (byte) main::s#3 = (byte) main::s#1 [phi:main::@4/main::@8->main::@1#0] -- register_copy
//SEG24 [5] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@4/main::@8->main::@1#1] -- register_copy
jmp b1
@ -1064,6 +1170,6 @@ main: {
b4:
//SEG26 [11] (byte) main::s#1 ← -- (byte) main::s#3 [ main::i#1 main::s#1 ] ( main:2 [ main::i#1 main::s#1 ] ) -- yby=_dec_yby
dey
jmp b1_from_b8
jmp b1
}

View File

@ -30,11 +30,6 @@ void print_ln() {
char_cursor = line_cursor;
}
Adding pre/post-modifier (byte*) char_cursor ← ++ (byte*) char_cursor
Adding pre/post-modifier (byte*) print_str::str ← ++ (byte*) print_str::str
PROGRAM

View File

@ -32,5 +32,4 @@ main: {
inc nxt+1
!:
jmp b1
rts
}

View File

@ -1406,6 +1406,81 @@ main: {
rts
}
Removing unreachable instruction rts
Succesful ASM optimization Pass5AfterRtsElimination
ASSEMBLER
//SEG0 Basic Upstart
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
//SEG1 Global Constants & labels
.const SCREEN = $400
.const SCROLL = $d016
TEXT: .text "01234567@"
//SEG2 @begin
//SEG3 [1] phi from @begin to @1 [phi:@begin->@1]
//SEG4 @1
//SEG5 [2] call main param-assignment [ ] ( )
//SEG6 [4] phi from @1 to main [phi:@1->main]
jsr main
//SEG7 [3] phi from @1 to @end [phi:@1->@end]
//SEG8 @end
//SEG9 main
main: {
.label nxt = 2
//SEG10 [5] phi from main to main::@1 [phi:main->main::@1]
//SEG11 [5] phi (byte) main::i#2 = (byte/signed byte/word/signed word) 0 [phi:main->main::@1#0] -- xby=coby1
ldx #0
//SEG12 [5] phi (byte*) main::nxt#3 = (const byte[]) TEXT#0 [phi:main->main::@1#1] -- zpptrby1=cowo1
lda #<TEXT
sta nxt
lda #>TEXT
sta nxt+1
jmp b1
//SEG13 [5] phi from main::@2 to main::@1 [phi:main::@2->main::@1]
//SEG14 [5] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@2->main::@1#0] -- register_copy
//SEG15 [5] phi (byte*) main::nxt#3 = (byte*) main::nxt#1 [phi:main::@2->main::@1#1] -- register_copy
//SEG16 main::@1
b1:
//SEG17 [6] (byte) main::c#0 ← *((byte*) main::nxt#3) [ main::nxt#3 main::i#2 main::c#0 ] ( main:2 [ main::nxt#3 main::i#2 main::c#0 ] ) -- yby=_deref_zpptrby1
ldy #0
lda (nxt),y
tay
//SEG18 [7] if((byte) main::c#0!=(byte) '@') goto main::@2 [ main::nxt#3 main::i#2 main::c#0 ] ( main:2 [ main::nxt#3 main::i#2 main::c#0 ] ) -- yby_neq_coby1_then_la1
cpy #'@'
bne b2
//SEG19 main::@3
//SEG20 [8] (byte) main::c#1 ← *((const byte[]) TEXT#0) [ main::i#2 main::c#1 ] ( main:2 [ main::i#2 main::c#1 ] ) -- yby=_deref_cowo1
ldy TEXT
//SEG21 [9] phi from main::@3 to main::@2 [phi:main::@3->main::@2]
//SEG22 [9] phi (byte*) main::nxt#4 = (const byte[]) TEXT#0 [phi:main::@3->main::@2#0] -- zpptrby1=cowo1
lda #<TEXT
sta nxt
lda #>TEXT
sta nxt+1
//SEG23 [9] phi (byte) main::c#2 = (byte) main::c#1 [phi:main::@3->main::@2#1] -- register_copy
jmp b2
//SEG24 [9] phi from main::@1 to main::@2 [phi:main::@1->main::@2]
//SEG25 [9] phi (byte*) main::nxt#4 = (byte*) main::nxt#3 [phi:main::@1->main::@2#0] -- register_copy
//SEG26 [9] phi (byte) main::c#2 = (byte) main::c#0 [phi:main::@1->main::@2#1] -- register_copy
//SEG27 main::@2
b2:
//SEG28 [10] (byte) main::i#1 ← ++ (byte) main::i#2 [ main::i#1 main::c#2 main::nxt#4 ] ( main:2 [ main::i#1 main::c#2 main::nxt#4 ] ) -- xby=_inc_xby
inx
//SEG29 [11] *((const byte*) SCREEN#0 + (byte) main::i#1) ← (byte) main::c#2 [ main::i#1 main::nxt#4 ] ( main:2 [ main::i#1 main::nxt#4 ] ) -- cowo1_derefidx_xby=yby
tya
sta SCREEN,x
//SEG30 [12] (byte*) main::nxt#1 ← ++ (byte*) main::nxt#4 [ main::nxt#1 main::i#1 ] ( main:2 [ main::nxt#1 main::i#1 ] ) -- zpptrby1=_inc_zpptrby1
inc nxt
bne !+
inc nxt+1
!:
//SEG31 [13] if(true) goto main::@1 [ main::nxt#1 main::i#1 ] ( main:2 [ main::nxt#1 main::i#1 ] ) -- true_then_la1
jmp b1
//SEG32 main::@return
//SEG33 [14] return [ ] ( main:2 [ ] )
}
Removing instruction jmp b1
Removing instruction jmp b2
Succesful ASM optimization Pass5NextJumpElimination
@ -1478,7 +1553,6 @@ main: {
jmp b1
//SEG32 main::@return
//SEG33 [14] return [ ] ( main:2 [ ] )
rts
}
FINAL SYMBOL TABLE
@ -1581,6 +1655,5 @@ main: {
jmp b1
//SEG32 main::@return
//SEG33 [14] return [ ] ( main:2 [ ] )
rts
}

View File

@ -56,7 +56,6 @@ main: {
stx SCROLL
dec BGCOL
jmp b2
rts
}
fillscreen: {
.const fill = $20

View File

@ -4275,6 +4275,343 @@ fillscreen: {
rts
}
Skipping double jump to b2 in bne b2_from_b2
Succesful ASM optimization Pass5DoubleJumpElimination
ASSEMBLER
//SEG0 Basic Upstart
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
//SEG1 Global Constants & labels
.const SCREEN = $400
.const RASTER = $d012
.const BGCOL = $d020
.const SCROLL = $d016
TEXT: .text "-= this is rex of camelot testing a scroller created in kickc. kickc is an optimizing c-compiler for 6502 assembler. =- @"
//SEG2 @begin
//SEG3 [1] phi from @begin to @2 [phi:@begin->@2]
//SEG4 @2
//SEG5 [2] call main param-assignment [ ] ( )
//SEG6 [4] phi from @2 to main [phi:@2->main]
jsr main
//SEG7 [3] phi from @2 to @end [phi:@2->@end]
//SEG8 @end
//SEG9 main
main: {
.const line = SCREEN+$28
.label nxt = 2
//SEG10 [5] call fillscreen param-assignment [ ] ( main:2 [ ] )
//SEG11 [28] phi from main to fillscreen [phi:main->fillscreen]
jsr fillscreen
//SEG12 [6] phi from main to main::@2 [phi:main->main::@2]
//SEG13 [6] phi (byte*) main::nxt#9 = (const byte*) TEXT#0 [phi:main->main::@2#0] -- zpptrby1=cowo1
lda #<TEXT
sta nxt
lda #>TEXT
sta nxt+1
//SEG14 [6] phi (byte) main::scroll#7 = (byte/signed byte/word/signed word) 7 [phi:main->main::@2#1] -- xby=coby1
ldx #7
jmp b2
//SEG15 [6] phi from main::@2 to main::@2 [phi:main::@2->main::@2]
b2_from_b2:
jmp b2
//SEG16 [6] phi from main::@4 to main::@2 [phi:main::@4->main::@2]
//SEG17 [6] phi (byte*) main::nxt#9 = (byte*) main::nxt#10 [phi:main::@4->main::@2#0] -- register_copy
//SEG18 [6] phi (byte) main::scroll#7 = (byte) main::scroll#10 [phi:main::@4->main::@2#1] -- register_copy
//SEG19 main::@2
b2:
//SEG20 [7] if(*((const byte*) RASTER#0)!=(byte/word/signed word) 254) goto main::@2 [ main::scroll#7 main::nxt#9 ] ( main:2 [ main::scroll#7 main::nxt#9 ] ) -- _deref_cowo1_neq_coby2_then_la1
lda RASTER
cmp #$fe
bne b2
//SEG21 main::@3
b3:
//SEG22 [8] if(*((const byte*) RASTER#0)!=(byte/word/signed word) 255) goto main::@3 [ main::scroll#7 main::nxt#9 ] ( main:2 [ main::scroll#7 main::nxt#9 ] ) -- _deref_cowo1_neq_coby2_then_la1
lda RASTER
cmp #$ff
bne b3
//SEG23 main::@8
//SEG24 [9] *((const byte*) BGCOL#0) ← ++ *((const byte*) BGCOL#0) [ main::scroll#7 main::nxt#9 ] ( main:2 [ main::scroll#7 main::nxt#9 ] ) -- _deref_cowo1=_inc__deref_cowo1
inc BGCOL
//SEG25 [10] (byte) main::scroll#1 ← -- (byte) main::scroll#7 [ main::nxt#9 main::scroll#1 ] ( main:2 [ main::nxt#9 main::scroll#1 ] ) -- xby=_dec_xby
dex
//SEG26 [11] if((byte) main::scroll#1!=(byte/word/signed word) 255) goto main::@4 [ main::nxt#9 main::scroll#1 ] ( main:2 [ main::nxt#9 main::scroll#1 ] ) -- xby_neq_coby1_then_la1
cpx #$ff
bne b4
//SEG27 [12] phi from main::@8 to main::@5 [phi:main::@8->main::@5]
//SEG28 [12] phi (byte) main::i#2 = (byte/signed byte/word/signed word) 0 [phi:main::@8->main::@5#0] -- xby=coby1
ldx #0
jmp b5
//SEG29 [12] phi from main::@5 to main::@5 [phi:main::@5->main::@5]
//SEG30 [12] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@5->main::@5#0] -- register_copy
//SEG31 main::@5
b5:
//SEG32 [13] (byte~) main::$7 ← (const byte[]) main::line#0+(byte/signed byte/word/signed word) 1 *idx (byte) main::i#2 [ main::nxt#9 main::i#2 main::$7 ] ( main:2 [ main::nxt#9 main::i#2 main::$7 ] ) -- aby=cowo1_derefidx_xby
lda line+1,x
//SEG33 [14] *((const byte[]) main::line#0 + (byte) main::i#2) ← (byte~) main::$7 [ main::nxt#9 main::i#2 ] ( main:2 [ main::nxt#9 main::i#2 ] ) -- cowo1_derefidx_xby=aby
sta line,x
//SEG34 [15] (byte) main::i#1 ← ++ (byte) main::i#2 [ main::nxt#9 main::i#1 ] ( main:2 [ main::nxt#9 main::i#1 ] ) -- xby=_inc_xby
inx
//SEG35 [16] if((byte) main::i#1!=(byte/signed byte/word/signed word) 39) goto main::@5 [ main::nxt#9 main::i#1 ] ( main:2 [ main::nxt#9 main::i#1 ] ) -- xby_neq_coby1_then_la1
cpx #$27
bne b5
//SEG36 main::@10
//SEG37 [17] (byte) main::c#0 ← *((byte*) main::nxt#9) [ main::nxt#9 main::c#0 ] ( main:2 [ main::nxt#9 main::c#0 ] ) -- xby=_deref_zpptrby1
ldy #0
lda (nxt),y
tax
//SEG38 [18] if((byte) main::c#0!=(byte) '@') goto main::@6 [ main::nxt#9 main::c#0 ] ( main:2 [ main::nxt#9 main::c#0 ] ) -- xby_neq_coby1_then_la1
cpx #'@'
bne b6
//SEG39 main::@11
//SEG40 [19] (byte) main::c#1 ← *((const byte*) TEXT#0) [ main::c#1 ] ( main:2 [ main::c#1 ] ) -- xby=_deref_cowo1
ldx TEXT
//SEG41 [20] phi from main::@11 to main::@6 [phi:main::@11->main::@6]
//SEG42 [20] phi (byte*) main::nxt#4 = (const byte*) TEXT#0 [phi:main::@11->main::@6#0] -- zpptrby1=cowo1
lda #<TEXT
sta nxt
lda #>TEXT
sta nxt+1
//SEG43 [20] phi (byte) main::c#2 = (byte) main::c#1 [phi:main::@11->main::@6#1] -- register_copy
jmp b6
//SEG44 [20] phi from main::@10 to main::@6 [phi:main::@10->main::@6]
//SEG45 [20] phi (byte*) main::nxt#4 = (byte*) main::nxt#9 [phi:main::@10->main::@6#0] -- register_copy
//SEG46 [20] phi (byte) main::c#2 = (byte) main::c#0 [phi:main::@10->main::@6#1] -- register_copy
//SEG47 main::@6
b6:
//SEG48 [21] *((const byte[]) main::line#0+(byte/signed byte/word/signed word) 39) ← (byte) main::c#2 [ main::nxt#4 ] ( main:2 [ main::nxt#4 ] ) -- _deref_cowo1=xby
stx line+$27
//SEG49 [22] (byte*) main::nxt#1 ← ++ (byte*) main::nxt#4 [ main::nxt#1 ] ( main:2 [ main::nxt#1 ] ) -- zpptrby1=_inc_zpptrby1
inc nxt
bne !+
inc nxt+1
!:
//SEG50 [23] phi from main::@6 to main::@4 [phi:main::@6->main::@4]
//SEG51 [23] phi (byte*) main::nxt#10 = (byte*) main::nxt#1 [phi:main::@6->main::@4#0] -- register_copy
//SEG52 [23] phi (byte) main::scroll#10 = (byte/signed byte/word/signed word) 7 [phi:main::@6->main::@4#1] -- xby=coby1
ldx #7
jmp b4
//SEG53 [23] phi from main::@8 to main::@4 [phi:main::@8->main::@4]
//SEG54 [23] phi (byte*) main::nxt#10 = (byte*) main::nxt#9 [phi:main::@8->main::@4#0] -- register_copy
//SEG55 [23] phi (byte) main::scroll#10 = (byte) main::scroll#1 [phi:main::@8->main::@4#1] -- register_copy
//SEG56 main::@4
b4:
//SEG57 [24] *((const byte*) SCROLL#0) ← (byte) main::scroll#10 [ main::scroll#10 main::nxt#10 ] ( main:2 [ main::scroll#10 main::nxt#10 ] ) -- _deref_cowo1=xby
stx SCROLL
//SEG58 [25] *((const byte*) BGCOL#0) ← -- *((const byte*) BGCOL#0) [ main::scroll#10 main::nxt#10 ] ( main:2 [ main::scroll#10 main::nxt#10 ] ) -- _deref_cowo1=_dec__deref_cowo1
dec BGCOL
//SEG59 [26] if(true) goto main::@2 [ main::scroll#10 main::nxt#10 ] ( main:2 [ main::scroll#10 main::nxt#10 ] ) -- true_then_la1
jmp b2
//SEG60 main::@return
//SEG61 [27] return [ ] ( main:2 [ ] )
rts
}
//SEG62 fillscreen
fillscreen: {
.const fill = $20
.label cursor = 2
//SEG63 [29] phi from fillscreen to fillscreen::@1 [phi:fillscreen->fillscreen::@1]
//SEG64 [29] phi (byte*) fillscreen::cursor#2 = (const byte*) SCREEN#0 [phi:fillscreen->fillscreen::@1#0] -- zpptrby1=cowo1
lda #<SCREEN
sta cursor
lda #>SCREEN
sta cursor+1
jmp b1
//SEG65 [29] phi from fillscreen::@1 to fillscreen::@1 [phi:fillscreen::@1->fillscreen::@1]
//SEG66 [29] phi (byte*) fillscreen::cursor#2 = (byte*) fillscreen::cursor#1 [phi:fillscreen::@1->fillscreen::@1#0] -- register_copy
//SEG67 fillscreen::@1
b1:
//SEG68 [30] *((byte*) fillscreen::cursor#2) ← (const byte) fillscreen::fill#0 [ fillscreen::cursor#2 ] ( main:2::fillscreen:5 [ fillscreen::cursor#2 ] ) -- _deref_zpptrby1=coby1
ldy #0
lda #fill
sta (cursor),y
//SEG69 [31] (byte*) fillscreen::cursor#1 ← ++ (byte*) fillscreen::cursor#2 [ fillscreen::cursor#1 ] ( main:2::fillscreen:5 [ fillscreen::cursor#1 ] ) -- zpptrby1=_inc_zpptrby1
inc cursor
bne !+
inc cursor+1
!:
//SEG70 [32] if((byte*) fillscreen::cursor#1<(const byte*) SCREEN#0+(word/signed word) 1000) goto fillscreen::@1 [ fillscreen::cursor#1 ] ( main:2::fillscreen:5 [ fillscreen::cursor#1 ] ) -- zpptrby1_lt_cowo1_then_la1
lda cursor+1
cmp #>SCREEN+$3e8
bcc b1
bne !+
lda cursor
cmp #<SCREEN+$3e8
bcc b1
!:
//SEG71 fillscreen::@return
//SEG72 [33] return [ ] ( main:2::fillscreen:5 [ ] )
rts
}
Removing unreachable instruction rts
Succesful ASM optimization Pass5AfterRtsElimination
ASSEMBLER
//SEG0 Basic Upstart
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
//SEG1 Global Constants & labels
.const SCREEN = $400
.const RASTER = $d012
.const BGCOL = $d020
.const SCROLL = $d016
TEXT: .text "-= this is rex of camelot testing a scroller created in kickc. kickc is an optimizing c-compiler for 6502 assembler. =- @"
//SEG2 @begin
//SEG3 [1] phi from @begin to @2 [phi:@begin->@2]
//SEG4 @2
//SEG5 [2] call main param-assignment [ ] ( )
//SEG6 [4] phi from @2 to main [phi:@2->main]
jsr main
//SEG7 [3] phi from @2 to @end [phi:@2->@end]
//SEG8 @end
//SEG9 main
main: {
.const line = SCREEN+$28
.label nxt = 2
//SEG10 [5] call fillscreen param-assignment [ ] ( main:2 [ ] )
//SEG11 [28] phi from main to fillscreen [phi:main->fillscreen]
jsr fillscreen
//SEG12 [6] phi from main to main::@2 [phi:main->main::@2]
//SEG13 [6] phi (byte*) main::nxt#9 = (const byte*) TEXT#0 [phi:main->main::@2#0] -- zpptrby1=cowo1
lda #<TEXT
sta nxt
lda #>TEXT
sta nxt+1
//SEG14 [6] phi (byte) main::scroll#7 = (byte/signed byte/word/signed word) 7 [phi:main->main::@2#1] -- xby=coby1
ldx #7
jmp b2
//SEG15 [6] phi from main::@2 to main::@2 [phi:main::@2->main::@2]
b2_from_b2:
jmp b2
//SEG16 [6] phi from main::@4 to main::@2 [phi:main::@4->main::@2]
//SEG17 [6] phi (byte*) main::nxt#9 = (byte*) main::nxt#10 [phi:main::@4->main::@2#0] -- register_copy
//SEG18 [6] phi (byte) main::scroll#7 = (byte) main::scroll#10 [phi:main::@4->main::@2#1] -- register_copy
//SEG19 main::@2
b2:
//SEG20 [7] if(*((const byte*) RASTER#0)!=(byte/word/signed word) 254) goto main::@2 [ main::scroll#7 main::nxt#9 ] ( main:2 [ main::scroll#7 main::nxt#9 ] ) -- _deref_cowo1_neq_coby2_then_la1
lda RASTER
cmp #$fe
bne b2
//SEG21 main::@3
b3:
//SEG22 [8] if(*((const byte*) RASTER#0)!=(byte/word/signed word) 255) goto main::@3 [ main::scroll#7 main::nxt#9 ] ( main:2 [ main::scroll#7 main::nxt#9 ] ) -- _deref_cowo1_neq_coby2_then_la1
lda RASTER
cmp #$ff
bne b3
//SEG23 main::@8
//SEG24 [9] *((const byte*) BGCOL#0) ← ++ *((const byte*) BGCOL#0) [ main::scroll#7 main::nxt#9 ] ( main:2 [ main::scroll#7 main::nxt#9 ] ) -- _deref_cowo1=_inc__deref_cowo1
inc BGCOL
//SEG25 [10] (byte) main::scroll#1 ← -- (byte) main::scroll#7 [ main::nxt#9 main::scroll#1 ] ( main:2 [ main::nxt#9 main::scroll#1 ] ) -- xby=_dec_xby
dex
//SEG26 [11] if((byte) main::scroll#1!=(byte/word/signed word) 255) goto main::@4 [ main::nxt#9 main::scroll#1 ] ( main:2 [ main::nxt#9 main::scroll#1 ] ) -- xby_neq_coby1_then_la1
cpx #$ff
bne b4
//SEG27 [12] phi from main::@8 to main::@5 [phi:main::@8->main::@5]
//SEG28 [12] phi (byte) main::i#2 = (byte/signed byte/word/signed word) 0 [phi:main::@8->main::@5#0] -- xby=coby1
ldx #0
jmp b5
//SEG29 [12] phi from main::@5 to main::@5 [phi:main::@5->main::@5]
//SEG30 [12] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@5->main::@5#0] -- register_copy
//SEG31 main::@5
b5:
//SEG32 [13] (byte~) main::$7 ← (const byte[]) main::line#0+(byte/signed byte/word/signed word) 1 *idx (byte) main::i#2 [ main::nxt#9 main::i#2 main::$7 ] ( main:2 [ main::nxt#9 main::i#2 main::$7 ] ) -- aby=cowo1_derefidx_xby
lda line+1,x
//SEG33 [14] *((const byte[]) main::line#0 + (byte) main::i#2) ← (byte~) main::$7 [ main::nxt#9 main::i#2 ] ( main:2 [ main::nxt#9 main::i#2 ] ) -- cowo1_derefidx_xby=aby
sta line,x
//SEG34 [15] (byte) main::i#1 ← ++ (byte) main::i#2 [ main::nxt#9 main::i#1 ] ( main:2 [ main::nxt#9 main::i#1 ] ) -- xby=_inc_xby
inx
//SEG35 [16] if((byte) main::i#1!=(byte/signed byte/word/signed word) 39) goto main::@5 [ main::nxt#9 main::i#1 ] ( main:2 [ main::nxt#9 main::i#1 ] ) -- xby_neq_coby1_then_la1
cpx #$27
bne b5
//SEG36 main::@10
//SEG37 [17] (byte) main::c#0 ← *((byte*) main::nxt#9) [ main::nxt#9 main::c#0 ] ( main:2 [ main::nxt#9 main::c#0 ] ) -- xby=_deref_zpptrby1
ldy #0
lda (nxt),y
tax
//SEG38 [18] if((byte) main::c#0!=(byte) '@') goto main::@6 [ main::nxt#9 main::c#0 ] ( main:2 [ main::nxt#9 main::c#0 ] ) -- xby_neq_coby1_then_la1
cpx #'@'
bne b6
//SEG39 main::@11
//SEG40 [19] (byte) main::c#1 ← *((const byte*) TEXT#0) [ main::c#1 ] ( main:2 [ main::c#1 ] ) -- xby=_deref_cowo1
ldx TEXT
//SEG41 [20] phi from main::@11 to main::@6 [phi:main::@11->main::@6]
//SEG42 [20] phi (byte*) main::nxt#4 = (const byte*) TEXT#0 [phi:main::@11->main::@6#0] -- zpptrby1=cowo1
lda #<TEXT
sta nxt
lda #>TEXT
sta nxt+1
//SEG43 [20] phi (byte) main::c#2 = (byte) main::c#1 [phi:main::@11->main::@6#1] -- register_copy
jmp b6
//SEG44 [20] phi from main::@10 to main::@6 [phi:main::@10->main::@6]
//SEG45 [20] phi (byte*) main::nxt#4 = (byte*) main::nxt#9 [phi:main::@10->main::@6#0] -- register_copy
//SEG46 [20] phi (byte) main::c#2 = (byte) main::c#0 [phi:main::@10->main::@6#1] -- register_copy
//SEG47 main::@6
b6:
//SEG48 [21] *((const byte[]) main::line#0+(byte/signed byte/word/signed word) 39) ← (byte) main::c#2 [ main::nxt#4 ] ( main:2 [ main::nxt#4 ] ) -- _deref_cowo1=xby
stx line+$27
//SEG49 [22] (byte*) main::nxt#1 ← ++ (byte*) main::nxt#4 [ main::nxt#1 ] ( main:2 [ main::nxt#1 ] ) -- zpptrby1=_inc_zpptrby1
inc nxt
bne !+
inc nxt+1
!:
//SEG50 [23] phi from main::@6 to main::@4 [phi:main::@6->main::@4]
//SEG51 [23] phi (byte*) main::nxt#10 = (byte*) main::nxt#1 [phi:main::@6->main::@4#0] -- register_copy
//SEG52 [23] phi (byte) main::scroll#10 = (byte/signed byte/word/signed word) 7 [phi:main::@6->main::@4#1] -- xby=coby1
ldx #7
jmp b4
//SEG53 [23] phi from main::@8 to main::@4 [phi:main::@8->main::@4]
//SEG54 [23] phi (byte*) main::nxt#10 = (byte*) main::nxt#9 [phi:main::@8->main::@4#0] -- register_copy
//SEG55 [23] phi (byte) main::scroll#10 = (byte) main::scroll#1 [phi:main::@8->main::@4#1] -- register_copy
//SEG56 main::@4
b4:
//SEG57 [24] *((const byte*) SCROLL#0) ← (byte) main::scroll#10 [ main::scroll#10 main::nxt#10 ] ( main:2 [ main::scroll#10 main::nxt#10 ] ) -- _deref_cowo1=xby
stx SCROLL
//SEG58 [25] *((const byte*) BGCOL#0) ← -- *((const byte*) BGCOL#0) [ main::scroll#10 main::nxt#10 ] ( main:2 [ main::scroll#10 main::nxt#10 ] ) -- _deref_cowo1=_dec__deref_cowo1
dec BGCOL
//SEG59 [26] if(true) goto main::@2 [ main::scroll#10 main::nxt#10 ] ( main:2 [ main::scroll#10 main::nxt#10 ] ) -- true_then_la1
jmp b2
//SEG60 main::@return
//SEG61 [27] return [ ] ( main:2 [ ] )
}
//SEG62 fillscreen
fillscreen: {
.const fill = $20
.label cursor = 2
//SEG63 [29] phi from fillscreen to fillscreen::@1 [phi:fillscreen->fillscreen::@1]
//SEG64 [29] phi (byte*) fillscreen::cursor#2 = (const byte*) SCREEN#0 [phi:fillscreen->fillscreen::@1#0] -- zpptrby1=cowo1
lda #<SCREEN
sta cursor
lda #>SCREEN
sta cursor+1
jmp b1
//SEG65 [29] phi from fillscreen::@1 to fillscreen::@1 [phi:fillscreen::@1->fillscreen::@1]
//SEG66 [29] phi (byte*) fillscreen::cursor#2 = (byte*) fillscreen::cursor#1 [phi:fillscreen::@1->fillscreen::@1#0] -- register_copy
//SEG67 fillscreen::@1
b1:
//SEG68 [30] *((byte*) fillscreen::cursor#2) ← (const byte) fillscreen::fill#0 [ fillscreen::cursor#2 ] ( main:2::fillscreen:5 [ fillscreen::cursor#2 ] ) -- _deref_zpptrby1=coby1
ldy #0
lda #fill
sta (cursor),y
//SEG69 [31] (byte*) fillscreen::cursor#1 ← ++ (byte*) fillscreen::cursor#2 [ fillscreen::cursor#1 ] ( main:2::fillscreen:5 [ fillscreen::cursor#1 ] ) -- zpptrby1=_inc_zpptrby1
inc cursor
bne !+
inc cursor+1
!:
//SEG70 [32] if((byte*) fillscreen::cursor#1<(const byte*) SCREEN#0+(word/signed word) 1000) goto fillscreen::@1 [ fillscreen::cursor#1 ] ( main:2::fillscreen:5 [ fillscreen::cursor#1 ] ) -- zpptrby1_lt_cowo1_then_la1
lda cursor+1
cmp #>SCREEN+$3e8
bcc b1
bne !+
lda cursor
cmp #<SCREEN+$3e8
bcc b1
!:
//SEG71 fillscreen::@return
//SEG72 [33] return [ ] ( main:2::fillscreen:5 [ ] )
rts
}
Removing instruction jmp b2
Removing instruction jmp b5
Removing instruction jmp b6
@ -4326,7 +4663,7 @@ main: {
//SEG20 [7] if(*((const byte*) RASTER#0)!=(byte/word/signed word) 254) goto main::@2 [ main::scroll#7 main::nxt#9 ] ( main:2 [ main::scroll#7 main::nxt#9 ] ) -- _deref_cowo1_neq_coby2_then_la1
lda RASTER
cmp #$fe
bne b2_from_b2
bne b2
//SEG21 main::@3
b3:
//SEG22 [8] if(*((const byte*) RASTER#0)!=(byte/word/signed word) 255) goto main::@3 [ main::scroll#7 main::nxt#9 ] ( main:2 [ main::scroll#7 main::nxt#9 ] ) -- _deref_cowo1_neq_coby2_then_la1
@ -4404,7 +4741,6 @@ main: {
jmp b2
//SEG60 main::@return
//SEG61 [27] return [ ] ( main:2 [ ] )
rts
}
//SEG62 fillscreen
fillscreen: {
@ -4443,7 +4779,6 @@ fillscreen: {
rts
}
Replacing label b2_from_b2 with b2
Removing instruction b2_from_b2:
Succesful ASM optimization Pass5RedundantLabelElimination
ASSEMBLER
@ -4568,7 +4903,6 @@ main: {
jmp b2
//SEG60 main::@return
//SEG61 [27] return [ ] ( main:2 [ ] )
rts
}
//SEG62 fillscreen
fillscreen: {
@ -4730,7 +5064,6 @@ main: {
jmp b2
//SEG60 main::@return
//SEG61 [27] return [ ] ( main:2 [ ] )
rts
}
//SEG62 fillscreen
fillscreen: {
@ -4949,7 +5282,6 @@ main: {
jmp b2
//SEG60 main::@return
//SEG61 [27] return [ ] ( main:2 [ ] )
rts
}
//SEG62 fillscreen
fillscreen: {

View File

@ -37,7 +37,6 @@ main: {
jsr scroll_soft
dec BGCOL
jmp b2
rts
}
scroll_soft: {
dex

View File

@ -10421,6 +10421,743 @@ fillscreen: {
rts
}
Skipping double jump to b2 in bne b2_from_b2
Succesful ASM optimization Pass5DoubleJumpElimination
ASSEMBLER
//SEG0 Basic Upstart
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
//SEG1 Global Constants & labels
.const PROCPORT = 1
.const CHARGEN = $d000
.const SCREEN = $400
.const RASTER = $d012
.const BGCOL = $d020
.const SCROLL = $d016
.label current_bit = 2
.label current_chargen = 3
.label nxt = 7
TEXT: .text "-= this is rex of camelot testing a scroller created in kickc. kickc is an optimizing c-compiler for 6502 assembler. =- @"
//SEG2 @begin
//SEG3 [1] phi from @begin to @6 [phi:@begin->@6]
//SEG4 @6
//SEG5 [2] call main param-assignment [ ] ( )
//SEG6 [4] phi from @6 to main [phi:@6->main]
jsr main
//SEG7 [3] phi from @6 to @end [phi:@6->@end]
//SEG8 @end
//SEG9 main
main: {
//SEG10 [5] call fillscreen param-assignment [ ] ( main:2 [ ] )
//SEG11 [76] phi from main to fillscreen [phi:main->fillscreen]
jsr fillscreen
//SEG12 [6] phi from main to main::@2 [phi:main->main::@2]
//SEG13 [6] phi (byte*) current_chargen#27 = (const byte*) CHARGEN#0 [phi:main->main::@2#0] -- zpptrby1=cowo1
lda #<CHARGEN
sta current_chargen
lda #>CHARGEN
sta current_chargen+1
//SEG14 [6] phi (byte*) nxt#31 = (const byte*) TEXT#0 [phi:main->main::@2#1] -- zpptrby1=cowo1
lda #<TEXT
sta nxt
lda #>TEXT
sta nxt+1
//SEG15 [6] phi (byte) current_bit#29 = (byte/signed byte/word/signed word) 1 [phi:main->main::@2#2] -- zpby1=coby1
lda #1
sta current_bit
//SEG16 [6] phi (byte) scroll#18 = (byte/signed byte/word/signed word) 7 [phi:main->main::@2#3] -- xby=coby1
ldx #7
jmp b2
//SEG17 [6] phi from main::@2 to main::@2 [phi:main::@2->main::@2]
b2_from_b2:
jmp b2
//SEG18 [6] phi from main::@8 to main::@2 [phi:main::@8->main::@2]
//SEG19 [6] phi (byte*) current_chargen#27 = (byte*) current_chargen#11 [phi:main::@8->main::@2#0] -- register_copy
//SEG20 [6] phi (byte*) nxt#31 = (byte*) nxt#14 [phi:main::@8->main::@2#1] -- register_copy
//SEG21 [6] phi (byte) current_bit#29 = (byte) current_bit#12 [phi:main::@8->main::@2#2] -- register_copy
//SEG22 [6] phi (byte) scroll#18 = (byte) scroll#10 [phi:main::@8->main::@2#3] -- register_copy
//SEG23 main::@2
b2:
//SEG24 [7] if(*((const byte*) RASTER#0)!=(byte/word/signed word) 254) goto main::@2 [ scroll#18 current_bit#29 nxt#31 current_chargen#27 ] ( main:2 [ scroll#18 current_bit#29 nxt#31 current_chargen#27 ] ) -- _deref_cowo1_neq_coby2_then_la1
lda RASTER
cmp #$fe
bne b2
//SEG25 main::@3
b3:
//SEG26 [8] if(*((const byte*) RASTER#0)!=(byte/word/signed word) 255) goto main::@3 [ scroll#18 current_bit#29 nxt#31 current_chargen#27 ] ( main:2 [ scroll#18 current_bit#29 nxt#31 current_chargen#27 ] ) -- _deref_cowo1_neq_coby2_then_la1
lda RASTER
cmp #$ff
bne b3
//SEG27 main::@5
//SEG28 [9] *((const byte*) BGCOL#0) ← ++ *((const byte*) BGCOL#0) [ scroll#18 current_bit#29 nxt#31 current_chargen#27 ] ( main:2 [ scroll#18 current_bit#29 nxt#31 current_chargen#27 ] ) -- _deref_cowo1=_inc__deref_cowo1
inc BGCOL
//SEG29 [10] call scroll_soft param-assignment [ scroll#10 current_bit#12 nxt#14 current_chargen#11 ] ( main:2 [ scroll#10 current_bit#12 nxt#14 current_chargen#11 ] )
jsr scroll_soft
//SEG30 main::@8
//SEG31 [11] *((const byte*) BGCOL#0) ← -- *((const byte*) BGCOL#0) [ scroll#10 current_bit#12 nxt#14 current_chargen#11 ] ( main:2 [ scroll#10 current_bit#12 nxt#14 current_chargen#11 ] ) -- _deref_cowo1=_dec__deref_cowo1
dec BGCOL
//SEG32 [12] if(true) goto main::@2 [ scroll#10 current_bit#12 nxt#14 current_chargen#11 ] ( main:2 [ scroll#10 current_bit#12 nxt#14 current_chargen#11 ] ) -- true_then_la1
jmp b2
//SEG33 main::@return
//SEG34 [13] return [ ] ( main:2 [ ] )
rts
}
//SEG35 scroll_soft
scroll_soft: {
//SEG36 [14] (byte) scroll#3 ← -- (byte) scroll#18 [ current_bit#29 nxt#31 current_chargen#27 scroll#3 ] ( main:2::scroll_soft:10 [ current_bit#29 nxt#31 current_chargen#27 scroll#3 ] ) -- xby=_dec_xby
dex
//SEG37 [15] if((byte) scroll#3!=(byte/word/signed word) 255) goto scroll_soft::@1 [ current_bit#29 nxt#31 current_chargen#27 scroll#3 ] ( main:2::scroll_soft:10 [ current_bit#29 nxt#31 current_chargen#27 scroll#3 ] ) -- xby_neq_coby1_then_la1
cpx #$ff
bne b1
//SEG38 [16] phi from scroll_soft to scroll_soft::@2 [phi:scroll_soft->scroll_soft::@2]
//SEG39 scroll_soft::@2
//SEG40 [17] call scroll_bit param-assignment [ current_bit#21 nxt#36 current_chargen#19 ] ( main:2::scroll_soft:10 [ current_bit#21 nxt#36 current_chargen#19 ] )
jsr scroll_bit
//SEG41 [18] phi from scroll_soft::@2 to scroll_soft::@1 [phi:scroll_soft::@2->scroll_soft::@1]
//SEG42 [18] phi (byte*) current_chargen#11 = (byte*) current_chargen#19 [phi:scroll_soft::@2->scroll_soft::@1#0] -- register_copy
//SEG43 [18] phi (byte*) nxt#14 = (byte*) nxt#36 [phi:scroll_soft::@2->scroll_soft::@1#1] -- register_copy
//SEG44 [18] phi (byte) current_bit#12 = (byte) current_bit#21 [phi:scroll_soft::@2->scroll_soft::@1#2] -- register_copy
//SEG45 [18] phi (byte) scroll#10 = (byte/signed byte/word/signed word) 7 [phi:scroll_soft::@2->scroll_soft::@1#3] -- xby=coby1
ldx #7
jmp b1
//SEG46 [18] phi from scroll_soft to scroll_soft::@1 [phi:scroll_soft->scroll_soft::@1]
//SEG47 [18] phi (byte*) current_chargen#11 = (byte*) current_chargen#27 [phi:scroll_soft->scroll_soft::@1#0] -- register_copy
//SEG48 [18] phi (byte*) nxt#14 = (byte*) nxt#31 [phi:scroll_soft->scroll_soft::@1#1] -- register_copy
//SEG49 [18] phi (byte) current_bit#12 = (byte) current_bit#29 [phi:scroll_soft->scroll_soft::@1#2] -- register_copy
//SEG50 [18] phi (byte) scroll#10 = (byte) scroll#3 [phi:scroll_soft->scroll_soft::@1#3] -- register_copy
//SEG51 scroll_soft::@1
b1:
//SEG52 [19] *((const byte*) SCROLL#0) ← (byte) scroll#10 [ scroll#10 current_bit#12 nxt#14 current_chargen#11 ] ( main:2::scroll_soft:10 [ scroll#10 current_bit#12 nxt#14 current_chargen#11 ] ) -- _deref_cowo1=xby
stx SCROLL
//SEG53 scroll_soft::@return
//SEG54 [20] return [ scroll#10 current_bit#12 nxt#14 current_chargen#11 ] ( main:2::scroll_soft:10 [ scroll#10 current_bit#12 nxt#14 current_chargen#11 ] )
rts
}
//SEG55 scroll_bit
scroll_bit: {
.label _4 = 9
.label _5 = 3
.label c = 9
.label sc = 5
//SEG56 [21] (byte~) scroll_bit::$0 ← (byte) current_bit#29 >> (byte/signed byte/word/signed word) 1 [ nxt#31 current_chargen#27 scroll_bit::$0 ] ( main:2::scroll_soft:10::scroll_bit:17 [ nxt#31 current_chargen#27 scroll_bit::$0 ] ) -- aby=zpby1_ror_1
lda current_bit
lsr
//SEG57 [22] (byte) current_bit#5 ← (byte~) scroll_bit::$0 [ nxt#31 current_chargen#27 current_bit#5 ] ( main:2::scroll_soft:10::scroll_bit:17 [ nxt#31 current_chargen#27 current_bit#5 ] ) -- zpby1=aby
sta current_bit
//SEG58 [23] if((byte) current_bit#5!=(byte/signed byte/word/signed word) 0) goto scroll_bit::@1 [ nxt#31 current_chargen#27 current_bit#5 ] ( main:2::scroll_soft:10::scroll_bit:17 [ nxt#31 current_chargen#27 current_bit#5 ] ) -- zpby1_neq_0_then_la1
bne b1
//SEG59 [24] phi from scroll_bit to scroll_bit::@4 [phi:scroll_bit->scroll_bit::@4]
//SEG60 scroll_bit::@4
//SEG61 [25] call next_char param-assignment [ next_char::c#2 nxt#19 ] ( main:2::scroll_soft:10::scroll_bit:17 [ next_char::c#2 nxt#19 ] )
jsr next_char
//SEG62 [26] (byte) next_char::return#0 ← (byte) next_char::c#2 [ next_char::return#0 nxt#19 ] ( main:2::scroll_soft:10::scroll_bit:17 [ next_char::return#0 nxt#19 ] )
// (byte) next_char::return#0 = (byte) next_char::c#2 // register copy reg byte a
//SEG63 scroll_bit::@8
//SEG64 [27] (byte~) scroll_bit::$3 ← (byte) next_char::return#0 [ scroll_bit::$3 nxt#19 ] ( main:2::scroll_soft:10::scroll_bit:17 [ scroll_bit::$3 nxt#19 ] )
// (byte~) scroll_bit::$3 = (byte) next_char::return#0 // register copy reg byte a
//SEG65 [28] (word) scroll_bit::c#0 ← ((word)) (byte~) scroll_bit::$3 [ scroll_bit::c#0 nxt#19 ] ( main:2::scroll_soft:10::scroll_bit:17 [ scroll_bit::c#0 nxt#19 ] ) -- zpwo1=_word_aby
sta c
lda #0
sta c+1
//SEG66 [29] (word~) scroll_bit::$4 ← (word) scroll_bit::c#0 << (byte/signed byte/word/signed word) 3 [ scroll_bit::$4 nxt#19 ] ( main:2::scroll_soft:10::scroll_bit:17 [ scroll_bit::$4 nxt#19 ] ) -- zpwo1=zpwo1_rol_3
asl _4
rol _4+1
asl _4
rol _4+1
asl _4
rol _4+1
//SEG67 [30] (byte*~) scroll_bit::$5 ← (const byte*) CHARGEN#0 + (word~) scroll_bit::$4 [ scroll_bit::$5 nxt#19 ] ( main:2::scroll_soft:10::scroll_bit:17 [ scroll_bit::$5 nxt#19 ] ) -- zpptrby1=cowo1_plus_zpwo1
lda #<CHARGEN
clc
adc _4
sta _5
lda #>CHARGEN
adc _4+1
sta _5+1
//SEG68 [31] (byte*) current_chargen#5 ← (byte*~) scroll_bit::$5 [ current_chargen#5 nxt#19 ] ( main:2::scroll_soft:10::scroll_bit:17 [ current_chargen#5 nxt#19 ] )
// (byte*) current_chargen#5 = (byte*~) scroll_bit::$5 // register copy zp ZP_PTR_BYTE:3
//SEG69 [32] phi from scroll_bit::@8 to scroll_bit::@1 [phi:scroll_bit::@8->scroll_bit::@1]
//SEG70 [32] phi (byte*) nxt#36 = (byte*) nxt#19 [phi:scroll_bit::@8->scroll_bit::@1#0] -- register_copy
//SEG71 [32] phi (byte) current_bit#21 = (byte/word/signed word) 128 [phi:scroll_bit::@8->scroll_bit::@1#1] -- zpby1=coby1
lda #$80
sta current_bit
//SEG72 [32] phi (byte*) current_chargen#19 = (byte*) current_chargen#5 [phi:scroll_bit::@8->scroll_bit::@1#2] -- register_copy
jmp b1
//SEG73 [32] phi from scroll_bit to scroll_bit::@1 [phi:scroll_bit->scroll_bit::@1]
//SEG74 [32] phi (byte*) nxt#36 = (byte*) nxt#31 [phi:scroll_bit->scroll_bit::@1#0] -- register_copy
//SEG75 [32] phi (byte) current_bit#21 = (byte) current_bit#5 [phi:scroll_bit->scroll_bit::@1#1] -- register_copy
//SEG76 [32] phi (byte*) current_chargen#19 = (byte*) current_chargen#27 [phi:scroll_bit->scroll_bit::@1#2] -- register_copy
//SEG77 scroll_bit::@1
b1:
//SEG78 [33] call scroll_hard param-assignment [ current_bit#21 nxt#36 current_chargen#19 ] ( main:2::scroll_soft:10::scroll_bit:17 [ current_bit#21 nxt#36 current_chargen#19 ] )
//SEG79 [49] phi from scroll_bit::@1 to scroll_hard [phi:scroll_bit::@1->scroll_hard]
jsr scroll_hard
//SEG80 scroll_bit::@7
//SEG81 asm { sei }
sei
//SEG82 [35] *((const byte*) PROCPORT#0) ← (byte/signed byte/word/signed word) 50 [ current_bit#21 nxt#36 current_chargen#19 ] ( main:2::scroll_soft:10::scroll_bit:17 [ current_bit#21 nxt#36 current_chargen#19 ] ) -- _deref_cowo1=coby2
lda #$32
sta PROCPORT
//SEG83 [36] phi from scroll_bit::@7 to scroll_bit::@2 [phi:scroll_bit::@7->scroll_bit::@2]
//SEG84 [36] phi (byte*) scroll_bit::sc#2 = (const byte*) SCREEN#0+(byte/signed byte/word/signed word) 40+(byte/signed byte/word/signed word) 39 [phi:scroll_bit::@7->scroll_bit::@2#0] -- zpptrby1=cowo1
lda #<SCREEN+$28+$27
sta sc
lda #>SCREEN+$28+$27
sta sc+1
//SEG85 [36] phi (byte) scroll_bit::r#2 = (byte/signed byte/word/signed word) 0 [phi:scroll_bit::@7->scroll_bit::@2#1] -- xby=coby1
ldx #0
jmp b2
//SEG86 [36] phi from scroll_bit::@3 to scroll_bit::@2 [phi:scroll_bit::@3->scroll_bit::@2]
//SEG87 [36] phi (byte*) scroll_bit::sc#2 = (byte*) scroll_bit::sc#1 [phi:scroll_bit::@3->scroll_bit::@2#0] -- register_copy
//SEG88 [36] phi (byte) scroll_bit::r#2 = (byte) scroll_bit::r#1 [phi:scroll_bit::@3->scroll_bit::@2#1] -- register_copy
//SEG89 scroll_bit::@2
b2:
//SEG90 [37] (byte) scroll_bit::bits#0 ← (byte*) current_chargen#19 *idx (byte) scroll_bit::r#2 [ current_bit#21 nxt#36 current_chargen#19 scroll_bit::r#2 scroll_bit::sc#2 scroll_bit::bits#0 ] ( main:2::scroll_soft:10::scroll_bit:17 [ current_bit#21 nxt#36 current_chargen#19 scroll_bit::r#2 scroll_bit::sc#2 scroll_bit::bits#0 ] ) -- aby=zpptrby1_derefidx_xby
stx $ff
ldy $ff
lda (current_chargen),y
//SEG91 [38] (byte~) scroll_bit::$10 ← (byte) scroll_bit::bits#0 & (byte) current_bit#21 [ current_bit#21 nxt#36 current_chargen#19 scroll_bit::r#2 scroll_bit::sc#2 scroll_bit::$10 ] ( main:2::scroll_soft:10::scroll_bit:17 [ current_bit#21 nxt#36 current_chargen#19 scroll_bit::r#2 scroll_bit::sc#2 scroll_bit::$10 ] ) -- aby=aby_band_zpby1
and current_bit
//SEG92 [39] if((byte~) scroll_bit::$10==(byte/signed byte/word/signed word) 0) goto scroll_bit::@3 [ current_bit#21 nxt#36 current_chargen#19 scroll_bit::r#2 scroll_bit::sc#2 ] ( main:2::scroll_soft:10::scroll_bit:17 [ current_bit#21 nxt#36 current_chargen#19 scroll_bit::r#2 scroll_bit::sc#2 ] ) -- aby_eq_0_then_la1
cmp #0
beq b3_from_b2
//SEG93 [40] phi from scroll_bit::@2 to scroll_bit::@5 [phi:scroll_bit::@2->scroll_bit::@5]
//SEG94 scroll_bit::@5
//SEG95 [41] phi from scroll_bit::@5 to scroll_bit::@3 [phi:scroll_bit::@5->scroll_bit::@3]
//SEG96 [41] phi (byte) scroll_bit::b#2 = (byte/word/signed word) 128+(byte) ' ' [phi:scroll_bit::@5->scroll_bit::@3#0] -- aby=coby1
lda #$80+' '
jmp b3
//SEG97 [41] phi from scroll_bit::@2 to scroll_bit::@3 [phi:scroll_bit::@2->scroll_bit::@3]
b3_from_b2:
//SEG98 [41] phi (byte) scroll_bit::b#2 = (byte) ' ' [phi:scroll_bit::@2->scroll_bit::@3#0] -- aby=coby1
lda #' '
//SEG99 scroll_bit::@3
b3:
//SEG100 [42] *((byte*) scroll_bit::sc#2) ← (byte) scroll_bit::b#2 [ current_bit#21 nxt#36 current_chargen#19 scroll_bit::r#2 scroll_bit::sc#2 ] ( main:2::scroll_soft:10::scroll_bit:17 [ current_bit#21 nxt#36 current_chargen#19 scroll_bit::r#2 scroll_bit::sc#2 ] ) -- _deref_zpptrby1=aby
ldy #0
sta (sc),y
//SEG101 [43] (byte*) scroll_bit::sc#1 ← (byte*) scroll_bit::sc#2 + (byte/signed byte/word/signed word) 40 [ current_bit#21 nxt#36 current_chargen#19 scroll_bit::r#2 scroll_bit::sc#1 ] ( main:2::scroll_soft:10::scroll_bit:17 [ current_bit#21 nxt#36 current_chargen#19 scroll_bit::r#2 scroll_bit::sc#1 ] ) -- zpptrby1=zpptrby1_plus_coby1
lda sc
clc
adc #$28
sta sc
bcc !+
inc sc+1
!:
//SEG102 [44] (byte) scroll_bit::r#1 ← ++ (byte) scroll_bit::r#2 [ current_bit#21 nxt#36 current_chargen#19 scroll_bit::r#1 scroll_bit::sc#1 ] ( main:2::scroll_soft:10::scroll_bit:17 [ current_bit#21 nxt#36 current_chargen#19 scroll_bit::r#1 scroll_bit::sc#1 ] ) -- xby=_inc_xby
inx
//SEG103 [45] if((byte) scroll_bit::r#1!=(byte/signed byte/word/signed word) 8) goto scroll_bit::@2 [ current_bit#21 nxt#36 current_chargen#19 scroll_bit::r#1 scroll_bit::sc#1 ] ( main:2::scroll_soft:10::scroll_bit:17 [ current_bit#21 nxt#36 current_chargen#19 scroll_bit::r#1 scroll_bit::sc#1 ] ) -- xby_neq_coby1_then_la1
cpx #8
bne b2
//SEG104 scroll_bit::@6
//SEG105 [46] *((const byte*) PROCPORT#0) ← (byte/signed byte/word/signed word) 55 [ current_bit#21 nxt#36 current_chargen#19 ] ( main:2::scroll_soft:10::scroll_bit:17 [ current_bit#21 nxt#36 current_chargen#19 ] ) -- _deref_cowo1=coby2
lda #$37
sta PROCPORT
//SEG106 asm { cli }
cli
//SEG107 scroll_bit::@return
//SEG108 [48] return [ current_bit#21 nxt#36 current_chargen#19 ] ( main:2::scroll_soft:10::scroll_bit:17 [ current_bit#21 nxt#36 current_chargen#19 ] )
rts
}
//SEG109 scroll_hard
scroll_hard: {
.const line0 = SCREEN+$28*0
.const line1 = SCREEN+$28*1
.const line2 = SCREEN+$28*2
.const line3 = SCREEN+$28*3
.const line4 = SCREEN+$28*4
.const line5 = SCREEN+$28*5
.const line6 = SCREEN+$28*6
.const line7 = SCREEN+$28*7
//SEG110 [50] phi from scroll_hard to scroll_hard::@1 [phi:scroll_hard->scroll_hard::@1]
//SEG111 [50] phi (byte) scroll_hard::i#2 = (byte/signed byte/word/signed word) 0 [phi:scroll_hard->scroll_hard::@1#0] -- xby=coby1
ldx #0
jmp b1
//SEG112 [50] phi from scroll_hard::@1 to scroll_hard::@1 [phi:scroll_hard::@1->scroll_hard::@1]
//SEG113 [50] phi (byte) scroll_hard::i#2 = (byte) scroll_hard::i#1 [phi:scroll_hard::@1->scroll_hard::@1#0] -- register_copy
//SEG114 scroll_hard::@1
b1:
//SEG115 [51] (byte~) scroll_hard::$17 ← (const byte[]) scroll_hard::line0#0+(byte/signed byte/word/signed word) 1 *idx (byte) scroll_hard::i#2 [ scroll_hard::i#2 scroll_hard::$17 ] ( main:2::scroll_soft:10::scroll_bit:17::scroll_hard:33 [ current_bit#21 nxt#36 current_chargen#19 scroll_hard::i#2 scroll_hard::$17 ] ) -- aby=cowo1_derefidx_xby
lda line0+1,x
//SEG116 [52] *((const byte[]) scroll_hard::line0#0 + (byte) scroll_hard::i#2) ← (byte~) scroll_hard::$17 [ scroll_hard::i#2 ] ( main:2::scroll_soft:10::scroll_bit:17::scroll_hard:33 [ current_bit#21 nxt#36 current_chargen#19 scroll_hard::i#2 ] ) -- cowo1_derefidx_xby=aby
sta line0,x
//SEG117 [53] (byte~) scroll_hard::$19 ← (const byte[]) scroll_hard::line1#0+(byte/signed byte/word/signed word) 1 *idx (byte) scroll_hard::i#2 [ scroll_hard::i#2 scroll_hard::$19 ] ( main:2::scroll_soft:10::scroll_bit:17::scroll_hard:33 [ current_bit#21 nxt#36 current_chargen#19 scroll_hard::i#2 scroll_hard::$19 ] ) -- aby=cowo1_derefidx_xby
lda line1+1,x
//SEG118 [54] *((const byte[]) scroll_hard::line1#0 + (byte) scroll_hard::i#2) ← (byte~) scroll_hard::$19 [ scroll_hard::i#2 ] ( main:2::scroll_soft:10::scroll_bit:17::scroll_hard:33 [ current_bit#21 nxt#36 current_chargen#19 scroll_hard::i#2 ] ) -- cowo1_derefidx_xby=aby
sta line1,x
//SEG119 [55] (byte~) scroll_hard::$21 ← (const byte[]) scroll_hard::line2#0+(byte/signed byte/word/signed word) 1 *idx (byte) scroll_hard::i#2 [ scroll_hard::i#2 scroll_hard::$21 ] ( main:2::scroll_soft:10::scroll_bit:17::scroll_hard:33 [ current_bit#21 nxt#36 current_chargen#19 scroll_hard::i#2 scroll_hard::$21 ] ) -- aby=cowo1_derefidx_xby
lda line2+1,x
//SEG120 [56] *((const byte[]) scroll_hard::line2#0 + (byte) scroll_hard::i#2) ← (byte~) scroll_hard::$21 [ scroll_hard::i#2 ] ( main:2::scroll_soft:10::scroll_bit:17::scroll_hard:33 [ current_bit#21 nxt#36 current_chargen#19 scroll_hard::i#2 ] ) -- cowo1_derefidx_xby=aby
sta line2,x
//SEG121 [57] (byte~) scroll_hard::$23 ← (const byte[]) scroll_hard::line3#0+(byte/signed byte/word/signed word) 1 *idx (byte) scroll_hard::i#2 [ scroll_hard::i#2 scroll_hard::$23 ] ( main:2::scroll_soft:10::scroll_bit:17::scroll_hard:33 [ current_bit#21 nxt#36 current_chargen#19 scroll_hard::i#2 scroll_hard::$23 ] ) -- aby=cowo1_derefidx_xby
lda line3+1,x
//SEG122 [58] *((const byte[]) scroll_hard::line3#0 + (byte) scroll_hard::i#2) ← (byte~) scroll_hard::$23 [ scroll_hard::i#2 ] ( main:2::scroll_soft:10::scroll_bit:17::scroll_hard:33 [ current_bit#21 nxt#36 current_chargen#19 scroll_hard::i#2 ] ) -- cowo1_derefidx_xby=aby
sta line3,x
//SEG123 [59] (byte~) scroll_hard::$25 ← (const byte[]) scroll_hard::line4#0+(byte/signed byte/word/signed word) 1 *idx (byte) scroll_hard::i#2 [ scroll_hard::i#2 scroll_hard::$25 ] ( main:2::scroll_soft:10::scroll_bit:17::scroll_hard:33 [ current_bit#21 nxt#36 current_chargen#19 scroll_hard::i#2 scroll_hard::$25 ] ) -- aby=cowo1_derefidx_xby
lda line4+1,x
//SEG124 [60] *((const byte[]) scroll_hard::line4#0 + (byte) scroll_hard::i#2) ← (byte~) scroll_hard::$25 [ scroll_hard::i#2 ] ( main:2::scroll_soft:10::scroll_bit:17::scroll_hard:33 [ current_bit#21 nxt#36 current_chargen#19 scroll_hard::i#2 ] ) -- cowo1_derefidx_xby=aby
sta line4,x
//SEG125 [61] (byte~) scroll_hard::$27 ← (const byte[]) scroll_hard::line5#0+(byte/signed byte/word/signed word) 1 *idx (byte) scroll_hard::i#2 [ scroll_hard::i#2 scroll_hard::$27 ] ( main:2::scroll_soft:10::scroll_bit:17::scroll_hard:33 [ current_bit#21 nxt#36 current_chargen#19 scroll_hard::i#2 scroll_hard::$27 ] ) -- aby=cowo1_derefidx_xby
lda line5+1,x
//SEG126 [62] *((const byte[]) scroll_hard::line5#0 + (byte) scroll_hard::i#2) ← (byte~) scroll_hard::$27 [ scroll_hard::i#2 ] ( main:2::scroll_soft:10::scroll_bit:17::scroll_hard:33 [ current_bit#21 nxt#36 current_chargen#19 scroll_hard::i#2 ] ) -- cowo1_derefidx_xby=aby
sta line5,x
//SEG127 [63] (byte~) scroll_hard::$29 ← (const byte[]) scroll_hard::line6#0+(byte/signed byte/word/signed word) 1 *idx (byte) scroll_hard::i#2 [ scroll_hard::i#2 scroll_hard::$29 ] ( main:2::scroll_soft:10::scroll_bit:17::scroll_hard:33 [ current_bit#21 nxt#36 current_chargen#19 scroll_hard::i#2 scroll_hard::$29 ] ) -- aby=cowo1_derefidx_xby
lda line6+1,x
//SEG128 [64] *((const byte[]) scroll_hard::line6#0 + (byte) scroll_hard::i#2) ← (byte~) scroll_hard::$29 [ scroll_hard::i#2 ] ( main:2::scroll_soft:10::scroll_bit:17::scroll_hard:33 [ current_bit#21 nxt#36 current_chargen#19 scroll_hard::i#2 ] ) -- cowo1_derefidx_xby=aby
sta line6,x
//SEG129 [65] (byte~) scroll_hard::$31 ← (const byte[]) scroll_hard::line7#0+(byte/signed byte/word/signed word) 1 *idx (byte) scroll_hard::i#2 [ scroll_hard::i#2 scroll_hard::$31 ] ( main:2::scroll_soft:10::scroll_bit:17::scroll_hard:33 [ current_bit#21 nxt#36 current_chargen#19 scroll_hard::i#2 scroll_hard::$31 ] ) -- aby=cowo1_derefidx_xby
lda line7+1,x
//SEG130 [66] *((const byte[]) scroll_hard::line7#0 + (byte) scroll_hard::i#2) ← (byte~) scroll_hard::$31 [ scroll_hard::i#2 ] ( main:2::scroll_soft:10::scroll_bit:17::scroll_hard:33 [ current_bit#21 nxt#36 current_chargen#19 scroll_hard::i#2 ] ) -- cowo1_derefidx_xby=aby
sta line7,x
//SEG131 [67] (byte) scroll_hard::i#1 ← ++ (byte) scroll_hard::i#2 [ scroll_hard::i#1 ] ( main:2::scroll_soft:10::scroll_bit:17::scroll_hard:33 [ current_bit#21 nxt#36 current_chargen#19 scroll_hard::i#1 ] ) -- xby=_inc_xby
inx
//SEG132 [68] if((byte) scroll_hard::i#1!=(byte/signed byte/word/signed word) 39) goto scroll_hard::@1 [ scroll_hard::i#1 ] ( main:2::scroll_soft:10::scroll_bit:17::scroll_hard:33 [ current_bit#21 nxt#36 current_chargen#19 scroll_hard::i#1 ] ) -- xby_neq_coby1_then_la1
cpx #$27
bne b1
//SEG133 scroll_hard::@return
//SEG134 [69] return [ ] ( main:2::scroll_soft:10::scroll_bit:17::scroll_hard:33 [ current_bit#21 nxt#36 current_chargen#19 ] )
rts
}
//SEG135 next_char
next_char: {
//SEG136 [70] (byte) next_char::c#0 ← *((byte*) nxt#31) [ nxt#31 next_char::c#0 ] ( main:2::scroll_soft:10::scroll_bit:17::next_char:25 [ nxt#31 next_char::c#0 ] ) -- aby=_deref_zpptrby1
ldy #0
lda (nxt),y
//SEG137 [71] if((byte) next_char::c#0!=(byte) '@') goto next_char::@1 [ nxt#31 next_char::c#0 ] ( main:2::scroll_soft:10::scroll_bit:17::next_char:25 [ nxt#31 next_char::c#0 ] ) -- aby_neq_coby1_then_la1
cmp #'@'
bne b1
//SEG138 next_char::@2
//SEG139 [72] (byte) next_char::c#1 ← *((const byte*) TEXT#0) [ next_char::c#1 ] ( main:2::scroll_soft:10::scroll_bit:17::next_char:25 [ next_char::c#1 ] ) -- aby=_deref_cowo1
lda TEXT
//SEG140 [73] phi from next_char::@2 to next_char::@1 [phi:next_char::@2->next_char::@1]
//SEG141 [73] phi (byte) next_char::c#2 = (byte) next_char::c#1 [phi:next_char::@2->next_char::@1#0] -- register_copy
//SEG142 [73] phi (byte*) nxt#18 = (const byte*) TEXT#0 [phi:next_char::@2->next_char::@1#1] -- zpptrby1=cowo1
lda #<TEXT
sta nxt
lda #>TEXT
sta nxt+1
jmp b1
//SEG143 [73] phi from next_char to next_char::@1 [phi:next_char->next_char::@1]
//SEG144 [73] phi (byte) next_char::c#2 = (byte) next_char::c#0 [phi:next_char->next_char::@1#0] -- register_copy
//SEG145 [73] phi (byte*) nxt#18 = (byte*) nxt#31 [phi:next_char->next_char::@1#1] -- register_copy
//SEG146 next_char::@1
b1:
//SEG147 [74] (byte*) nxt#19 ← ++ (byte*) nxt#18 [ next_char::c#2 nxt#19 ] ( main:2::scroll_soft:10::scroll_bit:17::next_char:25 [ next_char::c#2 nxt#19 ] ) -- zpptrby1=_inc_zpptrby1
inc nxt
bne !+
inc nxt+1
!:
//SEG148 next_char::@return
//SEG149 [75] return [ next_char::c#2 nxt#19 ] ( main:2::scroll_soft:10::scroll_bit:17::next_char:25 [ next_char::c#2 nxt#19 ] )
rts
}
//SEG150 fillscreen
fillscreen: {
.const fill = $20
.label cursor = 3
//SEG151 [77] phi from fillscreen to fillscreen::@1 [phi:fillscreen->fillscreen::@1]
//SEG152 [77] phi (byte*) fillscreen::cursor#2 = (const byte*) SCREEN#0 [phi:fillscreen->fillscreen::@1#0] -- zpptrby1=cowo1
lda #<SCREEN
sta cursor
lda #>SCREEN
sta cursor+1
jmp b1
//SEG153 [77] phi from fillscreen::@1 to fillscreen::@1 [phi:fillscreen::@1->fillscreen::@1]
//SEG154 [77] phi (byte*) fillscreen::cursor#2 = (byte*) fillscreen::cursor#1 [phi:fillscreen::@1->fillscreen::@1#0] -- register_copy
//SEG155 fillscreen::@1
b1:
//SEG156 [78] *((byte*) fillscreen::cursor#2) ← (const byte) fillscreen::fill#0 [ fillscreen::cursor#2 ] ( main:2::fillscreen:5 [ fillscreen::cursor#2 ] ) -- _deref_zpptrby1=coby1
ldy #0
lda #fill
sta (cursor),y
//SEG157 [79] (byte*) fillscreen::cursor#1 ← ++ (byte*) fillscreen::cursor#2 [ fillscreen::cursor#1 ] ( main:2::fillscreen:5 [ fillscreen::cursor#1 ] ) -- zpptrby1=_inc_zpptrby1
inc cursor
bne !+
inc cursor+1
!:
//SEG158 [80] if((byte*) fillscreen::cursor#1<(const byte*) SCREEN#0+(word/signed word) 1000) goto fillscreen::@1 [ fillscreen::cursor#1 ] ( main:2::fillscreen:5 [ fillscreen::cursor#1 ] ) -- zpptrby1_lt_cowo1_then_la1
lda cursor+1
cmp #>SCREEN+$3e8
bcc b1
bne !+
lda cursor
cmp #<SCREEN+$3e8
bcc b1
!:
//SEG159 fillscreen::@return
//SEG160 [81] return [ ] ( main:2::fillscreen:5 [ ] )
rts
}
Removing unreachable instruction rts
Succesful ASM optimization Pass5AfterRtsElimination
ASSEMBLER
//SEG0 Basic Upstart
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
//SEG1 Global Constants & labels
.const PROCPORT = 1
.const CHARGEN = $d000
.const SCREEN = $400
.const RASTER = $d012
.const BGCOL = $d020
.const SCROLL = $d016
.label current_bit = 2
.label current_chargen = 3
.label nxt = 7
TEXT: .text "-= this is rex of camelot testing a scroller created in kickc. kickc is an optimizing c-compiler for 6502 assembler. =- @"
//SEG2 @begin
//SEG3 [1] phi from @begin to @6 [phi:@begin->@6]
//SEG4 @6
//SEG5 [2] call main param-assignment [ ] ( )
//SEG6 [4] phi from @6 to main [phi:@6->main]
jsr main
//SEG7 [3] phi from @6 to @end [phi:@6->@end]
//SEG8 @end
//SEG9 main
main: {
//SEG10 [5] call fillscreen param-assignment [ ] ( main:2 [ ] )
//SEG11 [76] phi from main to fillscreen [phi:main->fillscreen]
jsr fillscreen
//SEG12 [6] phi from main to main::@2 [phi:main->main::@2]
//SEG13 [6] phi (byte*) current_chargen#27 = (const byte*) CHARGEN#0 [phi:main->main::@2#0] -- zpptrby1=cowo1
lda #<CHARGEN
sta current_chargen
lda #>CHARGEN
sta current_chargen+1
//SEG14 [6] phi (byte*) nxt#31 = (const byte*) TEXT#0 [phi:main->main::@2#1] -- zpptrby1=cowo1
lda #<TEXT
sta nxt
lda #>TEXT
sta nxt+1
//SEG15 [6] phi (byte) current_bit#29 = (byte/signed byte/word/signed word) 1 [phi:main->main::@2#2] -- zpby1=coby1
lda #1
sta current_bit
//SEG16 [6] phi (byte) scroll#18 = (byte/signed byte/word/signed word) 7 [phi:main->main::@2#3] -- xby=coby1
ldx #7
jmp b2
//SEG17 [6] phi from main::@2 to main::@2 [phi:main::@2->main::@2]
b2_from_b2:
jmp b2
//SEG18 [6] phi from main::@8 to main::@2 [phi:main::@8->main::@2]
//SEG19 [6] phi (byte*) current_chargen#27 = (byte*) current_chargen#11 [phi:main::@8->main::@2#0] -- register_copy
//SEG20 [6] phi (byte*) nxt#31 = (byte*) nxt#14 [phi:main::@8->main::@2#1] -- register_copy
//SEG21 [6] phi (byte) current_bit#29 = (byte) current_bit#12 [phi:main::@8->main::@2#2] -- register_copy
//SEG22 [6] phi (byte) scroll#18 = (byte) scroll#10 [phi:main::@8->main::@2#3] -- register_copy
//SEG23 main::@2
b2:
//SEG24 [7] if(*((const byte*) RASTER#0)!=(byte/word/signed word) 254) goto main::@2 [ scroll#18 current_bit#29 nxt#31 current_chargen#27 ] ( main:2 [ scroll#18 current_bit#29 nxt#31 current_chargen#27 ] ) -- _deref_cowo1_neq_coby2_then_la1
lda RASTER
cmp #$fe
bne b2
//SEG25 main::@3
b3:
//SEG26 [8] if(*((const byte*) RASTER#0)!=(byte/word/signed word) 255) goto main::@3 [ scroll#18 current_bit#29 nxt#31 current_chargen#27 ] ( main:2 [ scroll#18 current_bit#29 nxt#31 current_chargen#27 ] ) -- _deref_cowo1_neq_coby2_then_la1
lda RASTER
cmp #$ff
bne b3
//SEG27 main::@5
//SEG28 [9] *((const byte*) BGCOL#0) ← ++ *((const byte*) BGCOL#0) [ scroll#18 current_bit#29 nxt#31 current_chargen#27 ] ( main:2 [ scroll#18 current_bit#29 nxt#31 current_chargen#27 ] ) -- _deref_cowo1=_inc__deref_cowo1
inc BGCOL
//SEG29 [10] call scroll_soft param-assignment [ scroll#10 current_bit#12 nxt#14 current_chargen#11 ] ( main:2 [ scroll#10 current_bit#12 nxt#14 current_chargen#11 ] )
jsr scroll_soft
//SEG30 main::@8
//SEG31 [11] *((const byte*) BGCOL#0) ← -- *((const byte*) BGCOL#0) [ scroll#10 current_bit#12 nxt#14 current_chargen#11 ] ( main:2 [ scroll#10 current_bit#12 nxt#14 current_chargen#11 ] ) -- _deref_cowo1=_dec__deref_cowo1
dec BGCOL
//SEG32 [12] if(true) goto main::@2 [ scroll#10 current_bit#12 nxt#14 current_chargen#11 ] ( main:2 [ scroll#10 current_bit#12 nxt#14 current_chargen#11 ] ) -- true_then_la1
jmp b2
//SEG33 main::@return
//SEG34 [13] return [ ] ( main:2 [ ] )
}
//SEG35 scroll_soft
scroll_soft: {
//SEG36 [14] (byte) scroll#3 ← -- (byte) scroll#18 [ current_bit#29 nxt#31 current_chargen#27 scroll#3 ] ( main:2::scroll_soft:10 [ current_bit#29 nxt#31 current_chargen#27 scroll#3 ] ) -- xby=_dec_xby
dex
//SEG37 [15] if((byte) scroll#3!=(byte/word/signed word) 255) goto scroll_soft::@1 [ current_bit#29 nxt#31 current_chargen#27 scroll#3 ] ( main:2::scroll_soft:10 [ current_bit#29 nxt#31 current_chargen#27 scroll#3 ] ) -- xby_neq_coby1_then_la1
cpx #$ff
bne b1
//SEG38 [16] phi from scroll_soft to scroll_soft::@2 [phi:scroll_soft->scroll_soft::@2]
//SEG39 scroll_soft::@2
//SEG40 [17] call scroll_bit param-assignment [ current_bit#21 nxt#36 current_chargen#19 ] ( main:2::scroll_soft:10 [ current_bit#21 nxt#36 current_chargen#19 ] )
jsr scroll_bit
//SEG41 [18] phi from scroll_soft::@2 to scroll_soft::@1 [phi:scroll_soft::@2->scroll_soft::@1]
//SEG42 [18] phi (byte*) current_chargen#11 = (byte*) current_chargen#19 [phi:scroll_soft::@2->scroll_soft::@1#0] -- register_copy
//SEG43 [18] phi (byte*) nxt#14 = (byte*) nxt#36 [phi:scroll_soft::@2->scroll_soft::@1#1] -- register_copy
//SEG44 [18] phi (byte) current_bit#12 = (byte) current_bit#21 [phi:scroll_soft::@2->scroll_soft::@1#2] -- register_copy
//SEG45 [18] phi (byte) scroll#10 = (byte/signed byte/word/signed word) 7 [phi:scroll_soft::@2->scroll_soft::@1#3] -- xby=coby1
ldx #7
jmp b1
//SEG46 [18] phi from scroll_soft to scroll_soft::@1 [phi:scroll_soft->scroll_soft::@1]
//SEG47 [18] phi (byte*) current_chargen#11 = (byte*) current_chargen#27 [phi:scroll_soft->scroll_soft::@1#0] -- register_copy
//SEG48 [18] phi (byte*) nxt#14 = (byte*) nxt#31 [phi:scroll_soft->scroll_soft::@1#1] -- register_copy
//SEG49 [18] phi (byte) current_bit#12 = (byte) current_bit#29 [phi:scroll_soft->scroll_soft::@1#2] -- register_copy
//SEG50 [18] phi (byte) scroll#10 = (byte) scroll#3 [phi:scroll_soft->scroll_soft::@1#3] -- register_copy
//SEG51 scroll_soft::@1
b1:
//SEG52 [19] *((const byte*) SCROLL#0) ← (byte) scroll#10 [ scroll#10 current_bit#12 nxt#14 current_chargen#11 ] ( main:2::scroll_soft:10 [ scroll#10 current_bit#12 nxt#14 current_chargen#11 ] ) -- _deref_cowo1=xby
stx SCROLL
//SEG53 scroll_soft::@return
//SEG54 [20] return [ scroll#10 current_bit#12 nxt#14 current_chargen#11 ] ( main:2::scroll_soft:10 [ scroll#10 current_bit#12 nxt#14 current_chargen#11 ] )
rts
}
//SEG55 scroll_bit
scroll_bit: {
.label _4 = 9
.label _5 = 3
.label c = 9
.label sc = 5
//SEG56 [21] (byte~) scroll_bit::$0 ← (byte) current_bit#29 >> (byte/signed byte/word/signed word) 1 [ nxt#31 current_chargen#27 scroll_bit::$0 ] ( main:2::scroll_soft:10::scroll_bit:17 [ nxt#31 current_chargen#27 scroll_bit::$0 ] ) -- aby=zpby1_ror_1
lda current_bit
lsr
//SEG57 [22] (byte) current_bit#5 ← (byte~) scroll_bit::$0 [ nxt#31 current_chargen#27 current_bit#5 ] ( main:2::scroll_soft:10::scroll_bit:17 [ nxt#31 current_chargen#27 current_bit#5 ] ) -- zpby1=aby
sta current_bit
//SEG58 [23] if((byte) current_bit#5!=(byte/signed byte/word/signed word) 0) goto scroll_bit::@1 [ nxt#31 current_chargen#27 current_bit#5 ] ( main:2::scroll_soft:10::scroll_bit:17 [ nxt#31 current_chargen#27 current_bit#5 ] ) -- zpby1_neq_0_then_la1
bne b1
//SEG59 [24] phi from scroll_bit to scroll_bit::@4 [phi:scroll_bit->scroll_bit::@4]
//SEG60 scroll_bit::@4
//SEG61 [25] call next_char param-assignment [ next_char::c#2 nxt#19 ] ( main:2::scroll_soft:10::scroll_bit:17 [ next_char::c#2 nxt#19 ] )
jsr next_char
//SEG62 [26] (byte) next_char::return#0 ← (byte) next_char::c#2 [ next_char::return#0 nxt#19 ] ( main:2::scroll_soft:10::scroll_bit:17 [ next_char::return#0 nxt#19 ] )
// (byte) next_char::return#0 = (byte) next_char::c#2 // register copy reg byte a
//SEG63 scroll_bit::@8
//SEG64 [27] (byte~) scroll_bit::$3 ← (byte) next_char::return#0 [ scroll_bit::$3 nxt#19 ] ( main:2::scroll_soft:10::scroll_bit:17 [ scroll_bit::$3 nxt#19 ] )
// (byte~) scroll_bit::$3 = (byte) next_char::return#0 // register copy reg byte a
//SEG65 [28] (word) scroll_bit::c#0 ← ((word)) (byte~) scroll_bit::$3 [ scroll_bit::c#0 nxt#19 ] ( main:2::scroll_soft:10::scroll_bit:17 [ scroll_bit::c#0 nxt#19 ] ) -- zpwo1=_word_aby
sta c
lda #0
sta c+1
//SEG66 [29] (word~) scroll_bit::$4 ← (word) scroll_bit::c#0 << (byte/signed byte/word/signed word) 3 [ scroll_bit::$4 nxt#19 ] ( main:2::scroll_soft:10::scroll_bit:17 [ scroll_bit::$4 nxt#19 ] ) -- zpwo1=zpwo1_rol_3
asl _4
rol _4+1
asl _4
rol _4+1
asl _4
rol _4+1
//SEG67 [30] (byte*~) scroll_bit::$5 ← (const byte*) CHARGEN#0 + (word~) scroll_bit::$4 [ scroll_bit::$5 nxt#19 ] ( main:2::scroll_soft:10::scroll_bit:17 [ scroll_bit::$5 nxt#19 ] ) -- zpptrby1=cowo1_plus_zpwo1
lda #<CHARGEN
clc
adc _4
sta _5
lda #>CHARGEN
adc _4+1
sta _5+1
//SEG68 [31] (byte*) current_chargen#5 ← (byte*~) scroll_bit::$5 [ current_chargen#5 nxt#19 ] ( main:2::scroll_soft:10::scroll_bit:17 [ current_chargen#5 nxt#19 ] )
// (byte*) current_chargen#5 = (byte*~) scroll_bit::$5 // register copy zp ZP_PTR_BYTE:3
//SEG69 [32] phi from scroll_bit::@8 to scroll_bit::@1 [phi:scroll_bit::@8->scroll_bit::@1]
//SEG70 [32] phi (byte*) nxt#36 = (byte*) nxt#19 [phi:scroll_bit::@8->scroll_bit::@1#0] -- register_copy
//SEG71 [32] phi (byte) current_bit#21 = (byte/word/signed word) 128 [phi:scroll_bit::@8->scroll_bit::@1#1] -- zpby1=coby1
lda #$80
sta current_bit
//SEG72 [32] phi (byte*) current_chargen#19 = (byte*) current_chargen#5 [phi:scroll_bit::@8->scroll_bit::@1#2] -- register_copy
jmp b1
//SEG73 [32] phi from scroll_bit to scroll_bit::@1 [phi:scroll_bit->scroll_bit::@1]
//SEG74 [32] phi (byte*) nxt#36 = (byte*) nxt#31 [phi:scroll_bit->scroll_bit::@1#0] -- register_copy
//SEG75 [32] phi (byte) current_bit#21 = (byte) current_bit#5 [phi:scroll_bit->scroll_bit::@1#1] -- register_copy
//SEG76 [32] phi (byte*) current_chargen#19 = (byte*) current_chargen#27 [phi:scroll_bit->scroll_bit::@1#2] -- register_copy
//SEG77 scroll_bit::@1
b1:
//SEG78 [33] call scroll_hard param-assignment [ current_bit#21 nxt#36 current_chargen#19 ] ( main:2::scroll_soft:10::scroll_bit:17 [ current_bit#21 nxt#36 current_chargen#19 ] )
//SEG79 [49] phi from scroll_bit::@1 to scroll_hard [phi:scroll_bit::@1->scroll_hard]
jsr scroll_hard
//SEG80 scroll_bit::@7
//SEG81 asm { sei }
sei
//SEG82 [35] *((const byte*) PROCPORT#0) ← (byte/signed byte/word/signed word) 50 [ current_bit#21 nxt#36 current_chargen#19 ] ( main:2::scroll_soft:10::scroll_bit:17 [ current_bit#21 nxt#36 current_chargen#19 ] ) -- _deref_cowo1=coby2
lda #$32
sta PROCPORT
//SEG83 [36] phi from scroll_bit::@7 to scroll_bit::@2 [phi:scroll_bit::@7->scroll_bit::@2]
//SEG84 [36] phi (byte*) scroll_bit::sc#2 = (const byte*) SCREEN#0+(byte/signed byte/word/signed word) 40+(byte/signed byte/word/signed word) 39 [phi:scroll_bit::@7->scroll_bit::@2#0] -- zpptrby1=cowo1
lda #<SCREEN+$28+$27
sta sc
lda #>SCREEN+$28+$27
sta sc+1
//SEG85 [36] phi (byte) scroll_bit::r#2 = (byte/signed byte/word/signed word) 0 [phi:scroll_bit::@7->scroll_bit::@2#1] -- xby=coby1
ldx #0
jmp b2
//SEG86 [36] phi from scroll_bit::@3 to scroll_bit::@2 [phi:scroll_bit::@3->scroll_bit::@2]
//SEG87 [36] phi (byte*) scroll_bit::sc#2 = (byte*) scroll_bit::sc#1 [phi:scroll_bit::@3->scroll_bit::@2#0] -- register_copy
//SEG88 [36] phi (byte) scroll_bit::r#2 = (byte) scroll_bit::r#1 [phi:scroll_bit::@3->scroll_bit::@2#1] -- register_copy
//SEG89 scroll_bit::@2
b2:
//SEG90 [37] (byte) scroll_bit::bits#0 ← (byte*) current_chargen#19 *idx (byte) scroll_bit::r#2 [ current_bit#21 nxt#36 current_chargen#19 scroll_bit::r#2 scroll_bit::sc#2 scroll_bit::bits#0 ] ( main:2::scroll_soft:10::scroll_bit:17 [ current_bit#21 nxt#36 current_chargen#19 scroll_bit::r#2 scroll_bit::sc#2 scroll_bit::bits#0 ] ) -- aby=zpptrby1_derefidx_xby
stx $ff
ldy $ff
lda (current_chargen),y
//SEG91 [38] (byte~) scroll_bit::$10 ← (byte) scroll_bit::bits#0 & (byte) current_bit#21 [ current_bit#21 nxt#36 current_chargen#19 scroll_bit::r#2 scroll_bit::sc#2 scroll_bit::$10 ] ( main:2::scroll_soft:10::scroll_bit:17 [ current_bit#21 nxt#36 current_chargen#19 scroll_bit::r#2 scroll_bit::sc#2 scroll_bit::$10 ] ) -- aby=aby_band_zpby1
and current_bit
//SEG92 [39] if((byte~) scroll_bit::$10==(byte/signed byte/word/signed word) 0) goto scroll_bit::@3 [ current_bit#21 nxt#36 current_chargen#19 scroll_bit::r#2 scroll_bit::sc#2 ] ( main:2::scroll_soft:10::scroll_bit:17 [ current_bit#21 nxt#36 current_chargen#19 scroll_bit::r#2 scroll_bit::sc#2 ] ) -- aby_eq_0_then_la1
cmp #0
beq b3_from_b2
//SEG93 [40] phi from scroll_bit::@2 to scroll_bit::@5 [phi:scroll_bit::@2->scroll_bit::@5]
//SEG94 scroll_bit::@5
//SEG95 [41] phi from scroll_bit::@5 to scroll_bit::@3 [phi:scroll_bit::@5->scroll_bit::@3]
//SEG96 [41] phi (byte) scroll_bit::b#2 = (byte/word/signed word) 128+(byte) ' ' [phi:scroll_bit::@5->scroll_bit::@3#0] -- aby=coby1
lda #$80+' '
jmp b3
//SEG97 [41] phi from scroll_bit::@2 to scroll_bit::@3 [phi:scroll_bit::@2->scroll_bit::@3]
b3_from_b2:
//SEG98 [41] phi (byte) scroll_bit::b#2 = (byte) ' ' [phi:scroll_bit::@2->scroll_bit::@3#0] -- aby=coby1
lda #' '
//SEG99 scroll_bit::@3
b3:
//SEG100 [42] *((byte*) scroll_bit::sc#2) ← (byte) scroll_bit::b#2 [ current_bit#21 nxt#36 current_chargen#19 scroll_bit::r#2 scroll_bit::sc#2 ] ( main:2::scroll_soft:10::scroll_bit:17 [ current_bit#21 nxt#36 current_chargen#19 scroll_bit::r#2 scroll_bit::sc#2 ] ) -- _deref_zpptrby1=aby
ldy #0
sta (sc),y
//SEG101 [43] (byte*) scroll_bit::sc#1 ← (byte*) scroll_bit::sc#2 + (byte/signed byte/word/signed word) 40 [ current_bit#21 nxt#36 current_chargen#19 scroll_bit::r#2 scroll_bit::sc#1 ] ( main:2::scroll_soft:10::scroll_bit:17 [ current_bit#21 nxt#36 current_chargen#19 scroll_bit::r#2 scroll_bit::sc#1 ] ) -- zpptrby1=zpptrby1_plus_coby1
lda sc
clc
adc #$28
sta sc
bcc !+
inc sc+1
!:
//SEG102 [44] (byte) scroll_bit::r#1 ← ++ (byte) scroll_bit::r#2 [ current_bit#21 nxt#36 current_chargen#19 scroll_bit::r#1 scroll_bit::sc#1 ] ( main:2::scroll_soft:10::scroll_bit:17 [ current_bit#21 nxt#36 current_chargen#19 scroll_bit::r#1 scroll_bit::sc#1 ] ) -- xby=_inc_xby
inx
//SEG103 [45] if((byte) scroll_bit::r#1!=(byte/signed byte/word/signed word) 8) goto scroll_bit::@2 [ current_bit#21 nxt#36 current_chargen#19 scroll_bit::r#1 scroll_bit::sc#1 ] ( main:2::scroll_soft:10::scroll_bit:17 [ current_bit#21 nxt#36 current_chargen#19 scroll_bit::r#1 scroll_bit::sc#1 ] ) -- xby_neq_coby1_then_la1
cpx #8
bne b2
//SEG104 scroll_bit::@6
//SEG105 [46] *((const byte*) PROCPORT#0) ← (byte/signed byte/word/signed word) 55 [ current_bit#21 nxt#36 current_chargen#19 ] ( main:2::scroll_soft:10::scroll_bit:17 [ current_bit#21 nxt#36 current_chargen#19 ] ) -- _deref_cowo1=coby2
lda #$37
sta PROCPORT
//SEG106 asm { cli }
cli
//SEG107 scroll_bit::@return
//SEG108 [48] return [ current_bit#21 nxt#36 current_chargen#19 ] ( main:2::scroll_soft:10::scroll_bit:17 [ current_bit#21 nxt#36 current_chargen#19 ] )
rts
}
//SEG109 scroll_hard
scroll_hard: {
.const line0 = SCREEN+$28*0
.const line1 = SCREEN+$28*1
.const line2 = SCREEN+$28*2
.const line3 = SCREEN+$28*3
.const line4 = SCREEN+$28*4
.const line5 = SCREEN+$28*5
.const line6 = SCREEN+$28*6
.const line7 = SCREEN+$28*7
//SEG110 [50] phi from scroll_hard to scroll_hard::@1 [phi:scroll_hard->scroll_hard::@1]
//SEG111 [50] phi (byte) scroll_hard::i#2 = (byte/signed byte/word/signed word) 0 [phi:scroll_hard->scroll_hard::@1#0] -- xby=coby1
ldx #0
jmp b1
//SEG112 [50] phi from scroll_hard::@1 to scroll_hard::@1 [phi:scroll_hard::@1->scroll_hard::@1]
//SEG113 [50] phi (byte) scroll_hard::i#2 = (byte) scroll_hard::i#1 [phi:scroll_hard::@1->scroll_hard::@1#0] -- register_copy
//SEG114 scroll_hard::@1
b1:
//SEG115 [51] (byte~) scroll_hard::$17 ← (const byte[]) scroll_hard::line0#0+(byte/signed byte/word/signed word) 1 *idx (byte) scroll_hard::i#2 [ scroll_hard::i#2 scroll_hard::$17 ] ( main:2::scroll_soft:10::scroll_bit:17::scroll_hard:33 [ current_bit#21 nxt#36 current_chargen#19 scroll_hard::i#2 scroll_hard::$17 ] ) -- aby=cowo1_derefidx_xby
lda line0+1,x
//SEG116 [52] *((const byte[]) scroll_hard::line0#0 + (byte) scroll_hard::i#2) ← (byte~) scroll_hard::$17 [ scroll_hard::i#2 ] ( main:2::scroll_soft:10::scroll_bit:17::scroll_hard:33 [ current_bit#21 nxt#36 current_chargen#19 scroll_hard::i#2 ] ) -- cowo1_derefidx_xby=aby
sta line0,x
//SEG117 [53] (byte~) scroll_hard::$19 ← (const byte[]) scroll_hard::line1#0+(byte/signed byte/word/signed word) 1 *idx (byte) scroll_hard::i#2 [ scroll_hard::i#2 scroll_hard::$19 ] ( main:2::scroll_soft:10::scroll_bit:17::scroll_hard:33 [ current_bit#21 nxt#36 current_chargen#19 scroll_hard::i#2 scroll_hard::$19 ] ) -- aby=cowo1_derefidx_xby
lda line1+1,x
//SEG118 [54] *((const byte[]) scroll_hard::line1#0 + (byte) scroll_hard::i#2) ← (byte~) scroll_hard::$19 [ scroll_hard::i#2 ] ( main:2::scroll_soft:10::scroll_bit:17::scroll_hard:33 [ current_bit#21 nxt#36 current_chargen#19 scroll_hard::i#2 ] ) -- cowo1_derefidx_xby=aby
sta line1,x
//SEG119 [55] (byte~) scroll_hard::$21 ← (const byte[]) scroll_hard::line2#0+(byte/signed byte/word/signed word) 1 *idx (byte) scroll_hard::i#2 [ scroll_hard::i#2 scroll_hard::$21 ] ( main:2::scroll_soft:10::scroll_bit:17::scroll_hard:33 [ current_bit#21 nxt#36 current_chargen#19 scroll_hard::i#2 scroll_hard::$21 ] ) -- aby=cowo1_derefidx_xby
lda line2+1,x
//SEG120 [56] *((const byte[]) scroll_hard::line2#0 + (byte) scroll_hard::i#2) ← (byte~) scroll_hard::$21 [ scroll_hard::i#2 ] ( main:2::scroll_soft:10::scroll_bit:17::scroll_hard:33 [ current_bit#21 nxt#36 current_chargen#19 scroll_hard::i#2 ] ) -- cowo1_derefidx_xby=aby
sta line2,x
//SEG121 [57] (byte~) scroll_hard::$23 ← (const byte[]) scroll_hard::line3#0+(byte/signed byte/word/signed word) 1 *idx (byte) scroll_hard::i#2 [ scroll_hard::i#2 scroll_hard::$23 ] ( main:2::scroll_soft:10::scroll_bit:17::scroll_hard:33 [ current_bit#21 nxt#36 current_chargen#19 scroll_hard::i#2 scroll_hard::$23 ] ) -- aby=cowo1_derefidx_xby
lda line3+1,x
//SEG122 [58] *((const byte[]) scroll_hard::line3#0 + (byte) scroll_hard::i#2) ← (byte~) scroll_hard::$23 [ scroll_hard::i#2 ] ( main:2::scroll_soft:10::scroll_bit:17::scroll_hard:33 [ current_bit#21 nxt#36 current_chargen#19 scroll_hard::i#2 ] ) -- cowo1_derefidx_xby=aby
sta line3,x
//SEG123 [59] (byte~) scroll_hard::$25 ← (const byte[]) scroll_hard::line4#0+(byte/signed byte/word/signed word) 1 *idx (byte) scroll_hard::i#2 [ scroll_hard::i#2 scroll_hard::$25 ] ( main:2::scroll_soft:10::scroll_bit:17::scroll_hard:33 [ current_bit#21 nxt#36 current_chargen#19 scroll_hard::i#2 scroll_hard::$25 ] ) -- aby=cowo1_derefidx_xby
lda line4+1,x
//SEG124 [60] *((const byte[]) scroll_hard::line4#0 + (byte) scroll_hard::i#2) ← (byte~) scroll_hard::$25 [ scroll_hard::i#2 ] ( main:2::scroll_soft:10::scroll_bit:17::scroll_hard:33 [ current_bit#21 nxt#36 current_chargen#19 scroll_hard::i#2 ] ) -- cowo1_derefidx_xby=aby
sta line4,x
//SEG125 [61] (byte~) scroll_hard::$27 ← (const byte[]) scroll_hard::line5#0+(byte/signed byte/word/signed word) 1 *idx (byte) scroll_hard::i#2 [ scroll_hard::i#2 scroll_hard::$27 ] ( main:2::scroll_soft:10::scroll_bit:17::scroll_hard:33 [ current_bit#21 nxt#36 current_chargen#19 scroll_hard::i#2 scroll_hard::$27 ] ) -- aby=cowo1_derefidx_xby
lda line5+1,x
//SEG126 [62] *((const byte[]) scroll_hard::line5#0 + (byte) scroll_hard::i#2) ← (byte~) scroll_hard::$27 [ scroll_hard::i#2 ] ( main:2::scroll_soft:10::scroll_bit:17::scroll_hard:33 [ current_bit#21 nxt#36 current_chargen#19 scroll_hard::i#2 ] ) -- cowo1_derefidx_xby=aby
sta line5,x
//SEG127 [63] (byte~) scroll_hard::$29 ← (const byte[]) scroll_hard::line6#0+(byte/signed byte/word/signed word) 1 *idx (byte) scroll_hard::i#2 [ scroll_hard::i#2 scroll_hard::$29 ] ( main:2::scroll_soft:10::scroll_bit:17::scroll_hard:33 [ current_bit#21 nxt#36 current_chargen#19 scroll_hard::i#2 scroll_hard::$29 ] ) -- aby=cowo1_derefidx_xby
lda line6+1,x
//SEG128 [64] *((const byte[]) scroll_hard::line6#0 + (byte) scroll_hard::i#2) ← (byte~) scroll_hard::$29 [ scroll_hard::i#2 ] ( main:2::scroll_soft:10::scroll_bit:17::scroll_hard:33 [ current_bit#21 nxt#36 current_chargen#19 scroll_hard::i#2 ] ) -- cowo1_derefidx_xby=aby
sta line6,x
//SEG129 [65] (byte~) scroll_hard::$31 ← (const byte[]) scroll_hard::line7#0+(byte/signed byte/word/signed word) 1 *idx (byte) scroll_hard::i#2 [ scroll_hard::i#2 scroll_hard::$31 ] ( main:2::scroll_soft:10::scroll_bit:17::scroll_hard:33 [ current_bit#21 nxt#36 current_chargen#19 scroll_hard::i#2 scroll_hard::$31 ] ) -- aby=cowo1_derefidx_xby
lda line7+1,x
//SEG130 [66] *((const byte[]) scroll_hard::line7#0 + (byte) scroll_hard::i#2) ← (byte~) scroll_hard::$31 [ scroll_hard::i#2 ] ( main:2::scroll_soft:10::scroll_bit:17::scroll_hard:33 [ current_bit#21 nxt#36 current_chargen#19 scroll_hard::i#2 ] ) -- cowo1_derefidx_xby=aby
sta line7,x
//SEG131 [67] (byte) scroll_hard::i#1 ← ++ (byte) scroll_hard::i#2 [ scroll_hard::i#1 ] ( main:2::scroll_soft:10::scroll_bit:17::scroll_hard:33 [ current_bit#21 nxt#36 current_chargen#19 scroll_hard::i#1 ] ) -- xby=_inc_xby
inx
//SEG132 [68] if((byte) scroll_hard::i#1!=(byte/signed byte/word/signed word) 39) goto scroll_hard::@1 [ scroll_hard::i#1 ] ( main:2::scroll_soft:10::scroll_bit:17::scroll_hard:33 [ current_bit#21 nxt#36 current_chargen#19 scroll_hard::i#1 ] ) -- xby_neq_coby1_then_la1
cpx #$27
bne b1
//SEG133 scroll_hard::@return
//SEG134 [69] return [ ] ( main:2::scroll_soft:10::scroll_bit:17::scroll_hard:33 [ current_bit#21 nxt#36 current_chargen#19 ] )
rts
}
//SEG135 next_char
next_char: {
//SEG136 [70] (byte) next_char::c#0 ← *((byte*) nxt#31) [ nxt#31 next_char::c#0 ] ( main:2::scroll_soft:10::scroll_bit:17::next_char:25 [ nxt#31 next_char::c#0 ] ) -- aby=_deref_zpptrby1
ldy #0
lda (nxt),y
//SEG137 [71] if((byte) next_char::c#0!=(byte) '@') goto next_char::@1 [ nxt#31 next_char::c#0 ] ( main:2::scroll_soft:10::scroll_bit:17::next_char:25 [ nxt#31 next_char::c#0 ] ) -- aby_neq_coby1_then_la1
cmp #'@'
bne b1
//SEG138 next_char::@2
//SEG139 [72] (byte) next_char::c#1 ← *((const byte*) TEXT#0) [ next_char::c#1 ] ( main:2::scroll_soft:10::scroll_bit:17::next_char:25 [ next_char::c#1 ] ) -- aby=_deref_cowo1
lda TEXT
//SEG140 [73] phi from next_char::@2 to next_char::@1 [phi:next_char::@2->next_char::@1]
//SEG141 [73] phi (byte) next_char::c#2 = (byte) next_char::c#1 [phi:next_char::@2->next_char::@1#0] -- register_copy
//SEG142 [73] phi (byte*) nxt#18 = (const byte*) TEXT#0 [phi:next_char::@2->next_char::@1#1] -- zpptrby1=cowo1
lda #<TEXT
sta nxt
lda #>TEXT
sta nxt+1
jmp b1
//SEG143 [73] phi from next_char to next_char::@1 [phi:next_char->next_char::@1]
//SEG144 [73] phi (byte) next_char::c#2 = (byte) next_char::c#0 [phi:next_char->next_char::@1#0] -- register_copy
//SEG145 [73] phi (byte*) nxt#18 = (byte*) nxt#31 [phi:next_char->next_char::@1#1] -- register_copy
//SEG146 next_char::@1
b1:
//SEG147 [74] (byte*) nxt#19 ← ++ (byte*) nxt#18 [ next_char::c#2 nxt#19 ] ( main:2::scroll_soft:10::scroll_bit:17::next_char:25 [ next_char::c#2 nxt#19 ] ) -- zpptrby1=_inc_zpptrby1
inc nxt
bne !+
inc nxt+1
!:
//SEG148 next_char::@return
//SEG149 [75] return [ next_char::c#2 nxt#19 ] ( main:2::scroll_soft:10::scroll_bit:17::next_char:25 [ next_char::c#2 nxt#19 ] )
rts
}
//SEG150 fillscreen
fillscreen: {
.const fill = $20
.label cursor = 3
//SEG151 [77] phi from fillscreen to fillscreen::@1 [phi:fillscreen->fillscreen::@1]
//SEG152 [77] phi (byte*) fillscreen::cursor#2 = (const byte*) SCREEN#0 [phi:fillscreen->fillscreen::@1#0] -- zpptrby1=cowo1
lda #<SCREEN
sta cursor
lda #>SCREEN
sta cursor+1
jmp b1
//SEG153 [77] phi from fillscreen::@1 to fillscreen::@1 [phi:fillscreen::@1->fillscreen::@1]
//SEG154 [77] phi (byte*) fillscreen::cursor#2 = (byte*) fillscreen::cursor#1 [phi:fillscreen::@1->fillscreen::@1#0] -- register_copy
//SEG155 fillscreen::@1
b1:
//SEG156 [78] *((byte*) fillscreen::cursor#2) ← (const byte) fillscreen::fill#0 [ fillscreen::cursor#2 ] ( main:2::fillscreen:5 [ fillscreen::cursor#2 ] ) -- _deref_zpptrby1=coby1
ldy #0
lda #fill
sta (cursor),y
//SEG157 [79] (byte*) fillscreen::cursor#1 ← ++ (byte*) fillscreen::cursor#2 [ fillscreen::cursor#1 ] ( main:2::fillscreen:5 [ fillscreen::cursor#1 ] ) -- zpptrby1=_inc_zpptrby1
inc cursor
bne !+
inc cursor+1
!:
//SEG158 [80] if((byte*) fillscreen::cursor#1<(const byte*) SCREEN#0+(word/signed word) 1000) goto fillscreen::@1 [ fillscreen::cursor#1 ] ( main:2::fillscreen:5 [ fillscreen::cursor#1 ] ) -- zpptrby1_lt_cowo1_then_la1
lda cursor+1
cmp #>SCREEN+$3e8
bcc b1
bne !+
lda cursor
cmp #<SCREEN+$3e8
bcc b1
!:
//SEG159 fillscreen::@return
//SEG160 [81] return [ ] ( main:2::fillscreen:5 [ ] )
rts
}
Removing instruction jmp b2
Removing instruction jmp b1
Removing instruction jmp b1
@ -10487,7 +11224,7 @@ main: {
//SEG24 [7] if(*((const byte*) RASTER#0)!=(byte/word/signed word) 254) goto main::@2 [ scroll#18 current_bit#29 nxt#31 current_chargen#27 ] ( main:2 [ scroll#18 current_bit#29 nxt#31 current_chargen#27 ] ) -- _deref_cowo1_neq_coby2_then_la1
lda RASTER
cmp #$fe
bne b2_from_b2
bne b2
//SEG25 main::@3
b3:
//SEG26 [8] if(*((const byte*) RASTER#0)!=(byte/word/signed word) 255) goto main::@3 [ scroll#18 current_bit#29 nxt#31 current_chargen#27 ] ( main:2 [ scroll#18 current_bit#29 nxt#31 current_chargen#27 ] ) -- _deref_cowo1_neq_coby2_then_la1
@ -10506,7 +11243,6 @@ main: {
jmp b2
//SEG33 main::@return
//SEG34 [13] return [ ] ( main:2 [ ] )
rts
}
//SEG35 scroll_soft
scroll_soft: {
@ -10789,7 +11525,6 @@ fillscreen: {
rts
}
Replacing label b2_from_b2 with b2
Removing instruction b2_from_b2:
Succesful ASM optimization Pass5RedundantLabelElimination
ASSEMBLER
@ -10868,7 +11603,6 @@ main: {
jmp b2
//SEG33 main::@return
//SEG34 [13] return [ ] ( main:2 [ ] )
rts
}
//SEG35 scroll_soft
scroll_soft: {
@ -11228,7 +11962,6 @@ main: {
jmp b2
//SEG33 main::@return
//SEG34 [13] return [ ] ( main:2 [ ] )
rts
}
//SEG35 scroll_soft
scroll_soft: {
@ -11735,7 +12468,6 @@ main: {
jmp b2
//SEG33 main::@return
//SEG34 [13] return [ ] ( main:2 [ ] )
rts
}
//SEG35 scroll_soft
scroll_soft: {

View File

@ -15,7 +15,6 @@ main: {
jsr render
jsr animate
jmp b1
rts
}
animate: {
lda XPOS+0

View File

@ -9916,6 +9916,389 @@ initscreen: {
rts
}
Removing unreachable instruction rts
Succesful ASM optimization Pass5AfterRtsElimination
ASSEMBLER
//SEG0 Basic Upstart
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
//SEG1 Global Constants & labels
.const SCREEN = $400
.const COLORS = $d800
.const FILL = $e6
.const numpoints = 6
XPOS: .byte 5, $f, 6, $22, $15, $1f
YPOS: .byte 5, 8, $e, 2, $11, $16
COLS: .byte 1, 2, 3, 4, 5, 7
//SEG2 @begin
//SEG3 [1] phi from @begin to @5 [phi:@begin->@5]
//SEG4 @5
//SEG5 [2] call main param-assignment [ ] ( )
//SEG6 [4] phi from @5 to main [phi:@5->main]
jsr main
//SEG7 [3] phi from @5 to @end [phi:@5->@end]
//SEG8 @end
//SEG9 main
main: {
//SEG10 [5] call initscreen param-assignment [ ] ( main:2 [ ] )
//SEG11 [91] phi from main to initscreen [phi:main->initscreen]
jsr initscreen
//SEG12 [6] phi from main main::@5 to main::@1 [phi:main/main::@5->main::@1]
//SEG13 main::@1
b1:
//SEG14 [7] call render param-assignment [ ] ( main:2 [ ] )
//SEG15 [51] phi from main::@1 to render [phi:main::@1->render]
jsr render
//SEG16 [8] phi from main::@1 to main::@4 [phi:main::@1->main::@4]
//SEG17 main::@4
//SEG18 [9] call animate param-assignment [ ] ( main:2 [ ] )
jsr animate
//SEG19 main::@5
//SEG20 [10] if(true) goto main::@1 [ ] ( main:2 [ ] ) -- true_then_la1
jmp b1
//SEG21 main::@return
//SEG22 [11] return [ ] ( main:2 [ ] )
}
//SEG23 animate
animate: {
//SEG24 [12] (byte~) animate::$0 ← * (const byte[]) XPOS#0+(byte/signed byte/word/signed word) 0 [ animate::$0 ] ( main:2::animate:9 [ animate::$0 ] ) -- aby=_deref_cowo1
lda XPOS+0
//SEG25 [13] (byte~) animate::$1 ← (byte~) animate::$0 + (byte/signed byte/word/signed word) 1 [ animate::$1 ] ( main:2::animate:9 [ animate::$1 ] ) -- aby=aby_plus_1
clc
adc #1
//SEG26 [14] *((const byte[]) XPOS#0+(byte/signed byte/word/signed word) 0) ← (byte~) animate::$1 [ ] ( main:2::animate:9 [ ] ) -- _deref_cowo1=aby
sta XPOS+0
//SEG27 [15] (byte~) animate::$2 ← * (const byte[]) XPOS#0+(byte/signed byte/word/signed word) 0 [ animate::$2 ] ( main:2::animate:9 [ animate::$2 ] ) -- aby=_deref_cowo1
//SEG28 [16] if((byte~) animate::$2!=(byte/signed byte/word/signed word) 40) goto animate::@1 [ ] ( main:2::animate:9 [ ] ) -- aby_neq_coby1_then_la1
cmp #$28
bne b1
//SEG29 animate::@7
//SEG30 [17] *((const byte[]) XPOS#0+(byte/signed byte/word/signed word) 0) ← (byte/signed byte/word/signed word) 0 [ ] ( main:2::animate:9 [ ] ) -- _deref_cowo1=coby2
lda #0
sta XPOS+0
//SEG31 animate::@1
b1:
//SEG32 [18] (byte~) animate::$5 ← * (const byte[]) YPOS#0+(byte/signed byte/word/signed word) 0 [ animate::$5 ] ( main:2::animate:9 [ animate::$5 ] ) -- aby=_deref_cowo1
lda YPOS+0
//SEG33 [19] (byte~) animate::$6 ← (byte~) animate::$5 + (byte/signed byte/word/signed word) 1 [ animate::$6 ] ( main:2::animate:9 [ animate::$6 ] ) -- aby=aby_plus_1
clc
adc #1
//SEG34 [20] *((const byte[]) YPOS#0+(byte/signed byte/word/signed word) 0) ← (byte~) animate::$6 [ ] ( main:2::animate:9 [ ] ) -- _deref_cowo1=aby
sta YPOS+0
//SEG35 [21] (byte~) animate::$7 ← * (const byte[]) YPOS#0+(byte/signed byte/word/signed word) 0 [ animate::$7 ] ( main:2::animate:9 [ animate::$7 ] ) -- aby=_deref_cowo1
//SEG36 [22] if((byte~) animate::$7!=(byte/signed byte/word/signed word) 25) goto animate::@2 [ ] ( main:2::animate:9 [ ] ) -- aby_neq_coby1_then_la1
cmp #$19
bne b2
//SEG37 animate::@8
//SEG38 [23] *((const byte[]) YPOS#0+(byte/signed byte/word/signed word) 0) ← (byte/signed byte/word/signed word) 0 [ ] ( main:2::animate:9 [ ] ) -- _deref_cowo1=coby2
lda #0
sta YPOS+0
//SEG39 animate::@2
b2:
//SEG40 [24] (byte~) animate::$10 ← * (const byte[]) XPOS#0+(byte/signed byte/word/signed word) 1 [ animate::$10 ] ( main:2::animate:9 [ animate::$10 ] ) -- xby=_deref_cowo1
ldx XPOS+1
//SEG41 [25] (byte~) animate::$11 ← (byte~) animate::$10 - (byte/signed byte/word/signed word) 1 [ animate::$11 ] ( main:2::animate:9 [ animate::$11 ] ) -- xby=xby_minus_1
dex
//SEG42 [26] *((const byte[]) XPOS#0+(byte/signed byte/word/signed word) 1) ← (byte~) animate::$11 [ ] ( main:2::animate:9 [ ] ) -- _deref_cowo1=xby
stx XPOS+1
//SEG43 [27] (byte~) animate::$12 ← * (const byte[]) XPOS#0+(byte/signed byte/word/signed word) 1 [ animate::$12 ] ( main:2::animate:9 [ animate::$12 ] ) -- aby=_deref_cowo1
txa
//SEG44 [28] if((byte~) animate::$12!=(byte/word/signed word) 255) goto animate::@3 [ ] ( main:2::animate:9 [ ] ) -- aby_neq_coby1_then_la1
cmp #$ff
bne b3
//SEG45 animate::@9
//SEG46 [29] *((const byte[]) XPOS#0+(byte/signed byte/word/signed word) 1) ← (byte/signed byte/word/signed word) 40 [ ] ( main:2::animate:9 [ ] ) -- _deref_cowo1=coby2
lda #$28
sta XPOS+1
//SEG47 animate::@3
b3:
//SEG48 [30] (byte~) animate::$15 ← * (const byte[]) YPOS#0+(byte/signed byte/word/signed word) 2 [ animate::$15 ] ( main:2::animate:9 [ animate::$15 ] ) -- aby=_deref_cowo1
lda YPOS+2
//SEG49 [31] (byte~) animate::$16 ← (byte~) animate::$15 + (byte/signed byte/word/signed word) 1 [ animate::$16 ] ( main:2::animate:9 [ animate::$16 ] ) -- aby=aby_plus_1
clc
adc #1
//SEG50 [32] *((const byte[]) YPOS#0+(byte/signed byte/word/signed word) 2) ← (byte~) animate::$16 [ ] ( main:2::animate:9 [ ] ) -- _deref_cowo1=aby
sta YPOS+2
//SEG51 [33] (byte~) animate::$17 ← * (const byte[]) YPOS#0+(byte/signed byte/word/signed word) 2 [ animate::$17 ] ( main:2::animate:9 [ animate::$17 ] ) -- aby=_deref_cowo1
//SEG52 [34] if((byte~) animate::$17!=(byte/signed byte/word/signed word) 25) goto animate::@4 [ ] ( main:2::animate:9 [ ] ) -- aby_neq_coby1_then_la1
cmp #$19
bne b4
//SEG53 animate::@10
//SEG54 [35] *((const byte[]) YPOS#0+(byte/signed byte/word/signed word) 2) ← (byte/signed byte/word/signed word) 0 [ ] ( main:2::animate:9 [ ] ) -- _deref_cowo1=coby2
lda #0
sta YPOS+2
//SEG55 animate::@4
b4:
//SEG56 [36] (byte~) animate::$20 ← * (const byte[]) YPOS#0+(byte/signed byte/word/signed word) 3 [ animate::$20 ] ( main:2::animate:9 [ animate::$20 ] ) -- xby=_deref_cowo1
ldx YPOS+3
//SEG57 [37] (byte~) animate::$21 ← (byte~) animate::$20 - (byte/signed byte/word/signed word) 1 [ animate::$21 ] ( main:2::animate:9 [ animate::$21 ] ) -- xby=xby_minus_1
dex
//SEG58 [38] *((const byte[]) YPOS#0+(byte/signed byte/word/signed word) 3) ← (byte~) animate::$21 [ ] ( main:2::animate:9 [ ] ) -- _deref_cowo1=xby
stx YPOS+3
//SEG59 [39] (byte~) animate::$22 ← * (const byte[]) YPOS#0+(byte/signed byte/word/signed word) 3 [ animate::$22 ] ( main:2::animate:9 [ animate::$22 ] ) -- aby=_deref_cowo1
txa
//SEG60 [40] if((byte~) animate::$22!=(byte/word/signed word) 255) goto animate::@return [ ] ( main:2::animate:9 [ ] ) -- aby_neq_coby1_then_la1
cmp #$ff
bne breturn
//SEG61 animate::@11
//SEG62 [41] *((const byte[]) YPOS#0+(byte/signed byte/word/signed word) 3) ← (byte/signed byte/word/signed word) 25 [ ] ( main:2::animate:9 [ ] ) -- _deref_cowo1=coby2
lda #$19
sta YPOS+3
//SEG63 [42] (byte~) animate::$25 ← * (const byte[]) XPOS#0+(byte/signed byte/word/signed word) 3 [ animate::$25 ] ( main:2::animate:9 [ animate::$25 ] ) -- aby=_deref_cowo1
lda XPOS+3
//SEG64 [43] (byte~) animate::$26 ← (byte~) animate::$25 + (byte/signed byte/word/signed word) 7 [ animate::$26 ] ( main:2::animate:9 [ animate::$26 ] ) -- aby=aby_plus_coby1
clc
adc #7
//SEG65 [44] *((const byte[]) XPOS#0+(byte/signed byte/word/signed word) 3) ← (byte~) animate::$26 [ ] ( main:2::animate:9 [ ] ) -- _deref_cowo1=aby
sta XPOS+3
//SEG66 [45] (byte~) animate::$27 ← * (const byte[]) XPOS#0+(byte/signed byte/word/signed word) 3 [ animate::$27 ] ( main:2::animate:9 [ animate::$27 ] ) -- aby=_deref_cowo1
//SEG67 [46] if((byte~) animate::$27<(byte/signed byte/word/signed word) 40) goto animate::@return [ ] ( main:2::animate:9 [ ] ) -- aby_lt_coby1_then_la1
cmp #$28
bcc breturn
//SEG68 animate::@12
//SEG69 [47] (byte~) animate::$30 ← * (const byte[]) XPOS#0+(byte/signed byte/word/signed word) 3 [ animate::$30 ] ( main:2::animate:9 [ animate::$30 ] ) -- aby=_deref_cowo1
lda XPOS+3
//SEG70 [48] (byte~) animate::$31 ← (byte~) animate::$30 - (byte/signed byte/word/signed word) 40 [ animate::$31 ] ( main:2::animate:9 [ animate::$31 ] ) -- aby=aby_minus_coby1
sec
sbc #$28
//SEG71 [49] *((const byte[]) XPOS#0+(byte/signed byte/word/signed word) 3) ← (byte~) animate::$31 [ ] ( main:2::animate:9 [ ] ) -- _deref_cowo1=aby
sta XPOS+3
//SEG72 animate::@return
breturn:
//SEG73 [50] return [ ] ( main:2::animate:9 [ ] )
rts
}
//SEG74 render
render: {
.label x = 5
.label colline = 3
.label y = 2
//SEG75 [52] phi from render to render::@1 [phi:render->render::@1]
//SEG76 [52] phi (byte*) render::colline#5 = (const byte*) COLORS#0 [phi:render->render::@1#0] -- zpptrby1=cowo1
lda #<COLORS
sta colline
lda #>COLORS
sta colline+1
//SEG77 [52] phi (byte) render::y#4 = (byte/signed byte/word/signed word) 0 [phi:render->render::@1#1] -- zpby1=coby1
lda #0
sta y
jmp b1
//SEG78 [52] phi from render::@3 to render::@1 [phi:render::@3->render::@1]
//SEG79 [52] phi (byte*) render::colline#5 = (byte*) render::colline#1 [phi:render::@3->render::@1#0] -- register_copy
//SEG80 [52] phi (byte) render::y#4 = (byte) render::y#1 [phi:render::@3->render::@1#1] -- register_copy
//SEG81 render::@1
b1:
//SEG82 [53] phi from render::@1 to render::@2 [phi:render::@1->render::@2]
//SEG83 [53] phi (byte) render::x#2 = (byte/signed byte/word/signed word) 0 [phi:render::@1->render::@2#0] -- zpby1=coby1
lda #0
sta x
jmp b2
//SEG84 [53] phi from render::@5 to render::@2 [phi:render::@5->render::@2]
//SEG85 [53] phi (byte) render::x#2 = (byte) render::x#1 [phi:render::@5->render::@2#0] -- register_copy
//SEG86 render::@2
b2:
//SEG87 [54] (byte) findcol::x#0 ← (byte) render::x#2 [ render::y#4 render::colline#5 render::x#2 findcol::x#0 ] ( main:2::render:7 [ render::y#4 render::colline#5 render::x#2 findcol::x#0 ] )
// (byte) findcol::x#0 = (byte) render::x#2 // register copy zp ZP_BYTE:5
//SEG88 [55] (byte) findcol::y#0 ← (byte) render::y#4 [ render::y#4 render::colline#5 render::x#2 findcol::x#0 findcol::y#0 ] ( main:2::render:7 [ render::y#4 render::colline#5 render::x#2 findcol::x#0 findcol::y#0 ] )
// (byte) findcol::y#0 = (byte) render::y#4 // register copy zp ZP_BYTE:2
//SEG89 [56] call findcol param-assignment [ render::y#4 render::colline#5 render::x#2 findcol::return#2 ] ( main:2::render:7 [ render::y#4 render::colline#5 render::x#2 findcol::return#2 ] )
//SEG90 [66] phi from render::@2 to findcol [phi:render::@2->findcol]
jsr findcol
//SEG91 [57] (byte) findcol::return#0 ← (byte) findcol::return#2 [ render::y#4 render::colline#5 render::x#2 findcol::return#0 ] ( main:2::render:7 [ render::y#4 render::colline#5 render::x#2 findcol::return#0 ] ) -- aby=yby
tya
//SEG92 render::@5
//SEG93 [58] (byte) render::col#0 ← (byte) findcol::return#0 [ render::y#4 render::colline#5 render::x#2 render::col#0 ] ( main:2::render:7 [ render::y#4 render::colline#5 render::x#2 render::col#0 ] )
// (byte) render::col#0 = (byte) findcol::return#0 // register copy reg byte a
//SEG94 [59] *((byte*) render::colline#5 + (byte) render::x#2) ← (byte) render::col#0 [ render::y#4 render::colline#5 render::x#2 ] ( main:2::render:7 [ render::y#4 render::colline#5 render::x#2 ] ) -- zpptrby1_derefidx_zpby1=aby
ldy x
sta (colline),y
//SEG95 [60] (byte) render::x#1 ← ++ (byte) render::x#2 [ render::y#4 render::colline#5 render::x#1 ] ( main:2::render:7 [ render::y#4 render::colline#5 render::x#1 ] ) -- zpby1=_inc_zpby1
inc x
//SEG96 [61] if((byte) render::x#1!=(byte/signed byte/word/signed word) 40) goto render::@2 [ render::y#4 render::colline#5 render::x#1 ] ( main:2::render:7 [ render::y#4 render::colline#5 render::x#1 ] ) -- zpby1_neq_coby1_then_la1
lda x
cmp #$28
bne b2
//SEG97 render::@3
//SEG98 [62] (byte*) render::colline#1 ← (byte*) render::colline#5 + (byte/signed byte/word/signed word) 40 [ render::y#4 render::colline#1 ] ( main:2::render:7 [ render::y#4 render::colline#1 ] ) -- zpptrby1=zpptrby1_plus_coby1
lda colline
clc
adc #$28
sta colline
bcc !+
inc colline+1
!:
//SEG99 [63] (byte) render::y#1 ← ++ (byte) render::y#4 [ render::y#1 render::colline#1 ] ( main:2::render:7 [ render::y#1 render::colline#1 ] ) -- zpby1=_inc_zpby1
inc y
//SEG100 [64] if((byte) render::y#1!=(byte/signed byte/word/signed word) 25) goto render::@1 [ render::y#1 render::colline#1 ] ( main:2::render:7 [ render::y#1 render::colline#1 ] ) -- zpby1_neq_coby1_then_la1
lda y
cmp #$19
bne b1
//SEG101 render::@return
//SEG102 [65] return [ ] ( main:2::render:7 [ ] )
rts
}
//SEG103 findcol
findcol: {
.label x = 5
.label y = 2
.label xp = 7
.label yp = 8
.label diff = 7
.label mindiff = 6
//SEG104 [67] phi from findcol to findcol::@1 [phi:findcol->findcol::@1]
//SEG105 [67] phi (byte) findcol::mincol#10 = (byte/signed byte/word/signed word) 0 [phi:findcol->findcol::@1#0] -- yby=coby1
ldy #0
//SEG106 [67] phi (byte) findcol::mindiff#10 = (byte/word/signed word) 255 [phi:findcol->findcol::@1#1] -- zpby1=coby1
lda #$ff
sta mindiff
//SEG107 [67] phi (byte) findcol::i#10 = (byte/signed byte/word/signed word) 0 [phi:findcol->findcol::@1#2] -- xby=coby1
ldx #0
//SEG108 findcol::@1
b1:
//SEG109 [68] (byte) findcol::xp#0 ← (const byte[]) XPOS#0 *idx (byte) findcol::i#10 [ findcol::x#0 findcol::y#0 findcol::i#10 findcol::mindiff#10 findcol::mincol#10 findcol::xp#0 ] ( main:2::render:7::findcol:56 [ render::y#4 render::colline#5 render::x#2 findcol::x#0 findcol::y#0 findcol::i#10 findcol::mindiff#10 findcol::mincol#10 findcol::xp#0 ] ) -- zpby1=cowo1_derefidx_xby
lda XPOS,x
sta xp
//SEG110 [69] (byte) findcol::yp#0 ← (const byte[]) YPOS#0 *idx (byte) findcol::i#10 [ findcol::x#0 findcol::y#0 findcol::i#10 findcol::mindiff#10 findcol::mincol#10 findcol::xp#0 findcol::yp#0 ] ( main:2::render:7::findcol:56 [ render::y#4 render::colline#5 render::x#2 findcol::x#0 findcol::y#0 findcol::i#10 findcol::mindiff#10 findcol::mincol#10 findcol::xp#0 findcol::yp#0 ] ) -- zpby1=cowo1_derefidx_xby
lda YPOS,x
sta yp
//SEG111 [70] if((byte) findcol::x#0!=(byte) findcol::xp#0) goto findcol::@2 [ findcol::x#0 findcol::y#0 findcol::i#10 findcol::mindiff#10 findcol::mincol#10 findcol::xp#0 findcol::yp#0 ] ( main:2::render:7::findcol:56 [ render::y#4 render::colline#5 render::x#2 findcol::x#0 findcol::y#0 findcol::i#10 findcol::mindiff#10 findcol::mincol#10 findcol::xp#0 findcol::yp#0 ] ) -- zpby1_neq_zpby2_then_la1
lda x
cmp xp
bne b2
//SEG112 findcol::@9
//SEG113 [71] if((byte) findcol::y#0!=(byte) findcol::yp#0) goto findcol::@2 [ findcol::x#0 findcol::y#0 findcol::i#10 findcol::mindiff#10 findcol::mincol#10 findcol::xp#0 findcol::yp#0 ] ( main:2::render:7::findcol:56 [ render::y#4 render::colline#5 render::x#2 findcol::x#0 findcol::y#0 findcol::i#10 findcol::mindiff#10 findcol::mincol#10 findcol::xp#0 findcol::yp#0 ] ) -- zpby1_neq_zpby2_then_la1
lda y
cmp yp
bne b2
//SEG114 [72] phi from findcol::@9 to findcol::@return [phi:findcol::@9->findcol::@return]
//SEG115 [72] phi (byte) findcol::return#2 = (byte/signed byte/word/signed word) 0 [phi:findcol::@9->findcol::@return#0] -- yby=coby1
ldy #0
//SEG116 findcol::@return
breturn:
//SEG117 [73] return [ findcol::return#2 ] ( main:2::render:7::findcol:56 [ render::y#4 render::colline#5 render::x#2 findcol::return#2 ] )
rts
//SEG118 findcol::@2
b2:
//SEG119 [74] if((byte) findcol::x#0>=(byte) findcol::xp#0) goto findcol::@4 [ findcol::x#0 findcol::y#0 findcol::i#10 findcol::mindiff#10 findcol::mincol#10 findcol::xp#0 findcol::yp#0 ] ( main:2::render:7::findcol:56 [ render::y#4 render::colline#5 render::x#2 findcol::x#0 findcol::y#0 findcol::i#10 findcol::mindiff#10 findcol::mincol#10 findcol::xp#0 findcol::yp#0 ] ) -- zpby1_ge_zpby2_then_la1
lda x
cmp xp
bcs b4
//SEG120 findcol::@12
//SEG121 [75] (byte) findcol::diff#1 ← (byte) findcol::xp#0 - (byte) findcol::x#0 [ findcol::x#0 findcol::y#0 findcol::i#10 findcol::mindiff#10 findcol::mincol#10 findcol::yp#0 findcol::diff#1 ] ( main:2::render:7::findcol:56 [ render::y#4 render::colline#5 render::x#2 findcol::x#0 findcol::y#0 findcol::i#10 findcol::mindiff#10 findcol::mincol#10 findcol::yp#0 findcol::diff#1 ] ) -- zpby1=zpby1_minus_zpby2
lda diff
sec
sbc x
sta diff
//SEG122 [76] phi from findcol::@12 findcol::@4 to findcol::@5 [phi:findcol::@12/findcol::@4->findcol::@5]
//SEG123 [76] phi (byte) findcol::diff#4 = (byte) findcol::diff#1 [phi:findcol::@12/findcol::@4->findcol::@5#0] -- register_copy
//SEG124 findcol::@5
b5:
//SEG125 [77] if((byte) findcol::y#0>=(byte) findcol::yp#0) goto findcol::@6 [ findcol::x#0 findcol::y#0 findcol::i#10 findcol::mindiff#10 findcol::mincol#10 findcol::yp#0 findcol::diff#4 ] ( main:2::render:7::findcol:56 [ render::y#4 render::colline#5 render::x#2 findcol::x#0 findcol::y#0 findcol::i#10 findcol::mindiff#10 findcol::mincol#10 findcol::yp#0 findcol::diff#4 ] ) -- zpby1_ge_zpby2_then_la1
lda y
cmp yp
bcs b6
//SEG126 findcol::@14
//SEG127 [78] (byte~) findcol::$12 ← (byte) findcol::yp#0 - (byte) findcol::y#0 [ findcol::x#0 findcol::y#0 findcol::i#10 findcol::mindiff#10 findcol::mincol#10 findcol::diff#4 findcol::$12 ] ( main:2::render:7::findcol:56 [ render::y#4 render::colline#5 render::x#2 findcol::x#0 findcol::y#0 findcol::i#10 findcol::mindiff#10 findcol::mincol#10 findcol::diff#4 findcol::$12 ] ) -- aby=zpby1_minus_zpby2
lda yp
sec
sbc y
//SEG128 [79] (byte) findcol::diff#3 ← (byte) findcol::diff#4 + (byte~) findcol::$12 [ findcol::x#0 findcol::y#0 findcol::i#10 findcol::mindiff#10 findcol::mincol#10 findcol::diff#3 ] ( main:2::render:7::findcol:56 [ render::y#4 render::colline#5 render::x#2 findcol::x#0 findcol::y#0 findcol::i#10 findcol::mindiff#10 findcol::mincol#10 findcol::diff#3 ] ) -- aby=zpby1_plus_aby
clc
adc diff
//SEG129 [80] phi from findcol::@14 findcol::@6 to findcol::@7 [phi:findcol::@14/findcol::@6->findcol::@7]
//SEG130 [80] phi (byte) findcol::diff#6 = (byte) findcol::diff#3 [phi:findcol::@14/findcol::@6->findcol::@7#0] -- register_copy
//SEG131 findcol::@7
b7:
//SEG132 [81] if((byte) findcol::diff#6>=(byte) findcol::mindiff#10) goto findcol::@21 [ findcol::x#0 findcol::y#0 findcol::i#10 findcol::mindiff#10 findcol::mincol#10 findcol::diff#6 ] ( main:2::render:7::findcol:56 [ render::y#4 render::colline#5 render::x#2 findcol::x#0 findcol::y#0 findcol::i#10 findcol::mindiff#10 findcol::mincol#10 findcol::diff#6 ] ) -- aby_ge_zpby1_then_la1
cmp mindiff
bcs b21
//SEG133 findcol::@16
//SEG134 [82] (byte) findcol::mincol#1 ← (const byte[]) COLS#0 *idx (byte) findcol::i#10 [ findcol::x#0 findcol::y#0 findcol::i#10 findcol::diff#6 findcol::mincol#1 ] ( main:2::render:7::findcol:56 [ render::y#4 render::colline#5 render::x#2 findcol::x#0 findcol::y#0 findcol::i#10 findcol::diff#6 findcol::mincol#1 ] ) -- yby=cowo1_derefidx_xby
ldy COLS,x
//SEG135 [83] phi from findcol::@16 findcol::@21 to findcol::@8 [phi:findcol::@16/findcol::@21->findcol::@8]
//SEG136 [83] phi (byte) findcol::mindiff#11 = (byte) findcol::diff#6 [phi:findcol::@16/findcol::@21->findcol::@8#0] -- register_copy
//SEG137 [83] phi (byte) findcol::mincol#2 = (byte) findcol::mincol#1 [phi:findcol::@16/findcol::@21->findcol::@8#1] -- register_copy
//SEG138 findcol::@8
b8:
//SEG139 [84] (byte) findcol::i#1 ← ++ (byte) findcol::i#10 [ findcol::x#0 findcol::y#0 findcol::i#1 findcol::mincol#2 findcol::mindiff#11 ] ( main:2::render:7::findcol:56 [ render::y#4 render::colline#5 render::x#2 findcol::x#0 findcol::y#0 findcol::i#1 findcol::mincol#2 findcol::mindiff#11 ] ) -- xby=_inc_xby
inx
//SEG140 [85] if((byte) findcol::i#1<(const byte) numpoints#0) goto findcol::@19 [ findcol::x#0 findcol::y#0 findcol::i#1 findcol::mincol#2 findcol::mindiff#11 ] ( main:2::render:7::findcol:56 [ render::y#4 render::colline#5 render::x#2 findcol::x#0 findcol::y#0 findcol::i#1 findcol::mincol#2 findcol::mindiff#11 ] ) -- xby_lt_coby1_then_la1
cpx #numpoints
bcc b19
//SEG141 [72] phi from findcol::@8 to findcol::@return [phi:findcol::@8->findcol::@return]
//SEG142 [72] phi (byte) findcol::return#2 = (byte) findcol::mincol#2 [phi:findcol::@8->findcol::@return#0] -- register_copy
jmp breturn
//SEG143 findcol::@19
b19:
//SEG144 [86] (byte~) findcol::mindiff#13 ← (byte) findcol::mindiff#11 [ findcol::x#0 findcol::y#0 findcol::i#1 findcol::mindiff#13 findcol::mincol#2 ] ( main:2::render:7::findcol:56 [ render::y#4 render::colline#5 render::x#2 findcol::x#0 findcol::y#0 findcol::i#1 findcol::mindiff#13 findcol::mincol#2 ] ) -- zpby1=aby
sta mindiff
//SEG145 [67] phi from findcol::@19 to findcol::@1 [phi:findcol::@19->findcol::@1]
//SEG146 [67] phi (byte) findcol::mincol#10 = (byte) findcol::mincol#2 [phi:findcol::@19->findcol::@1#0] -- register_copy
//SEG147 [67] phi (byte) findcol::mindiff#10 = (byte~) findcol::mindiff#13 [phi:findcol::@19->findcol::@1#1] -- register_copy
//SEG148 [67] phi (byte) findcol::i#10 = (byte) findcol::i#1 [phi:findcol::@19->findcol::@1#2] -- register_copy
jmp b1
//SEG149 findcol::@21
b21:
//SEG150 [87] (byte~) findcol::mindiff#14 ← (byte) findcol::mindiff#10 [ findcol::x#0 findcol::y#0 findcol::i#10 findcol::mincol#10 findcol::mindiff#14 ] ( main:2::render:7::findcol:56 [ render::y#4 render::colline#5 render::x#2 findcol::x#0 findcol::y#0 findcol::i#10 findcol::mincol#10 findcol::mindiff#14 ] ) -- aby=zpby1
lda mindiff
jmp b8
//SEG151 findcol::@6
b6:
//SEG152 [88] (byte~) findcol::$14 ← (byte) findcol::y#0 - (byte) findcol::yp#0 [ findcol::x#0 findcol::y#0 findcol::i#10 findcol::mindiff#10 findcol::mincol#10 findcol::diff#4 findcol::$14 ] ( main:2::render:7::findcol:56 [ render::y#4 render::colline#5 render::x#2 findcol::x#0 findcol::y#0 findcol::i#10 findcol::mindiff#10 findcol::mincol#10 findcol::diff#4 findcol::$14 ] ) -- aby=zpby1_minus_zpby2
lda y
sec
sbc yp
//SEG153 [89] (byte) findcol::diff#2 ← (byte) findcol::diff#4 + (byte~) findcol::$14 [ findcol::x#0 findcol::y#0 findcol::i#10 findcol::mindiff#10 findcol::mincol#10 findcol::diff#2 ] ( main:2::render:7::findcol:56 [ render::y#4 render::colline#5 render::x#2 findcol::x#0 findcol::y#0 findcol::i#10 findcol::mindiff#10 findcol::mincol#10 findcol::diff#2 ] ) -- aby=zpby1_plus_aby
clc
adc diff
jmp b7
//SEG154 findcol::@4
b4:
//SEG155 [90] (byte) findcol::diff#0 ← (byte) findcol::x#0 - (byte) findcol::xp#0 [ findcol::x#0 findcol::y#0 findcol::i#10 findcol::mindiff#10 findcol::mincol#10 findcol::yp#0 findcol::diff#0 ] ( main:2::render:7::findcol:56 [ render::y#4 render::colline#5 render::x#2 findcol::x#0 findcol::y#0 findcol::i#10 findcol::mindiff#10 findcol::mincol#10 findcol::yp#0 findcol::diff#0 ] ) -- zpby1=zpby2_minus_zpby1
lda x
sec
sbc diff
sta diff
jmp b5
}
//SEG156 initscreen
initscreen: {
.label screen = 3
//SEG157 [92] phi from initscreen to initscreen::@1 [phi:initscreen->initscreen::@1]
//SEG158 [92] phi (byte*) initscreen::screen#2 = (const byte*) SCREEN#0 [phi:initscreen->initscreen::@1#0] -- zpptrby1=cowo1
lda #<SCREEN
sta screen
lda #>SCREEN
sta screen+1
jmp b1
//SEG159 [92] phi from initscreen::@1 to initscreen::@1 [phi:initscreen::@1->initscreen::@1]
//SEG160 [92] phi (byte*) initscreen::screen#2 = (byte*) initscreen::screen#1 [phi:initscreen::@1->initscreen::@1#0] -- register_copy
//SEG161 initscreen::@1
b1:
//SEG162 [93] *((byte*) initscreen::screen#2) ← (const byte) FILL#0 [ initscreen::screen#2 ] ( main:2::initscreen:5 [ initscreen::screen#2 ] ) -- _deref_zpptrby1=coby1
ldy #0
lda #FILL
sta (screen),y
//SEG163 [94] (byte*) initscreen::screen#1 ← ++ (byte*) initscreen::screen#2 [ initscreen::screen#1 ] ( main:2::initscreen:5 [ initscreen::screen#1 ] ) -- zpptrby1=_inc_zpptrby1
inc screen
bne !+
inc screen+1
!:
//SEG164 [95] if((byte*) initscreen::screen#1<(const byte*) SCREEN#0+(word/signed word) 1000) goto initscreen::@1 [ initscreen::screen#1 ] ( main:2::initscreen:5 [ initscreen::screen#1 ] ) -- zpptrby1_lt_cowo1_then_la1
lda screen+1
cmp #>SCREEN+$3e8
bcc b1
bne !+
lda screen
cmp #<SCREEN+$3e8
bcc b1
!:
//SEG165 initscreen::@return
//SEG166 [96] return [ ] ( main:2::initscreen:5 [ ] )
rts
}
Removing instruction jmp b1
Removing instruction jmp b2
Removing instruction jmp b1
@ -9961,7 +10344,6 @@ main: {
jmp b1
//SEG21 main::@return
//SEG22 [11] return [ ] ( main:2 [ ] )
rts
}
//SEG23 animate
animate: {
@ -10342,7 +10724,6 @@ main: {
jmp b1
//SEG21 main::@return
//SEG22 [11] return [ ] ( main:2 [ ] )
rts
}
//SEG23 animate
animate: {
@ -10880,7 +11261,6 @@ main: {
jmp b1
//SEG21 main::@return
//SEG22 [11] return [ ] ( main:2 [ ] )
rts
}
//SEG23 animate
animate: {