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

Changed HEAP to grow down from $a000. Fixed inner increment problem. Closes #216

This commit is contained in:
jespergravgaard 2019-07-09 11:40:56 +02:00
parent b5222c7929
commit a7ac33a653
44 changed files with 1729 additions and 1010 deletions

View File

@ -0,0 +1,4 @@
inc {c1},x
bne !+
inc {c1}+1,x
!:

View File

@ -0,0 +1,9 @@
clc
lda {c1},y
adc #1
sta {c1},y
bne !+
lda {c1}+1,y
adc #0
sta {c1}+1,y
!:

View File

@ -0,0 +1,5 @@
lda ({z2}),y
sta {z1}
iny
lda ({z2}),y
sta {z1}+1

View File

@ -0,0 +1,5 @@
lda {z2}
sta ({z1}),y
iny
lda {z2}+1
sta ({z1}),y

View File

@ -0,0 +1,6 @@
lda ({z2}),y
asl
sta {z1}
lda #0
rol
sta {z1}+1

View File

@ -1948,21 +1948,27 @@ public class Pass0GenerateStatementSequence extends KickCBaseVisitor<Object> {
@Override
public Void visitExprPostMod(KickCParser.ExprPostModContext ctx) {
// First handle the ++/-- modifier
RValue child = (RValue) mainParser.visit(ctx.expr());
String op = ((TerminalNode) ctx.getChild(1)).getSymbol().getText();
Operator operator = Operators.getUnary(op);
PrePostModifier modifier = new PrePostModifier(child, operator);
postMods.add(modifier);
// First visit sub-expressions in case they have ++/-- themselves
this.visit(ctx.expr());
return null;
}
@Override
public Void visitExprPreMod(KickCParser.ExprPreModContext ctx) {
// First handle the ++/-- modifier
RValue child = (RValue) mainParser.visit(ctx.expr());
String op = ((TerminalNode) ctx.getChild(0)).getSymbol().getText();
Operator operator = Operators.getUnary(op);
PrePostModifier modifier = new PrePostModifier(child, operator);
preMods.add(modifier);
// Then visit sub-expressions in case they have ++/--
this.visit(ctx.expr());
return null;
}

View File

@ -1,22 +1,23 @@
// Implementation of functions found int C stdlib.h / stdlib.c
// Start of the heap used by malloc()
unsigned char* HEAP_START = 0xc000;
// Top of the heap used by malloc()
unsigned char* HEAP_TOP = 0xa000;
// Head of the heap. Moved forward for each malloc()
unsigned char* heap_head = HEAP_START;
// Head of the heap. Moved backward each malloc()
unsigned char* heap_head = HEAP_TOP;
// Allocates a block of size bytes of memory, returning a pointer to the beginning of the block.
// The content of the newly allocated block of memory is not initialized, remaining with indeterminate values.
void* malloc(unsigned int size) {
unsigned char* mem = heap_head;
heap_head+= size;
unsigned char* mem = heap_head-size;
heap_head = mem;
return mem;
}
// A block of memory previously allocated by a call to malloc is deallocated, making it available again for further allocations.
// If ptr is a null pointer, the function does nothing.
void free(void* ptr) {
// TODO: So far no support for freeing stuff
}
// Searches an array of nitems unsigned words, the initial member of which is pointed to by base, for a member that matches the value key.

View File

@ -36,6 +36,11 @@ public class TestPrograms {
public TestPrograms() {
}
@Test
public void testInnerIncrementProblem() throws IOException, URISyntaxException {
compileAndCompare("inner-increment-problem", log());
}
@Test
public void testFillSquare() throws IOException, URISyntaxException {
compileAndCompare("fill-square");

View File

@ -0,0 +1,14 @@
// Inner increment is not being done properly (screen++)
const word[0x100] CHAR_COUNTS;
void main() {
// Count the number of the different chars on the screen
byte* screen = 0x0400;
for( word i:0..999) {
CHAR_COUNTS[*screen++]++;
}
}

View File

@ -5,7 +5,6 @@ import "stdlib"
import "sqr"
import "atan2"
// Screen containing distance to center
const byte* SCREEN_DIST = malloc(1000);
// Screen containing angle to center
@ -49,18 +48,39 @@ void main() {
*/
}
// The number of buckets in our bucket sort
const byte NUM_BUCKETS = 0x30;
// Array containing the bucket size for each of the 256 buckets
const byte* BUCKET_SIZES = malloc(0x80);
const byte[] BUCKET_SIZES = malloc(NUM_BUCKETS*sizeof(byte));
//const word*[] BUCKETS = malloc(NUM_BUCKETS*sizeof(word*));
void init_buckets() {
// Init bucket sizes to 0
for(byte i:0..0x7f) BUCKET_SIZES[i]=0;
for(byte i:0..NUM_BUCKETS-1) BUCKET_SIZES[i]=0;
// first find bucket sizes - by counting number of chars with each distance value
byte* dist = SCREEN_DIST;
for( word i:0..999 ) {
BUCKET_SIZES[*dist]++;
dist++;
for( word i:0..999) {
BUCKET_SIZES[*dist++]++;
}
/*
// Allocate the buckets
for( byte i:0..NUM_BUCKETS-1) {
BUCKETS[i] = malloc(BUCKET_SIZES[i]*sizeof(byte*));
}
// Iterate all distances and fill the buckets with indices into the screens
const byte[] BUCKET_IDX = malloc(NUM_BUCKETS*sizeof(byte));
for(byte i:0..NUM_BUCKETS-1) BUCKET_IDX[i]=0;
dist = SCREEN_DIST;
for(word i:0..999) {
byte distance = *dist++;
word* bucket = BUCKETS[distance];
byte idx = BUCKET_IDX[distance];
bucket[idx] = dist-SCREEN_DIST;
BUCKET_IDX[distance]++;
}
*/
}

View File

@ -13,8 +13,8 @@
.const OFFSET_STRUCT_PROCESSINGSPRITE_COL = $a
.const OFFSET_STRUCT_PROCESSINGSPRITE_STATUS = $b
.const OFFSET_STRUCT_PROCESSINGSPRITE_SCREENPTR = $c
// Start of the heap used by malloc()
.label HEAP_START = $c000
// Top of the heap used by malloc()
.label HEAP_TOP = $a000
// The number of iterations performed during 16-bit CORDIC atan2 calculation
.const CORDIC_ITERATIONS_16 = $f
// Processor port data direction register
@ -79,9 +79,9 @@
.label SCREEN_COPY = $2b
.label SCREEN_DIST = $2d
bbegin:
lda #<HEAP_START
lda #<HEAP_TOP
sta heap_head
lda #>HEAP_START
lda #>HEAP_TOP
sta heap_head+1
jsr malloc
lda malloc.mem
@ -943,15 +943,15 @@ atan2_16: {
malloc: {
.label mem = $2d
lda heap_head
sec
sbc #<$3e8
sta mem
lda heap_head+1
sbc #>$3e8
sta mem+1
clc
lda heap_head
adc #<$3e8
lda mem
sta heap_head
lda heap_head+1
adc #>$3e8
lda mem+1
sta heap_head+1
rts
}

View File

@ -425,9 +425,9 @@ atan2_16::@1: scope:[atan2_16] from atan2_16
[242] (signed word~) atan2_16::yi#16 ← (signed word) atan2_16::y#0
to:atan2_16::@3
malloc: scope:[malloc] from @1 @3
[243] (byte*) heap_head#5 ← phi( @1/(const byte*) HEAP_START#0 @3/(byte*) heap_head#1 )
[244] (byte*) malloc::mem#0 ← (byte*) heap_head#5
[245] (byte*) heap_head#1 ← (byte*) heap_head#5 + (word) $3e8
[243] (byte*) heap_head#5 ← phi( @1/(const byte*) HEAP_TOP#0 @3/(byte*) heap_head#1 )
[244] (byte*) malloc::mem#0 ← (byte*) heap_head#5 - (word) $3e8
[245] (byte*) heap_head#1 ← (byte*) malloc::mem#0
to:malloc::@return
malloc::@return: scope:[malloc] from malloc
[246] return

View File

@ -111,7 +111,7 @@ Rewriting struct pointer member access *((struct ProcessingSprite*) processChars
Rewriting struct pointer member access *((struct ProcessingSprite*) processChars::processing).y
Warning! Adding boolean cast to non-boolean condition (byte~) processChars::$11
Warning! Adding boolean cast to non-boolean sub-expression (byte) atan2_16::shift
Identified constant variable (byte*) HEAP_START
Identified constant variable (byte*) HEAP_TOP
Inlined call (byte~) vicSelectGfxBank::$0 ← call toDd00 (byte*) vicSelectGfxBank::gfx
Culled Empty Block (label) malloc::@1
Culled Empty Block (label) @1
@ -166,14 +166,15 @@ Adding versioned struct unwinding for (struct ProcessingChar) getCharToProcess::
CONTROL FLOW GRAPH SSA
@begin: scope:[] from
(byte*) HEAP_START#0 ← ((byte*)) (number) $c000
(byte*) heap_head#0 ← (byte*) HEAP_START#0
(byte*) HEAP_TOP#0 ← ((byte*)) (number) $a000
(byte*) heap_head#0 ← (byte*) HEAP_TOP#0
to:@6
malloc: scope:[malloc] from @17 @28
(word) malloc::size#2 ← phi( @17/(word) malloc::size#0 @28/(word) malloc::size#1 )
(byte*) heap_head#5 ← phi( @17/(byte*) heap_head#9 @28/(byte*) heap_head#3 )
(byte*) malloc::mem#0 ← (byte*) heap_head#5
(byte*) heap_head#1 ← (byte*) heap_head#5 + (word) malloc::size#2
(byte*~) malloc::$0 ← (byte*) heap_head#5 - (word) malloc::size#2
(byte*) malloc::mem#0 ← (byte*~) malloc::$0
(byte*) heap_head#1 ← (byte*) malloc::mem#0
(void*) malloc::return#0 ← ((void*)) (byte*) malloc::mem#0
to:malloc::@return
malloc::@return: scope:[malloc] from malloc
@ -1333,8 +1334,8 @@ SYMBOL TABLE SSA
(bool) DEBUG#0
(void()**) HARDWARE_IRQ
(void()**) HARDWARE_IRQ#0
(byte*) HEAP_START
(byte*) HEAP_START#0
(byte*) HEAP_TOP
(byte*) HEAP_TOP#0
(byte*) IRQ_ENABLE
(byte*) IRQ_ENABLE#0
(byte) IRQ_RASTER
@ -1977,6 +1978,7 @@ interrupt(HARDWARE_ALL)(void()) irqTop()
(byte*) main::src#1
(byte*) main::src#2
(void*()) malloc((word) malloc::size)
(byte*~) malloc::$0
(label) malloc::@return
(byte*) malloc::mem
(byte*) malloc::mem#0
@ -2434,7 +2436,7 @@ Adding number conversion cast (unumber) $80 in *((byte*) VIC_CONTROL#0) ← *((b
Adding number conversion cast (unumber) $30 in (byte) RASTER_IRQ_TOP#0 ← (number) $30
Adding number conversion cast (unumber) $ff in (byte) RASTER_IRQ_MIDDLE#0 ← (number) $ff
Successful SSA optimization PassNAddNumberTypeConversions
Inlining cast (byte*) HEAP_START#0 ← (byte*)(number) $c000
Inlining cast (byte*) HEAP_TOP#0 ← (byte*)(number) $a000
Inlining cast (void*) malloc::return#0 ← (void*)(byte*) malloc::mem#0
Inlining cast (byte) CORDIC_ITERATIONS_16#0 ← (unumber)(number) $f
Inlining cast (word) atan2_16::angle#0 ← (unumber)(number) 0
@ -2519,7 +2521,7 @@ Inlining cast *((byte*) SPRITES_EXPAND_Y#0) ← (unumber)(number) 0
Inlining cast (byte) RASTER_IRQ_TOP#0 ← (unumber)(number) $30
Inlining cast (byte) RASTER_IRQ_MIDDLE#0 ← (unumber)(number) $ff
Successful SSA optimization Pass2InlineCast
Simplifying constant pointer cast (byte*) 49152
Simplifying constant pointer cast (byte*) 40960
Simplifying constant integer cast $f
Simplifying constant integer cast 0
Simplifying constant integer cast 0
@ -2800,19 +2802,20 @@ Inferred type updated to byte in (unumber~) init_angle_screen::$11 ← > (word~)
Inferred type updated to byte in (unumber~) init_angle_screen::$13 ← (byte) $80 + (byte) init_angle_screen::ang_w#0
Inferred type updated to byte in (unumber~) init_angle_screen::$14 ← (byte) $80 - (byte) init_angle_screen::ang_w#0
Inferred type updated to byte in (unumber~) initSprites::$0 ← (byte) NUM_PROCESSING#0 * (byte) $40
Inversing boolean not [37] (bool~) atan2_16::$18 ← (signed word) atan2_16::yi#3 != (signed byte) 0 from [36] (bool~) atan2_16::$17 ← (signed word) atan2_16::yi#3 == (signed byte) 0
Inversing boolean not [46] (bool~) atan2_16::$11 ← (signed word) atan2_16::x#4 >= (signed byte) 0 from [45] (bool~) atan2_16::$10 ← (signed word) atan2_16::x#4 < (signed byte) 0
Inversing boolean not [57] (bool~) atan2_16::$20 ← (byte) 0 == (byte) atan2_16::shift#4 from [56] (bool~) atan2_16::$25 ← (byte) 0 != (byte) atan2_16::shift#4
Inversing boolean not [81] (bool~) atan2_16::$14 ← (signed word) atan2_16::y#4 >= (signed byte) 0 from [80] (bool~) atan2_16::$13 ← (signed word) atan2_16::y#4 < (signed byte) 0
Inversing boolean not [211] (bool~) main::$11 ← (byte) main::center_dist#0 != (byte) NOT_FOUND#0 from [210] (bool~) main::$10 ← (byte) main::center_dist#0 == (byte) NOT_FOUND#0
Inversing boolean not [237] (bool~) getCharToProcess::$3 ← *((byte*) getCharToProcess::screen_line#2 + (byte) getCharToProcess::x#2) == (byte) ' ' from [236] (bool~) getCharToProcess::$2 ← *((byte*) getCharToProcess::screen_line#2 + (byte) getCharToProcess::x#2) != (byte) ' '
Inversing boolean not [246] (bool~) getCharToProcess::$5 ← (byte) getCharToProcess::dist#0 >= (byte) getCharToProcess::closest_dist#2 from [245] (bool~) getCharToProcess::$4 ← (byte) getCharToProcess::dist#0 < (byte) getCharToProcess::closest_dist#2
Inversing boolean not [260] (bool~) getCharToProcess::$1 ← (byte) getCharToProcess::closest_dist#3 == (byte) NOT_FOUND#0 from [259] (bool~) getCharToProcess::$0 ← (byte) getCharToProcess::closest_dist#3 != (byte) NOT_FOUND#0
Inversing boolean not [288] (bool~) startProcessing::$26 ← *((byte*) startProcessing::$41 + (byte~) startProcessing::$30) != (const byte) STATUS_FREE from [287] (bool~) startProcessing::$25 ← *((byte*) startProcessing::$41 + (byte~) startProcessing::$30) == (const byte) STATUS_FREE
Inversing boolean not [395] (bool~) processChars::$5 ← *((byte*) processChars::$41) == (const byte) STATUS_FREE from [394] (bool~) processChars::$4 ← *((byte*) processChars::$41) != (const byte) STATUS_FREE
Inversing boolean not [404] (bool~) processChars::$7 ← *((byte*) processChars::$42) != (const byte) STATUS_NEW from [403] (bool~) processChars::$6 ← *((byte*) processChars::$42) == (const byte) STATUS_NEW
Inversing boolean not [38] (bool~) atan2_16::$18 ← (signed word) atan2_16::yi#3 != (signed byte) 0 from [37] (bool~) atan2_16::$17 ← (signed word) atan2_16::yi#3 == (signed byte) 0
Inversing boolean not [47] (bool~) atan2_16::$11 ← (signed word) atan2_16::x#4 >= (signed byte) 0 from [46] (bool~) atan2_16::$10 ← (signed word) atan2_16::x#4 < (signed byte) 0
Inversing boolean not [58] (bool~) atan2_16::$20 ← (byte) 0 == (byte) atan2_16::shift#4 from [57] (bool~) atan2_16::$25 ← (byte) 0 != (byte) atan2_16::shift#4
Inversing boolean not [82] (bool~) atan2_16::$14 ← (signed word) atan2_16::y#4 >= (signed byte) 0 from [81] (bool~) atan2_16::$13 ← (signed word) atan2_16::y#4 < (signed byte) 0
Inversing boolean not [212] (bool~) main::$11 ← (byte) main::center_dist#0 != (byte) NOT_FOUND#0 from [211] (bool~) main::$10 ← (byte) main::center_dist#0 == (byte) NOT_FOUND#0
Inversing boolean not [238] (bool~) getCharToProcess::$3 ← *((byte*) getCharToProcess::screen_line#2 + (byte) getCharToProcess::x#2) == (byte) ' ' from [237] (bool~) getCharToProcess::$2 ← *((byte*) getCharToProcess::screen_line#2 + (byte) getCharToProcess::x#2) != (byte) ' '
Inversing boolean not [247] (bool~) getCharToProcess::$5 ← (byte) getCharToProcess::dist#0 >= (byte) getCharToProcess::closest_dist#2 from [246] (bool~) getCharToProcess::$4 ← (byte) getCharToProcess::dist#0 < (byte) getCharToProcess::closest_dist#2
Inversing boolean not [261] (bool~) getCharToProcess::$1 ← (byte) getCharToProcess::closest_dist#3 == (byte) NOT_FOUND#0 from [260] (bool~) getCharToProcess::$0 ← (byte) getCharToProcess::closest_dist#3 != (byte) NOT_FOUND#0
Inversing boolean not [289] (bool~) startProcessing::$26 ← *((byte*) startProcessing::$41 + (byte~) startProcessing::$30) != (const byte) STATUS_FREE from [288] (bool~) startProcessing::$25 ← *((byte*) startProcessing::$41 + (byte~) startProcessing::$30) == (const byte) STATUS_FREE
Inversing boolean not [396] (bool~) processChars::$5 ← *((byte*) processChars::$41) == (const byte) STATUS_FREE from [395] (bool~) processChars::$4 ← *((byte*) processChars::$41) != (const byte) STATUS_FREE
Inversing boolean not [405] (bool~) processChars::$7 ← *((byte*) processChars::$42) != (const byte) STATUS_NEW from [404] (bool~) processChars::$6 ← *((byte*) processChars::$42) == (const byte) STATUS_NEW
Successful SSA optimization Pass2UnaryNotSimplification
Alias (byte*) HEAP_START#0 = (byte*) heap_head#0 (byte*) heap_head#11 (byte*) heap_head#10 (byte*) heap_head#9
Alias (byte*) HEAP_TOP#0 = (byte*) heap_head#0 (byte*) heap_head#11 (byte*) heap_head#10 (byte*) heap_head#9
Alias (byte*) malloc::mem#0 = (byte*~) malloc::$0
Alias (void*) malloc::return#0 = (void*) malloc::return#4 (void*) malloc::return#1
Alias (byte*) heap_head#1 = (byte*) heap_head#6 (byte*) heap_head#2
Alias (signed word) atan2_16::y#1 = (signed word) atan2_16::y#2 (signed word~) atan2_16::$3 (signed word) atan2_16::y#3
@ -3064,62 +3067,62 @@ Successful SSA optimization Pass2IdenticalPhiElimination
Identical Phi Values (signed word) atan2_16::x#4 (signed word) atan2_16::x#17
Identical Phi Values (signed word) atan2_16::y#4 (signed word) atan2_16::y#19
Successful SSA optimization Pass2IdenticalPhiElimination
Identified duplicate assignment right side [440] (byte~) processChars::$17 ← (byte) processChars::i#10 * (byte) 2
Identified duplicate assignment right side [441] (byte~) processChars::$17 ← (byte) processChars::i#10 * (byte) 2
Successful SSA optimization Pass2DuplicateRValueIdentification
Simple Condition (bool~) atan2_16::$0 [15] if((signed word) atan2_16::y#0>=(signed byte) 0) goto atan2_16::@1
Simple Condition (bool~) atan2_16::$5 [24] if((signed word) atan2_16::x#0>=(signed byte) 0) goto atan2_16::@4
Simple Condition (bool~) atan2_16::$18 [38] if((signed word) atan2_16::yi#3!=(signed byte) 0) goto atan2_16::@16
Simple Condition (bool~) atan2_16::$11 [47] if((signed word) atan2_16::x#17>=(signed byte) 0) goto atan2_16::@7
Simple Condition (bool~) atan2_16::$19 [50] if((byte) atan2_16::shift#2>=(byte) 2) goto atan2_16::@19
Simple Condition (bool~) atan2_16::$20 [58] if((byte) 0==(byte) atan2_16::shift#2) goto atan2_16::@25
Simple Condition (bool~) atan2_16::$21 [61] if((signed word) atan2_16::yi#3>=(signed byte) 0) goto atan2_16::@26
Simple Condition (bool~) atan2_16::$22 [78] if((byte) atan2_16::i#1!=rangelast(0,atan2_16::$16)) goto atan2_16::@15
Simple Condition (bool~) atan2_16::$14 [82] if((signed word) atan2_16::y#19>=(signed byte) 0) goto atan2_16::@8
Simple Condition (bool~) main::$6 [163] if((byte*) main::src#1!=(byte*~) main::$5) goto main::@1
Simple Condition (bool~) main::$8 [189] if((byte) main::i#1!=rangelast(0,main::$7)) goto main::@3
Simple Condition (bool~) main::$11 [212] if((byte) main::center_dist#0!=(byte) NOT_FOUND#0) goto main::@6
Simple Condition (bool~) getCharToProcess::$3 [238] if(*((byte*) getCharToProcess::screen_line#4 + (byte) getCharToProcess::x#2)==(byte) ' ') goto getCharToProcess::@5
Simple Condition (bool~) getCharToProcess::$6 [242] if((byte) getCharToProcess::x#1!=rangelast(0,$27)) goto getCharToProcess::@4
Simple Condition (bool~) getCharToProcess::$5 [247] if((byte) getCharToProcess::dist#0>=(byte) getCharToProcess::closest_dist#2) goto getCharToProcess::@5
Simple Condition (bool~) getCharToProcess::$7 [257] if((byte) getCharToProcess::y#1!=rangelast(0,$18)) goto getCharToProcess::@3
Simple Condition (bool~) getCharToProcess::$1 [261] if((byte) getCharToProcess::return_dist#1==(byte) NOT_FOUND#0) goto getCharToProcess::@1
Simple Condition (bool~) startProcessing::$26 [289] if(*((byte*) startProcessing::$41 + (byte~) startProcessing::$30)!=(const byte) STATUS_FREE) goto startProcessing::@3
Simple Condition (bool~) startProcessing::$27 [293] if((byte) startProcessing::i#1!=rangelast(0,startProcessing::$24)) goto startProcessing::@2
Simple Condition (bool~) startProcessing::$28 [298] if((byte) startProcessing::freeIdx#2==(byte) $ff) goto startProcessing::@1
Simple Condition (bool~) startProcessing::$29 [328] if((byte) startProcessing::i1#1!=rangelast(0,7)) goto startProcessing::@9
Simple Condition (bool~) processChars::$5 [396] if(*((byte*) processChars::$41)==(const byte) STATUS_FREE) goto processChars::@3
Simple Condition (bool~) processChars::$34 [400] if((byte) processChars::i#1!=rangelast(0,processChars::$1)) goto processChars::@2
Simple Condition (bool~) processChars::$7 [405] if(*((byte*) processChars::$42)!=(const byte) STATUS_NEW) goto processChars::@4
Simple Condition (bool~) processChars::$66 [412] if((byte) 0!=(byte~) processChars::$11) goto processChars::@5
Simple Condition (bool~) init_angle_screen::$15 [537] if((byte) init_angle_screen::x#1<=(byte) $13) goto init_angle_screen::@2
Simple Condition (bool~) init_angle_screen::$16 [543] if((byte) init_angle_screen::y#1!=rangelast(0,$c)) goto init_angle_screen::@1
Simple Condition (bool~) initSprites::$2 [552] if((byte*) initSprites::sp#1<(byte*~) initSprites::$1) goto initSprites::@1
Simple Condition (bool~) initSprites::$3 [558] if((byte) initSprites::i#1!=rangelast(0,7)) goto initSprites::@3
Simple Condition (bool~) setupRasterIrq::$0 [569] if((word) setupRasterIrq::raster#0<(word) $100) goto setupRasterIrq::@1
Simple Condition (bool~) irqTop::$2 [593] if((byte) irqTop::i#1!=rangelast(0,4)) goto irqTop::@3
Simple Condition (bool~) irqTop::$3 [600] if((byte) irqTop::i1#1!=rangelast(0,7)) goto irqTop::@5
Simple Condition (bool~) irqBottom::$4 [615] if((byte) irqBottom::i#1!=rangelast(0,4)) goto irqBottom::@5
Simple Condition (bool~) atan2_16::$0 [16] if((signed word) atan2_16::y#0>=(signed byte) 0) goto atan2_16::@1
Simple Condition (bool~) atan2_16::$5 [25] if((signed word) atan2_16::x#0>=(signed byte) 0) goto atan2_16::@4
Simple Condition (bool~) atan2_16::$18 [39] if((signed word) atan2_16::yi#3!=(signed byte) 0) goto atan2_16::@16
Simple Condition (bool~) atan2_16::$11 [48] if((signed word) atan2_16::x#17>=(signed byte) 0) goto atan2_16::@7
Simple Condition (bool~) atan2_16::$19 [51] if((byte) atan2_16::shift#2>=(byte) 2) goto atan2_16::@19
Simple Condition (bool~) atan2_16::$20 [59] if((byte) 0==(byte) atan2_16::shift#2) goto atan2_16::@25
Simple Condition (bool~) atan2_16::$21 [62] if((signed word) atan2_16::yi#3>=(signed byte) 0) goto atan2_16::@26
Simple Condition (bool~) atan2_16::$22 [79] if((byte) atan2_16::i#1!=rangelast(0,atan2_16::$16)) goto atan2_16::@15
Simple Condition (bool~) atan2_16::$14 [83] if((signed word) atan2_16::y#19>=(signed byte) 0) goto atan2_16::@8
Simple Condition (bool~) main::$6 [164] if((byte*) main::src#1!=(byte*~) main::$5) goto main::@1
Simple Condition (bool~) main::$8 [190] if((byte) main::i#1!=rangelast(0,main::$7)) goto main::@3
Simple Condition (bool~) main::$11 [213] if((byte) main::center_dist#0!=(byte) NOT_FOUND#0) goto main::@6
Simple Condition (bool~) getCharToProcess::$3 [239] if(*((byte*) getCharToProcess::screen_line#4 + (byte) getCharToProcess::x#2)==(byte) ' ') goto getCharToProcess::@5
Simple Condition (bool~) getCharToProcess::$6 [243] if((byte) getCharToProcess::x#1!=rangelast(0,$27)) goto getCharToProcess::@4
Simple Condition (bool~) getCharToProcess::$5 [248] if((byte) getCharToProcess::dist#0>=(byte) getCharToProcess::closest_dist#2) goto getCharToProcess::@5
Simple Condition (bool~) getCharToProcess::$7 [258] if((byte) getCharToProcess::y#1!=rangelast(0,$18)) goto getCharToProcess::@3
Simple Condition (bool~) getCharToProcess::$1 [262] if((byte) getCharToProcess::return_dist#1==(byte) NOT_FOUND#0) goto getCharToProcess::@1
Simple Condition (bool~) startProcessing::$26 [290] if(*((byte*) startProcessing::$41 + (byte~) startProcessing::$30)!=(const byte) STATUS_FREE) goto startProcessing::@3
Simple Condition (bool~) startProcessing::$27 [294] if((byte) startProcessing::i#1!=rangelast(0,startProcessing::$24)) goto startProcessing::@2
Simple Condition (bool~) startProcessing::$28 [299] if((byte) startProcessing::freeIdx#2==(byte) $ff) goto startProcessing::@1
Simple Condition (bool~) startProcessing::$29 [329] if((byte) startProcessing::i1#1!=rangelast(0,7)) goto startProcessing::@9
Simple Condition (bool~) processChars::$5 [397] if(*((byte*) processChars::$41)==(const byte) STATUS_FREE) goto processChars::@3
Simple Condition (bool~) processChars::$34 [401] if((byte) processChars::i#1!=rangelast(0,processChars::$1)) goto processChars::@2
Simple Condition (bool~) processChars::$7 [406] if(*((byte*) processChars::$42)!=(const byte) STATUS_NEW) goto processChars::@4
Simple Condition (bool~) processChars::$66 [413] if((byte) 0!=(byte~) processChars::$11) goto processChars::@5
Simple Condition (bool~) init_angle_screen::$15 [538] if((byte) init_angle_screen::x#1<=(byte) $13) goto init_angle_screen::@2
Simple Condition (bool~) init_angle_screen::$16 [544] if((byte) init_angle_screen::y#1!=rangelast(0,$c)) goto init_angle_screen::@1
Simple Condition (bool~) initSprites::$2 [553] if((byte*) initSprites::sp#1<(byte*~) initSprites::$1) goto initSprites::@1
Simple Condition (bool~) initSprites::$3 [559] if((byte) initSprites::i#1!=rangelast(0,7)) goto initSprites::@3
Simple Condition (bool~) setupRasterIrq::$0 [570] if((word) setupRasterIrq::raster#0<(word) $100) goto setupRasterIrq::@1
Simple Condition (bool~) irqTop::$2 [594] if((byte) irqTop::i#1!=rangelast(0,4)) goto irqTop::@3
Simple Condition (bool~) irqTop::$3 [601] if((byte) irqTop::i1#1!=rangelast(0,7)) goto irqTop::@5
Simple Condition (bool~) irqBottom::$4 [616] if((byte) irqBottom::i#1!=rangelast(0,4)) goto irqBottom::@5
Successful SSA optimization Pass2ConditionalJumpSimplification
Rewriting || if()-condition to two if()s [452] (bool~) processChars::$24 ← (bool~) processChars::$22 || (bool~) processChars::$23
Rewriting || if()-condition to two if()s [453] (bool~) processChars::$24 ← (bool~) processChars::$22 || (bool~) processChars::$23
Successful SSA optimization Pass2ConditionalAndOrRewriting
Rewriting || if()-condition to two if()s [449] (bool~) processChars::$22 ← (bool~) processChars::$20 || (bool~) processChars::$21
Rewriting || if()-condition to two if()s [450] (bool~) processChars::$22 ← (bool~) processChars::$20 || (bool~) processChars::$21
Successful SSA optimization Pass2ConditionalAndOrRewriting
Rewriting || if()-condition to two if()s [446] (bool~) processChars::$20 ← (bool~) processChars::$18 || (bool~) processChars::$19
Rewriting || if()-condition to two if()s [447] (bool~) processChars::$20 ← (bool~) processChars::$18 || (bool~) processChars::$19
Successful SSA optimization Pass2ConditionalAndOrRewriting
Rewriting ! if()-condition to reversed if() [489] (bool~) processChars::$0 ← ! (bool) DEBUG#0
Rewriting ! if()-condition to reversed if() [490] (bool~) processChars::$0 ← ! (bool) DEBUG#0
Successful SSA optimization Pass2ConditionalAndOrRewriting
Rewriting ! if()-condition to reversed if() [583] (bool~) irqTop::$0 ← ! (bool) DEBUG#0
Rewriting ! if()-condition to reversed if() [584] (bool~) irqTop::$0 ← ! (bool) DEBUG#0
Successful SSA optimization Pass2ConditionalAndOrRewriting
Rewriting ! if()-condition to reversed if() [606] (bool~) irqBottom::$0 ← ! (bool) DEBUG#0
Rewriting ! if()-condition to reversed if() [607] (bool~) irqBottom::$0 ← ! (bool) DEBUG#0
Successful SSA optimization Pass2ConditionalAndOrRewriting
Rewriting ! if()-condition to reversed if() [609] (bool~) irqBottom::$2 ← ! (bool) DEBUG#0
Rewriting ! if()-condition to reversed if() [610] (bool~) irqBottom::$2 ← ! (bool) DEBUG#0
Successful SSA optimization Pass2ConditionalAndOrRewriting
Negating conditional jump and destination [78] if((byte) atan2_16::i#1==rangelast(0,atan2_16::$16)) goto atan2_16::@17
Constant right-side identified [193] (void()*) setupRasterIrq::irqRoutine#0 ← & interrupt(HARDWARE_ALL)(void()) irqTop()
Constant right-side identified [586] (void()*~) irqTop::$1 ← & interrupt(HARDWARE_ALL)(void()) irqBottom()
Constant right-side identified [619] (void()*~) irqBottom::$3 ← & interrupt(HARDWARE_ALL)(void()) irqTop()
Negating conditional jump and destination [79] if((byte) atan2_16::i#1==rangelast(0,atan2_16::$16)) goto atan2_16::@17
Constant right-side identified [194] (void()*) setupRasterIrq::irqRoutine#0 ← & interrupt(HARDWARE_ALL)(void()) irqTop()
Constant right-side identified [587] (void()*~) irqTop::$1 ← & interrupt(HARDWARE_ALL)(void()) irqBottom()
Constant right-side identified [620] (void()*~) irqBottom::$3 ← & interrupt(HARDWARE_ALL)(void()) irqTop()
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant (const byte*) HEAP_START#0 = (byte*) 49152
Constant (const byte*) HEAP_TOP#0 = (byte*) 40960
Constant (const byte) CORDIC_ITERATIONS_16#0 = $f
Constant (const word[CORDIC_ITERATIONS_16#0]) CORDIC_ATAN2_ANGLES_16#0 = kickasm {{ .for (var i=0; i<CORDIC_ITERATIONS_16; i++)
.word 256*2*256*atan(1/pow(2,i))/PI/2
@ -3202,75 +3205,75 @@ Constant (const word) setupRasterIrq::raster#0 = RASTER_IRQ_TOP#0
Constant (const byte) getCharToProcess::closest_dist#0 = NOT_FOUND#0
Constant (const byte*) initSprites::sp#0 = SPRITE_DATA#0
Successful SSA optimization Pass2ConstantIdentification
Constant value identified { fill( NUM_PROCESSING#0, 0) } in [150] (struct ProcessingSprite[NUM_PROCESSING#0]) PROCESSING#0 ← { fill( NUM_PROCESSING#0, 0) }
Constant value identified (word)BORDER_YPOS_BOTTOM#0 in [380] (word~) $10 ← (word)(const byte) BORDER_YPOS_BOTTOM#0
Constant value identified { fill( NUM_PROCESSING#0, 0) } in [151] (struct ProcessingSprite[NUM_PROCESSING#0]) PROCESSING#0 ← { fill( NUM_PROCESSING#0, 0) }
Constant value identified (word)BORDER_YPOS_BOTTOM#0 in [381] (word~) $10 ← (word)(const byte) BORDER_YPOS_BOTTOM#0
Successful SSA optimization Pass2ConstantValues
if() condition always true - replacing block destination [219] if(true) goto main::@5
if() condition always true - replacing block destination [224] if(true) goto main::@11
if() condition always false - eliminating [490] if((const bool) DEBUG#0) goto processChars::@16
if() condition always true - replacing block destination [569] if((const word) setupRasterIrq::raster#0<(word) $100) goto setupRasterIrq::@1
if() condition always false - eliminating [584] if((const bool) DEBUG#0) goto irqTop::@2
if() condition always false - eliminating [607] if((const bool) DEBUG#0) goto irqBottom::@3
if() condition always false - eliminating [610] if((const bool) DEBUG#0) goto irqBottom::@4
if() condition always true - replacing block destination [220] if(true) goto main::@5
if() condition always true - replacing block destination [225] if(true) goto main::@11
if() condition always false - eliminating [491] if((const bool) DEBUG#0) goto processChars::@16
if() condition always true - replacing block destination [570] if((const word) setupRasterIrq::raster#0<(word) $100) goto setupRasterIrq::@1
if() condition always false - eliminating [585] if((const bool) DEBUG#0) goto irqTop::@2
if() condition always false - eliminating [608] if((const bool) DEBUG#0) goto irqBottom::@3
if() condition always false - eliminating [611] if((const bool) DEBUG#0) goto irqBottom::@4
Successful SSA optimization Pass2ConstantIfs
Resolved ranged next value [240] getCharToProcess::x#1 ← ++ getCharToProcess::x#2 to ++
Resolved ranged comparison value [242] if(getCharToProcess::x#1!=rangelast(0,$27)) goto getCharToProcess::@4 to (number) $28
Resolved ranged next value [255] getCharToProcess::y#1 ← ++ getCharToProcess::y#2 to ++
Resolved ranged comparison value [257] if(getCharToProcess::y#1!=rangelast(0,$18)) goto getCharToProcess::@3 to (number) $19
Resolved ranged next value [326] startProcessing::i1#1 ← ++ startProcessing::i1#2 to ++
Resolved ranged comparison value [328] if(startProcessing::i1#1!=rangelast(0,7)) goto startProcessing::@9 to (number) 8
Resolved ranged next value [541] init_angle_screen::y#1 ← ++ init_angle_screen::y#4 to ++
Resolved ranged comparison value [543] if(init_angle_screen::y#1!=rangelast(0,$c)) goto init_angle_screen::@1 to (number) $d
Resolved ranged next value [556] initSprites::i#1 ← ++ initSprites::i#2 to ++
Resolved ranged comparison value [558] if(initSprites::i#1!=rangelast(0,7)) goto initSprites::@3 to (number) 8
Resolved ranged next value [591] irqTop::i#1 ← ++ irqTop::i#2 to ++
Resolved ranged comparison value [593] if(irqTop::i#1!=rangelast(0,4)) goto irqTop::@3 to (number) 5
Resolved ranged next value [598] irqTop::i1#1 ← ++ irqTop::i1#2 to ++
Resolved ranged comparison value [600] if(irqTop::i1#1!=rangelast(0,7)) goto irqTop::@5 to (number) 8
Resolved ranged next value [613] irqBottom::i#1 ← ++ irqBottom::i#2 to ++
Resolved ranged comparison value [615] if(irqBottom::i#1!=rangelast(0,4)) goto irqBottom::@5 to (number) 5
Rewriting conditional comparison [537] if((byte) init_angle_screen::x#1<=(byte) $13) goto init_angle_screen::@2
Converting *(pointer+n) to pointer[n] [272] *((byte*~) getCharToProcess::$11) ← (byte) ' ' -- *(getCharToProcess::$10 + getCharToProcess::return_x#1)
Converting *(pointer+n) to pointer[n] [391] (byte) processChars::bitmask#0 ← (byte) 1 << *((byte*) processChars::$40) -- *((byte*)processChars::processing#0 + OFFSET_STRUCT_PROCESSINGSPRITE_ID)
Converting *(pointer+n) to pointer[n] [396] if(*((byte*) processChars::$41)==(const byte) STATUS_FREE) goto processChars::@3 -- *((byte*)processChars::processing#0 + OFFSET_STRUCT_PROCESSINGSPRITE_STATUS)
Converting *(pointer+n) to pointer[n] [405] if(*((byte*) processChars::$42)!=(const byte) STATUS_NEW) goto processChars::@4 -- *((byte*)processChars::processing#0 + OFFSET_STRUCT_PROCESSINGSPRITE_STATUS)
Converting *(pointer+n) to pointer[n] [408] (word) processChars::xpos#0 ← *((word*) processChars::$43) >> (byte) 4 -- *((word*)processChars::processing#0 + OFFSET_STRUCT_PROCESSINGSPRITE_X)
Converting *(pointer+n) to pointer[n] [415] *(*((byte**) processChars::$44)) ← (byte) ' ' -- *((byte**)processChars::processing#0 + OFFSET_STRUCT_PROCESSINGSPRITE_SCREENPTR)
Converting *(pointer+n) to pointer[n] [419] *((const byte*) SPRITES_COLS#0 + *((byte*) processChars::$46)) ← *((byte*) processChars::$45) -- *((byte*)processChars::processing#0 + OFFSET_STRUCT_PROCESSINGSPRITE_COL)
Converting *(pointer+n) to pointer[n] [419] *((const byte*) SPRITES_COLS#0 + *((byte*) processChars::$46)) ← *((byte*)(struct ProcessingSprite*) processChars::processing#0 + (const byte) OFFSET_STRUCT_PROCESSINGSPRITE_COL) -- *((byte*)processChars::processing#0 + OFFSET_STRUCT_PROCESSINGSPRITE_ID)
Converting *(pointer+n) to pointer[n] [422] (byte*~) processChars::$9 ← (byte*~) processChars::$8 + *((byte*) processChars::$47) -- *((byte*)processChars::processing#0 + OFFSET_STRUCT_PROCESSINGSPRITE_ID)
Converting *(pointer+n) to pointer[n] [424] *((byte*~) processChars::$9) ← *((byte*) processChars::$48) -- *((byte*)processChars::processing#0 + OFFSET_STRUCT_PROCESSINGSPRITE_PTR)
Converting *(pointer+n) to pointer[n] [424] *((byte*~) processChars::$9) ← *((byte*)(struct ProcessingSprite*) processChars::processing#0 + (const byte) OFFSET_STRUCT_PROCESSINGSPRITE_PTR) -- *(processChars::$8 + *((byte*)processChars::processing#0 + OFFSET_STRUCT_PROCESSINGSPRITE_ID))
Converting *(pointer+n) to pointer[n] [426] *((byte*) processChars::$49) ← (const byte) STATUS_PROCESSING -- *((byte*)processChars::processing#0 + OFFSET_STRUCT_PROCESSINGSPRITE_STATUS)
Converting *(pointer+n) to pointer[n] [437] (word~) processChars::$15 ← *((word*) processChars::$50) >> (byte) 4 -- *((word*)processChars::processing#0 + OFFSET_STRUCT_PROCESSINGSPRITE_Y)
Converting *(pointer+n) to pointer[n] [443] (bool~) processChars::$18 ← *((word*) processChars::$51) < (word) XPOS_LEFTMOST#0 -- *((word*)processChars::processing#0 + OFFSET_STRUCT_PROCESSINGSPRITE_X)
Converting *(pointer+n) to pointer[n] [445] (bool~) processChars::$19 ← *((word*) processChars::$52) > (word) XPOS_RIGHTMOST#0 -- *((word*)processChars::processing#0 + OFFSET_STRUCT_PROCESSINGSPRITE_X)
Converting *(pointer+n) to pointer[n] [448] (bool~) processChars::$21 ← *((word*) processChars::$53) < (word) YPOS_TOPMOST#0 -- *((word*)processChars::processing#0 + OFFSET_STRUCT_PROCESSINGSPRITE_Y)
Converting *(pointer+n) to pointer[n] [451] (bool~) processChars::$23 ← *((word*) processChars::$54) > (word) YPOS_BOTTOMMOST#0 -- *((word*)processChars::processing#0 + OFFSET_STRUCT_PROCESSINGSPRITE_Y)
Converting *(pointer+n) to pointer[n] [456] *((byte*) processChars::$55) ← (const byte) STATUS_FREE -- *((byte*)processChars::processing#0 + OFFSET_STRUCT_PROCESSINGSPRITE_STATUS)
Converting *(pointer+n) to pointer[n] [468] *((word*) processChars::$57) ← *((word*) processChars::$56) + *((const word[$28]) VXSIN#0 + (byte~) processChars::$38) -- *((word*)processChars::processing#0 + OFFSET_STRUCT_PROCESSINGSPRITE_VX)
Converting *(pointer+n) to pointer[n] [468] *((word*) processChars::$57) ← *((word*)(struct ProcessingSprite*) processChars::processing#0 + (const byte) OFFSET_STRUCT_PROCESSINGSPRITE_VX) + *((const word[$28]) VXSIN#0 + (byte~) processChars::$38) -- *((word*)processChars::processing#0 + OFFSET_STRUCT_PROCESSINGSPRITE_VX)
Converting *(pointer+n) to pointer[n] [472] *((word*) processChars::$60) ← *((word*) processChars::$58) + *((word*) processChars::$59) -- *((word*)processChars::processing#0 + OFFSET_STRUCT_PROCESSINGSPRITE_X)
Converting *(pointer+n) to pointer[n] [472] *((word*) processChars::$60) ← *((word*)(struct ProcessingSprite*) processChars::processing#0 + (const byte) OFFSET_STRUCT_PROCESSINGSPRITE_X) + *((word*) processChars::$59) -- *((word*)processChars::processing#0 + OFFSET_STRUCT_PROCESSINGSPRITE_VX)
Converting *(pointer+n) to pointer[n] [472] *((word*) processChars::$60) ← *((word*)(struct ProcessingSprite*) processChars::processing#0 + (const byte) OFFSET_STRUCT_PROCESSINGSPRITE_X) + *((word*)(struct ProcessingSprite*) processChars::processing#0 + (const byte) OFFSET_STRUCT_PROCESSINGSPRITE_VX) -- *((word*)processChars::processing#0 + OFFSET_STRUCT_PROCESSINGSPRITE_X)
Converting *(pointer+n) to pointer[n] [481] *((word*) processChars::$62) ← *((word*) processChars::$61) + *((const word[$19]) VYSIN#0 + (byte~) processChars::$39) -- *((word*)processChars::processing#0 + OFFSET_STRUCT_PROCESSINGSPRITE_VY)
Converting *(pointer+n) to pointer[n] [481] *((word*) processChars::$62) ← *((word*)(struct ProcessingSprite*) processChars::processing#0 + (const byte) OFFSET_STRUCT_PROCESSINGSPRITE_VY) + *((const word[$19]) VYSIN#0 + (byte~) processChars::$39) -- *((word*)processChars::processing#0 + OFFSET_STRUCT_PROCESSINGSPRITE_VY)
Converting *(pointer+n) to pointer[n] [485] *((word*) processChars::$65) ← *((word*) processChars::$63) + *((word*) processChars::$64) -- *((word*)processChars::processing#0 + OFFSET_STRUCT_PROCESSINGSPRITE_Y)
Converting *(pointer+n) to pointer[n] [485] *((word*) processChars::$65) ← *((word*)(struct ProcessingSprite*) processChars::processing#0 + (const byte) OFFSET_STRUCT_PROCESSINGSPRITE_Y) + *((word*) processChars::$64) -- *((word*)processChars::processing#0 + OFFSET_STRUCT_PROCESSINGSPRITE_VY)
Converting *(pointer+n) to pointer[n] [485] *((word*) processChars::$65) ← *((word*)(struct ProcessingSprite*) processChars::processing#0 + (const byte) OFFSET_STRUCT_PROCESSINGSPRITE_Y) + *((word*)(struct ProcessingSprite*) processChars::processing#0 + (const byte) OFFSET_STRUCT_PROCESSINGSPRITE_VY) -- *((word*)processChars::processing#0 + OFFSET_STRUCT_PROCESSINGSPRITE_Y)
Resolved ranged next value [241] getCharToProcess::x#1 ← ++ getCharToProcess::x#2 to ++
Resolved ranged comparison value [243] if(getCharToProcess::x#1!=rangelast(0,$27)) goto getCharToProcess::@4 to (number) $28
Resolved ranged next value [256] getCharToProcess::y#1 ← ++ getCharToProcess::y#2 to ++
Resolved ranged comparison value [258] if(getCharToProcess::y#1!=rangelast(0,$18)) goto getCharToProcess::@3 to (number) $19
Resolved ranged next value [327] startProcessing::i1#1 ← ++ startProcessing::i1#2 to ++
Resolved ranged comparison value [329] if(startProcessing::i1#1!=rangelast(0,7)) goto startProcessing::@9 to (number) 8
Resolved ranged next value [542] init_angle_screen::y#1 ← ++ init_angle_screen::y#4 to ++
Resolved ranged comparison value [544] if(init_angle_screen::y#1!=rangelast(0,$c)) goto init_angle_screen::@1 to (number) $d
Resolved ranged next value [557] initSprites::i#1 ← ++ initSprites::i#2 to ++
Resolved ranged comparison value [559] if(initSprites::i#1!=rangelast(0,7)) goto initSprites::@3 to (number) 8
Resolved ranged next value [592] irqTop::i#1 ← ++ irqTop::i#2 to ++
Resolved ranged comparison value [594] if(irqTop::i#1!=rangelast(0,4)) goto irqTop::@3 to (number) 5
Resolved ranged next value [599] irqTop::i1#1 ← ++ irqTop::i1#2 to ++
Resolved ranged comparison value [601] if(irqTop::i1#1!=rangelast(0,7)) goto irqTop::@5 to (number) 8
Resolved ranged next value [614] irqBottom::i#1 ← ++ irqBottom::i#2 to ++
Resolved ranged comparison value [616] if(irqBottom::i#1!=rangelast(0,4)) goto irqBottom::@5 to (number) 5
Rewriting conditional comparison [538] if((byte) init_angle_screen::x#1<=(byte) $13) goto init_angle_screen::@2
Converting *(pointer+n) to pointer[n] [273] *((byte*~) getCharToProcess::$11) ← (byte) ' ' -- *(getCharToProcess::$10 + getCharToProcess::return_x#1)
Converting *(pointer+n) to pointer[n] [392] (byte) processChars::bitmask#0 ← (byte) 1 << *((byte*) processChars::$40) -- *((byte*)processChars::processing#0 + OFFSET_STRUCT_PROCESSINGSPRITE_ID)
Converting *(pointer+n) to pointer[n] [397] if(*((byte*) processChars::$41)==(const byte) STATUS_FREE) goto processChars::@3 -- *((byte*)processChars::processing#0 + OFFSET_STRUCT_PROCESSINGSPRITE_STATUS)
Converting *(pointer+n) to pointer[n] [406] if(*((byte*) processChars::$42)!=(const byte) STATUS_NEW) goto processChars::@4 -- *((byte*)processChars::processing#0 + OFFSET_STRUCT_PROCESSINGSPRITE_STATUS)
Converting *(pointer+n) to pointer[n] [409] (word) processChars::xpos#0 ← *((word*) processChars::$43) >> (byte) 4 -- *((word*)processChars::processing#0 + OFFSET_STRUCT_PROCESSINGSPRITE_X)
Converting *(pointer+n) to pointer[n] [416] *(*((byte**) processChars::$44)) ← (byte) ' ' -- *((byte**)processChars::processing#0 + OFFSET_STRUCT_PROCESSINGSPRITE_SCREENPTR)
Converting *(pointer+n) to pointer[n] [420] *((const byte*) SPRITES_COLS#0 + *((byte*) processChars::$46)) ← *((byte*) processChars::$45) -- *((byte*)processChars::processing#0 + OFFSET_STRUCT_PROCESSINGSPRITE_COL)
Converting *(pointer+n) to pointer[n] [420] *((const byte*) SPRITES_COLS#0 + *((byte*) processChars::$46)) ← *((byte*)(struct ProcessingSprite*) processChars::processing#0 + (const byte) OFFSET_STRUCT_PROCESSINGSPRITE_COL) -- *((byte*)processChars::processing#0 + OFFSET_STRUCT_PROCESSINGSPRITE_ID)
Converting *(pointer+n) to pointer[n] [423] (byte*~) processChars::$9 ← (byte*~) processChars::$8 + *((byte*) processChars::$47) -- *((byte*)processChars::processing#0 + OFFSET_STRUCT_PROCESSINGSPRITE_ID)
Converting *(pointer+n) to pointer[n] [425] *((byte*~) processChars::$9) ← *((byte*) processChars::$48) -- *((byte*)processChars::processing#0 + OFFSET_STRUCT_PROCESSINGSPRITE_PTR)
Converting *(pointer+n) to pointer[n] [425] *((byte*~) processChars::$9) ← *((byte*)(struct ProcessingSprite*) processChars::processing#0 + (const byte) OFFSET_STRUCT_PROCESSINGSPRITE_PTR) -- *(processChars::$8 + *((byte*)processChars::processing#0 + OFFSET_STRUCT_PROCESSINGSPRITE_ID))
Converting *(pointer+n) to pointer[n] [427] *((byte*) processChars::$49) ← (const byte) STATUS_PROCESSING -- *((byte*)processChars::processing#0 + OFFSET_STRUCT_PROCESSINGSPRITE_STATUS)
Converting *(pointer+n) to pointer[n] [438] (word~) processChars::$15 ← *((word*) processChars::$50) >> (byte) 4 -- *((word*)processChars::processing#0 + OFFSET_STRUCT_PROCESSINGSPRITE_Y)
Converting *(pointer+n) to pointer[n] [444] (bool~) processChars::$18 ← *((word*) processChars::$51) < (word) XPOS_LEFTMOST#0 -- *((word*)processChars::processing#0 + OFFSET_STRUCT_PROCESSINGSPRITE_X)
Converting *(pointer+n) to pointer[n] [446] (bool~) processChars::$19 ← *((word*) processChars::$52) > (word) XPOS_RIGHTMOST#0 -- *((word*)processChars::processing#0 + OFFSET_STRUCT_PROCESSINGSPRITE_X)
Converting *(pointer+n) to pointer[n] [449] (bool~) processChars::$21 ← *((word*) processChars::$53) < (word) YPOS_TOPMOST#0 -- *((word*)processChars::processing#0 + OFFSET_STRUCT_PROCESSINGSPRITE_Y)
Converting *(pointer+n) to pointer[n] [452] (bool~) processChars::$23 ← *((word*) processChars::$54) > (word) YPOS_BOTTOMMOST#0 -- *((word*)processChars::processing#0 + OFFSET_STRUCT_PROCESSINGSPRITE_Y)
Converting *(pointer+n) to pointer[n] [457] *((byte*) processChars::$55) ← (const byte) STATUS_FREE -- *((byte*)processChars::processing#0 + OFFSET_STRUCT_PROCESSINGSPRITE_STATUS)
Converting *(pointer+n) to pointer[n] [469] *((word*) processChars::$57) ← *((word*) processChars::$56) + *((const word[$28]) VXSIN#0 + (byte~) processChars::$38) -- *((word*)processChars::processing#0 + OFFSET_STRUCT_PROCESSINGSPRITE_VX)
Converting *(pointer+n) to pointer[n] [469] *((word*) processChars::$57) ← *((word*)(struct ProcessingSprite*) processChars::processing#0 + (const byte) OFFSET_STRUCT_PROCESSINGSPRITE_VX) + *((const word[$28]) VXSIN#0 + (byte~) processChars::$38) -- *((word*)processChars::processing#0 + OFFSET_STRUCT_PROCESSINGSPRITE_VX)
Converting *(pointer+n) to pointer[n] [473] *((word*) processChars::$60) ← *((word*) processChars::$58) + *((word*) processChars::$59) -- *((word*)processChars::processing#0 + OFFSET_STRUCT_PROCESSINGSPRITE_X)
Converting *(pointer+n) to pointer[n] [473] *((word*) processChars::$60) ← *((word*)(struct ProcessingSprite*) processChars::processing#0 + (const byte) OFFSET_STRUCT_PROCESSINGSPRITE_X) + *((word*) processChars::$59) -- *((word*)processChars::processing#0 + OFFSET_STRUCT_PROCESSINGSPRITE_VX)
Converting *(pointer+n) to pointer[n] [473] *((word*) processChars::$60) ← *((word*)(struct ProcessingSprite*) processChars::processing#0 + (const byte) OFFSET_STRUCT_PROCESSINGSPRITE_X) + *((word*)(struct ProcessingSprite*) processChars::processing#0 + (const byte) OFFSET_STRUCT_PROCESSINGSPRITE_VX) -- *((word*)processChars::processing#0 + OFFSET_STRUCT_PROCESSINGSPRITE_X)
Converting *(pointer+n) to pointer[n] [482] *((word*) processChars::$62) ← *((word*) processChars::$61) + *((const word[$19]) VYSIN#0 + (byte~) processChars::$39) -- *((word*)processChars::processing#0 + OFFSET_STRUCT_PROCESSINGSPRITE_VY)
Converting *(pointer+n) to pointer[n] [482] *((word*) processChars::$62) ← *((word*)(struct ProcessingSprite*) processChars::processing#0 + (const byte) OFFSET_STRUCT_PROCESSINGSPRITE_VY) + *((const word[$19]) VYSIN#0 + (byte~) processChars::$39) -- *((word*)processChars::processing#0 + OFFSET_STRUCT_PROCESSINGSPRITE_VY)
Converting *(pointer+n) to pointer[n] [486] *((word*) processChars::$65) ← *((word*) processChars::$63) + *((word*) processChars::$64) -- *((word*)processChars::processing#0 + OFFSET_STRUCT_PROCESSINGSPRITE_Y)
Converting *(pointer+n) to pointer[n] [486] *((word*) processChars::$65) ← *((word*)(struct ProcessingSprite*) processChars::processing#0 + (const byte) OFFSET_STRUCT_PROCESSINGSPRITE_Y) + *((word*) processChars::$64) -- *((word*)processChars::processing#0 + OFFSET_STRUCT_PROCESSINGSPRITE_VY)
Converting *(pointer+n) to pointer[n] [486] *((word*) processChars::$65) ← *((word*)(struct ProcessingSprite*) processChars::processing#0 + (const byte) OFFSET_STRUCT_PROCESSINGSPRITE_Y) + *((word*)(struct ProcessingSprite*) processChars::processing#0 + (const byte) OFFSET_STRUCT_PROCESSINGSPRITE_VY) -- *((word*)processChars::processing#0 + OFFSET_STRUCT_PROCESSINGSPRITE_Y)
Successful SSA optimization Pass2InlineDerefIdx
Simplifying expression containing zero (word*)PROCESSING#0 in [169] (word*) main::$17 ← (word*)(struct ProcessingSprite[NUM_PROCESSING#0]) PROCESSING#0 + (const byte) OFFSET_STRUCT_PROCESSINGSPRITE_X
Simplifying expression containing zero (word*)PROCESSING#0 in [349] (word*) startProcessing::$32 ← (word*)(struct ProcessingSprite[NUM_PROCESSING#0]) PROCESSING#0 + (const byte) OFFSET_STRUCT_PROCESSINGSPRITE_X
Simplifying expression containing zero (word*)processChars::processing#0 in [407] (word*) processChars::$43 ← (word*)(struct ProcessingSprite*) processChars::processing#0 + (const byte) OFFSET_STRUCT_PROCESSINGSPRITE_X
Simplifying expression containing zero (word*)processChars::processing#0 in [408] (word) processChars::xpos#0 ← *((word*)(struct ProcessingSprite*) processChars::processing#0 + (const byte) OFFSET_STRUCT_PROCESSINGSPRITE_X) >> (byte) 4
Simplifying expression containing zero (word*)processChars::processing#0 in [442] (word*) processChars::$51 ← (word*)(struct ProcessingSprite*) processChars::processing#0 + (const byte) OFFSET_STRUCT_PROCESSINGSPRITE_X
Simplifying expression containing zero (word*)processChars::processing#0 in [443] (bool~) processChars::$18 ← *((word*)(struct ProcessingSprite*) processChars::processing#0 + (const byte) OFFSET_STRUCT_PROCESSINGSPRITE_X) < (word) XPOS_LEFTMOST#0
Simplifying expression containing zero (word*)processChars::processing#0 in [444] (word*) processChars::$52 ← (word*)(struct ProcessingSprite*) processChars::processing#0 + (const byte) OFFSET_STRUCT_PROCESSINGSPRITE_X
Simplifying expression containing zero (word*)processChars::processing#0 in [445] (bool~) processChars::$19 ← *((word*)(struct ProcessingSprite*) processChars::processing#0 + (const byte) OFFSET_STRUCT_PROCESSINGSPRITE_X) > (word) XPOS_RIGHTMOST#0
Simplifying expression containing zero (word*)processChars::processing#0 in [469] (word*) processChars::$58 ← (word*)(struct ProcessingSprite*) processChars::processing#0 + (const byte) OFFSET_STRUCT_PROCESSINGSPRITE_X
Simplifying expression containing zero (word*)processChars::processing#0 in [471] (word*) processChars::$60 ← (word*)(struct ProcessingSprite*) processChars::processing#0 + (const byte) OFFSET_STRUCT_PROCESSINGSPRITE_X
Simplifying expression containing zero (word*)processChars::processing#0 in [472] *((word*)(struct ProcessingSprite*) processChars::processing#0 + (const byte) OFFSET_STRUCT_PROCESSINGSPRITE_X) ← *((word*)(struct ProcessingSprite*) processChars::processing#0 + (const byte) OFFSET_STRUCT_PROCESSINGSPRITE_X) + *((word*)(struct ProcessingSprite*) processChars::processing#0 + (const byte) OFFSET_STRUCT_PROCESSINGSPRITE_VX)
Simplifying expression containing zero (word*)processChars::processing#0 in [472] *((word*)(struct ProcessingSprite*) processChars::processing#0 + (const byte) OFFSET_STRUCT_PROCESSINGSPRITE_X) ← *((word*)(struct ProcessingSprite*) processChars::processing#0) + *((word*)(struct ProcessingSprite*) processChars::processing#0 + (const byte) OFFSET_STRUCT_PROCESSINGSPRITE_VX)
Simplifying expression containing zero (word*)PROCESSING#0 in [170] (word*) main::$17 ← (word*)(struct ProcessingSprite[NUM_PROCESSING#0]) PROCESSING#0 + (const byte) OFFSET_STRUCT_PROCESSINGSPRITE_X
Simplifying expression containing zero (word*)PROCESSING#0 in [350] (word*) startProcessing::$32 ← (word*)(struct ProcessingSprite[NUM_PROCESSING#0]) PROCESSING#0 + (const byte) OFFSET_STRUCT_PROCESSINGSPRITE_X
Simplifying expression containing zero (word*)processChars::processing#0 in [408] (word*) processChars::$43 ← (word*)(struct ProcessingSprite*) processChars::processing#0 + (const byte) OFFSET_STRUCT_PROCESSINGSPRITE_X
Simplifying expression containing zero (word*)processChars::processing#0 in [409] (word) processChars::xpos#0 ← *((word*)(struct ProcessingSprite*) processChars::processing#0 + (const byte) OFFSET_STRUCT_PROCESSINGSPRITE_X) >> (byte) 4
Simplifying expression containing zero (word*)processChars::processing#0 in [443] (word*) processChars::$51 ← (word*)(struct ProcessingSprite*) processChars::processing#0 + (const byte) OFFSET_STRUCT_PROCESSINGSPRITE_X
Simplifying expression containing zero (word*)processChars::processing#0 in [444] (bool~) processChars::$18 ← *((word*)(struct ProcessingSprite*) processChars::processing#0 + (const byte) OFFSET_STRUCT_PROCESSINGSPRITE_X) < (word) XPOS_LEFTMOST#0
Simplifying expression containing zero (word*)processChars::processing#0 in [445] (word*) processChars::$52 ← (word*)(struct ProcessingSprite*) processChars::processing#0 + (const byte) OFFSET_STRUCT_PROCESSINGSPRITE_X
Simplifying expression containing zero (word*)processChars::processing#0 in [446] (bool~) processChars::$19 ← *((word*)(struct ProcessingSprite*) processChars::processing#0 + (const byte) OFFSET_STRUCT_PROCESSINGSPRITE_X) > (word) XPOS_RIGHTMOST#0
Simplifying expression containing zero (word*)processChars::processing#0 in [470] (word*) processChars::$58 ← (word*)(struct ProcessingSprite*) processChars::processing#0 + (const byte) OFFSET_STRUCT_PROCESSINGSPRITE_X
Simplifying expression containing zero (word*)processChars::processing#0 in [472] (word*) processChars::$60 ← (word*)(struct ProcessingSprite*) processChars::processing#0 + (const byte) OFFSET_STRUCT_PROCESSINGSPRITE_X
Simplifying expression containing zero (word*)processChars::processing#0 in [473] *((word*)(struct ProcessingSprite*) processChars::processing#0 + (const byte) OFFSET_STRUCT_PROCESSINGSPRITE_X) ← *((word*)(struct ProcessingSprite*) processChars::processing#0 + (const byte) OFFSET_STRUCT_PROCESSINGSPRITE_X) + *((word*)(struct ProcessingSprite*) processChars::processing#0 + (const byte) OFFSET_STRUCT_PROCESSINGSPRITE_VX)
Simplifying expression containing zero (word*)processChars::processing#0 in [473] *((word*)(struct ProcessingSprite*) processChars::processing#0 + (const byte) OFFSET_STRUCT_PROCESSINGSPRITE_X) ← *((word*)(struct ProcessingSprite*) processChars::processing#0) + *((word*)(struct ProcessingSprite*) processChars::processing#0 + (const byte) OFFSET_STRUCT_PROCESSINGSPRITE_VX)
Successful SSA optimization PassNSimplifyExpressionWithZero
Eliminating unused variable (byte) startProcessing::center_dist#0 and assignment [97] (byte) startProcessing::center_dist#0 ← (byte) main::center_dist#0
Eliminating unused variable (struct ProcessingChar) getCharToProcess::return#0 and assignment [119] (struct ProcessingChar) getCharToProcess::return#0 ← struct-unwound {(byte) getCharToProcess::return_x#1, (byte) getCharToProcess::return_y#1, (byte) getCharToProcess::return_dist#1}
@ -3793,11 +3796,12 @@ Coalesced [316] atan2_16::xd#11 ← atan2_16::xd#1
Coalesced [317] atan2_16::yd#11 ← atan2_16::yd#1
Not coalescing [318] atan2_16::xi#13 ← atan2_16::x#0
Not coalescing [319] atan2_16::yi#16 ← atan2_16::y#0
Not coalescing [322] heap_head#1 ← malloc::mem#0
Coalesced [375] processChars::numActive#17 ← processChars::numActive#1
Coalesced [381] processChars::i#13 ← processChars::i#1
Coalesced [382] processChars::numActive#15 ← processChars::numActive#3
Coalesced (already) [387] processChars::numActive#16 ← processChars::numActive#10
Coalesced down to 36 phi equivalence classes
Coalesced down to 37 phi equivalence classes
Culled Empty Block (label) @6
Culled Empty Block (label) @13
Culled Empty Block (label) @20
@ -4330,9 +4334,9 @@ atan2_16::@1: scope:[atan2_16] from atan2_16
[242] (signed word~) atan2_16::yi#16 ← (signed word) atan2_16::y#0
to:atan2_16::@3
malloc: scope:[malloc] from @1 @3
[243] (byte*) heap_head#5 ← phi( @1/(const byte*) HEAP_START#0 @3/(byte*) heap_head#1 )
[244] (byte*) malloc::mem#0 ← (byte*) heap_head#5
[245] (byte*) heap_head#1 ← (byte*) heap_head#5 + (word) $3e8
[243] (byte*) heap_head#5 ← phi( @1/(const byte*) HEAP_TOP#0 @3/(byte*) heap_head#1 )
[244] (byte*) malloc::mem#0 ← (byte*) heap_head#5 - (word) $3e8
[245] (byte*) heap_head#1 ← (byte*) malloc::mem#0
to:malloc::@return
malloc::@return: scope:[malloc] from malloc
[246] return
@ -4465,7 +4469,7 @@ VARIABLE REGISTER WEIGHTS
(byte) CORDIC_ITERATIONS_16
(bool) DEBUG
(void()**) HARDWARE_IRQ
(byte*) HEAP_START
(byte*) HEAP_TOP
(byte*) IRQ_ENABLE
(byte) IRQ_RASTER
(byte*) IRQ_STATUS
@ -4620,7 +4624,7 @@ VARIABLE REGISTER WEIGHTS
(byte) getCharToProcess::y#7 80.2
(byte*) heap_head
(byte*) heap_head#1 1.0
(byte*) heap_head#5 3.0
(byte*) heap_head#5 4.0
(void()) initSprites()
(byte) initSprites::i
(byte) initSprites::i#1 16.5
@ -4693,7 +4697,7 @@ interrupt(HARDWARE_ALL)(void()) irqTop()
(byte*) main::src#2 16.5
(void*()) malloc((word) malloc::size)
(byte*) malloc::mem
(byte*) malloc::mem#0 0.4
(byte*) malloc::mem#0 0.8
(void*) malloc::return
(word) malloc::size
(void()) processChars()
@ -5211,8 +5215,8 @@ INITIAL ASM
.const OFFSET_STRUCT_PROCESSINGSPRITE_COL = $a
.const OFFSET_STRUCT_PROCESSINGSPRITE_STATUS = $b
.const OFFSET_STRUCT_PROCESSINGSPRITE_SCREENPTR = $c
// Start of the heap used by malloc()
.label HEAP_START = $c000
// Top of the heap used by malloc()
.label HEAP_TOP = $a000
// The number of iterations performed during 16-bit CORDIC atan2 calculation
.const CORDIC_ITERATIONS_16 = $f
// Processor port data direction register
@ -5286,10 +5290,10 @@ b1:
// [2] call malloc
// [243] phi from @1 to malloc [phi:@1->malloc]
malloc_from_b1:
// [243] phi (byte*) heap_head#5 = (const byte*) HEAP_START#0 [phi:@1->malloc#0] -- pbuz1=pbuc1
lda #<HEAP_START
// [243] phi (byte*) heap_head#5 = (const byte*) HEAP_TOP#0 [phi:@1->malloc#0] -- pbuz1=pbuc1
lda #<HEAP_TOP
sta heap_head
lda #>HEAP_START
lda #>HEAP_TOP
sta heap_head+1
jsr malloc
jmp b3
@ -6921,18 +6925,18 @@ atan2_16: {
// The content of the newly allocated block of memory is not initialized, remaining with indeterminate values.
malloc: {
.label mem = $9e
// [244] (byte*) malloc::mem#0 ← (byte*) heap_head#5 -- pbuz1=pbuz2
// [244] (byte*) malloc::mem#0 ← (byte*) heap_head#5 - (word) $3e8 -- pbuz1=pbuz2_minus_vwuc1
lda heap_head
sec
sbc #<$3e8
sta mem
lda heap_head+1
sbc #>$3e8
sta mem+1
// [245] (byte*) heap_head#1 ← (byte*) heap_head#5 + (word) $3e8 -- pbuz1=pbuz1_plus_vwuc1
clc
lda heap_head
adc #<$3e8
// [245] (byte*) heap_head#1 ← (byte*) malloc::mem#0 -- pbuz1=pbuz2
lda mem
sta heap_head
lda heap_head+1
adc #>$3e8
lda mem+1
sta heap_head+1
jmp breturn
// malloc::@return
@ -7626,8 +7630,8 @@ Statement [238] (signed word) atan2_16::xd#1 ← (signed word) atan2_16::xd#3 >>
Statement [239] (signed word) atan2_16::yd#1 ← (signed word) atan2_16::yd#3 >> (signed byte) 2 [ atan2_16::x#0 atan2_16::y#0 atan2_16::yi#3 atan2_16::xi#3 atan2_16::i#2 atan2_16::angle#12 atan2_16::shift#2 atan2_16::xd#1 atan2_16::yd#1 ] ( main:7::init_angle_screen:10::atan2_16:180 [ SCREEN_COPY#0 SCREEN_DIST#0 init_angle_screen::y#4 init_angle_screen::screen_bottomline#5 init_angle_screen::screen_topline#5 init_angle_screen::x#2 init_angle_screen::xb#2 atan2_16::x#0 atan2_16::y#0 atan2_16::yi#3 atan2_16::xi#3 atan2_16::i#2 atan2_16::angle#12 atan2_16::shift#2 atan2_16::xd#1 atan2_16::yd#1 ] ) always clobbers reg byte a
Statement [241] (signed word~) atan2_16::xi#13 ← (signed word) atan2_16::x#0 [ atan2_16::x#0 atan2_16::y#0 atan2_16::yi#0 atan2_16::xi#13 ] ( main:7::init_angle_screen:10::atan2_16:180 [ SCREEN_COPY#0 SCREEN_DIST#0 init_angle_screen::y#4 init_angle_screen::screen_bottomline#5 init_angle_screen::screen_topline#5 init_angle_screen::x#2 init_angle_screen::xb#2 atan2_16::x#0 atan2_16::y#0 atan2_16::yi#0 atan2_16::xi#13 ] ) always clobbers reg byte a
Statement [242] (signed word~) atan2_16::yi#16 ← (signed word) atan2_16::y#0 [ atan2_16::x#0 atan2_16::y#0 atan2_16::yi#16 ] ( main:7::init_angle_screen:10::atan2_16:180 [ SCREEN_COPY#0 SCREEN_DIST#0 init_angle_screen::y#4 init_angle_screen::screen_bottomline#5 init_angle_screen::screen_topline#5 init_angle_screen::x#2 init_angle_screen::xb#2 atan2_16::x#0 atan2_16::y#0 atan2_16::yi#16 ] ) always clobbers reg byte a
Statement [244] (byte*) malloc::mem#0 ← (byte*) heap_head#5 [ malloc::mem#0 heap_head#5 ] ( malloc:2 [ malloc::mem#0 heap_head#5 ] malloc:4 [ malloc::mem#0 heap_head#5 ] ) always clobbers reg byte a
Statement [245] (byte*) heap_head#1 ← (byte*) heap_head#5 + (word) $3e8 [ malloc::mem#0 heap_head#1 ] ( malloc:2 [ malloc::mem#0 heap_head#1 ] malloc:4 [ malloc::mem#0 heap_head#1 ] ) always clobbers reg byte a
Statement [244] (byte*) malloc::mem#0 ← (byte*) heap_head#5 - (word) $3e8 [ malloc::mem#0 ] ( malloc:2 [ malloc::mem#0 ] malloc:4 [ malloc::mem#0 ] ) always clobbers reg byte a
Statement [245] (byte*) heap_head#1 ← (byte*) malloc::mem#0 [ malloc::mem#0 heap_head#1 ] ( malloc:2 [ malloc::mem#0 heap_head#1 ] malloc:4 [ malloc::mem#0 heap_head#1 ] ) always clobbers reg byte a
Statement [250] *((const byte*) RASTER#0) ← (const byte) RASTER_IRQ_TOP#0 [ ] ( [ ] ) always clobbers reg byte a
Statement [251] *((const void()**) HARDWARE_IRQ#0) ← &interrupt(HARDWARE_ALL)(void()) irqTop() [ ] ( [ ] ) always clobbers reg byte a
Statement [252] *((const byte*) IRQ_STATUS#0) ← (const byte) IRQ_RASTER#0 [ ] ( [ ] ) always clobbers reg byte a
@ -7834,8 +7838,8 @@ Statement [238] (signed word) atan2_16::xd#1 ← (signed word) atan2_16::xd#3 >>
Statement [239] (signed word) atan2_16::yd#1 ← (signed word) atan2_16::yd#3 >> (signed byte) 2 [ atan2_16::x#0 atan2_16::y#0 atan2_16::yi#3 atan2_16::xi#3 atan2_16::i#2 atan2_16::angle#12 atan2_16::shift#2 atan2_16::xd#1 atan2_16::yd#1 ] ( main:7::init_angle_screen:10::atan2_16:180 [ SCREEN_COPY#0 SCREEN_DIST#0 init_angle_screen::y#4 init_angle_screen::screen_bottomline#5 init_angle_screen::screen_topline#5 init_angle_screen::x#2 init_angle_screen::xb#2 atan2_16::x#0 atan2_16::y#0 atan2_16::yi#3 atan2_16::xi#3 atan2_16::i#2 atan2_16::angle#12 atan2_16::shift#2 atan2_16::xd#1 atan2_16::yd#1 ] ) always clobbers reg byte a
Statement [241] (signed word~) atan2_16::xi#13 ← (signed word) atan2_16::x#0 [ atan2_16::x#0 atan2_16::y#0 atan2_16::yi#0 atan2_16::xi#13 ] ( main:7::init_angle_screen:10::atan2_16:180 [ SCREEN_COPY#0 SCREEN_DIST#0 init_angle_screen::y#4 init_angle_screen::screen_bottomline#5 init_angle_screen::screen_topline#5 init_angle_screen::x#2 init_angle_screen::xb#2 atan2_16::x#0 atan2_16::y#0 atan2_16::yi#0 atan2_16::xi#13 ] ) always clobbers reg byte a
Statement [242] (signed word~) atan2_16::yi#16 ← (signed word) atan2_16::y#0 [ atan2_16::x#0 atan2_16::y#0 atan2_16::yi#16 ] ( main:7::init_angle_screen:10::atan2_16:180 [ SCREEN_COPY#0 SCREEN_DIST#0 init_angle_screen::y#4 init_angle_screen::screen_bottomline#5 init_angle_screen::screen_topline#5 init_angle_screen::x#2 init_angle_screen::xb#2 atan2_16::x#0 atan2_16::y#0 atan2_16::yi#16 ] ) always clobbers reg byte a
Statement [244] (byte*) malloc::mem#0 ← (byte*) heap_head#5 [ malloc::mem#0 heap_head#5 ] ( malloc:2 [ malloc::mem#0 heap_head#5 ] malloc:4 [ malloc::mem#0 heap_head#5 ] ) always clobbers reg byte a
Statement [245] (byte*) heap_head#1 ← (byte*) heap_head#5 + (word) $3e8 [ malloc::mem#0 heap_head#1 ] ( malloc:2 [ malloc::mem#0 heap_head#1 ] malloc:4 [ malloc::mem#0 heap_head#1 ] ) always clobbers reg byte a
Statement [244] (byte*) malloc::mem#0 ← (byte*) heap_head#5 - (word) $3e8 [ malloc::mem#0 ] ( malloc:2 [ malloc::mem#0 ] malloc:4 [ malloc::mem#0 ] ) always clobbers reg byte a
Statement [245] (byte*) heap_head#1 ← (byte*) malloc::mem#0 [ malloc::mem#0 heap_head#1 ] ( malloc:2 [ malloc::mem#0 heap_head#1 ] malloc:4 [ malloc::mem#0 heap_head#1 ] ) always clobbers reg byte a
Statement [250] *((const byte*) RASTER#0) ← (const byte) RASTER_IRQ_TOP#0 [ ] ( [ ] ) always clobbers reg byte a
Statement [251] *((const void()**) HARDWARE_IRQ#0) ← &interrupt(HARDWARE_ALL)(void()) irqTop() [ ] ( [ ] ) always clobbers reg byte a
Statement [252] *((const byte*) IRQ_STATUS#0) ← (const byte) IRQ_RASTER#0 [ ] ( [ ] ) always clobbers reg byte a
@ -8022,8 +8026,8 @@ Uplift Scope [init_angle_screen] 202: zp ZP_BYTE:135 [ init_angle_screen::$2 ] 2
Uplift Scope [processChars] 33.73: zp ZP_BYTE:51 [ processChars::numActive#10 processChars::numActive#3 processChars::numActive#1 ] 22: zp ZP_BYTE:160 [ processChars::$67 ] 22: zp ZP_BYTE:161 [ processChars::$68 ] 22: zp ZP_BYTE:162 [ processChars::$69 ] 22: zp ZP_BYTE:163 [ processChars::$70 ] 22: zp ZP_BYTE:164 [ processChars::$37 ] 22: zp ZP_BYTE:170 [ processChars::$11 ] 22: zp ZP_BYTE:171 [ processChars::$12 ] 22: zp ZP_BYTE:173 [ processChars::$14 ] 22: zp ZP_BYTE:179 [ processChars::$26 ] 22: zp ZP_BYTE:180 [ processChars::xchar#0 ] 22: zp ZP_BYTE:181 [ processChars::$38 ] 22: zp ZP_BYTE:182 [ processChars::$30 ] 22: zp ZP_BYTE:183 [ processChars::ychar#0 ] 22: zp ZP_BYTE:184 [ processChars::$39 ] 22: zp ZP_BYTE:185 [ processChars::$33 ] 17.9: zp ZP_BYTE:50 [ processChars::i#10 processChars::i#1 ] 11: zp ZP_WORD:174 [ processChars::$15 ] 11: zp ZP_WORD:177 [ processChars::$25 ] 6.6: zp ZP_BYTE:172 [ processChars::$17 ] 2.75: zp ZP_BYTE:176 [ processChars::ypos#0 ] 2.2: zp ZP_BYTE:167 [ processChars::bitmask#0 ] 2.06: zp ZP_WORD:168 [ processChars::xpos#0 ] 0.31: zp ZP_WORD:165 [ processChars::processing#0 ]
Uplift Scope [main] 27.5: zp ZP_WORD:2 [ main::src#2 main::src#1 ] 26.67: zp ZP_WORD:4 [ main::dst#2 main::dst#1 main::dst#0 ] 22: zp ZP_BYTE:58 [ main::$26 ] 22: zp ZP_BYTE:59 [ main::$27 ] 22: zp ZP_BYTE:60 [ main::$28 ] 22: zp ZP_BYTE:61 [ main::$29 ] 22: zp ZP_BYTE:68 [ main::center_dist#0 ] 20.17: zp ZP_BYTE:6 [ main::i#2 main::i#1 ] 12.22: zp ZP_BYTE:62 [ main::$16 ] 5.5: zp ZP_BYTE:66 [ main::center_x#0 ] 5.5: zp ZP_BYTE:67 [ main::center_y#0 ]
Uplift Scope [initSprites] 33: zp ZP_WORD:24 [ initSprites::sp#2 initSprites::sp#1 ] 33: zp ZP_BYTE:26 [ initSprites::i#2 initSprites::i#1 ]
Uplift Scope [] 4: zp ZP_WORD:48 [ heap_head#5 heap_head#1 ] 0.03: zp ZP_WORD:54 [ SCREEN_DIST#0 ] 0.03: zp ZP_WORD:52 [ SCREEN_COPY#0 ]
Uplift Scope [malloc] 0.4: zp ZP_WORD:158 [ malloc::mem#0 ]
Uplift Scope [] 5: zp ZP_WORD:48 [ heap_head#5 heap_head#1 ] 0.03: zp ZP_WORD:54 [ SCREEN_DIST#0 ] 0.03: zp ZP_WORD:52 [ SCREEN_COPY#0 ]
Uplift Scope [malloc] 0.8: zp ZP_WORD:158 [ malloc::mem#0 ]
Uplift Scope [ProcessingChar]
Uplift Scope [ProcessingSprite]
Uplift Scope [ProcessingSprite::$0]
@ -8256,8 +8260,8 @@ ASSEMBLER BEFORE OPTIMIZATION
.const OFFSET_STRUCT_PROCESSINGSPRITE_COL = $a
.const OFFSET_STRUCT_PROCESSINGSPRITE_STATUS = $b
.const OFFSET_STRUCT_PROCESSINGSPRITE_SCREENPTR = $c
// Start of the heap used by malloc()
.label HEAP_START = $c000
// Top of the heap used by malloc()
.label HEAP_TOP = $a000
// The number of iterations performed during 16-bit CORDIC atan2 calculation
.const CORDIC_ITERATIONS_16 = $f
// Processor port data direction register
@ -8331,10 +8335,10 @@ b1:
// [2] call malloc
// [243] phi from @1 to malloc [phi:@1->malloc]
malloc_from_b1:
// [243] phi (byte*) heap_head#5 = (const byte*) HEAP_START#0 [phi:@1->malloc#0] -- pbuz1=pbuc1
lda #<HEAP_START
// [243] phi (byte*) heap_head#5 = (const byte*) HEAP_TOP#0 [phi:@1->malloc#0] -- pbuz1=pbuc1
lda #<HEAP_TOP
sta heap_head
lda #>HEAP_START
lda #>HEAP_TOP
sta heap_head+1
jsr malloc
jmp b3
@ -9767,18 +9771,18 @@ atan2_16: {
// The content of the newly allocated block of memory is not initialized, remaining with indeterminate values.
malloc: {
.label mem = $2d
// [244] (byte*) malloc::mem#0 ← (byte*) heap_head#5 -- pbuz1=pbuz2
// [244] (byte*) malloc::mem#0 ← (byte*) heap_head#5 - (word) $3e8 -- pbuz1=pbuz2_minus_vwuc1
lda heap_head
sec
sbc #<$3e8
sta mem
lda heap_head+1
sbc #>$3e8
sta mem+1
// [245] (byte*) heap_head#1 ← (byte*) heap_head#5 + (word) $3e8 -- pbuz1=pbuz1_plus_vwuc1
clc
lda heap_head
adc #<$3e8
// [245] (byte*) heap_head#1 ← (byte*) malloc::mem#0 -- pbuz1=pbuz2
lda mem
sta heap_head
lda heap_head+1
adc #>$3e8
lda mem+1
sta heap_head+1
jmp breturn
// malloc::@return
@ -10564,8 +10568,8 @@ FINAL SYMBOL TABLE
(bool) DEBUG
(void()**) HARDWARE_IRQ
(const void()**) HARDWARE_IRQ#0 HARDWARE_IRQ = (void()**) 65534
(byte*) HEAP_START
(const byte*) HEAP_START#0 HEAP_START = (byte*) 49152
(byte*) HEAP_TOP
(const byte*) HEAP_TOP#0 HEAP_TOP = (byte*) 40960
(byte*) IRQ_ENABLE
(const byte*) IRQ_ENABLE#0 IRQ_ENABLE = (byte*) 53274
(byte) IRQ_RASTER
@ -10805,7 +10809,7 @@ FINAL SYMBOL TABLE
(byte) getCharToProcess::y#7 y zp ZP_BYTE:16 80.2
(byte*) heap_head
(byte*) heap_head#1 heap_head zp ZP_WORD:39 1.0
(byte*) heap_head#5 heap_head zp ZP_WORD:39 3.0
(byte*) heap_head#5 heap_head zp ZP_WORD:39 4.0
(void()) initSprites()
(label) initSprites::@1
(label) initSprites::@2
@ -10903,7 +10907,7 @@ interrupt(HARDWARE_ALL)(void()) irqTop()
(void*()) malloc((word) malloc::size)
(label) malloc::@return
(byte*) malloc::mem
(byte*) malloc::mem#0 mem zp ZP_WORD:45 0.4
(byte*) malloc::mem#0 mem zp ZP_WORD:45 0.8
(void*) malloc::return
(word) malloc::size
(void()) processChars()
@ -11168,8 +11172,8 @@ Score: 1113582
.const OFFSET_STRUCT_PROCESSINGSPRITE_COL = $a
.const OFFSET_STRUCT_PROCESSINGSPRITE_STATUS = $b
.const OFFSET_STRUCT_PROCESSINGSPRITE_SCREENPTR = $c
// Start of the heap used by malloc()
.label HEAP_START = $c000
// Top of the heap used by malloc()
.label HEAP_TOP = $a000
// The number of iterations performed during 16-bit CORDIC atan2 calculation
.const CORDIC_ITERATIONS_16 = $f
// Processor port data direction register
@ -11240,10 +11244,10 @@ bbegin:
// malloc(1000)
// [2] call malloc
// [243] phi from @1 to malloc [phi:@1->malloc]
// [243] phi (byte*) heap_head#5 = (const byte*) HEAP_START#0 [phi:@1->malloc#0] -- pbuz1=pbuc1
lda #<HEAP_START
// [243] phi (byte*) heap_head#5 = (const byte*) HEAP_TOP#0 [phi:@1->malloc#0] -- pbuz1=pbuc1
lda #<HEAP_TOP
sta heap_head
lda #>HEAP_START
lda #>HEAP_TOP
sta heap_head+1
jsr malloc
// @3
@ -12646,20 +12650,20 @@ atan2_16: {
// The content of the newly allocated block of memory is not initialized, remaining with indeterminate values.
malloc: {
.label mem = $2d
// mem = heap_head
// [244] (byte*) malloc::mem#0 ← (byte*) heap_head#5 -- pbuz1=pbuz2
// mem = heap_head-size
// [244] (byte*) malloc::mem#0 ← (byte*) heap_head#5 - (word) $3e8 -- pbuz1=pbuz2_minus_vwuc1
lda heap_head
sec
sbc #<$3e8
sta mem
lda heap_head+1
sbc #>$3e8
sta mem+1
// heap_head+= size
// [245] (byte*) heap_head#1 ← (byte*) heap_head#5 + (word) $3e8 -- pbuz1=pbuz1_plus_vwuc1
clc
lda heap_head
adc #<$3e8
// heap_head = mem
// [245] (byte*) heap_head#1 ← (byte*) malloc::mem#0 -- pbuz1=pbuz2
lda mem
sta heap_head
lda heap_head+1
adc #>$3e8
lda mem+1
sta heap_head+1
// malloc::@return
// }

View File

@ -32,8 +32,8 @@
(bool) DEBUG
(void()**) HARDWARE_IRQ
(const void()**) HARDWARE_IRQ#0 HARDWARE_IRQ = (void()**) 65534
(byte*) HEAP_START
(const byte*) HEAP_START#0 HEAP_START = (byte*) 49152
(byte*) HEAP_TOP
(const byte*) HEAP_TOP#0 HEAP_TOP = (byte*) 40960
(byte*) IRQ_ENABLE
(const byte*) IRQ_ENABLE#0 IRQ_ENABLE = (byte*) 53274
(byte) IRQ_RASTER
@ -273,7 +273,7 @@
(byte) getCharToProcess::y#7 y zp ZP_BYTE:16 80.2
(byte*) heap_head
(byte*) heap_head#1 heap_head zp ZP_WORD:39 1.0
(byte*) heap_head#5 heap_head zp ZP_WORD:39 3.0
(byte*) heap_head#5 heap_head zp ZP_WORD:39 4.0
(void()) initSprites()
(label) initSprites::@1
(label) initSprites::@2
@ -371,7 +371,7 @@ interrupt(HARDWARE_ALL)(void()) irqTop()
(void*()) malloc((word) malloc::size)
(label) malloc::@return
(byte*) malloc::mem
(byte*) malloc::mem#0 mem zp ZP_WORD:45 0.4
(byte*) malloc::mem#0 mem zp ZP_WORD:45 0.8
(void*) malloc::return
(word) malloc::size
(void()) processChars()

View File

@ -0,0 +1,40 @@
// Inner increment is not being done properly (screen++)
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
main: {
.label screen = 2
.label i = 4
lda #<0
sta i
sta i+1
lda #<$400
sta screen
lda #>$400
sta screen+1
b1:
ldy #0
lda (screen),y
asl
tax
inc CHAR_COUNTS,x
bne !+
inc CHAR_COUNTS+1,x
!:
inc screen
bne !+
inc screen+1
!:
inc i
bne !+
inc i+1
!:
lda i+1
cmp #>$3e8
bne b1
lda i
cmp #<$3e8
bne b1
rts
}
CHAR_COUNTS: .fill 2*$100, 0

View File

@ -0,0 +1,24 @@
@begin: scope:[] from
[0] phi()
to:@1
@1: scope:[] from @begin
[1] phi()
[2] call main
to:@end
@end: scope:[] from @1
[3] phi()
main: scope:[main] from @1
[4] phi()
to:main::@1
main::@1: scope:[main] from main main::@1
[5] (word) main::i#2 ← phi( main/(word) 0 main::@1/(word) main::i#1 )
[5] (byte*) main::screen#2 ← phi( main/(byte*) 1024 main::@1/(byte*) main::screen#1 )
[6] (byte~) main::$1 ← *((byte*) main::screen#2) << (byte) 1
[7] *((const word[$100]) CHAR_COUNTS#0 + (byte~) main::$1) ← ++ *((const word[$100]) CHAR_COUNTS#0 + (byte~) main::$1)
[8] (byte*) main::screen#1 ← ++ (byte*) main::screen#2
[9] (word) main::i#1 ← ++ (word) main::i#2
[10] if((word) main::i#1!=(word) $3e8) goto main::@1
to:main::@return
main::@return: scope:[main] from main::@1
[11] return
to:@return

View File

@ -0,0 +1,460 @@
Fixing pointer array-indexing *((word[$100]) CHAR_COUNTS + *((byte*) main::screen))
Fixing pointer array-indexing *((word[$100]) CHAR_COUNTS + *((byte*) main::screen))
Culled Empty Block (label) main::@2
CONTROL FLOW GRAPH SSA
@begin: scope:[] from
(word[$100]) CHAR_COUNTS#0 ← { fill( $100, 0) }
to:@1
main: scope:[main] from @1
(byte*) main::screen#0 ← ((byte*)) (number) $400
(word) main::i#0 ← (word) 0
to:main::@1
main::@1: scope:[main] from main main::@1
(word) main::i#2 ← phi( main/(word) main::i#0 main::@1/(word) main::i#1 )
(byte*) main::screen#2 ← phi( main/(byte*) main::screen#0 main::@1/(byte*) main::screen#1 )
(byte~) main::$1 ← *((byte*) main::screen#2) * (const byte) SIZEOF_WORD
*((word[$100]) CHAR_COUNTS#0 + (byte~) main::$1) ← ++ *((word[$100]) CHAR_COUNTS#0 + (byte~) main::$1)
(byte*) main::screen#1 ← ++ (byte*) main::screen#2
(word) main::i#1 ← (word) main::i#2 + rangenext(0,$3e7)
(bool~) main::$0 ← (word) main::i#1 != rangelast(0,$3e7)
if((bool~) main::$0) goto main::@1
to:main::@return
main::@return: scope:[main] from main::@1
return
to:@return
@1: scope:[] from @begin
call main
to:@2
@2: scope:[] from @1
to:@end
@end: scope:[] from @2
SYMBOL TABLE SSA
(label) @1
(label) @2
(label) @begin
(label) @end
(word[$100]) CHAR_COUNTS
(word[$100]) CHAR_COUNTS#0
(const byte) SIZEOF_WORD = (byte) 2
(void()) main()
(bool~) main::$0
(byte~) main::$1
(label) main::@1
(label) main::@return
(word) main::i
(word) main::i#0
(word) main::i#1
(word) main::i#2
(byte*) main::screen
(byte*) main::screen#0
(byte*) main::screen#1
(byte*) main::screen#2
Inlining cast (byte*) main::screen#0 ← (byte*)(number) $400
Successful SSA optimization Pass2InlineCast
Simplifying constant pointer cast (byte*) 1024
Successful SSA optimization PassNCastSimplification
Simple Condition (bool~) main::$0 [9] if((word) main::i#1!=rangelast(0,$3e7)) goto main::@1
Successful SSA optimization Pass2ConditionalJumpSimplification
Constant right-side identified [0] (word[$100]) CHAR_COUNTS#0 ← { fill( $100, 0) }
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant (const word[$100]) CHAR_COUNTS#0 = { fill( $100, 0) }
Constant (const byte*) main::screen#0 = (byte*) 1024
Constant (const word) main::i#0 = 0
Successful SSA optimization Pass2ConstantIdentification
Resolved ranged next value [7] main::i#1 ← ++ main::i#2 to ++
Resolved ranged comparison value [9] if(main::i#1!=rangelast(0,$3e7)) goto main::@1 to (number) $3e8
Adding number conversion cast (unumber) $3e8 in if((word) main::i#1!=(number) $3e8) goto main::@1
Successful SSA optimization PassNAddNumberTypeConversions
Simplifying constant integer cast $3e8
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (word) $3e8
Successful SSA optimization PassNFinalizeNumberTypeConversions
Rewriting multiplication to use shift [1] (byte~) main::$1 ← *((byte*) main::screen#2) * (const byte) SIZEOF_WORD
Successful SSA optimization Pass2MultiplyToShiftRewriting
Inlining constant with var siblings (const byte*) main::screen#0
Inlining constant with var siblings (const word) main::i#0
Constant inlined main::screen#0 = (byte*) 1024
Constant inlined main::i#0 = (word) 0
Successful SSA optimization Pass2ConstantInlining
Eliminating unused constant (const byte) SIZEOF_WORD
Successful SSA optimization PassNEliminateUnusedVars
Added new block during phi lifting main::@3(between main::@1 and main::@1)
Adding NOP phi() at start of @begin
Adding NOP phi() at start of @1
Adding NOP phi() at start of @2
Adding NOP phi() at start of @end
Adding NOP phi() at start of main
CALL GRAPH
Calls in [] to main:2
Created 2 initial phi equivalence classes
Coalesced [13] main::screen#3 ← main::screen#1
Coalesced [14] main::i#3 ← main::i#1
Coalesced down to 2 phi equivalence classes
Culled Empty Block (label) @2
Culled Empty Block (label) main::@3
Adding NOP phi() at start of @begin
Adding NOP phi() at start of @1
Adding NOP phi() at start of @end
Adding NOP phi() at start of main
FINAL CONTROL FLOW GRAPH
@begin: scope:[] from
[0] phi()
to:@1
@1: scope:[] from @begin
[1] phi()
[2] call main
to:@end
@end: scope:[] from @1
[3] phi()
main: scope:[main] from @1
[4] phi()
to:main::@1
main::@1: scope:[main] from main main::@1
[5] (word) main::i#2 ← phi( main/(word) 0 main::@1/(word) main::i#1 )
[5] (byte*) main::screen#2 ← phi( main/(byte*) 1024 main::@1/(byte*) main::screen#1 )
[6] (byte~) main::$1 ← *((byte*) main::screen#2) << (byte) 1
[7] *((const word[$100]) CHAR_COUNTS#0 + (byte~) main::$1) ← ++ *((const word[$100]) CHAR_COUNTS#0 + (byte~) main::$1)
[8] (byte*) main::screen#1 ← ++ (byte*) main::screen#2
[9] (word) main::i#1 ← ++ (word) main::i#2
[10] if((word) main::i#1!=(word) $3e8) goto main::@1
to:main::@return
main::@return: scope:[main] from main::@1
[11] return
to:@return
VARIABLE REGISTER WEIGHTS
(word[$100]) CHAR_COUNTS
(void()) main()
(byte~) main::$1 33.0
(word) main::i
(word) main::i#1 16.5
(word) main::i#2 5.5
(byte*) main::screen
(byte*) main::screen#1 7.333333333333333
(byte*) main::screen#2 11.0
Initial phi equivalence classes
[ main::screen#2 main::screen#1 ]
[ main::i#2 main::i#1 ]
Added variable main::$1 to zero page equivalence class [ main::$1 ]
Complete equivalence classes
[ main::screen#2 main::screen#1 ]
[ main::i#2 main::i#1 ]
[ main::$1 ]
Allocated zp ZP_WORD:2 [ main::screen#2 main::screen#1 ]
Allocated zp ZP_WORD:4 [ main::i#2 main::i#1 ]
Allocated zp ZP_BYTE:6 [ main::$1 ]
INITIAL ASM
// File Comments
// Inner increment is not being done properly (screen++)
// Basic Upstart
.pc = $801 "Basic"
:BasicUpstart(bbegin)
.pc = $80d "Program"
// Global Constants & labels
// @begin
bbegin:
// [1] phi from @begin to @1 [phi:@begin->@1]
b1_from_bbegin:
jmp b1
// @1
b1:
// [2] call main
// [4] phi from @1 to main [phi:@1->main]
main_from_b1:
jsr main
// [3] phi from @1 to @end [phi:@1->@end]
bend_from_b1:
jmp bend
// @end
bend:
// main
main: {
.label _1 = 6
.label screen = 2
.label i = 4
// [5] phi from main to main::@1 [phi:main->main::@1]
b1_from_main:
// [5] phi (word) main::i#2 = (word) 0 [phi:main->main::@1#0] -- vwuz1=vwuc1
lda #<0
sta i
lda #>0
sta i+1
// [5] phi (byte*) main::screen#2 = (byte*) 1024 [phi:main->main::@1#1] -- pbuz1=pbuc1
lda #<$400
sta screen
lda #>$400
sta screen+1
jmp b1
// [5] phi from main::@1 to main::@1 [phi:main::@1->main::@1]
b1_from_b1:
// [5] phi (word) main::i#2 = (word) main::i#1 [phi:main::@1->main::@1#0] -- register_copy
// [5] phi (byte*) main::screen#2 = (byte*) main::screen#1 [phi:main::@1->main::@1#1] -- register_copy
jmp b1
// main::@1
b1:
// [6] (byte~) main::$1 ← *((byte*) main::screen#2) << (byte) 1 -- vbuz1=_deref_pbuz2_rol_1
ldy #0
lda (screen),y
asl
sta _1
// [7] *((const word[$100]) CHAR_COUNTS#0 + (byte~) main::$1) ← ++ *((const word[$100]) CHAR_COUNTS#0 + (byte~) main::$1) -- pwuc1_derefidx_vbuz1=_inc_pwuc1_derefidx_vbuz1
ldx _1
inc CHAR_COUNTS,x
bne !+
inc CHAR_COUNTS+1,x
!:
// [8] (byte*) main::screen#1 ← ++ (byte*) main::screen#2 -- pbuz1=_inc_pbuz1
inc screen
bne !+
inc screen+1
!:
// [9] (word) main::i#1 ← ++ (word) main::i#2 -- vwuz1=_inc_vwuz1
inc i
bne !+
inc i+1
!:
// [10] if((word) main::i#1!=(word) $3e8) goto main::@1 -- vwuz1_neq_vwuc1_then_la1
lda i+1
cmp #>$3e8
bne b1_from_b1
lda i
cmp #<$3e8
bne b1_from_b1
jmp breturn
// main::@return
breturn:
// [11] return
rts
}
// File Data
CHAR_COUNTS: .fill 2*$100, 0
REGISTER UPLIFT POTENTIAL REGISTERS
Statement [6] (byte~) main::$1 ← *((byte*) main::screen#2) << (byte) 1 [ main::screen#2 main::i#2 main::$1 ] ( main:2 [ main::screen#2 main::i#2 main::$1 ] ) always clobbers reg byte a reg byte y
Statement [10] if((word) main::i#1!=(word) $3e8) goto main::@1 [ main::screen#1 main::i#1 ] ( main:2 [ main::screen#1 main::i#1 ] ) always clobbers reg byte a
Potential registers zp ZP_WORD:2 [ main::screen#2 main::screen#1 ] : zp ZP_WORD:2 ,
Potential registers zp ZP_WORD:4 [ main::i#2 main::i#1 ] : zp ZP_WORD:4 ,
Potential registers zp ZP_BYTE:6 [ main::$1 ] : zp ZP_BYTE:6 , reg byte a , reg byte x , reg byte y ,
REGISTER UPLIFT SCOPES
Uplift Scope [main] 33: zp ZP_BYTE:6 [ main::$1 ] 22: zp ZP_WORD:4 [ main::i#2 main::i#1 ] 18.33: zp ZP_WORD:2 [ main::screen#2 main::screen#1 ]
Uplift Scope []
Uplifting [main] best 988 combination reg byte a [ main::$1 ] zp ZP_WORD:4 [ main::i#2 main::i#1 ] zp ZP_WORD:2 [ main::screen#2 main::screen#1 ]
Uplifting [] best 988 combination
ASSEMBLER BEFORE OPTIMIZATION
// File Comments
// Inner increment is not being done properly (screen++)
// Basic Upstart
.pc = $801 "Basic"
:BasicUpstart(bbegin)
.pc = $80d "Program"
// Global Constants & labels
// @begin
bbegin:
// [1] phi from @begin to @1 [phi:@begin->@1]
b1_from_bbegin:
jmp b1
// @1
b1:
// [2] call main
// [4] phi from @1 to main [phi:@1->main]
main_from_b1:
jsr main
// [3] phi from @1 to @end [phi:@1->@end]
bend_from_b1:
jmp bend
// @end
bend:
// main
main: {
.label screen = 2
.label i = 4
// [5] phi from main to main::@1 [phi:main->main::@1]
b1_from_main:
// [5] phi (word) main::i#2 = (word) 0 [phi:main->main::@1#0] -- vwuz1=vwuc1
lda #<0
sta i
lda #>0
sta i+1
// [5] phi (byte*) main::screen#2 = (byte*) 1024 [phi:main->main::@1#1] -- pbuz1=pbuc1
lda #<$400
sta screen
lda #>$400
sta screen+1
jmp b1
// [5] phi from main::@1 to main::@1 [phi:main::@1->main::@1]
b1_from_b1:
// [5] phi (word) main::i#2 = (word) main::i#1 [phi:main::@1->main::@1#0] -- register_copy
// [5] phi (byte*) main::screen#2 = (byte*) main::screen#1 [phi:main::@1->main::@1#1] -- register_copy
jmp b1
// main::@1
b1:
// [6] (byte~) main::$1 ← *((byte*) main::screen#2) << (byte) 1 -- vbuaa=_deref_pbuz1_rol_1
ldy #0
lda (screen),y
asl
// [7] *((const word[$100]) CHAR_COUNTS#0 + (byte~) main::$1) ← ++ *((const word[$100]) CHAR_COUNTS#0 + (byte~) main::$1) -- pwuc1_derefidx_vbuaa=_inc_pwuc1_derefidx_vbuaa
tax
inc CHAR_COUNTS,x
bne !+
inc CHAR_COUNTS+1,x
!:
// [8] (byte*) main::screen#1 ← ++ (byte*) main::screen#2 -- pbuz1=_inc_pbuz1
inc screen
bne !+
inc screen+1
!:
// [9] (word) main::i#1 ← ++ (word) main::i#2 -- vwuz1=_inc_vwuz1
inc i
bne !+
inc i+1
!:
// [10] if((word) main::i#1!=(word) $3e8) goto main::@1 -- vwuz1_neq_vwuc1_then_la1
lda i+1
cmp #>$3e8
bne b1_from_b1
lda i
cmp #<$3e8
bne b1_from_b1
jmp breturn
// main::@return
breturn:
// [11] return
rts
}
// File Data
CHAR_COUNTS: .fill 2*$100, 0
ASSEMBLER OPTIMIZATIONS
Removing instruction jmp b1
Removing instruction jmp bend
Removing instruction jmp b1
Removing instruction jmp breturn
Succesful ASM optimization Pass5NextJumpElimination
Removing instruction lda #>0
Succesful ASM optimization Pass5UnnecesaryLoadElimination
Replacing label b1_from_b1 with b1
Replacing label b1_from_b1 with b1
Removing instruction b1_from_bbegin:
Removing instruction b1:
Removing instruction main_from_b1:
Removing instruction bend_from_b1:
Removing instruction b1_from_b1:
Succesful ASM optimization Pass5RedundantLabelElimination
Removing instruction bend:
Removing instruction b1_from_main:
Removing instruction breturn:
Succesful ASM optimization Pass5UnusedLabelElimination
Updating BasicUpstart to call main directly
Removing instruction jsr main
Succesful ASM optimization Pass5SkipBegin
Removing instruction jmp b1
Succesful ASM optimization Pass5NextJumpElimination
Removing instruction bbegin:
Succesful ASM optimization Pass5UnusedLabelElimination
FINAL SYMBOL TABLE
(label) @1
(label) @begin
(label) @end
(word[$100]) CHAR_COUNTS
(const word[$100]) CHAR_COUNTS#0 CHAR_COUNTS = { fill( $100, 0) }
(void()) main()
(byte~) main::$1 reg byte a 33.0
(label) main::@1
(label) main::@return
(word) main::i
(word) main::i#1 i zp ZP_WORD:4 16.5
(word) main::i#2 i zp ZP_WORD:4 5.5
(byte*) main::screen
(byte*) main::screen#1 screen zp ZP_WORD:2 7.333333333333333
(byte*) main::screen#2 screen zp ZP_WORD:2 11.0
zp ZP_WORD:2 [ main::screen#2 main::screen#1 ]
zp ZP_WORD:4 [ main::i#2 main::i#1 ]
reg byte a [ main::$1 ]
FINAL ASSEMBLER
Score: 866
// File Comments
// Inner increment is not being done properly (screen++)
// Basic Upstart
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
// Global Constants & labels
// @begin
// [1] phi from @begin to @1 [phi:@begin->@1]
// @1
// [2] call main
// [4] phi from @1 to main [phi:@1->main]
// [3] phi from @1 to @end [phi:@1->@end]
// @end
// main
main: {
.label screen = 2
.label i = 4
// [5] phi from main to main::@1 [phi:main->main::@1]
// [5] phi (word) main::i#2 = (word) 0 [phi:main->main::@1#0] -- vwuz1=vwuc1
lda #<0
sta i
sta i+1
// [5] phi (byte*) main::screen#2 = (byte*) 1024 [phi:main->main::@1#1] -- pbuz1=pbuc1
lda #<$400
sta screen
lda #>$400
sta screen+1
// [5] phi from main::@1 to main::@1 [phi:main::@1->main::@1]
// [5] phi (word) main::i#2 = (word) main::i#1 [phi:main::@1->main::@1#0] -- register_copy
// [5] phi (byte*) main::screen#2 = (byte*) main::screen#1 [phi:main::@1->main::@1#1] -- register_copy
// main::@1
b1:
// CHAR_COUNTS[*screen++]++;
// [6] (byte~) main::$1 ← *((byte*) main::screen#2) << (byte) 1 -- vbuaa=_deref_pbuz1_rol_1
ldy #0
lda (screen),y
asl
// [7] *((const word[$100]) CHAR_COUNTS#0 + (byte~) main::$1) ← ++ *((const word[$100]) CHAR_COUNTS#0 + (byte~) main::$1) -- pwuc1_derefidx_vbuaa=_inc_pwuc1_derefidx_vbuaa
tax
inc CHAR_COUNTS,x
bne !+
inc CHAR_COUNTS+1,x
!:
// [8] (byte*) main::screen#1 ← ++ (byte*) main::screen#2 -- pbuz1=_inc_pbuz1
inc screen
bne !+
inc screen+1
!:
// for( word i:0..999)
// [9] (word) main::i#1 ← ++ (word) main::i#2 -- vwuz1=_inc_vwuz1
inc i
bne !+
inc i+1
!:
// [10] if((word) main::i#1!=(word) $3e8) goto main::@1 -- vwuz1_neq_vwuc1_then_la1
lda i+1
cmp #>$3e8
bne b1
lda i
cmp #<$3e8
bne b1
// main::@return
// }
// [11] return
rts
}
// File Data
CHAR_COUNTS: .fill 2*$100, 0

View File

@ -0,0 +1,19 @@
(label) @1
(label) @begin
(label) @end
(word[$100]) CHAR_COUNTS
(const word[$100]) CHAR_COUNTS#0 CHAR_COUNTS = { fill( $100, 0) }
(void()) main()
(byte~) main::$1 reg byte a 33.0
(label) main::@1
(label) main::@return
(word) main::i
(word) main::i#1 i zp ZP_WORD:4 16.5
(word) main::i#2 i zp ZP_WORD:4 5.5
(byte*) main::screen
(byte*) main::screen#1 screen zp ZP_WORD:2 7.333333333333333
(byte*) main::screen#2 screen zp ZP_WORD:2 11.0
zp ZP_WORD:2 [ main::screen#2 main::screen#1 ]
zp ZP_WORD:4 [ main::i#2 main::i#1 ]
reg byte a [ main::$1 ]

View File

@ -2,8 +2,8 @@
.pc = $801 "Basic"
:BasicUpstart(bbegin)
.pc = $80d "Program"
// Start of the heap used by malloc()
.label HEAP_START = $c000
// Top of the heap used by malloc()
.label HEAP_TOP = $a000
.label BYTES = malloc.return
bbegin:
jsr malloc
@ -22,6 +22,8 @@ main: {
// Allocates a block of size bytes of memory, returning a pointer to the beginning of the block.
// The content of the newly allocated block of memory is not initialized, remaining with indeterminate values.
malloc: {
.label return = HEAP_START
.const size = $100
.label mem = HEAP_TOP-size
.label return = mem
rts
}

View File

@ -1,7 +1,7 @@
Fixing pointer addition (word*~) bsearch16u::$7 ← (word*) bsearch16u::items + (byte~) bsearch16u::$6
Fixing pointer addition (word*~) bsearch16u::$15 ← (word*) bsearch16u::pivot + (number) 1
Fixing pointer addition (word*~) bsearch16u::$1 ← (word*) bsearch16u::items - (number) 1
Identified constant variable (byte*) HEAP_START
Identified constant variable (byte*) HEAP_TOP
Culled Empty Block (label) malloc::@1
Culled Empty Block (label) @1
Culled Empty Block (label) @2
@ -9,14 +9,15 @@ Culled Empty Block (label) main::@2
CONTROL FLOW GRAPH SSA
@begin: scope:[] from
(byte*) HEAP_START#0 ← ((byte*)) (number) $c000
(byte*) heap_head#0 ← (byte*) HEAP_START#0
(byte*) HEAP_TOP#0 ← ((byte*)) (number) $a000
(byte*) heap_head#0 ← (byte*) HEAP_TOP#0
to:@3
malloc: scope:[malloc] from @3
(word) malloc::size#1 ← phi( @3/(word) malloc::size#0 )
(byte*) heap_head#4 ← phi( @3/(byte*) heap_head#7 )
(byte*) malloc::mem#0 ← (byte*) heap_head#4
(byte*) heap_head#1 ← (byte*) heap_head#4 + (word) malloc::size#1
(byte*~) malloc::$0 ← (byte*) heap_head#4 - (word) malloc::size#1
(byte*) malloc::mem#0 ← (byte*~) malloc::$0
(byte*) heap_head#1 ← (byte*) malloc::mem#0
(void*) malloc::return#0 ← ((void*)) (byte*) malloc::mem#0
to:malloc::@return
malloc::@return: scope:[malloc] from malloc
@ -75,8 +76,8 @@ SYMBOL TABLE SSA
(byte*) BYTES#1
(byte*) BYTES#2
(byte*) BYTES#3
(byte*) HEAP_START
(byte*) HEAP_START#0
(byte*) HEAP_TOP
(byte*) HEAP_TOP#0
(byte*) heap_head
(byte*) heap_head#0
(byte*) heap_head#1
@ -95,6 +96,7 @@ SYMBOL TABLE SSA
(byte) main::i#1
(byte) main::i#2
(void*()) malloc((word) malloc::size)
(byte*~) malloc::$0
(label) malloc::@return
(byte*) malloc::mem
(byte*) malloc::mem#0
@ -110,17 +112,18 @@ SYMBOL TABLE SSA
Adding number conversion cast (unumber) $100 in (word) malloc::size#0 ← (number) $100
Successful SSA optimization PassNAddNumberTypeConversions
Inlining cast (byte*) HEAP_START#0 ← (byte*)(number) $c000
Inlining cast (byte*) HEAP_TOP#0 ← (byte*)(number) $a000
Inlining cast (void*) malloc::return#0 ← (void*)(byte*) malloc::mem#0
Inlining cast (word) malloc::size#0 ← (unumber)(number) $100
Inlining cast (byte*) BYTES#0 ← (byte*)(void*~) $0
Successful SSA optimization Pass2InlineCast
Simplifying constant pointer cast (byte*) 49152
Simplifying constant pointer cast (byte*) 40960
Simplifying constant integer cast $100
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (word) $100
Successful SSA optimization PassNFinalizeNumberTypeConversions
Alias (byte*) HEAP_START#0 = (byte*) heap_head#0 (byte*) heap_head#7
Alias (byte*) HEAP_TOP#0 = (byte*) heap_head#0 (byte*) heap_head#7
Alias (byte*) malloc::mem#0 = (byte*~) malloc::$0
Alias (void*) malloc::return#0 = (void*) malloc::return#3 (void*) malloc::return#1
Alias (byte*) heap_head#1 = (byte*) heap_head#5 (byte*) heap_head#2
Alias (void*) malloc::return#2 = (void*) malloc::return#4
@ -129,27 +132,21 @@ Alias (byte*) BYTES#0 = (byte*) BYTES#3
Successful SSA optimization Pass2AliasElimination
Self Phi Eliminated (byte*) BYTES#1
Successful SSA optimization Pass2SelfPhiElimination
Identical Phi Values (byte*) heap_head#4 (byte*) HEAP_START#0
Identical Phi Values (byte*) heap_head#4 (byte*) HEAP_TOP#0
Identical Phi Values (word) malloc::size#1 (word) malloc::size#0
Identical Phi Values (byte*) heap_head#3 (byte*) heap_head#1
Identical Phi Values (byte*) BYTES#2 (byte*) BYTES#0
Identical Phi Values (byte*) BYTES#1 (byte*) BYTES#2
Successful SSA optimization Pass2IdenticalPhiElimination
Simple Condition (bool~) main::$0 [24] if((byte) main::i#1!=rangelast(0,$ff)) goto main::@1
Simple Condition (bool~) main::$0 [25] if((byte) main::i#1!=rangelast(0,$ff)) goto main::@1
Successful SSA optimization Pass2ConditionalJumpSimplification
Constant (const byte*) HEAP_START#0 = (byte*) 49152
Constant (const byte*) HEAP_TOP#0 = (byte*) 40960
Constant (const word) malloc::size#0 = $100
Constant (const byte) main::i#0 = 0
Successful SSA optimization Pass2ConstantIdentification
Constant (const byte*) malloc::mem#0 = HEAP_START#0
Successful SSA optimization Pass2ConstantIdentification
Constant value identified (void*)malloc::mem#0 in [5] (void*) malloc::return#0 ← (void*)(const byte*) malloc::mem#0
Successful SSA optimization Pass2ConstantValues
Resolved ranged next value [22] main::i#1 ← ++ main::i#2 to ++
Resolved ranged comparison value [24] if(main::i#1!=rangelast(0,$ff)) goto main::@1 to (number) 0
Eliminating unused variable (byte*) heap_head#1 and assignment [0] (byte*) heap_head#1 ← (const byte*) HEAP_START#0 + (const word) malloc::size#0
Successful SSA optimization PassNEliminateUnusedVars
Eliminating unused constant (const word) malloc::size#0
Resolved ranged next value [23] main::i#1 ← ++ main::i#2 to ++
Resolved ranged comparison value [25] if(main::i#1!=rangelast(0,$ff)) goto main::@1 to (number) 0
Eliminating unused variable (byte*) heap_head#1 and assignment [1] (byte*) heap_head#1 ← (byte*) malloc::mem#0
Successful SSA optimization PassNEliminateUnusedVars
Adding number conversion cast (unumber) 0 in if((byte) main::i#1!=(number) 0) goto main::@1
Successful SSA optimization PassNAddNumberTypeConversions
@ -157,6 +154,12 @@ Simplifying constant integer cast 0
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (byte) 0
Successful SSA optimization PassNFinalizeNumberTypeConversions
Constant right-side identified [0] (byte*) malloc::mem#0 ← (const byte*) HEAP_TOP#0 - (const word) malloc::size#0
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant (const byte*) malloc::mem#0 = HEAP_TOP#0-malloc::size#0
Successful SSA optimization Pass2ConstantIdentification
Constant value identified (void*)malloc::mem#0 in [1] (void*) malloc::return#0 ← (void*)(const byte*) malloc::mem#0
Successful SSA optimization Pass2ConstantValues
Constant (const void*) malloc::return#0 = (void*)malloc::mem#0
Successful SSA optimization Pass2ConstantIdentification
Constant (const void*) malloc::return#2 = malloc::return#0
@ -169,10 +172,9 @@ Constant (const byte*) BYTES#0 = (byte*)$0
Successful SSA optimization Pass2ConstantIdentification
Inlining constant with different constant siblings (const void*) malloc::return#2
Inlining constant with var siblings (const byte) main::i#0
Constant inlined $0 = (const void*) malloc::return#0
Constant inlined main::i#0 = (byte) 0
Constant inlined malloc::return#2 = (const void*) malloc::return#0
Constant inlined malloc::mem#0 = (const byte*) HEAP_START#0
Constant inlined $0 = (const void*) malloc::return#0
Successful SSA optimization Pass2ConstantInlining
Added new block during phi lifting main::@3(between main::@1 and main::@1)
Adding NOP phi() at start of @begin
@ -237,7 +239,7 @@ malloc::@return: scope:[malloc] from malloc
VARIABLE REGISTER WEIGHTS
(byte*) BYTES
(byte*) HEAP_START
(byte*) HEAP_TOP
(byte*) heap_head
(void()) main()
(byte) main::i
@ -262,8 +264,8 @@ INITIAL ASM
:BasicUpstart(bbegin)
.pc = $80d "Program"
// Global Constants & labels
// Start of the heap used by malloc()
.label HEAP_START = $c000
// Top of the heap used by malloc()
.label HEAP_TOP = $a000
.label BYTES = malloc.return
// @begin
bbegin:
@ -325,7 +327,9 @@ main: {
// Allocates a block of size bytes of memory, returning a pointer to the beginning of the block.
// The content of the newly allocated block of memory is not initialized, remaining with indeterminate values.
malloc: {
.label return = HEAP_START
.const size = $100
.label mem = HEAP_TOP-size
.label return = mem
jmp breturn
// malloc::@return
breturn:
@ -354,8 +358,8 @@ ASSEMBLER BEFORE OPTIMIZATION
:BasicUpstart(bbegin)
.pc = $80d "Program"
// Global Constants & labels
// Start of the heap used by malloc()
.label HEAP_START = $c000
// Top of the heap used by malloc()
.label HEAP_TOP = $a000
.label BYTES = malloc.return
// @begin
bbegin:
@ -413,7 +417,9 @@ main: {
// Allocates a block of size bytes of memory, returning a pointer to the beginning of the block.
// The content of the newly allocated block of memory is not initialized, remaining with indeterminate values.
malloc: {
.label return = HEAP_START
.const size = $100
.label mem = HEAP_TOP-size
.label return = mem
jmp breturn
// malloc::@return
breturn:
@ -457,8 +463,8 @@ FINAL SYMBOL TABLE
(label) @end
(byte*) BYTES
(const byte*) BYTES#0 BYTES = (byte*)(const void*) malloc::return#0
(byte*) HEAP_START
(const byte*) HEAP_START#0 HEAP_START = (byte*) 49152
(byte*) HEAP_TOP
(const byte*) HEAP_TOP#0 HEAP_TOP = (byte*) 40960
(byte*) heap_head
(void()) main()
(label) main::@1
@ -469,9 +475,11 @@ FINAL SYMBOL TABLE
(void*()) malloc((word) malloc::size)
(label) malloc::@return
(byte*) malloc::mem
(const byte*) malloc::mem#0 mem = (const byte*) HEAP_TOP#0-(const word) malloc::size#0
(void*) malloc::return
(const void*) malloc::return#0 return = (void*)(const byte*) HEAP_START#0
(const void*) malloc::return#0 return = (void*)(const byte*) malloc::mem#0
(word) malloc::size
(const word) malloc::size#0 size = (word) $100
reg byte x [ main::i#2 main::i#1 ]
@ -486,8 +494,8 @@ Score: 185
:BasicUpstart(bbegin)
.pc = $80d "Program"
// Global Constants & labels
// Start of the heap used by malloc()
.label HEAP_START = $c000
// Top of the heap used by malloc()
.label HEAP_TOP = $a000
.label BYTES = malloc.return
// @begin
bbegin:
@ -533,7 +541,9 @@ main: {
// Allocates a block of size bytes of memory, returning a pointer to the beginning of the block.
// The content of the newly allocated block of memory is not initialized, remaining with indeterminate values.
malloc: {
.label return = HEAP_START
.const size = $100
.label mem = HEAP_TOP-size
.label return = mem
// malloc::@return
// [13] return
rts

View File

@ -4,8 +4,8 @@
(label) @end
(byte*) BYTES
(const byte*) BYTES#0 BYTES = (byte*)(const void*) malloc::return#0
(byte*) HEAP_START
(const byte*) HEAP_START#0 HEAP_START = (byte*) 49152
(byte*) HEAP_TOP
(const byte*) HEAP_TOP#0 HEAP_TOP = (byte*) 40960
(byte*) heap_head
(void()) main()
(label) main::@1
@ -16,8 +16,10 @@
(void*()) malloc((word) malloc::size)
(label) malloc::@return
(byte*) malloc::mem
(const byte*) malloc::mem#0 mem = (const byte*) HEAP_TOP#0-(const word) malloc::size#0
(void*) malloc::return
(const void*) malloc::return#0 return = (void*)(const byte*) HEAP_START#0
(const void*) malloc::return#0 return = (void*)(const byte*) malloc::mem#0
(word) malloc::size
(const word) malloc::size#0 size = (word) $100
reg byte x [ main::i#2 main::i#1 ]

View File

@ -3,8 +3,8 @@
:BasicUpstart(bbegin)
.pc = $80d "Program"
.const SIZEOF_WORD = 2
// Start of the heap used by malloc()
.label HEAP_START = $c000
// Top of the heap used by malloc()
.label HEAP_TOP = $a000
.label WORDS = malloc.return
bbegin:
jsr malloc
@ -39,6 +39,8 @@ main: {
// Allocates a block of size bytes of memory, returning a pointer to the beginning of the block.
// The content of the newly allocated block of memory is not initialized, remaining with indeterminate values.
malloc: {
.label return = HEAP_START
.const size = $200
.label mem = HEAP_TOP-size
.label return = mem
rts
}

View File

@ -2,7 +2,7 @@ Fixing pointer addition (word*~) bsearch16u::$7 ← (word*) bsearch16u::items +
Fixing pointer addition (word*~) bsearch16u::$15 ← (word*) bsearch16u::pivot + (number) 1
Fixing pointer addition (word*~) bsearch16u::$1 ← (word*) bsearch16u::items - (number) 1
Fixing pointer increment (word*) main::w ← ++ (word*) main::w
Identified constant variable (byte*) HEAP_START
Identified constant variable (byte*) HEAP_TOP
Culled Empty Block (label) malloc::@1
Culled Empty Block (label) @1
Culled Empty Block (label) @2
@ -10,14 +10,15 @@ Culled Empty Block (label) main::@2
CONTROL FLOW GRAPH SSA
@begin: scope:[] from
(byte*) HEAP_START#0 ← ((byte*)) (number) $c000
(byte*) heap_head#0 ← (byte*) HEAP_START#0
(byte*) HEAP_TOP#0 ← ((byte*)) (number) $a000
(byte*) heap_head#0 ← (byte*) HEAP_TOP#0
to:@3
malloc: scope:[malloc] from @3
(word) malloc::size#1 ← phi( @3/(word) malloc::size#0 )
(byte*) heap_head#4 ← phi( @3/(byte*) heap_head#7 )
(byte*) malloc::mem#0 ← (byte*) heap_head#4
(byte*) heap_head#1 ← (byte*) heap_head#4 + (word) malloc::size#1
(byte*~) malloc::$0 ← (byte*) heap_head#4 - (word) malloc::size#1
(byte*) malloc::mem#0 ← (byte*~) malloc::$0
(byte*) heap_head#1 ← (byte*) malloc::mem#0
(void*) malloc::return#0 ← ((void*)) (byte*) malloc::mem#0
to:malloc::@return
malloc::@return: scope:[malloc] from malloc
@ -73,8 +74,8 @@ SYMBOL TABLE SSA
(label) @6
(label) @begin
(label) @end
(byte*) HEAP_START
(byte*) HEAP_START#0
(byte*) HEAP_TOP
(byte*) HEAP_TOP#0
(const byte) SIZEOF_WORD = (byte) 2
(word*) WORDS
(word*) WORDS#0
@ -102,6 +103,7 @@ SYMBOL TABLE SSA
(word*) main::w#1
(word*) main::w#2
(void*()) malloc((word) malloc::size)
(byte*~) malloc::$0
(label) malloc::@return
(byte*) malloc::mem
(byte*) malloc::mem#0
@ -117,43 +119,38 @@ SYMBOL TABLE SSA
Adding number conversion cast (unumber) $200 in (word) malloc::size#0 ← (number) $200
Successful SSA optimization PassNAddNumberTypeConversions
Inlining cast (byte*) HEAP_START#0 ← (byte*)(number) $c000
Inlining cast (byte*) HEAP_TOP#0 ← (byte*)(number) $a000
Inlining cast (void*) malloc::return#0 ← (void*)(byte*) malloc::mem#0
Inlining cast (word) malloc::size#0 ← (unumber)(number) $200
Inlining cast (word*) WORDS#0 ← (word*)(void*~) $0
Successful SSA optimization Pass2InlineCast
Simplifying constant pointer cast (byte*) 49152
Simplifying constant pointer cast (byte*) 40960
Simplifying constant integer cast $200
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (word) $200
Successful SSA optimization PassNFinalizeNumberTypeConversions
Alias (byte*) HEAP_START#0 = (byte*) heap_head#0 (byte*) heap_head#7
Alias (byte*) HEAP_TOP#0 = (byte*) heap_head#0 (byte*) heap_head#7
Alias (byte*) malloc::mem#0 = (byte*~) malloc::$0
Alias (void*) malloc::return#0 = (void*) malloc::return#3 (void*) malloc::return#1
Alias (byte*) heap_head#1 = (byte*) heap_head#5 (byte*) heap_head#2
Alias (void*) malloc::return#2 = (void*) malloc::return#4
Alias (byte*) heap_head#3 = (byte*) heap_head#6
Alias (word*) WORDS#0 = (word*) WORDS#2
Successful SSA optimization Pass2AliasElimination
Identical Phi Values (byte*) heap_head#4 (byte*) HEAP_START#0
Identical Phi Values (byte*) heap_head#4 (byte*) HEAP_TOP#0
Identical Phi Values (word) malloc::size#1 (word) malloc::size#0
Identical Phi Values (byte*) heap_head#3 (byte*) heap_head#1
Identical Phi Values (word*) WORDS#1 (word*) WORDS#0
Successful SSA optimization Pass2IdenticalPhiElimination
Simple Condition (bool~) main::$0 [26] if((byte) main::i#1!=rangelast(0,$ff)) goto main::@1
Simple Condition (bool~) main::$0 [27] if((byte) main::i#1!=rangelast(0,$ff)) goto main::@1
Successful SSA optimization Pass2ConditionalJumpSimplification
Constant (const byte*) HEAP_START#0 = (byte*) 49152
Constant (const byte*) HEAP_TOP#0 = (byte*) 40960
Constant (const word) malloc::size#0 = $200
Constant (const byte) main::i#0 = 0
Successful SSA optimization Pass2ConstantIdentification
Constant (const byte*) malloc::mem#0 = HEAP_START#0
Successful SSA optimization Pass2ConstantIdentification
Constant value identified (void*)malloc::mem#0 in [5] (void*) malloc::return#0 ← (void*)(const byte*) malloc::mem#0
Successful SSA optimization Pass2ConstantValues
Resolved ranged next value [24] main::i#1 ← ++ main::i#2 to ++
Resolved ranged comparison value [26] if(main::i#1!=rangelast(0,$ff)) goto main::@1 to (number) 0
Eliminating unused variable (byte*) heap_head#1 and assignment [0] (byte*) heap_head#1 ← (const byte*) HEAP_START#0 + (const word) malloc::size#0
Successful SSA optimization PassNEliminateUnusedVars
Eliminating unused constant (const word) malloc::size#0
Resolved ranged next value [25] main::i#1 ← ++ main::i#2 to ++
Resolved ranged comparison value [27] if(main::i#1!=rangelast(0,$ff)) goto main::@1 to (number) 0
Eliminating unused variable (byte*) heap_head#1 and assignment [1] (byte*) heap_head#1 ← (byte*) malloc::mem#0
Successful SSA optimization PassNEliminateUnusedVars
Adding number conversion cast (unumber) 0 in if((byte) main::i#1!=(number) 0) goto main::@1
Successful SSA optimization PassNAddNumberTypeConversions
@ -161,6 +158,12 @@ Simplifying constant integer cast 0
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (byte) 0
Successful SSA optimization PassNFinalizeNumberTypeConversions
Constant right-side identified [0] (byte*) malloc::mem#0 ← (const byte*) HEAP_TOP#0 - (const word) malloc::size#0
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant (const byte*) malloc::mem#0 = HEAP_TOP#0-malloc::size#0
Successful SSA optimization Pass2ConstantIdentification
Constant value identified (void*)malloc::mem#0 in [1] (void*) malloc::return#0 ← (void*)(const byte*) malloc::mem#0
Successful SSA optimization Pass2ConstantValues
Constant (const void*) malloc::return#0 = (void*)malloc::mem#0
Successful SSA optimization Pass2ConstantIdentification
Constant (const void*) malloc::return#2 = malloc::return#0
@ -178,7 +181,6 @@ Inlining constant with var siblings (const byte) main::i#0
Inlining constant with var siblings (const word*) main::w#0
Constant inlined main::i#0 = (byte) 0
Constant inlined malloc::return#2 = (const void*) malloc::return#0
Constant inlined malloc::mem#0 = (const byte*) HEAP_START#0
Constant inlined $0 = (const void*) malloc::return#0
Constant inlined main::w#0 = (const word*) WORDS#0
Successful SSA optimization Pass2ConstantInlining
@ -247,7 +249,7 @@ malloc::@return: scope:[malloc] from malloc
VARIABLE REGISTER WEIGHTS
(byte*) HEAP_START
(byte*) HEAP_TOP
(word*) WORDS
(byte*) heap_head
(void()) main()
@ -280,8 +282,8 @@ INITIAL ASM
.pc = $80d "Program"
// Global Constants & labels
.const SIZEOF_WORD = 2
// Start of the heap used by malloc()
.label HEAP_START = $c000
// Top of the heap used by malloc()
.label HEAP_TOP = $a000
.label WORDS = malloc.return
// @begin
bbegin:
@ -361,7 +363,9 @@ main: {
// Allocates a block of size bytes of memory, returning a pointer to the beginning of the block.
// The content of the newly allocated block of memory is not initialized, remaining with indeterminate values.
malloc: {
.label return = HEAP_START
.const size = $200
.label mem = HEAP_TOP-size
.label return = mem
jmp breturn
// malloc::@return
breturn:
@ -399,8 +403,8 @@ ASSEMBLER BEFORE OPTIMIZATION
.pc = $80d "Program"
// Global Constants & labels
.const SIZEOF_WORD = 2
// Start of the heap used by malloc()
.label HEAP_START = $c000
// Top of the heap used by malloc()
.label HEAP_TOP = $a000
.label WORDS = malloc.return
// @begin
bbegin:
@ -477,7 +481,9 @@ main: {
// Allocates a block of size bytes of memory, returning a pointer to the beginning of the block.
// The content of the newly allocated block of memory is not initialized, remaining with indeterminate values.
malloc: {
.label return = HEAP_START
.const size = $200
.label mem = HEAP_TOP-size
.label return = mem
jmp breturn
// malloc::@return
breturn:
@ -519,8 +525,8 @@ FINAL SYMBOL TABLE
(label) @2
(label) @begin
(label) @end
(byte*) HEAP_START
(const byte*) HEAP_START#0 HEAP_START = (byte*) 49152
(byte*) HEAP_TOP
(const byte*) HEAP_TOP#0 HEAP_TOP = (byte*) 40960
(const byte) SIZEOF_WORD SIZEOF_WORD = (byte) 2
(word*) WORDS
(const word*) WORDS#0 WORDS = (word*)(const void*) malloc::return#0
@ -537,9 +543,11 @@ FINAL SYMBOL TABLE
(void*()) malloc((word) malloc::size)
(label) malloc::@return
(byte*) malloc::mem
(const byte*) malloc::mem#0 mem = (const byte*) HEAP_TOP#0-(const word) malloc::size#0
(void*) malloc::return
(const void*) malloc::return#0 return = (void*)(const byte*) HEAP_START#0
(const void*) malloc::return#0 return = (void*)(const byte*) malloc::mem#0
(word) malloc::size
(const word) malloc::size#0 size = (word) $200
reg byte x [ main::i#2 main::i#1 ]
zp ZP_WORD:2 [ main::w#2 main::w#1 ]
@ -556,8 +564,8 @@ Score: 590
.pc = $80d "Program"
// Global Constants & labels
.const SIZEOF_WORD = 2
// Start of the heap used by malloc()
.label HEAP_START = $c000
// Top of the heap used by malloc()
.label HEAP_TOP = $a000
.label WORDS = malloc.return
// @begin
bbegin:
@ -623,7 +631,9 @@ main: {
// Allocates a block of size bytes of memory, returning a pointer to the beginning of the block.
// The content of the newly allocated block of memory is not initialized, remaining with indeterminate values.
malloc: {
.label return = HEAP_START
.const size = $200
.label mem = HEAP_TOP-size
.label return = mem
// malloc::@return
// [14] return
rts

View File

@ -2,8 +2,8 @@
(label) @2
(label) @begin
(label) @end
(byte*) HEAP_START
(const byte*) HEAP_START#0 HEAP_START = (byte*) 49152
(byte*) HEAP_TOP
(const byte*) HEAP_TOP#0 HEAP_TOP = (byte*) 40960
(const byte) SIZEOF_WORD SIZEOF_WORD = (byte) 2
(word*) WORDS
(const word*) WORDS#0 WORDS = (word*)(const void*) malloc::return#0
@ -20,9 +20,11 @@
(void*()) malloc((word) malloc::size)
(label) malloc::@return
(byte*) malloc::mem
(const byte*) malloc::mem#0 mem = (const byte*) HEAP_TOP#0-(const word) malloc::size#0
(void*) malloc::return
(const void*) malloc::return#0 return = (void*)(const byte*) HEAP_START#0
(const void*) malloc::return#0 return = (void*)(const byte*) malloc::mem#0
(word) malloc::size
(const word) malloc::size#0 size = (word) $200
reg byte x [ main::i#2 main::i#1 ]
zp ZP_WORD:2 [ main::w#2 main::w#1 ]

View File

@ -2,16 +2,16 @@
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
// Start of the heap used by malloc()
.label HEAP_START = $c000
// Top of the heap used by malloc()
.label HEAP_TOP = $a000
.label heap_head = 2
main: {
.label screen = $400
.label buf1 = 4
.label buf2 = 6
lda #<HEAP_START
lda #<HEAP_TOP
sta heap_head
lda #>HEAP_START
lda #>HEAP_TOP
sta heap_head+1
jsr malloc
lda malloc.mem
@ -50,15 +50,15 @@ free: {
malloc: {
.label mem = 6
lda heap_head
sec
sbc #<$64
sta mem
lda heap_head+1
sbc #>$64
sta mem+1
lda #$64
clc
adc heap_head
lda mem
sta heap_head
bcc !+
inc heap_head+1
!:
lda mem+1
sta heap_head+1
rts
}

View File

@ -48,9 +48,9 @@ free::@return: scope:[free] from free
[23] return
to:@return
malloc: scope:[malloc] from main main::@3
[24] (byte*) heap_head#7 ← phi( main/(const byte*) HEAP_START#0 main::@3/(byte*) heap_head#1 )
[25] (byte*) malloc::mem#0 ← (byte*) heap_head#7
[26] (byte*) heap_head#1 ← (byte*) heap_head#7 + (byte) $64
[24] (byte*) heap_head#7 ← phi( main/(const byte*) HEAP_TOP#0 main::@3/(byte*) heap_head#1 )
[25] (byte*) malloc::mem#0 ← (byte*) heap_head#7 - (byte) $64
[26] (byte*) heap_head#1 ← (byte*) malloc::mem#0
to:malloc::@return
malloc::@return: scope:[malloc] from malloc
[27] return

View File

@ -1,7 +1,7 @@
Fixing pointer addition (word*~) bsearch16u::$7 ← (word*) bsearch16u::items + (byte~) bsearch16u::$6
Fixing pointer addition (word*~) bsearch16u::$15 ← (word*) bsearch16u::pivot + (number) 1
Fixing pointer addition (word*~) bsearch16u::$1 ← (word*) bsearch16u::items - (number) 1
Identified constant variable (byte*) HEAP_START
Identified constant variable (byte*) HEAP_TOP
Identified constant variable (byte*) main::screen
Culled Empty Block (label) malloc::@1
Culled Empty Block (label) @1
@ -10,14 +10,15 @@ Culled Empty Block (label) @3
CONTROL FLOW GRAPH SSA
@begin: scope:[] from
(byte*) HEAP_START#0 ← ((byte*)) (number) $c000
(byte*) heap_head#0 ← (byte*) HEAP_START#0
(byte*) HEAP_TOP#0 ← ((byte*)) (number) $a000
(byte*) heap_head#0 ← (byte*) HEAP_TOP#0
to:@4
malloc: scope:[malloc] from main main::@3
(word) malloc::size#2 ← phi( main/(word) malloc::size#0 main::@3/(word) malloc::size#1 )
(byte*) heap_head#7 ← phi( main/(byte*) heap_head#13 main::@3/(byte*) heap_head#3 )
(byte*) malloc::mem#0 ← (byte*) heap_head#7
(byte*) heap_head#1 ← (byte*) heap_head#7 + (word) malloc::size#2
(byte*~) malloc::$0 ← (byte*) heap_head#7 - (word) malloc::size#2
(byte*) malloc::mem#0 ← (byte*~) malloc::$0
(byte*) heap_head#1 ← (byte*) malloc::mem#0
(void*) malloc::return#0 ← ((void*)) (byte*) malloc::mem#0
to:malloc::@return
malloc::@return: scope:[malloc] from malloc
@ -111,8 +112,8 @@ SYMBOL TABLE SSA
(label) @5
(label) @begin
(label) @end
(byte*) HEAP_START
(byte*) HEAP_START#0
(byte*) HEAP_TOP
(byte*) HEAP_TOP#0
(void()) free((void*) free::ptr)
(label) free::@return
(void*) free::ptr
@ -170,6 +171,7 @@ SYMBOL TABLE SSA
(byte*) main::screen
(byte*) main::screen#0
(void*()) malloc((word) malloc::size)
(byte*~) malloc::$0
(label) malloc::@return
(byte*) malloc::mem
(byte*) malloc::mem#0
@ -193,7 +195,7 @@ Adding number conversion cast (unumber) main::$4 in (number~) main::$4 ← (unum
Adding number conversion cast (unumber) 0 in *((byte*) main::screen#0 + (number) 0) ← *((byte*) main::buf1#3)
Adding number conversion cast (unumber) 1 in *((byte*) main::screen#0 + (number) 1) ← *((byte*) main::buf2#3)
Successful SSA optimization PassNAddNumberTypeConversions
Inlining cast (byte*) HEAP_START#0 ← (byte*)(number) $c000
Inlining cast (byte*) HEAP_TOP#0 ← (byte*)(number) $a000
Inlining cast (void*) malloc::return#0 ← (void*)(byte*) malloc::mem#0
Inlining cast (word) malloc::size#0 ← (unumber)(number) $64
Inlining cast (byte*) main::buf1#0 ← (byte*)(void*~) main::$0
@ -201,7 +203,7 @@ Inlining cast (word) malloc::size#1 ← (unumber)(number) $64
Inlining cast (byte*) main::buf2#0 ← (byte*)(void*~) main::$1
Inlining cast (byte*) main::screen#0 ← (byte*)(number) $400
Successful SSA optimization Pass2InlineCast
Simplifying constant pointer cast (byte*) 49152
Simplifying constant pointer cast (byte*) 40960
Simplifying constant integer cast $64
Simplifying constant integer cast $64
Simplifying constant integer cast $ff
@ -216,7 +218,8 @@ Finalized unsigned number type (byte) 0
Finalized unsigned number type (byte) 1
Successful SSA optimization PassNFinalizeNumberTypeConversions
Inferred type updated to byte in (unumber~) main::$4 ← (byte) $ff - (byte) main::i#2
Alias (byte*) HEAP_START#0 = (byte*) heap_head#0 (byte*) heap_head#15
Alias (byte*) HEAP_TOP#0 = (byte*) heap_head#0 (byte*) heap_head#15
Alias (byte*) malloc::mem#0 = (byte*~) malloc::$0
Alias (void*) malloc::return#0 = (void*) malloc::return#4 (void*) malloc::return#1
Alias (byte*) heap_head#1 = (byte*) heap_head#8 (byte*) heap_head#2
Alias (void*) malloc::return#2 = (void*) malloc::return#5
@ -233,7 +236,7 @@ Self Phi Eliminated (byte*) main::buf1#1
Self Phi Eliminated (byte*) main::buf2#1
Self Phi Eliminated (byte*) heap_head#11
Successful SSA optimization Pass2SelfPhiElimination
Identical Phi Values (byte*) heap_head#13 (byte*) HEAP_START#0
Identical Phi Values (byte*) heap_head#13 (byte*) HEAP_TOP#0
Identical Phi Values (byte*) heap_head#3 (byte*) heap_head#1
Identical Phi Values (byte*) heap_head#10 (byte*) heap_head#1
Identical Phi Values (byte*) main::buf1#1 (byte*) main::buf1#0
@ -241,17 +244,17 @@ Identical Phi Values (byte*) main::buf2#1 (byte*) main::buf2#0
Identical Phi Values (byte*) heap_head#11 (byte*) heap_head#10
Identical Phi Values (byte*) heap_head#12 (byte*) heap_head#11
Successful SSA optimization Pass2IdenticalPhiElimination
Simple Condition (bool~) main::$5 [33] if((byte) main::i#1!=rangelast(0,$63)) goto main::@1
Simple Condition (bool~) main::$5 [34] if((byte) main::i#1!=rangelast(0,$63)) goto main::@1
Successful SSA optimization Pass2ConditionalJumpSimplification
Constant (const byte*) HEAP_START#0 = (byte*) 49152
Constant (const byte*) HEAP_TOP#0 = (byte*) 40960
Constant (const word) malloc::size#0 = $64
Constant (const word) malloc::size#1 = $64
Constant (const byte) main::i#0 = 0
Constant (const byte*) main::screen#0 = (byte*) 1024
Successful SSA optimization Pass2ConstantIdentification
Resolved ranged next value [31] main::i#1 ← ++ main::i#2 to ++
Resolved ranged comparison value [33] if(main::i#1!=rangelast(0,$63)) goto main::@1 to (number) $64
Simplifying expression containing zero main::screen#0 in [42] *((const byte*) main::screen#0 + (byte) 0) ← *((byte*) main::buf1#0)
Resolved ranged next value [32] main::i#1 ← ++ main::i#2 to ++
Resolved ranged comparison value [34] if(main::i#1!=rangelast(0,$63)) goto main::@1 to (number) $64
Simplifying expression containing zero main::screen#0 in [43] *((const byte*) main::screen#0 + (byte) 0) ← *((byte*) main::buf1#0)
Successful SSA optimization PassNSimplifyExpressionWithZero
Eliminating unused variable (void*) free::ptr#0 and assignment [20] (void*) free::ptr#0 ← (void*)(byte*) main::buf1#0
Eliminating unused variable (void*) free::ptr#1 and assignment [22] (void*) free::ptr#1 ← (void*)(byte*) main::buf2#0
@ -297,7 +300,8 @@ Calls in [main] to malloc:6 malloc:9 free:18 free:20
Created 2 initial phi equivalence classes
Coalesced [8] heap_head#19 ← heap_head#1
Coalesced [24] main::i#3 ← main::i#1
Coalesced down to 2 phi equivalence classes
Not coalescing [29] heap_head#1 ← malloc::mem#0
Coalesced down to 3 phi equivalence classes
Culled Empty Block (label) @5
Culled Empty Block (label) main::@7
Renumbering block @4 to @1
@ -360,9 +364,9 @@ free::@return: scope:[free] from free
[23] return
to:@return
malloc: scope:[malloc] from main main::@3
[24] (byte*) heap_head#7 ← phi( main/(const byte*) HEAP_START#0 main::@3/(byte*) heap_head#1 )
[25] (byte*) malloc::mem#0 ← (byte*) heap_head#7
[26] (byte*) heap_head#1 ← (byte*) heap_head#7 + (byte) $64
[24] (byte*) heap_head#7 ← phi( main/(const byte*) HEAP_TOP#0 main::@3/(byte*) heap_head#1 )
[25] (byte*) malloc::mem#0 ← (byte*) heap_head#7 - (byte) $64
[26] (byte*) heap_head#1 ← (byte*) malloc::mem#0
to:malloc::@return
malloc::@return: scope:[malloc] from malloc
[27] return
@ -370,12 +374,12 @@ malloc::@return: scope:[malloc] from malloc
VARIABLE REGISTER WEIGHTS
(byte*) HEAP_START
(byte*) HEAP_TOP
(void()) free((void*) free::ptr)
(void*) free::ptr
(byte*) heap_head
(byte*) heap_head#1 1.0
(byte*) heap_head#7 3.0
(byte*) heap_head#7 4.0
(void()) main()
(byte~) main::$4 22.0
(byte*) main::buf1
@ -388,7 +392,7 @@ VARIABLE REGISTER WEIGHTS
(byte*) main::screen
(void*()) malloc((word) malloc::size)
(byte*) malloc::mem
(byte*) malloc::mem#0 0.4
(byte*) malloc::mem#0 0.8
(void*) malloc::return
(word) malloc::size
@ -421,8 +425,8 @@ INITIAL ASM
:BasicUpstart(bbegin)
.pc = $80d "Program"
// Global Constants & labels
// Start of the heap used by malloc()
.label HEAP_START = $c000
// Top of the heap used by malloc()
.label HEAP_TOP = $a000
.label heap_head = 3
// @begin
bbegin:
@ -450,10 +454,10 @@ main: {
// [5] call malloc
// [24] phi from main to malloc [phi:main->malloc]
malloc_from_main:
// [24] phi (byte*) heap_head#7 = (const byte*) HEAP_START#0 [phi:main->malloc#0] -- pbuz1=pbuc1
lda #<HEAP_START
// [24] phi (byte*) heap_head#7 = (const byte*) HEAP_TOP#0 [phi:main->malloc#0] -- pbuz1=pbuc1
lda #<HEAP_TOP
sta heap_head
lda #>HEAP_START
lda #>HEAP_TOP
sta heap_head+1
jsr malloc
jmp b3
@ -558,19 +562,19 @@ free: {
// The content of the newly allocated block of memory is not initialized, remaining with indeterminate values.
malloc: {
.label mem = $a
// [25] (byte*) malloc::mem#0 ← (byte*) heap_head#7 -- pbuz1=pbuz2
// [25] (byte*) malloc::mem#0 ← (byte*) heap_head#7 - (byte) $64 -- pbuz1=pbuz2_minus_vwuc1
lda heap_head
sec
sbc #<$64
sta mem
lda heap_head+1
sbc #>$64
sta mem+1
// [26] (byte*) heap_head#1 ← (byte*) heap_head#7 + (byte) $64 -- pbuz1=pbuz1_plus_vbuc1
lda #$64
clc
adc heap_head
// [26] (byte*) heap_head#1 ← (byte*) malloc::mem#0 -- pbuz1=pbuz2
lda mem
sta heap_head
bcc !+
inc heap_head+1
!:
lda mem+1
sta heap_head+1
jmp breturn
// malloc::@return
breturn:
@ -586,16 +590,16 @@ Statement [11] (byte~) main::$4 ← (byte) $ff - (byte) main::i#2 [ main::buf1#0
Removing always clobbered register reg byte a as potential for zp ZP_BYTE:2 [ main::i#2 main::i#1 ]
Statement [19] *((const byte*) main::screen#0) ← *((byte*)(void*) main::buf1#0) [ main::buf2#0 ] ( main:2 [ main::buf2#0 ] ) always clobbers reg byte a reg byte y
Statement [20] *((const byte*) main::screen#0+(byte) 1) ← *((byte*)(void*) main::buf2#0) [ ] ( main:2 [ ] ) always clobbers reg byte a reg byte y
Statement [25] (byte*) malloc::mem#0 ← (byte*) heap_head#7 [ malloc::mem#0 heap_head#7 ] ( main:2::malloc:5 [ malloc::mem#0 heap_head#7 ] main:2::malloc:7 [ main::buf1#0 malloc::mem#0 heap_head#7 ] ) always clobbers reg byte a
Statement [26] (byte*) heap_head#1 ← (byte*) heap_head#7 + (byte) $64 [ malloc::mem#0 heap_head#1 ] ( main:2::malloc:5 [ malloc::mem#0 heap_head#1 ] main:2::malloc:7 [ main::buf1#0 malloc::mem#0 heap_head#1 ] ) always clobbers reg byte a
Statement [25] (byte*) malloc::mem#0 ← (byte*) heap_head#7 - (byte) $64 [ malloc::mem#0 ] ( main:2::malloc:5 [ malloc::mem#0 ] main:2::malloc:7 [ main::buf1#0 malloc::mem#0 ] ) always clobbers reg byte a
Statement [26] (byte*) heap_head#1 ← (byte*) malloc::mem#0 [ malloc::mem#0 heap_head#1 ] ( main:2::malloc:5 [ malloc::mem#0 heap_head#1 ] main:2::malloc:7 [ main::buf1#0 malloc::mem#0 heap_head#1 ] ) always clobbers reg byte a
Statement [6] (void*) main::buf1#0 ← (void*)(byte*) malloc::mem#0 [ main::buf1#0 heap_head#1 ] ( main:2 [ main::buf1#0 heap_head#1 ] ) always clobbers reg byte a
Statement [8] (void*) main::buf2#0 ← (void*)(byte*) malloc::mem#0 [ main::buf1#0 main::buf2#0 ] ( main:2 [ main::buf1#0 main::buf2#0 ] ) always clobbers reg byte a
Statement [10] *((byte*)(void*) main::buf1#0 + (byte) main::i#2) ← (byte) main::i#2 [ main::buf1#0 main::buf2#0 main::i#2 ] ( main:2 [ main::buf1#0 main::buf2#0 main::i#2 ] ) always clobbers reg byte a
Statement [11] (byte~) main::$4 ← (byte) $ff - (byte) main::i#2 [ main::buf1#0 main::buf2#0 main::i#2 main::$4 ] ( main:2 [ main::buf1#0 main::buf2#0 main::i#2 main::$4 ] ) always clobbers reg byte a
Statement [19] *((const byte*) main::screen#0) ← *((byte*)(void*) main::buf1#0) [ main::buf2#0 ] ( main:2 [ main::buf2#0 ] ) always clobbers reg byte a reg byte y
Statement [20] *((const byte*) main::screen#0+(byte) 1) ← *((byte*)(void*) main::buf2#0) [ ] ( main:2 [ ] ) always clobbers reg byte a reg byte y
Statement [25] (byte*) malloc::mem#0 ← (byte*) heap_head#7 [ malloc::mem#0 heap_head#7 ] ( main:2::malloc:5 [ malloc::mem#0 heap_head#7 ] main:2::malloc:7 [ main::buf1#0 malloc::mem#0 heap_head#7 ] ) always clobbers reg byte a
Statement [26] (byte*) heap_head#1 ← (byte*) heap_head#7 + (byte) $64 [ malloc::mem#0 heap_head#1 ] ( main:2::malloc:5 [ malloc::mem#0 heap_head#1 ] main:2::malloc:7 [ main::buf1#0 malloc::mem#0 heap_head#1 ] ) always clobbers reg byte a
Statement [25] (byte*) malloc::mem#0 ← (byte*) heap_head#7 - (byte) $64 [ malloc::mem#0 ] ( main:2::malloc:5 [ malloc::mem#0 ] main:2::malloc:7 [ main::buf1#0 malloc::mem#0 ] ) always clobbers reg byte a
Statement [26] (byte*) heap_head#1 ← (byte*) malloc::mem#0 [ malloc::mem#0 heap_head#1 ] ( main:2::malloc:5 [ malloc::mem#0 heap_head#1 ] main:2::malloc:7 [ main::buf1#0 malloc::mem#0 heap_head#1 ] ) always clobbers reg byte a
Potential registers zp ZP_BYTE:2 [ main::i#2 main::i#1 ] : zp ZP_BYTE:2 , reg byte x , reg byte y ,
Potential registers zp ZP_WORD:3 [ heap_head#7 heap_head#1 ] : zp ZP_WORD:3 ,
Potential registers zp ZP_WORD:5 [ main::buf1#0 ] : zp ZP_WORD:5 ,
@ -605,14 +609,14 @@ Potential registers zp ZP_WORD:10 [ malloc::mem#0 ] : zp ZP_WORD:10 ,
REGISTER UPLIFT SCOPES
Uplift Scope [main] 33: zp ZP_BYTE:2 [ main::i#2 main::i#1 ] 22: zp ZP_BYTE:9 [ main::$4 ] 0.17: zp ZP_WORD:7 [ main::buf2#0 ] 0.15: zp ZP_WORD:5 [ main::buf1#0 ]
Uplift Scope [] 4: zp ZP_WORD:3 [ heap_head#7 heap_head#1 ]
Uplift Scope [malloc] 0.4: zp ZP_WORD:10 [ malloc::mem#0 ]
Uplift Scope [] 5: zp ZP_WORD:3 [ heap_head#7 heap_head#1 ]
Uplift Scope [malloc] 0.8: zp ZP_WORD:10 [ malloc::mem#0 ]
Uplift Scope [free]
Uplifting [main] best 555 combination reg byte y [ main::i#2 main::i#1 ] reg byte a [ main::$4 ] zp ZP_WORD:7 [ main::buf2#0 ] zp ZP_WORD:5 [ main::buf1#0 ]
Uplifting [] best 555 combination zp ZP_WORD:3 [ heap_head#7 heap_head#1 ]
Uplifting [malloc] best 555 combination zp ZP_WORD:10 [ malloc::mem#0 ]
Uplifting [free] best 555 combination
Uplifting [main] best 556 combination reg byte y [ main::i#2 main::i#1 ] reg byte a [ main::$4 ] zp ZP_WORD:7 [ main::buf2#0 ] zp ZP_WORD:5 [ main::buf1#0 ]
Uplifting [] best 556 combination zp ZP_WORD:3 [ heap_head#7 heap_head#1 ]
Uplifting [malloc] best 556 combination zp ZP_WORD:10 [ malloc::mem#0 ]
Uplifting [free] best 556 combination
Coalescing zero page register with common assignment [ zp ZP_WORD:7 [ main::buf2#0 ] ] with [ zp ZP_WORD:10 [ malloc::mem#0 ] ] - score: 1
Allocated (was zp ZP_WORD:3) zp ZP_WORD:2 [ heap_head#7 heap_head#1 ]
Allocated (was zp ZP_WORD:5) zp ZP_WORD:4 [ main::buf1#0 ]
@ -626,8 +630,8 @@ ASSEMBLER BEFORE OPTIMIZATION
:BasicUpstart(bbegin)
.pc = $80d "Program"
// Global Constants & labels
// Start of the heap used by malloc()
.label HEAP_START = $c000
// Top of the heap used by malloc()
.label HEAP_TOP = $a000
.label heap_head = 2
// @begin
bbegin:
@ -653,10 +657,10 @@ main: {
// [5] call malloc
// [24] phi from main to malloc [phi:main->malloc]
malloc_from_main:
// [24] phi (byte*) heap_head#7 = (const byte*) HEAP_START#0 [phi:main->malloc#0] -- pbuz1=pbuc1
lda #<HEAP_START
// [24] phi (byte*) heap_head#7 = (const byte*) HEAP_TOP#0 [phi:main->malloc#0] -- pbuz1=pbuc1
lda #<HEAP_TOP
sta heap_head
lda #>HEAP_START
lda #>HEAP_TOP
sta heap_head+1
jsr malloc
jmp b3
@ -752,19 +756,19 @@ free: {
// The content of the newly allocated block of memory is not initialized, remaining with indeterminate values.
malloc: {
.label mem = 6
// [25] (byte*) malloc::mem#0 ← (byte*) heap_head#7 -- pbuz1=pbuz2
// [25] (byte*) malloc::mem#0 ← (byte*) heap_head#7 - (byte) $64 -- pbuz1=pbuz2_minus_vwuc1
lda heap_head
sec
sbc #<$64
sta mem
lda heap_head+1
sbc #>$64
sta mem+1
// [26] (byte*) heap_head#1 ← (byte*) heap_head#7 + (byte) $64 -- pbuz1=pbuz1_plus_vbuc1
lda #$64
clc
adc heap_head
// [26] (byte*) heap_head#1 ← (byte*) malloc::mem#0 -- pbuz1=pbuz2
lda mem
sta heap_head
bcc !+
inc heap_head+1
!:
lda mem+1
sta heap_head+1
jmp breturn
// malloc::@return
breturn:
@ -824,14 +828,14 @@ FINAL SYMBOL TABLE
(label) @1
(label) @begin
(label) @end
(byte*) HEAP_START
(const byte*) HEAP_START#0 HEAP_START = (byte*) 49152
(byte*) HEAP_TOP
(const byte*) HEAP_TOP#0 HEAP_TOP = (byte*) 40960
(void()) free((void*) free::ptr)
(label) free::@return
(void*) free::ptr
(byte*) heap_head
(byte*) heap_head#1 heap_head zp ZP_WORD:2 1.0
(byte*) heap_head#7 heap_head zp ZP_WORD:2 3.0
(byte*) heap_head#7 heap_head zp ZP_WORD:2 4.0
(void()) main()
(byte~) main::$4 reg byte a 22.0
(label) main::@1
@ -853,7 +857,7 @@ FINAL SYMBOL TABLE
(void*()) malloc((word) malloc::size)
(label) malloc::@return
(byte*) malloc::mem
(byte*) malloc::mem#0 mem zp ZP_WORD:6 0.4
(byte*) malloc::mem#0 mem zp ZP_WORD:6 0.8
(void*) malloc::return
(word) malloc::size
@ -865,7 +869,7 @@ reg byte a [ main::$4 ]
FINAL ASSEMBLER
Score: 418
Score: 419
// File Comments
// Experiments with malloc()
@ -874,8 +878,8 @@ Score: 418
:BasicUpstart(main)
.pc = $80d "Program"
// Global Constants & labels
// Start of the heap used by malloc()
.label HEAP_START = $c000
// Top of the heap used by malloc()
.label HEAP_TOP = $a000
.label heap_head = 2
// @begin
// [1] phi from @begin to @1 [phi:@begin->@1]
@ -892,10 +896,10 @@ main: {
// malloc(100)
// [5] call malloc
// [24] phi from main to malloc [phi:main->malloc]
// [24] phi (byte*) heap_head#7 = (const byte*) HEAP_START#0 [phi:main->malloc#0] -- pbuz1=pbuc1
lda #<HEAP_START
// [24] phi (byte*) heap_head#7 = (const byte*) HEAP_TOP#0 [phi:main->malloc#0] -- pbuz1=pbuc1
lda #<HEAP_TOP
sta heap_head
lda #>HEAP_START
lda #>HEAP_TOP
sta heap_head+1
jsr malloc
// main::@3
@ -978,21 +982,21 @@ free: {
// The content of the newly allocated block of memory is not initialized, remaining with indeterminate values.
malloc: {
.label mem = 6
// mem = heap_head
// [25] (byte*) malloc::mem#0 ← (byte*) heap_head#7 -- pbuz1=pbuz2
// mem = heap_head-size
// [25] (byte*) malloc::mem#0 ← (byte*) heap_head#7 - (byte) $64 -- pbuz1=pbuz2_minus_vwuc1
lda heap_head
sec
sbc #<$64
sta mem
lda heap_head+1
sbc #>$64
sta mem+1
// heap_head+= size
// [26] (byte*) heap_head#1 ← (byte*) heap_head#7 + (byte) $64 -- pbuz1=pbuz1_plus_vbuc1
lda #$64
clc
adc heap_head
// heap_head = mem
// [26] (byte*) heap_head#1 ← (byte*) malloc::mem#0 -- pbuz1=pbuz2
lda mem
sta heap_head
bcc !+
inc heap_head+1
!:
lda mem+1
sta heap_head+1
// malloc::@return
// }
// [27] return

View File

@ -1,14 +1,14 @@
(label) @1
(label) @begin
(label) @end
(byte*) HEAP_START
(const byte*) HEAP_START#0 HEAP_START = (byte*) 49152
(byte*) HEAP_TOP
(const byte*) HEAP_TOP#0 HEAP_TOP = (byte*) 40960
(void()) free((void*) free::ptr)
(label) free::@return
(void*) free::ptr
(byte*) heap_head
(byte*) heap_head#1 heap_head zp ZP_WORD:2 1.0
(byte*) heap_head#7 heap_head zp ZP_WORD:2 3.0
(byte*) heap_head#7 heap_head zp ZP_WORD:2 4.0
(void()) main()
(byte~) main::$4 reg byte a 22.0
(label) main::@1
@ -30,7 +30,7 @@
(void*()) malloc((word) malloc::size)
(label) malloc::@return
(byte*) malloc::mem
(byte*) malloc::mem#0 mem zp ZP_WORD:6 0.4
(byte*) malloc::mem#0 mem zp ZP_WORD:6 0.8
(void*) malloc::return
(word) malloc::size

View File

@ -8,8 +8,8 @@
.label COLS = $d800
// The colors of the C64
.const BLACK = 0
// Start of the heap used by malloc()
.label HEAP_START = $c000
// Top of the heap used by malloc()
.label HEAP_TOP = $a000
// The number of iterations performed during 16-bit CORDIC atan2 calculation
.const CORDIC_ITERATIONS_16 = $f
.label print_line_cursor = $400
@ -26,7 +26,7 @@
.label SCREEN2 = $2c00
.const NUM_SQUARES = $30
.label heap_head = $32
.label SQUARES = $4f
.label SQUARES = $34
.label print_char_cursor = $f
// Screen containing distance to center
.label SCREEN_DIST = $36
@ -39,9 +39,9 @@ bbegin:
sta malloc.size
lda #>$3e8
sta malloc.size+1
lda #<HEAP_START
lda #<HEAP_TOP
sta heap_head
lda #>HEAP_START
lda #>HEAP_TOP
sta heap_head+1
jsr malloc
lda malloc.mem
@ -913,18 +913,18 @@ init_squares: {
// The content of the newly allocated block of memory is not initialized, remaining with indeterminate values.
// malloc(word zeropage($34) size)
malloc: {
.label mem = $4f
.label mem = $34
.label size = $34
lda heap_head
sec
sbc mem
sta mem
lda heap_head+1
sbc mem+1
sta mem+1
lda heap_head
clc
adc size
lda mem
sta heap_head
lda heap_head+1
adc size+1
lda mem+1
sta heap_head+1
rts
}

View File

@ -502,9 +502,9 @@ init_squares::@return: scope:[init_squares] from init_squares::@1
to:@return
malloc: scope:[malloc] from @1 @3 init_squares
[255] (word) malloc::size#3 ← phi( @1/(word) $3e8 @3/(word) $3e8 init_squares/(const byte) NUM_SQUARES#3*(const byte) SIZEOF_WORD )
[255] (byte*) heap_head#12 ← phi( @1/(const byte*) HEAP_START#0 @3/(byte*) heap_head#1 init_squares/(byte*) heap_head#1 )
[256] (byte*) malloc::mem#0 ← (byte*) heap_head#12
[257] (byte*) heap_head#1 ← (byte*) heap_head#12 + (word) malloc::size#3
[255] (byte*) heap_head#12 ← phi( @1/(const byte*) HEAP_TOP#0 @3/(byte*) heap_head#1 init_squares/(byte*) heap_head#1 )
[256] (byte*) malloc::mem#0 ← (byte*) heap_head#12 - (word) malloc::size#3
[257] (byte*) heap_head#1 ← (byte*) malloc::mem#0
to:malloc::@return
malloc::@return: scope:[malloc] from malloc
[258] return

View File

@ -8,7 +8,7 @@ Fixing pointer array-indexing *((word[CORDIC_ITERATIONS_16]) CORDIC_ATAN2_ANGLES
Fixing pointer array-indexing *((word[CORDIC_ITERATIONS_16]) CORDIC_ATAN2_ANGLES_16 + (byte) atan2_16::i)
Warning! Adding boolean cast to non-boolean condition *((byte*) strcpy::src)
Warning! Adding boolean cast to non-boolean sub-expression (byte) atan2_16::shift
Identified constant variable (byte*) HEAP_START
Identified constant variable (byte*) HEAP_TOP
Inlined call (byte~) vicSelectGfxBank::$0 ← call toDd00 (byte*) vicSelectGfxBank::gfx
Inlined call (byte~) main::$5 ← call toD018 (byte*) SCREEN1 (byte*) CHARSET
Inlined call (byte~) main::$7 ← call toD018 (byte*) SCREEN2 (byte*) CHARSET
@ -94,14 +94,15 @@ CONTROL FLOW GRAPH SSA
(byte) BLACK#0 ← (number) 0
to:@4
@4: scope:[] from @begin
(byte*) HEAP_START#0 ← ((byte*)) (number) $c000
(byte*) heap_head#0 ← (byte*) HEAP_START#0
(byte*) HEAP_TOP#0 ← ((byte*)) (number) $a000
(byte*) heap_head#0 ← (byte*) HEAP_TOP#0
to:@11
malloc: scope:[malloc] from @39 @45 init_squares
(word) malloc::size#3 ← phi( @39/(word) malloc::size#1 @45/(word) malloc::size#2 init_squares/(word) malloc::size#0 )
(byte*) heap_head#12 ← phi( @39/(byte*) heap_head#23 @45/(byte*) heap_head#5 init_squares/(byte*) heap_head#24 )
(byte*) malloc::mem#0 ← (byte*) heap_head#12
(byte*) heap_head#1 ← (byte*) heap_head#12 + (word) malloc::size#3
(byte*~) malloc::$0 ← (byte*) heap_head#12 - (word) malloc::size#3
(byte*) malloc::mem#0 ← (byte*~) malloc::$0
(byte*) heap_head#1 ← (byte*) malloc::mem#0
(void*) malloc::return#0 ← ((void*)) (byte*) malloc::mem#0
to:malloc::@return
malloc::@return: scope:[malloc] from malloc
@ -1415,8 +1416,8 @@ SYMBOL TABLE SSA
(byte) CORDIC_ITERATIONS_16#0
(byte*) D018
(byte*) D018#0
(byte*) HEAP_START
(byte*) HEAP_START#0
(byte*) HEAP_TOP
(byte*) HEAP_TOP#0
(byte) NUM_SQUARES
(byte) NUM_SQUARES#0
(byte) NUM_SQUARES#1
@ -2302,6 +2303,7 @@ SYMBOL TABLE SSA
(byte) make_plasma_charset::s#5
(byte) make_plasma_charset::s#6
(void*()) malloc((word) malloc::size)
(byte*~) malloc::$0
(label) malloc::@return
(byte*) malloc::mem
(byte*) malloc::mem#0
@ -2750,7 +2752,7 @@ Successful SSA optimization PassNAddArrayNumberTypeConversions
Inlining cast (byte*) D018#0 ← (byte*)(number) $d018
Inlining cast (byte*) COLS#0 ← (byte*)(number) $d800
Inlining cast (byte) BLACK#0 ← (unumber)(number) 0
Inlining cast (byte*) HEAP_START#0 ← (byte*)(number) $c000
Inlining cast (byte*) HEAP_TOP#0 ← (byte*)(number) $a000
Inlining cast (void*) malloc::return#0 ← (void*)(byte*) malloc::mem#0
Inlining cast (signed word~) bsearch16u::$8 ← (signed word)(word) bsearch16u::key#1
Inlining cast (signed word~) bsearch16u::$9 ← (signed word)*((word*) bsearch16u::pivot#0)
@ -2797,7 +2799,7 @@ Successful SSA optimization Pass2InlineCast
Simplifying constant pointer cast (byte*) 53272
Simplifying constant pointer cast (byte*) 55296
Simplifying constant integer cast 0
Simplifying constant pointer cast (byte*) 49152
Simplifying constant pointer cast (byte*) 40960
Simplifying constant integer cast 0
Simplifying constant integer cast 1
Simplifying constant integer cast 0
@ -3034,16 +3036,17 @@ Inferred type updated to byte in (unumber~) make_plasma_charset::$4 ← (byte~)
Inferred type updated to word in (unumber~) make_plasma_charset::$8 ← (word) make_plasma_charset::c#3 * (byte) 8
Inferred type updated to word in (unumber~) make_plasma_charset::$9 ← (word~) make_plasma_charset::$8 + (byte) make_plasma_charset::i#2
Inferred type updated to byte in (unumber~) make_plasma_charset::$11 ← (word) make_plasma_charset::c#4 & (byte) 7
Inversing boolean not [27] (bool~) bsearch16u::$12 ← (signed word) bsearch16u::result#0 != (signed byte) 0 from [26] (bool~) bsearch16u::$11 ← (signed word) bsearch16u::result#0 == (signed byte) 0
Inversing boolean not [34] (bool~) bsearch16u::$14 ← (signed word) bsearch16u::result#1 <= (signed byte) 0 from [33] (bool~) bsearch16u::$13 ← (signed word) bsearch16u::result#1 > (signed byte) 0
Inversing boolean not [150] (bool~) atan2_16::$18 ← (signed word) atan2_16::yi#3 != (signed byte) 0 from [149] (bool~) atan2_16::$17 ← (signed word) atan2_16::yi#3 == (signed byte) 0
Inversing boolean not [159] (bool~) atan2_16::$11 ← (signed word) atan2_16::x#4 >= (signed byte) 0 from [158] (bool~) atan2_16::$10 ← (signed word) atan2_16::x#4 < (signed byte) 0
Inversing boolean not [170] (bool~) atan2_16::$20 ← (byte) 0 == (byte) atan2_16::shift#4 from [169] (bool~) atan2_16::$25 ← (byte) 0 != (byte) atan2_16::shift#4
Inversing boolean not [194] (bool~) atan2_16::$14 ← (signed word) atan2_16::y#4 >= (signed byte) 0 from [193] (bool~) atan2_16::$13 ← (signed word) atan2_16::y#4 < (signed byte) 0
Inversing boolean not [524] (bool~) make_plasma_charset::$6 ← (byte~) make_plasma_charset::$4 <= (byte) make_plasma_charset::s#1 from [523] (bool~) make_plasma_charset::$5 ← (byte~) make_plasma_charset::$4 > (byte) make_plasma_charset::s#1
Inversing boolean not [542] (bool~) make_plasma_charset::$13 ← (byte~) make_plasma_charset::$11 != (byte) 0 from [541] (bool~) make_plasma_charset::$12 ← (byte~) make_plasma_charset::$11 == (byte) 0
Inversing boolean not [28] (bool~) bsearch16u::$12 ← (signed word) bsearch16u::result#0 != (signed byte) 0 from [27] (bool~) bsearch16u::$11 ← (signed word) bsearch16u::result#0 == (signed byte) 0
Inversing boolean not [35] (bool~) bsearch16u::$14 ← (signed word) bsearch16u::result#1 <= (signed byte) 0 from [34] (bool~) bsearch16u::$13 ← (signed word) bsearch16u::result#1 > (signed byte) 0
Inversing boolean not [151] (bool~) atan2_16::$18 ← (signed word) atan2_16::yi#3 != (signed byte) 0 from [150] (bool~) atan2_16::$17 ← (signed word) atan2_16::yi#3 == (signed byte) 0
Inversing boolean not [160] (bool~) atan2_16::$11 ← (signed word) atan2_16::x#4 >= (signed byte) 0 from [159] (bool~) atan2_16::$10 ← (signed word) atan2_16::x#4 < (signed byte) 0
Inversing boolean not [171] (bool~) atan2_16::$20 ← (byte) 0 == (byte) atan2_16::shift#4 from [170] (bool~) atan2_16::$25 ← (byte) 0 != (byte) atan2_16::shift#4
Inversing boolean not [195] (bool~) atan2_16::$14 ← (signed word) atan2_16::y#4 >= (signed byte) 0 from [194] (bool~) atan2_16::$13 ← (signed word) atan2_16::y#4 < (signed byte) 0
Inversing boolean not [525] (bool~) make_plasma_charset::$6 ← (byte~) make_plasma_charset::$4 <= (byte) make_plasma_charset::s#1 from [524] (bool~) make_plasma_charset::$5 ← (byte~) make_plasma_charset::$4 > (byte) make_plasma_charset::s#1
Inversing boolean not [543] (bool~) make_plasma_charset::$13 ← (byte~) make_plasma_charset::$11 != (byte) 0 from [542] (bool~) make_plasma_charset::$12 ← (byte~) make_plasma_charset::$11 == (byte) 0
Successful SSA optimization Pass2UnaryNotSimplification
Alias (byte*) HEAP_START#0 = (byte*) heap_head#0 (byte*) heap_head#44 (byte*) heap_head#40 (byte*) heap_head#36 (byte*) heap_head#31 (byte*) heap_head#23
Alias (byte*) HEAP_TOP#0 = (byte*) heap_head#0 (byte*) heap_head#44 (byte*) heap_head#40 (byte*) heap_head#36 (byte*) heap_head#31 (byte*) heap_head#23
Alias (byte*) malloc::mem#0 = (byte*~) malloc::$0
Alias (void*) malloc::return#0 = (void*) malloc::return#5 (void*) malloc::return#1
Alias (byte*) heap_head#1 = (byte*) heap_head#13 (byte*) heap_head#2
Alias (byte) bsearch16u::num#3 = (byte) bsearch16u::num#4 (byte) bsearch16u::num#8 (byte) bsearch16u::num#6
@ -3433,46 +3436,46 @@ Identical Phi Values (word*) SQUARES#9 (word*) SQUARES#18
Identical Phi Values (signed word) atan2_16::x#4 (signed word) atan2_16::x#17
Identical Phi Values (signed word) atan2_16::y#4 (signed word) atan2_16::y#19
Successful SSA optimization Pass2IdenticalPhiElimination
Simple Condition (bool~) bsearch16u::$5 [16] if((byte) bsearch16u::num#3>(byte) 0) goto bsearch16u::@7
Simple Condition (bool~) bsearch16u::$12 [28] if((signed word) bsearch16u::result#0!=(signed byte) 0) goto bsearch16u::@9
Simple Condition (bool~) bsearch16u::$0 [31] if(*((word*) bsearch16u::items#2)<=(word) bsearch16u::key#0) goto bsearch16u::@1
Simple Condition (bool~) bsearch16u::$14 [35] if((signed word) bsearch16u::result#0<=(signed byte) 0) goto bsearch16u::@10
Simple Condition (bool~) memset::$2 [65] if((byte*) memset::dst#1!=(byte*) memset::end#0) goto memset::@1
Simple Condition (bool~) init_squares::$5 [95] if((byte) init_squares::i#1!=rangelast(0,init_squares::$2)) goto init_squares::@1
Simple Condition (bool~) atan2_16::$0 [128] if((signed word) atan2_16::y#0>=(signed byte) 0) goto atan2_16::@1
Simple Condition (bool~) atan2_16::$5 [137] if((signed word) atan2_16::x#0>=(signed byte) 0) goto atan2_16::@4
Simple Condition (bool~) atan2_16::$18 [151] if((signed word) atan2_16::yi#3!=(signed byte) 0) goto atan2_16::@16
Simple Condition (bool~) atan2_16::$11 [160] if((signed word) atan2_16::x#17>=(signed byte) 0) goto atan2_16::@7
Simple Condition (bool~) atan2_16::$19 [163] if((byte) atan2_16::shift#2>=(byte) 2) goto atan2_16::@19
Simple Condition (bool~) atan2_16::$20 [171] if((byte) 0==(byte) atan2_16::shift#2) goto atan2_16::@25
Simple Condition (bool~) atan2_16::$21 [174] if((signed word) atan2_16::yi#3>=(signed byte) 0) goto atan2_16::@26
Simple Condition (bool~) atan2_16::$22 [191] if((byte) atan2_16::i#1!=rangelast(0,atan2_16::$16)) goto atan2_16::@15
Simple Condition (bool~) atan2_16::$14 [195] if((signed word) atan2_16::y#19>=(signed byte) 0) goto atan2_16::@8
Simple Condition (bool~) print_cls::$1 [224] if((byte*) print_cls::sc#1!=(byte*~) print_cls::$0) goto print_cls::@1
Simple Condition (bool~) doplasma::$3 [360] if((byte) doplasma::x#1!=rangelast(0,$27)) goto doplasma::@2
Simple Condition (bool~) doplasma::$4 [367] if((byte) doplasma::y#1!=rangelast(0,$19)) goto doplasma::@1
Simple Condition (bool~) init_angle_screen::$15 [416] if((byte) init_angle_screen::x#1<=(byte) $13) goto init_angle_screen::@2
Simple Condition (bool~) init_angle_screen::$16 [422] if((byte) init_angle_screen::y#1!=rangelast(0,$c)) goto init_angle_screen::@1
Simple Condition (bool~) init_dist_screen::$3 [438] if((byte) init_dist_screen::y2#0>=(byte) $18) goto init_dist_screen::@2
Simple Condition (bool~) init_dist_screen::$11 [459] if((byte) init_dist_screen::x2#0>=(byte) $27) goto init_dist_screen::@6
Simple Condition (bool~) init_dist_screen::$20 [489] if((byte) init_dist_screen::x#1<=(byte) $13) goto init_dist_screen::@5
Simple Condition (bool~) init_dist_screen::$21 [495] if((byte) init_dist_screen::y#1!=rangelast(0,$c)) goto init_dist_screen::@1
Simple Condition (bool~) make_plasma_charset::$6 [525] if((byte~) make_plasma_charset::$4<=(byte) make_plasma_charset::s#3) goto make_plasma_charset::@4
Simple Condition (bool~) make_plasma_charset::$7 [529] if((byte) make_plasma_charset::ii#1<(byte) 8) goto make_plasma_charset::@3
Simple Condition (bool~) make_plasma_charset::$10 [538] if((byte) make_plasma_charset::i#1<(byte) 8) goto make_plasma_charset::@2
Simple Condition (bool~) make_plasma_charset::$13 [543] if((byte~) make_plasma_charset::$11!=(byte) 0) goto make_plasma_charset::@9
Simple Condition (bool~) make_plasma_charset::$15 [547] if((word) make_plasma_charset::c#1<(word) $100) goto make_plasma_charset::@1
Simple Condition (bool~) bsearch16u::$5 [17] if((byte) bsearch16u::num#3>(byte) 0) goto bsearch16u::@7
Simple Condition (bool~) bsearch16u::$12 [29] if((signed word) bsearch16u::result#0!=(signed byte) 0) goto bsearch16u::@9
Simple Condition (bool~) bsearch16u::$0 [32] if(*((word*) bsearch16u::items#2)<=(word) bsearch16u::key#0) goto bsearch16u::@1
Simple Condition (bool~) bsearch16u::$14 [36] if((signed word) bsearch16u::result#0<=(signed byte) 0) goto bsearch16u::@10
Simple Condition (bool~) memset::$2 [66] if((byte*) memset::dst#1!=(byte*) memset::end#0) goto memset::@1
Simple Condition (bool~) init_squares::$5 [96] if((byte) init_squares::i#1!=rangelast(0,init_squares::$2)) goto init_squares::@1
Simple Condition (bool~) atan2_16::$0 [129] if((signed word) atan2_16::y#0>=(signed byte) 0) goto atan2_16::@1
Simple Condition (bool~) atan2_16::$5 [138] if((signed word) atan2_16::x#0>=(signed byte) 0) goto atan2_16::@4
Simple Condition (bool~) atan2_16::$18 [152] if((signed word) atan2_16::yi#3!=(signed byte) 0) goto atan2_16::@16
Simple Condition (bool~) atan2_16::$11 [161] if((signed word) atan2_16::x#17>=(signed byte) 0) goto atan2_16::@7
Simple Condition (bool~) atan2_16::$19 [164] if((byte) atan2_16::shift#2>=(byte) 2) goto atan2_16::@19
Simple Condition (bool~) atan2_16::$20 [172] if((byte) 0==(byte) atan2_16::shift#2) goto atan2_16::@25
Simple Condition (bool~) atan2_16::$21 [175] if((signed word) atan2_16::yi#3>=(signed byte) 0) goto atan2_16::@26
Simple Condition (bool~) atan2_16::$22 [192] if((byte) atan2_16::i#1!=rangelast(0,atan2_16::$16)) goto atan2_16::@15
Simple Condition (bool~) atan2_16::$14 [196] if((signed word) atan2_16::y#19>=(signed byte) 0) goto atan2_16::@8
Simple Condition (bool~) print_cls::$1 [225] if((byte*) print_cls::sc#1!=(byte*~) print_cls::$0) goto print_cls::@1
Simple Condition (bool~) doplasma::$3 [361] if((byte) doplasma::x#1!=rangelast(0,$27)) goto doplasma::@2
Simple Condition (bool~) doplasma::$4 [368] if((byte) doplasma::y#1!=rangelast(0,$19)) goto doplasma::@1
Simple Condition (bool~) init_angle_screen::$15 [417] if((byte) init_angle_screen::x#1<=(byte) $13) goto init_angle_screen::@2
Simple Condition (bool~) init_angle_screen::$16 [423] if((byte) init_angle_screen::y#1!=rangelast(0,$c)) goto init_angle_screen::@1
Simple Condition (bool~) init_dist_screen::$3 [439] if((byte) init_dist_screen::y2#0>=(byte) $18) goto init_dist_screen::@2
Simple Condition (bool~) init_dist_screen::$11 [460] if((byte) init_dist_screen::x2#0>=(byte) $27) goto init_dist_screen::@6
Simple Condition (bool~) init_dist_screen::$20 [490] if((byte) init_dist_screen::x#1<=(byte) $13) goto init_dist_screen::@5
Simple Condition (bool~) init_dist_screen::$21 [496] if((byte) init_dist_screen::y#1!=rangelast(0,$c)) goto init_dist_screen::@1
Simple Condition (bool~) make_plasma_charset::$6 [526] if((byte~) make_plasma_charset::$4<=(byte) make_plasma_charset::s#3) goto make_plasma_charset::@4
Simple Condition (bool~) make_plasma_charset::$7 [530] if((byte) make_plasma_charset::ii#1<(byte) 8) goto make_plasma_charset::@3
Simple Condition (bool~) make_plasma_charset::$10 [539] if((byte) make_plasma_charset::i#1<(byte) 8) goto make_plasma_charset::@2
Simple Condition (bool~) make_plasma_charset::$13 [544] if((byte~) make_plasma_charset::$11!=(byte) 0) goto make_plasma_charset::@9
Simple Condition (bool~) make_plasma_charset::$15 [548] if((word) make_plasma_charset::c#1<(word) $100) goto make_plasma_charset::@1
Successful SSA optimization Pass2ConditionalJumpSimplification
Negating conditional jump and destination [191] if((byte) atan2_16::i#1==rangelast(0,atan2_16::$16)) goto atan2_16::@17
Negating conditional jump and destination [192] if((byte) atan2_16::i#1==rangelast(0,atan2_16::$16)) goto atan2_16::@17
Successful SSA optimization Pass2ConditionalJumpSequenceImprovement
Constant right-side identified [44] (byte~) bsearch16u::$17 ← (byte) 1 * (const byte) SIZEOF_WORD
Constant right-side identified [51] (byte~) bsearch16u::$18 ← (byte) 1 * (const byte) SIZEOF_WORD
Constant right-side identified [502] (byte[8]) make_plasma_charset::bittab#0 ← { (byte) 1, (byte) 2, (byte) 4, (byte) 8, (byte) $10, (byte) $20, (byte) $40, (byte) $80 }
Constant right-side identified [45] (byte~) bsearch16u::$17 ← (byte) 1 * (const byte) SIZEOF_WORD
Constant right-side identified [52] (byte~) bsearch16u::$18 ← (byte) 1 * (const byte) SIZEOF_WORD
Constant right-side identified [503] (byte[8]) make_plasma_charset::bittab#0 ← { (byte) 1, (byte) 2, (byte) 4, (byte) 8, (byte) $10, (byte) $20, (byte) $40, (byte) $80 }
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant (const byte*) D018#0 = (byte*) 53272
Constant (const byte*) COLS#0 = (byte*) 55296
Constant (const byte) BLACK#0 = 0
Constant (const byte*) HEAP_START#0 = (byte*) 49152
Constant (const byte*) HEAP_TOP#0 = (byte*) 40960
Constant (const byte) bsearch16u::$17 = 1*SIZEOF_WORD
Constant (const byte) bsearch16u::$18 = 1*SIZEOF_WORD
Constant (const byte) NUM_SQUARES#0 = $ff
@ -3527,25 +3530,25 @@ Constant (const byte*) doplasma::screen#1 = SCREEN2#0
Constant (const byte*) main::toD0182_screen#0 = SCREEN2#0
Constant (const byte*) main::toD0182_gfx#0 = CHARSET#0
Successful SSA optimization Pass2ConstantIdentification
Constant value identified (void*)COLS#0 in [278] (void*) memset::str#0 ← (void*)(const byte*) COLS#0
Constant value identified (word)main::toD0181_screen#0 in [295] (word~) main::toD0181_$0#0 ← (word)(const byte*) main::toD0181_screen#0
Constant value identified (word)main::toD0181_gfx#0 in [299] (word~) main::toD0181_$4#0 ← (word)(const byte*) main::toD0181_gfx#0
Constant value identified (word)main::toD0182_screen#0 in [318] (word~) main::toD0182_$0#0 ← (word)(const byte*) main::toD0182_screen#0
Constant value identified (word)main::toD0182_gfx#0 in [322] (word~) main::toD0182_$4#0 ← (word)(const byte*) main::toD0182_gfx#0
Constant value identified (void*)COLS#0 in [279] (void*) memset::str#0 ← (void*)(const byte*) COLS#0
Constant value identified (word)main::toD0181_screen#0 in [296] (word~) main::toD0181_$0#0 ← (word)(const byte*) main::toD0181_screen#0
Constant value identified (word)main::toD0181_gfx#0 in [300] (word~) main::toD0181_$4#0 ← (word)(const byte*) main::toD0181_gfx#0
Constant value identified (word)main::toD0182_screen#0 in [319] (word~) main::toD0182_$0#0 ← (word)(const byte*) main::toD0182_screen#0
Constant value identified (word)main::toD0182_gfx#0 in [323] (word~) main::toD0182_$4#0 ← (word)(const byte*) main::toD0182_gfx#0
Successful SSA optimization Pass2ConstantValues
if() condition always true - replacing block destination [285] if(true) goto main::@2
if() condition always true - replacing block destination [286] if(true) goto main::@2
Successful SSA optimization Pass2ConstantIfs
Resolved ranged next value [358] doplasma::x#1 ← ++ doplasma::x#2 to ++
Resolved ranged comparison value [360] if(doplasma::x#1!=rangelast(0,$27)) goto doplasma::@2 to (number) $28
Resolved ranged next value [365] doplasma::y#1 ← ++ doplasma::y#4 to ++
Resolved ranged comparison value [367] if(doplasma::y#1!=rangelast(0,$19)) goto doplasma::@1 to (number) $1a
Resolved ranged next value [420] init_angle_screen::y#1 ← ++ init_angle_screen::y#4 to ++
Resolved ranged comparison value [422] if(init_angle_screen::y#1!=rangelast(0,$c)) goto init_angle_screen::@1 to (number) $d
Resolved ranged next value [493] init_dist_screen::y#1 ← ++ init_dist_screen::y#10 to ++
Resolved ranged comparison value [495] if(init_dist_screen::y#1!=rangelast(0,$c)) goto init_dist_screen::@1 to (number) $d
Rewriting conditional comparison [416] if((byte) init_angle_screen::x#1<=(byte) $13) goto init_angle_screen::@2
Rewriting conditional comparison [489] if((byte) init_dist_screen::x#1<=(byte) $13) goto init_dist_screen::@5
De-inlining pointer[w] to *(pointer+w) [535] *((byte*) make_plasma_charset::charset#6 + (word~) make_plasma_charset::$9) ← (byte) make_plasma_charset::b#3
Resolved ranged next value [359] doplasma::x#1 ← ++ doplasma::x#2 to ++
Resolved ranged comparison value [361] if(doplasma::x#1!=rangelast(0,$27)) goto doplasma::@2 to (number) $28
Resolved ranged next value [366] doplasma::y#1 ← ++ doplasma::y#4 to ++
Resolved ranged comparison value [368] if(doplasma::y#1!=rangelast(0,$19)) goto doplasma::@1 to (number) $1a
Resolved ranged next value [421] init_angle_screen::y#1 ← ++ init_angle_screen::y#4 to ++
Resolved ranged comparison value [423] if(init_angle_screen::y#1!=rangelast(0,$c)) goto init_angle_screen::@1 to (number) $d
Resolved ranged next value [494] init_dist_screen::y#1 ← ++ init_dist_screen::y#10 to ++
Resolved ranged comparison value [496] if(init_dist_screen::y#1!=rangelast(0,$c)) goto init_dist_screen::@1 to (number) $d
Rewriting conditional comparison [417] if((byte) init_angle_screen::x#1<=(byte) $13) goto init_angle_screen::@2
Rewriting conditional comparison [490] if((byte) init_dist_screen::x#1<=(byte) $13) goto init_dist_screen::@5
De-inlining pointer[w] to *(pointer+w) [536] *((byte*) make_plasma_charset::charset#6 + (word~) make_plasma_charset::$9) ← (byte) make_plasma_charset::b#3
Successful SSA optimization Pass2DeInlineWordDerefIdx
Eliminating unused variable (void*) memset::return#2 and assignment [130] (void*) memset::return#2 ← (void*) memset::str#0
Eliminating unused variable - keeping the phi block (byte*) heap_head#51
@ -3953,7 +3956,8 @@ Coalesced [342] init_squares::squares#4 ← init_squares::squares#0
Coalesced [352] init_squares::sqr#3 ← init_squares::sqr#1
Coalesced [353] init_squares::squares#3 ← init_squares::squares#1
Coalesced [354] init_squares::i#3 ← init_squares::i#1
Coalesced down to 45 phi equivalence classes
Not coalescing [357] heap_head#1 ← malloc::mem#0
Coalesced down to 46 phi equivalence classes
Culled Empty Block (label) @4
Culled Empty Block (label) @11
Culled Empty Block (label) @14
@ -4556,9 +4560,9 @@ init_squares::@return: scope:[init_squares] from init_squares::@1
to:@return
malloc: scope:[malloc] from @1 @3 init_squares
[255] (word) malloc::size#3 ← phi( @1/(word) $3e8 @3/(word) $3e8 init_squares/(const byte) NUM_SQUARES#3*(const byte) SIZEOF_WORD )
[255] (byte*) heap_head#12 ← phi( @1/(const byte*) HEAP_START#0 @3/(byte*) heap_head#1 init_squares/(byte*) heap_head#1 )
[256] (byte*) malloc::mem#0 ← (byte*) heap_head#12
[257] (byte*) heap_head#1 ← (byte*) heap_head#12 + (word) malloc::size#3
[255] (byte*) heap_head#12 ← phi( @1/(const byte*) HEAP_TOP#0 @3/(byte*) heap_head#1 init_squares/(byte*) heap_head#1 )
[256] (byte*) malloc::mem#0 ← (byte*) heap_head#12 - (word) malloc::size#3
[257] (byte*) heap_head#1 ← (byte*) malloc::mem#0
to:malloc::@return
malloc::@return: scope:[malloc] from malloc
[258] return
@ -4572,7 +4576,7 @@ VARIABLE REGISTER WEIGHTS
(word[CORDIC_ITERATIONS_16#0]) CORDIC_ATAN2_ANGLES_16
(byte) CORDIC_ITERATIONS_16
(byte*) D018
(byte*) HEAP_START
(byte*) HEAP_TOP
(byte) NUM_SQUARES
(byte*) SCREEN1
(byte*) SCREEN2
@ -4693,7 +4697,7 @@ VARIABLE REGISTER WEIGHTS
(byte) doplasma::y#4 22.444444444444443
(byte*) heap_head
(byte*) heap_head#1 0.6000000000000001
(byte*) heap_head#12 4.0
(byte*) heap_head#12 6.0
(void()) init_angle_screen((byte*) init_angle_screen::screen)
(word~) init_angle_screen::$10 202.0
(byte~) init_angle_screen::$12 202.0
@ -4833,10 +4837,10 @@ VARIABLE REGISTER WEIGHTS
(byte) make_plasma_charset::s#0 56.22222222222223
(void*()) malloc((word) malloc::size)
(byte*) malloc::mem
(byte*) malloc::mem#0 0.3333333333333333
(byte*) malloc::mem#0 0.6666666666666666
(void*) malloc::return
(word) malloc::size
(word) malloc::size#3 1.0
(word) malloc::size#3 2.0
(void*()) memset((void*) memset::str , (byte) memset::c , (word) memset::num)
(byte) memset::c
(byte*) memset::dst
@ -5210,8 +5214,8 @@ INITIAL ASM
.label COLS = $d800
// The colors of the C64
.const BLACK = 0
// Start of the heap used by malloc()
.label HEAP_START = $c000
// Top of the heap used by malloc()
.label HEAP_TOP = $a000
// The number of iterations performed during 16-bit CORDIC atan2 calculation
.const CORDIC_ITERATIONS_16 = $f
.label print_line_cursor = $400
@ -5251,10 +5255,10 @@ malloc_from_b1:
sta malloc.size
lda #>$3e8
sta malloc.size+1
// [255] phi (byte*) heap_head#12 = (const byte*) HEAP_START#0 [phi:@1->malloc#1] -- pbuz1=pbuc1
lda #<HEAP_START
// [255] phi (byte*) heap_head#12 = (const byte*) HEAP_TOP#0 [phi:@1->malloc#1] -- pbuz1=pbuc1
lda #<HEAP_TOP
sta heap_head
lda #>HEAP_START
lda #>HEAP_TOP
sta heap_head+1
jsr malloc
jmp b3
@ -7011,18 +7015,18 @@ init_squares: {
malloc: {
.label mem = $99
.label size = $40
// [256] (byte*) malloc::mem#0 ← (byte*) heap_head#12 -- pbuz1=pbuz2
// [256] (byte*) malloc::mem#0 ← (byte*) heap_head#12 - (word) malloc::size#3 -- pbuz1=pbuz2_minus_vwuz3
lda heap_head
sec
sbc size
sta mem
lda heap_head+1
sbc size+1
sta mem+1
// [257] (byte*) heap_head#1 ← (byte*) heap_head#12 + (word) malloc::size#3 -- pbuz1=pbuz1_plus_vwuz2
lda heap_head
clc
adc size
// [257] (byte*) heap_head#1 ← (byte*) malloc::mem#0 -- pbuz1=pbuz2
lda mem
sta heap_head
lda heap_head+1
adc size+1
lda mem+1
sta heap_head+1
jmp breturn
// malloc::@return
@ -7198,8 +7202,8 @@ Removing always clobbered register reg byte y as potential for zp ZP_BYTE:61 [ i
Statement [248] (word*) init_squares::squares#1 ← (word*) init_squares::squares#2 + (const byte) SIZEOF_WORD [ SQUARES#1 init_squares::sqr#2 init_squares::i#2 init_squares::squares#1 ] ( main:7::init_dist_screen:10::init_squares:171 [ SCREEN_DIST#0 SCREEN_ANGLE#0 init_dist_screen::screen#0 SQUARES#1 init_squares::sqr#2 init_squares::i#2 init_squares::squares#1 ] ) always clobbers reg byte a
Statement [249] (byte~) init_squares::$3 ← (byte) init_squares::i#2 << (byte) 1 [ SQUARES#1 init_squares::sqr#2 init_squares::i#2 init_squares::squares#1 init_squares::$3 ] ( main:7::init_dist_screen:10::init_squares:171 [ SCREEN_DIST#0 SCREEN_ANGLE#0 init_dist_screen::screen#0 SQUARES#1 init_squares::sqr#2 init_squares::i#2 init_squares::squares#1 init_squares::$3 ] ) always clobbers reg byte a
Statement [251] (word) init_squares::sqr#1 ← (word) init_squares::sqr#2 + (byte~) init_squares::$4 [ SQUARES#1 init_squares::i#2 init_squares::sqr#1 init_squares::squares#1 ] ( main:7::init_dist_screen:10::init_squares:171 [ SCREEN_DIST#0 SCREEN_ANGLE#0 init_dist_screen::screen#0 SQUARES#1 init_squares::i#2 init_squares::sqr#1 init_squares::squares#1 ] ) always clobbers reg byte a
Statement [256] (byte*) malloc::mem#0 ← (byte*) heap_head#12 [ malloc::mem#0 heap_head#12 malloc::size#3 ] ( malloc:2 [ malloc::mem#0 heap_head#12 malloc::size#3 ] malloc:4 [ malloc::mem#0 heap_head#12 malloc::size#3 ] main:7::init_dist_screen:10::init_squares:171::malloc:243 [ SCREEN_DIST#0 SCREEN_ANGLE#0 init_dist_screen::screen#0 malloc::mem#0 heap_head#12 malloc::size#3 ] ) always clobbers reg byte a
Statement [257] (byte*) heap_head#1 ← (byte*) heap_head#12 + (word) malloc::size#3 [ malloc::mem#0 heap_head#1 ] ( malloc:2 [ malloc::mem#0 heap_head#1 ] malloc:4 [ malloc::mem#0 heap_head#1 ] main:7::init_dist_screen:10::init_squares:171::malloc:243 [ SCREEN_DIST#0 SCREEN_ANGLE#0 init_dist_screen::screen#0 malloc::mem#0 heap_head#1 ] ) always clobbers reg byte a
Statement [256] (byte*) malloc::mem#0 ← (byte*) heap_head#12 - (word) malloc::size#3 [ malloc::mem#0 ] ( malloc:2 [ malloc::mem#0 ] malloc:4 [ malloc::mem#0 ] main:7::init_dist_screen:10::init_squares:171::malloc:243 [ SCREEN_DIST#0 SCREEN_ANGLE#0 init_dist_screen::screen#0 malloc::mem#0 ] ) always clobbers reg byte a
Statement [257] (byte*) heap_head#1 ← (byte*) malloc::mem#0 [ malloc::mem#0 heap_head#1 ] ( malloc:2 [ malloc::mem#0 heap_head#1 ] malloc:4 [ malloc::mem#0 heap_head#1 ] main:7::init_dist_screen:10::init_squares:171::malloc:243 [ SCREEN_DIST#0 SCREEN_ANGLE#0 init_dist_screen::screen#0 malloc::mem#0 heap_head#1 ] ) always clobbers reg byte a
Statement [3] (void*) SCREEN_DIST#0 ← (void*)(byte*) malloc::mem#0 [ SCREEN_DIST#0 heap_head#1 ] ( [ SCREEN_DIST#0 heap_head#1 ] ) always clobbers reg byte a
Statement [5] (void*) SCREEN_ANGLE#0 ← (void*)(byte*) malloc::mem#0 [ SCREEN_DIST#0 SCREEN_ANGLE#0 heap_head#1 ] ( [ SCREEN_DIST#0 SCREEN_ANGLE#0 heap_head#1 ] ) always clobbers reg byte a
Statement [9] (byte*) init_dist_screen::screen#0 ← (byte*)(void*) SCREEN_DIST#0 [ SCREEN_DIST#0 SCREEN_ANGLE#0 init_dist_screen::screen#0 heap_head#1 ] ( main:7 [ SCREEN_DIST#0 SCREEN_ANGLE#0 init_dist_screen::screen#0 heap_head#1 ] ) always clobbers reg byte a
@ -7324,8 +7328,8 @@ Statement [247] *((word*) init_squares::squares#2) ← (word) init_squares::sqr#
Statement [248] (word*) init_squares::squares#1 ← (word*) init_squares::squares#2 + (const byte) SIZEOF_WORD [ SQUARES#1 init_squares::sqr#2 init_squares::i#2 init_squares::squares#1 ] ( main:7::init_dist_screen:10::init_squares:171 [ SCREEN_DIST#0 SCREEN_ANGLE#0 init_dist_screen::screen#0 SQUARES#1 init_squares::sqr#2 init_squares::i#2 init_squares::squares#1 ] ) always clobbers reg byte a
Statement [249] (byte~) init_squares::$3 ← (byte) init_squares::i#2 << (byte) 1 [ SQUARES#1 init_squares::sqr#2 init_squares::i#2 init_squares::squares#1 init_squares::$3 ] ( main:7::init_dist_screen:10::init_squares:171 [ SCREEN_DIST#0 SCREEN_ANGLE#0 init_dist_screen::screen#0 SQUARES#1 init_squares::sqr#2 init_squares::i#2 init_squares::squares#1 init_squares::$3 ] ) always clobbers reg byte a
Statement [251] (word) init_squares::sqr#1 ← (word) init_squares::sqr#2 + (byte~) init_squares::$4 [ SQUARES#1 init_squares::i#2 init_squares::sqr#1 init_squares::squares#1 ] ( main:7::init_dist_screen:10::init_squares:171 [ SCREEN_DIST#0 SCREEN_ANGLE#0 init_dist_screen::screen#0 SQUARES#1 init_squares::i#2 init_squares::sqr#1 init_squares::squares#1 ] ) always clobbers reg byte a
Statement [256] (byte*) malloc::mem#0 ← (byte*) heap_head#12 [ malloc::mem#0 heap_head#12 malloc::size#3 ] ( malloc:2 [ malloc::mem#0 heap_head#12 malloc::size#3 ] malloc:4 [ malloc::mem#0 heap_head#12 malloc::size#3 ] main:7::init_dist_screen:10::init_squares:171::malloc:243 [ SCREEN_DIST#0 SCREEN_ANGLE#0 init_dist_screen::screen#0 malloc::mem#0 heap_head#12 malloc::size#3 ] ) always clobbers reg byte a
Statement [257] (byte*) heap_head#1 ← (byte*) heap_head#12 + (word) malloc::size#3 [ malloc::mem#0 heap_head#1 ] ( malloc:2 [ malloc::mem#0 heap_head#1 ] malloc:4 [ malloc::mem#0 heap_head#1 ] main:7::init_dist_screen:10::init_squares:171::malloc:243 [ SCREEN_DIST#0 SCREEN_ANGLE#0 init_dist_screen::screen#0 malloc::mem#0 heap_head#1 ] ) always clobbers reg byte a
Statement [256] (byte*) malloc::mem#0 ← (byte*) heap_head#12 - (word) malloc::size#3 [ malloc::mem#0 ] ( malloc:2 [ malloc::mem#0 ] malloc:4 [ malloc::mem#0 ] main:7::init_dist_screen:10::init_squares:171::malloc:243 [ SCREEN_DIST#0 SCREEN_ANGLE#0 init_dist_screen::screen#0 malloc::mem#0 ] ) always clobbers reg byte a
Statement [257] (byte*) heap_head#1 ← (byte*) malloc::mem#0 [ malloc::mem#0 heap_head#1 ] ( malloc:2 [ malloc::mem#0 heap_head#1 ] malloc:4 [ malloc::mem#0 heap_head#1 ] main:7::init_dist_screen:10::init_squares:171::malloc:243 [ SCREEN_DIST#0 SCREEN_ANGLE#0 init_dist_screen::screen#0 malloc::mem#0 heap_head#1 ] ) always clobbers reg byte a
Statement [3] (void*) SCREEN_DIST#0 ← (void*)(byte*) malloc::mem#0 [ SCREEN_DIST#0 heap_head#1 ] ( [ SCREEN_DIST#0 heap_head#1 ] ) always clobbers reg byte a
Statement [5] (void*) SCREEN_ANGLE#0 ← (void*)(byte*) malloc::mem#0 [ SCREEN_DIST#0 SCREEN_ANGLE#0 heap_head#1 ] ( [ SCREEN_DIST#0 SCREEN_ANGLE#0 heap_head#1 ] ) always clobbers reg byte a
Statement [9] (byte*) init_dist_screen::screen#0 ← (byte*)(void*) SCREEN_DIST#0 [ SCREEN_DIST#0 SCREEN_ANGLE#0 init_dist_screen::screen#0 heap_head#1 ] ( main:7 [ SCREEN_DIST#0 SCREEN_ANGLE#0 init_dist_screen::screen#0 heap_head#1 ] ) always clobbers reg byte a
@ -7449,8 +7453,8 @@ Statement [247] *((word*) init_squares::squares#2) ← (word) init_squares::sqr#
Statement [248] (word*) init_squares::squares#1 ← (word*) init_squares::squares#2 + (const byte) SIZEOF_WORD [ SQUARES#1 init_squares::sqr#2 init_squares::i#2 init_squares::squares#1 ] ( main:7::init_dist_screen:10::init_squares:171 [ SCREEN_DIST#0 SCREEN_ANGLE#0 init_dist_screen::screen#0 SQUARES#1 init_squares::sqr#2 init_squares::i#2 init_squares::squares#1 ] ) always clobbers reg byte a
Statement [249] (byte~) init_squares::$3 ← (byte) init_squares::i#2 << (byte) 1 [ SQUARES#1 init_squares::sqr#2 init_squares::i#2 init_squares::squares#1 init_squares::$3 ] ( main:7::init_dist_screen:10::init_squares:171 [ SCREEN_DIST#0 SCREEN_ANGLE#0 init_dist_screen::screen#0 SQUARES#1 init_squares::sqr#2 init_squares::i#2 init_squares::squares#1 init_squares::$3 ] ) always clobbers reg byte a
Statement [251] (word) init_squares::sqr#1 ← (word) init_squares::sqr#2 + (byte~) init_squares::$4 [ SQUARES#1 init_squares::i#2 init_squares::sqr#1 init_squares::squares#1 ] ( main:7::init_dist_screen:10::init_squares:171 [ SCREEN_DIST#0 SCREEN_ANGLE#0 init_dist_screen::screen#0 SQUARES#1 init_squares::i#2 init_squares::sqr#1 init_squares::squares#1 ] ) always clobbers reg byte a
Statement [256] (byte*) malloc::mem#0 ← (byte*) heap_head#12 [ malloc::mem#0 heap_head#12 malloc::size#3 ] ( malloc:2 [ malloc::mem#0 heap_head#12 malloc::size#3 ] malloc:4 [ malloc::mem#0 heap_head#12 malloc::size#3 ] main:7::init_dist_screen:10::init_squares:171::malloc:243 [ SCREEN_DIST#0 SCREEN_ANGLE#0 init_dist_screen::screen#0 malloc::mem#0 heap_head#12 malloc::size#3 ] ) always clobbers reg byte a
Statement [257] (byte*) heap_head#1 ← (byte*) heap_head#12 + (word) malloc::size#3 [ malloc::mem#0 heap_head#1 ] ( malloc:2 [ malloc::mem#0 heap_head#1 ] malloc:4 [ malloc::mem#0 heap_head#1 ] main:7::init_dist_screen:10::init_squares:171::malloc:243 [ SCREEN_DIST#0 SCREEN_ANGLE#0 init_dist_screen::screen#0 malloc::mem#0 heap_head#1 ] ) always clobbers reg byte a
Statement [256] (byte*) malloc::mem#0 ← (byte*) heap_head#12 - (word) malloc::size#3 [ malloc::mem#0 ] ( malloc:2 [ malloc::mem#0 ] malloc:4 [ malloc::mem#0 ] main:7::init_dist_screen:10::init_squares:171::malloc:243 [ SCREEN_DIST#0 SCREEN_ANGLE#0 init_dist_screen::screen#0 malloc::mem#0 ] ) always clobbers reg byte a
Statement [257] (byte*) heap_head#1 ← (byte*) malloc::mem#0 [ malloc::mem#0 heap_head#1 ] ( malloc:2 [ malloc::mem#0 heap_head#1 ] malloc:4 [ malloc::mem#0 heap_head#1 ] main:7::init_dist_screen:10::init_squares:171::malloc:243 [ SCREEN_DIST#0 SCREEN_ANGLE#0 init_dist_screen::screen#0 malloc::mem#0 heap_head#1 ] ) always clobbers reg byte a
Potential registers zp ZP_BYTE:2 [ sin_offset_x#10 sin_offset_x#14 sin_offset_x#12 ] : zp ZP_BYTE:2 ,
Potential registers zp ZP_BYTE:3 [ sin_offset_y#10 sin_offset_y#14 sin_offset_y#12 ] : zp ZP_BYTE:3 ,
Potential registers zp ZP_WORD:4 [ doplasma::angle#4 doplasma::angle#0 doplasma::angle#1 ] : zp ZP_WORD:4 ,
@ -7563,10 +7567,10 @@ Uplift Scope [init_dist_screen] 707: zp ZP_BYTE:52 [ init_dist_screen::xd#0 init
Uplift Scope [sqr] 338: zp ZP_BYTE:56 [ sqr::val#2 sqr::val#0 sqr::val#1 ] 202: zp ZP_WORD:119 [ sqr::return#3 ] 28.5: zp ZP_WORD:147 [ sqr::return#0 ] 22: zp ZP_WORD:114 [ sqr::return#2 ] 4: zp ZP_BYTE:146 [ sqr::$0 ]
Uplift Scope [sqrt] 202: zp ZP_BYTE:127 [ sqrt::return#2 ] 103: zp ZP_WORD:125 [ sqrt::val#0 ] 34.33: zp ZP_BYTE:139 [ sqrt::return#0 ] 4: zp ZP_WORD:133 [ sqrt::found#0 ] 4: zp ZP_WORD:135 [ sqrt::$3 ] 2: zp ZP_WORD:137 [ sqrt::$1 ]
Uplift Scope [init_squares] 25.17: zp ZP_WORD:59 [ init_squares::squares#2 init_squares::squares#1 init_squares::squares#0 ] 22: zp ZP_BYTE:61 [ init_squares::i#2 init_squares::i#1 ] 22: zp ZP_BYTE:151 [ init_squares::$3 ] 22: zp ZP_BYTE:152 [ init_squares::$4 ] 13.93: zp ZP_WORD:57 [ init_squares::sqr#2 init_squares::sqr#1 ]
Uplift Scope [] 16.42: zp ZP_WORD:16 [ print_char_cursor#49 print_char_cursor#18 print_char_cursor#1 ] 15.53: zp ZP_BYTE:3 [ sin_offset_y#10 sin_offset_y#14 sin_offset_y#12 ] 15.29: zp ZP_BYTE:2 [ sin_offset_x#10 sin_offset_x#14 sin_offset_x#12 ] 4.6: zp ZP_WORD:62 [ heap_head#12 heap_head#1 ] 0.05: zp ZP_WORD:68 [ SCREEN_ANGLE#0 ] 0.05: zp ZP_WORD:66 [ SCREEN_DIST#0 ] 0.03: zp ZP_WORD:149 [ SQUARES#1 ]
Uplift Scope [] 16.42: zp ZP_WORD:16 [ print_char_cursor#49 print_char_cursor#18 print_char_cursor#1 ] 15.53: zp ZP_BYTE:3 [ sin_offset_y#10 sin_offset_y#14 sin_offset_y#12 ] 15.29: zp ZP_BYTE:2 [ sin_offset_x#10 sin_offset_x#14 sin_offset_x#12 ] 6.6: zp ZP_WORD:62 [ heap_head#12 heap_head#1 ] 0.05: zp ZP_WORD:68 [ SCREEN_ANGLE#0 ] 0.05: zp ZP_WORD:66 [ SCREEN_DIST#0 ] 0.03: zp ZP_WORD:149 [ SQUARES#1 ]
Uplift Scope [memset] 33: zp ZP_WORD:12 [ memset::dst#2 memset::dst#1 ]
Uplift Scope [print_cls] 33: zp ZP_WORD:21 [ print_cls::sc#2 print_cls::sc#1 ]
Uplift Scope [malloc] 1: zp ZP_WORD:64 [ malloc::size#3 ] 0.33: zp ZP_WORD:153 [ malloc::mem#0 ]
Uplift Scope [malloc] 2: zp ZP_WORD:64 [ malloc::size#3 ] 0.67: zp ZP_WORD:153 [ malloc::mem#0 ]
Uplift Scope [print_char]
Uplift Scope [sid_rnd_init]
Uplift Scope [main]
@ -7633,6 +7637,7 @@ Uplifting [] best 1342544 combination zp ZP_BYTE:2 [ sin_offset_x#10 sin_offset_
Coalescing zero page register with common assignment [ zp ZP_WORD:24 [ init_angle_screen::screen_bottomline#5 init_angle_screen::screen_bottomline#0 init_angle_screen::screen_bottomline#1 ] ] with [ zp ZP_WORD:70 [ init_angle_screen::screen#0 ] ] - score: 1
Coalescing zero page register with common assignment [ zp ZP_WORD:35 [ atan2_16::angle#6 atan2_16::angle#12 atan2_16::angle#13 atan2_16::angle#2 atan2_16::angle#3 ] ] with [ zp ZP_WORD:37 [ atan2_16::return#0 atan2_16::angle#5 atan2_16::angle#11 atan2_16::angle#1 atan2_16::angle#4 ] ] - score: 1
Coalescing zero page register with common assignment [ zp ZP_WORD:53 [ bsearch16u::return#1 bsearch16u::return#6 bsearch16u::return#2 bsearch16u::items#2 bsearch16u::items#1 bsearch16u::items#8 bsearch16u::$2 bsearch16u::items#0 ] ] with [ zp ZP_WORD:131 [ bsearch16u::return#3 ] ] - score: 1
Coalescing zero page register with common assignment [ zp ZP_WORD:64 [ malloc::size#3 ] ] with [ zp ZP_WORD:153 [ malloc::mem#0 ] ] - score: 1
Coalescing zero page register with common assignment [ zp ZP_WORD:82 [ make_plasma_charset::$8 ] ] with [ zp ZP_WORD:84 [ make_plasma_charset::$9 ] ] - score: 1
Coalescing zero page register with common assignment [ zp ZP_WORD:92 [ init_angle_screen::xw#0 ] ] with [ zp ZP_WORD:97 [ atan2_16::x#0 ] ] - score: 1
Coalescing zero page register with common assignment [ zp ZP_WORD:95 [ init_angle_screen::yw#0 ] ] with [ zp ZP_WORD:99 [ atan2_16::y#0 ] ] - score: 1
@ -7642,9 +7647,9 @@ Coalescing zero page register with common assignment [ zp ZP_WORD:119 [ sqr::ret
Coalescing zero page register with common assignment [ zp ZP_WORD:119 [ sqr::return#3 init_dist_screen::xds#0 ] ] with [ zp ZP_WORD:147 [ sqr::return#0 ] ] - score: 1
Coalescing zero page register with common assignment [ zp ZP_WORD:123 [ init_dist_screen::ds#0 ] ] with [ zp ZP_WORD:125 [ sqrt::val#0 ] ] - score: 1
Coalescing zero page register with common assignment [ zp ZP_WORD:133 [ sqrt::found#0 ] ] with [ zp ZP_WORD:135 [ sqrt::$3 ] ] - score: 1
Coalescing zero page register with common assignment [ zp ZP_WORD:149 [ SQUARES#1 ] ] with [ zp ZP_WORD:153 [ malloc::mem#0 ] ] - score: 1
Coalescing zero page register with common assignment [ zp ZP_WORD:35 [ atan2_16::angle#6 atan2_16::angle#12 atan2_16::angle#13 atan2_16::angle#2 atan2_16::angle#3 atan2_16::return#0 atan2_16::angle#5 atan2_16::angle#11 atan2_16::angle#1 atan2_16::angle#4 ] ] with [ zp ZP_WORD:101 [ atan2_16::return#2 init_angle_screen::angle_w#0 ] ] - score: 1
Coalescing zero page register with common assignment [ zp ZP_WORD:53 [ bsearch16u::return#1 bsearch16u::return#6 bsearch16u::return#2 bsearch16u::items#2 bsearch16u::items#1 bsearch16u::items#8 bsearch16u::$2 bsearch16u::items#0 bsearch16u::return#3 ] ] with [ zp ZP_WORD:133 [ sqrt::found#0 sqrt::$3 ] ] - score: 1
Coalescing zero page register with common assignment [ zp ZP_WORD:64 [ malloc::size#3 malloc::mem#0 ] ] with [ zp ZP_WORD:149 [ SQUARES#1 ] ] - score: 1
Coalescing zero page register with common assignment [ zp ZP_WORD:82 [ make_plasma_charset::$8 make_plasma_charset::$9 ] ] with [ zp ZP_WORD:86 [ make_plasma_charset::$16 ] ] - score: 1
Coalescing zero page register with common assignment [ zp ZP_WORD:119 [ sqr::return#3 init_dist_screen::xds#0 sqr::return#0 ] ] with [ zp ZP_WORD:123 [ init_dist_screen::ds#0 sqrt::val#0 ] ] - score: 1
Coalescing zero page register with common assignment [ zp ZP_WORD:35 [ atan2_16::angle#6 atan2_16::angle#12 atan2_16::angle#13 atan2_16::angle#2 atan2_16::angle#3 atan2_16::return#0 atan2_16::angle#5 atan2_16::angle#11 atan2_16::angle#1 atan2_16::angle#4 atan2_16::return#2 init_angle_screen::angle_w#0 ] ] with [ zp ZP_WORD:105 [ init_angle_screen::$10 ] ] - score: 1
@ -7674,7 +7679,7 @@ Allocated (was zp ZP_WORD:53) zp ZP_WORD:44 [ bsearch16u::return#1 bsearch16u::r
Allocated (was zp ZP_WORD:57) zp ZP_WORD:46 [ init_squares::sqr#2 init_squares::sqr#1 ]
Allocated (was zp ZP_WORD:59) zp ZP_WORD:48 [ init_squares::squares#2 init_squares::squares#1 init_squares::squares#0 ]
Allocated (was zp ZP_WORD:62) zp ZP_WORD:50 [ heap_head#12 heap_head#1 ]
Allocated (was zp ZP_WORD:64) zp ZP_WORD:52 [ malloc::size#3 ]
Allocated (was zp ZP_WORD:64) zp ZP_WORD:52 [ malloc::size#3 malloc::mem#0 SQUARES#1 ]
Allocated (was zp ZP_WORD:66) zp ZP_WORD:54 [ SCREEN_DIST#0 ]
Allocated (was zp ZP_WORD:68) zp ZP_WORD:56 [ SCREEN_ANGLE#0 ]
Allocated (was zp ZP_WORD:72) zp ZP_WORD:58 [ doplasma::sin_x#0 ]
@ -7689,7 +7694,6 @@ Allocated (was zp ZP_WORD:114) zp ZP_WORD:71 [ sqr::return#2 init_dist_screen::y
Allocated (was zp ZP_WORD:119) zp ZP_WORD:73 [ sqr::return#3 init_dist_screen::xds#0 sqr::return#0 init_dist_screen::ds#0 sqrt::val#0 bsearch16u::key#0 ]
Allocated (was zp ZP_WORD:142) zp ZP_WORD:75 [ bsearch16u::pivot#0 ]
Allocated (was zp ZP_WORD:144) zp ZP_WORD:77 [ bsearch16u::result#0 ]
Allocated (was zp ZP_WORD:149) zp ZP_WORD:79 [ SQUARES#1 malloc::mem#0 ]
ASSEMBLER BEFORE OPTIMIZATION
// File Comments
@ -7705,8 +7709,8 @@ ASSEMBLER BEFORE OPTIMIZATION
.label COLS = $d800
// The colors of the C64
.const BLACK = 0
// Start of the heap used by malloc()
.label HEAP_START = $c000
// Top of the heap used by malloc()
.label HEAP_TOP = $a000
// The number of iterations performed during 16-bit CORDIC atan2 calculation
.const CORDIC_ITERATIONS_16 = $f
.label print_line_cursor = $400
@ -7723,7 +7727,7 @@ ASSEMBLER BEFORE OPTIMIZATION
.label SCREEN2 = $2c00
.const NUM_SQUARES = $30
.label heap_head = $32
.label SQUARES = $4f
.label SQUARES = $34
.label print_char_cursor = $f
// Screen containing distance to center
.label SCREEN_DIST = $36
@ -7746,10 +7750,10 @@ malloc_from_b1:
sta malloc.size
lda #>$3e8
sta malloc.size+1
// [255] phi (byte*) heap_head#12 = (const byte*) HEAP_START#0 [phi:@1->malloc#1] -- pbuz1=pbuc1
lda #<HEAP_START
// [255] phi (byte*) heap_head#12 = (const byte*) HEAP_TOP#0 [phi:@1->malloc#1] -- pbuz1=pbuc1
lda #<HEAP_TOP
sta heap_head
lda #>HEAP_START
lda #>HEAP_TOP
sta heap_head+1
jsr malloc
jmp b3
@ -9340,20 +9344,20 @@ init_squares: {
// The content of the newly allocated block of memory is not initialized, remaining with indeterminate values.
// malloc(word zeropage($34) size)
malloc: {
.label mem = $4f
.label mem = $34
.label size = $34
// [256] (byte*) malloc::mem#0 ← (byte*) heap_head#12 -- pbuz1=pbuz2
// [256] (byte*) malloc::mem#0 ← (byte*) heap_head#12 - (word) malloc::size#3 -- pbuz1=pbuz2_minus_vwuz1
lda heap_head
sec
sbc mem
sta mem
lda heap_head+1
sbc mem+1
sta mem+1
// [257] (byte*) heap_head#1 ← (byte*) heap_head#12 + (word) malloc::size#3 -- pbuz1=pbuz1_plus_vwuz2
lda heap_head
clc
adc size
// [257] (byte*) heap_head#1 ← (byte*) malloc::mem#0 -- pbuz1=pbuz2
lda mem
sta heap_head
lda heap_head+1
adc size+1
lda mem+1
sta heap_head+1
jmp breturn
// malloc::@return
@ -9695,8 +9699,8 @@ FINAL SYMBOL TABLE
(const byte) CORDIC_ITERATIONS_16#0 CORDIC_ITERATIONS_16 = (byte) $f
(byte*) D018
(const byte*) D018#0 D018 = (byte*) 53272
(byte*) HEAP_START
(const byte*) HEAP_START#0 HEAP_START = (byte*) 49152
(byte*) HEAP_TOP
(const byte*) HEAP_TOP#0 HEAP_TOP = (byte*) 40960
(byte) NUM_SQUARES
(const byte) NUM_SQUARES#3 NUM_SQUARES = (byte) $30
(byte*) SCREEN1
@ -9721,7 +9725,7 @@ FINAL SYMBOL TABLE
}}
(const byte) SIZEOF_WORD SIZEOF_WORD = (byte) 2
(word*) SQUARES
(void*) SQUARES#1 SQUARES zp ZP_WORD:79 0.03225806451612903
(void*) SQUARES#1 SQUARES zp ZP_WORD:52 0.03225806451612903
(word()) atan2_16((signed word) atan2_16::x , (signed word) atan2_16::y)
(signed word~) atan2_16::$2 $2 zp ZP_WORD:27 4.0
(byte~) atan2_16::$23 reg byte a 2002.0
@ -9865,7 +9869,7 @@ FINAL SYMBOL TABLE
(byte) doplasma::y#4 y zp ZP_BYTE:10 22.444444444444443
(byte*) heap_head
(byte*) heap_head#1 heap_head zp ZP_WORD:50 0.6000000000000001
(byte*) heap_head#12 heap_head zp ZP_WORD:50 4.0
(byte*) heap_head#12 heap_head zp ZP_WORD:50 6.0
(void()) init_angle_screen((byte*) init_angle_screen::screen)
(word~) init_angle_screen::$10 $10 zp ZP_WORD:31 202.0
(byte~) init_angle_screen::$12 reg byte a 202.0
@ -10052,10 +10056,10 @@ FINAL SYMBOL TABLE
(void*()) malloc((word) malloc::size)
(label) malloc::@return
(byte*) malloc::mem
(byte*) malloc::mem#0 mem zp ZP_WORD:79 0.3333333333333333
(byte*) malloc::mem#0 mem zp ZP_WORD:52 0.6666666666666666
(void*) malloc::return
(word) malloc::size
(word) malloc::size#3 size zp ZP_WORD:52 1.0
(word) malloc::size#3 size zp ZP_WORD:52 2.0
(void*()) memset((void*) memset::str , (byte) memset::c , (word) memset::num)
(label) memset::@1
(label) memset::@return
@ -10167,7 +10171,7 @@ zp ZP_WORD:46 [ init_squares::sqr#2 init_squares::sqr#1 ]
zp ZP_WORD:48 [ init_squares::squares#2 init_squares::squares#1 init_squares::squares#0 ]
reg byte x [ init_squares::i#2 init_squares::i#1 ]
zp ZP_WORD:50 [ heap_head#12 heap_head#1 ]
zp ZP_WORD:52 [ malloc::size#3 ]
zp ZP_WORD:52 [ malloc::size#3 malloc::mem#0 SQUARES#1 ]
zp ZP_WORD:54 [ SCREEN_DIST#0 ]
zp ZP_WORD:56 [ SCREEN_ANGLE#0 ]
zp ZP_WORD:58 [ doplasma::sin_x#0 ]
@ -10204,7 +10208,6 @@ reg byte a [ bsearch16u::$16 ]
zp ZP_WORD:75 [ bsearch16u::pivot#0 ]
zp ZP_WORD:77 [ bsearch16u::result#0 ]
reg byte a [ sqr::$0 ]
zp ZP_WORD:79 [ SQUARES#1 malloc::mem#0 ]
reg byte a [ init_squares::$3 ]
reg byte a [ init_squares::$4 ]
@ -10225,8 +10228,8 @@ Score: 1206726
.label COLS = $d800
// The colors of the C64
.const BLACK = 0
// Start of the heap used by malloc()
.label HEAP_START = $c000
// Top of the heap used by malloc()
.label HEAP_TOP = $a000
// The number of iterations performed during 16-bit CORDIC atan2 calculation
.const CORDIC_ITERATIONS_16 = $f
.label print_line_cursor = $400
@ -10243,7 +10246,7 @@ Score: 1206726
.label SCREEN2 = $2c00
.const NUM_SQUARES = $30
.label heap_head = $32
.label SQUARES = $4f
.label SQUARES = $34
.label print_char_cursor = $f
// Screen containing distance to center
.label SCREEN_DIST = $36
@ -10263,10 +10266,10 @@ bbegin:
sta malloc.size
lda #>$3e8
sta malloc.size+1
// [255] phi (byte*) heap_head#12 = (const byte*) HEAP_START#0 [phi:@1->malloc#1] -- pbuz1=pbuc1
lda #<HEAP_START
// [255] phi (byte*) heap_head#12 = (const byte*) HEAP_TOP#0 [phi:@1->malloc#1] -- pbuz1=pbuc1
lda #<HEAP_TOP
sta heap_head
lda #>HEAP_START
lda #>HEAP_TOP
sta heap_head+1
jsr malloc
// @3
@ -11776,22 +11779,22 @@ init_squares: {
// The content of the newly allocated block of memory is not initialized, remaining with indeterminate values.
// malloc(word zeropage($34) size)
malloc: {
.label mem = $4f
.label mem = $34
.label size = $34
// mem = heap_head
// [256] (byte*) malloc::mem#0 ← (byte*) heap_head#12 -- pbuz1=pbuz2
// mem = heap_head-size
// [256] (byte*) malloc::mem#0 ← (byte*) heap_head#12 - (word) malloc::size#3 -- pbuz1=pbuz2_minus_vwuz1
lda heap_head
sec
sbc mem
sta mem
lda heap_head+1
sbc mem+1
sta mem+1
// heap_head+= size
// [257] (byte*) heap_head#1 ← (byte*) heap_head#12 + (word) malloc::size#3 -- pbuz1=pbuz1_plus_vwuz2
lda heap_head
clc
adc size
// heap_head = mem
// [257] (byte*) heap_head#1 ← (byte*) malloc::mem#0 -- pbuz1=pbuz2
lda mem
sta heap_head
lda heap_head+1
adc size+1
lda mem+1
sta heap_head+1
// malloc::@return
// }

View File

@ -18,8 +18,8 @@
(const byte) CORDIC_ITERATIONS_16#0 CORDIC_ITERATIONS_16 = (byte) $f
(byte*) D018
(const byte*) D018#0 D018 = (byte*) 53272
(byte*) HEAP_START
(const byte*) HEAP_START#0 HEAP_START = (byte*) 49152
(byte*) HEAP_TOP
(const byte*) HEAP_TOP#0 HEAP_TOP = (byte*) 40960
(byte) NUM_SQUARES
(const byte) NUM_SQUARES#3 NUM_SQUARES = (byte) $30
(byte*) SCREEN1
@ -44,7 +44,7 @@
}}
(const byte) SIZEOF_WORD SIZEOF_WORD = (byte) 2
(word*) SQUARES
(void*) SQUARES#1 SQUARES zp ZP_WORD:79 0.03225806451612903
(void*) SQUARES#1 SQUARES zp ZP_WORD:52 0.03225806451612903
(word()) atan2_16((signed word) atan2_16::x , (signed word) atan2_16::y)
(signed word~) atan2_16::$2 $2 zp ZP_WORD:27 4.0
(byte~) atan2_16::$23 reg byte a 2002.0
@ -188,7 +188,7 @@
(byte) doplasma::y#4 y zp ZP_BYTE:10 22.444444444444443
(byte*) heap_head
(byte*) heap_head#1 heap_head zp ZP_WORD:50 0.6000000000000001
(byte*) heap_head#12 heap_head zp ZP_WORD:50 4.0
(byte*) heap_head#12 heap_head zp ZP_WORD:50 6.0
(void()) init_angle_screen((byte*) init_angle_screen::screen)
(word~) init_angle_screen::$10 $10 zp ZP_WORD:31 202.0
(byte~) init_angle_screen::$12 reg byte a 202.0
@ -375,10 +375,10 @@
(void*()) malloc((word) malloc::size)
(label) malloc::@return
(byte*) malloc::mem
(byte*) malloc::mem#0 mem zp ZP_WORD:79 0.3333333333333333
(byte*) malloc::mem#0 mem zp ZP_WORD:52 0.6666666666666666
(void*) malloc::return
(word) malloc::size
(word) malloc::size#3 size zp ZP_WORD:52 1.0
(word) malloc::size#3 size zp ZP_WORD:52 2.0
(void*()) memset((void*) memset::str , (byte) memset::c , (word) memset::num)
(label) memset::@1
(label) memset::@return
@ -490,7 +490,7 @@ zp ZP_WORD:46 [ init_squares::sqr#2 init_squares::sqr#1 ]
zp ZP_WORD:48 [ init_squares::squares#2 init_squares::squares#1 init_squares::squares#0 ]
reg byte x [ init_squares::i#2 init_squares::i#1 ]
zp ZP_WORD:50 [ heap_head#12 heap_head#1 ]
zp ZP_WORD:52 [ malloc::size#3 ]
zp ZP_WORD:52 [ malloc::size#3 malloc::mem#0 SQUARES#1 ]
zp ZP_WORD:54 [ SCREEN_DIST#0 ]
zp ZP_WORD:56 [ SCREEN_ANGLE#0 ]
zp ZP_WORD:58 [ doplasma::sin_x#0 ]
@ -527,6 +527,5 @@ reg byte a [ bsearch16u::$16 ]
zp ZP_WORD:75 [ bsearch16u::pivot#0 ]
zp ZP_WORD:77 [ bsearch16u::result#0 ]
reg byte a [ sqr::$0 ]
zp ZP_WORD:79 [ SQUARES#1 malloc::mem#0 ]
reg byte a [ init_squares::$3 ]
reg byte a [ init_squares::$4 ]

View File

@ -6,7 +6,7 @@ Fixing pointer addition (word*~) bsearch16u::$1 ← (word*) bsearch16u::items -
Fixing pointer array-indexing *((word[CORDIC_ITERATIONS_16]) CORDIC_ATAN2_ANGLES_16 + (byte) atan2_16::i)
Fixing pointer array-indexing *((word[CORDIC_ITERATIONS_16]) CORDIC_ATAN2_ANGLES_16 + (byte) atan2_16::i)
Warning! Adding boolean cast to non-boolean sub-expression (byte) atan2_16::shift
Identified constant variable (byte*) HEAP_START
Identified constant variable (byte*) HEAP_TOP
Identified constant variable (byte*) main::BASE_SCREEN
Identified constant variable (byte*) main::BASE_CHARSET
Inlined call (byte~) vicSelectGfxBank::$0 ← call toDd00 (byte*) vicSelectGfxBank::gfx

View File

@ -3,8 +3,8 @@
:BasicUpstart(main)
.pc = $80d "Program"
.const SIZEOF_WORD = 2
// Start of the heap used by malloc()
.label HEAP_START = $c000
// Top of the heap used by malloc()
.label HEAP_TOP = $a000
.label D018 = $d018
// CIA #2 Timer A+B Value (32-bit)
.label CIA2_TIMER_AB = $dd04
@ -426,7 +426,9 @@ init_squares: {
// Allocates a block of size bytes of memory, returning a pointer to the beginning of the block.
// The content of the newly allocated block of memory is not initialized, remaining with indeterminate values.
malloc: {
.label return = HEAP_START
.const size = NUM_SQUARES*SIZEOF_WORD
.label mem = HEAP_TOP-size
.label return = mem
rts
}
// Reset & start the processor clock time. The value can be read using clock().

View File

@ -6,7 +6,7 @@ Fixing pointer addition (word*~) bsearch16u::$1 ← (word*) bsearch16u::items -
Fixing pointer increment (word*) init_squares::squares ← ++ (word*) init_squares::squares
Fixing pointer addition (word~) sqrt::$1 ← (word*) sqrt::found - (word*) SQUARES
Fixing pointer array-indexing *((word*) SQUARES + (byte) sqr::val)
Identified constant variable (byte*) HEAP_START
Identified constant variable (byte*) HEAP_TOP
Identified constant variable (byte*) main::BASE_SCREEN
Identified constant variable (byte*) main::BASE_CHARSET
Inlined call (byte~) vicSelectGfxBank::$0 ← call toDd00 (byte*) vicSelectGfxBank::gfx
@ -65,14 +65,15 @@ Culled Empty Block (label) init_dist_screen::@12
CONTROL FLOW GRAPH SSA
@begin: scope:[] from
(byte*) HEAP_START#0 ← ((byte*)) (number) $c000
(byte*) heap_head#0 ← (byte*) HEAP_START#0
(byte*) HEAP_TOP#0 ← ((byte*)) (number) $a000
(byte*) heap_head#0 ← (byte*) HEAP_TOP#0
to:@3
malloc: scope:[malloc] from init_squares
(word) malloc::size#1 ← phi( init_squares/(word) malloc::size#0 )
(byte*) heap_head#10 ← phi( init_squares/(byte*) heap_head#19 )
(byte*) malloc::mem#0 ← (byte*) heap_head#10
(byte*) heap_head#1 ← (byte*) heap_head#10 + (word) malloc::size#1
(byte*~) malloc::$0 ← (byte*) heap_head#10 - (word) malloc::size#1
(byte*) malloc::mem#0 ← (byte*~) malloc::$0
(byte*) heap_head#1 ← (byte*) malloc::mem#0
(void*) malloc::return#0 ← ((void*)) (byte*) malloc::mem#0
to:malloc::@return
malloc::@return: scope:[malloc] from malloc
@ -830,8 +831,8 @@ SYMBOL TABLE SSA
(byte*) D018#0
(byte[]) FONT_HEX_PROTO
(byte[]) FONT_HEX_PROTO#0
(byte*) HEAP_START
(byte*) HEAP_START#0
(byte*) HEAP_TOP
(byte*) HEAP_TOP#0
(byte) NUM_SQUARES
(byte) NUM_SQUARES#0
(byte) NUM_SQUARES#1
@ -1368,6 +1369,7 @@ SYMBOL TABLE SSA
(byte*) main::toD0182_screen#0
(byte*) main::toD0182_screen#1
(void*()) malloc((word) malloc::size)
(byte*~) malloc::$0
(label) malloc::@return
(byte*) malloc::mem
(byte*) malloc::mem#0
@ -1583,7 +1585,7 @@ Adding number conversion cast (unumber) $28 in (byte*) init_dist_screen::screen_
Successful SSA optimization PassNAddNumberTypeConversions
Adding number conversion cast (byte) to elements in (byte[]) FONT_HEX_PROTO#0 ← { (byte)(number) 2, (byte)(number) 5, (byte)(number) 5, (byte)(number) 5, (byte)(number) 2, (byte)(number) 6, (byte)(number) 2, (byte)(number) 2, (byte)(number) 2, (byte)(number) 7, (byte)(number) 6, (byte)(number) 1, (byte)(number) 2, (byte)(number) 4, (byte)(number) 7, (byte)(number) 6, (byte)(number) 1, (byte)(number) 2, (byte)(number) 1, (byte)(number) 6, (byte)(number) 5, (byte)(number) 5, (byte)(number) 7, (byte)(number) 1, (byte)(number) 1, (byte)(number) 7, (byte)(number) 4, (byte)(number) 6, (byte)(number) 1, (byte)(number) 6, (byte)(number) 3, (byte)(number) 4, (byte)(number) 6, (byte)(number) 5, (byte)(number) 2, (byte)(number) 7, (byte)(number) 1, (byte)(number) 1, (byte)(number) 1, (byte)(number) 1, (byte)(number) 2, (byte)(number) 5, (byte)(number) 2, (byte)(number) 5, (byte)(number) 2, (byte)(number) 2, (byte)(number) 5, (byte)(number) 3, (byte)(number) 1, (byte)(number) 1, (byte)(number) 2, (byte)(number) 5, (byte)(number) 7, (byte)(number) 5, (byte)(number) 5, (byte)(number) 6, (byte)(number) 5, (byte)(number) 6, (byte)(number) 5, (byte)(number) 6, (byte)(number) 2, (byte)(number) 5, (byte)(number) 4, (byte)(number) 5, (byte)(number) 2, (byte)(number) 6, (byte)(number) 5, (byte)(number) 5, (byte)(number) 5, (byte)(number) 6, (byte)(number) 7, (byte)(number) 4, (byte)(number) 6, (byte)(number) 4, (byte)(number) 7, (byte)(number) 7, (byte)(number) 4, (byte)(number) 6, (byte)(number) 4, (byte)(number) 4 }
Successful SSA optimization PassNAddArrayNumberTypeConversions
Inlining cast (byte*) HEAP_START#0 ← (byte*)(number) $c000
Inlining cast (byte*) HEAP_TOP#0 ← (byte*)(number) $a000
Inlining cast (void*) malloc::return#0 ← (void*)(byte*) malloc::mem#0
Inlining cast (signed word~) bsearch16u::$8 ← (signed word)(word) bsearch16u::key#1
Inlining cast (signed word~) bsearch16u::$9 ← (signed word)*((word*) bsearch16u::pivot#0)
@ -1618,7 +1620,7 @@ Inlining cast (byte) NUM_SQUARES#3 ← (unumber)(number) $30
Inlining cast (byte) init_dist_screen::x#0 ← (unumber)(number) 0
Inlining cast (byte) init_dist_screen::xb#0 ← (unumber)(number) $27
Successful SSA optimization Pass2InlineCast
Simplifying constant pointer cast (byte*) 49152
Simplifying constant pointer cast (byte*) 40960
Simplifying constant integer cast 0
Simplifying constant integer cast 1
Simplifying constant integer cast 0
@ -1852,10 +1854,11 @@ Inferred type updated to byte in (unumber~) init_dist_screen::$15 ← (byte~) in
Inferred type updated to byte in (unumber~) init_dist_screen::$12 ← (byte) $27 - (byte) init_dist_screen::x2#2
Inferred type updated to byte in (unumber~) init_dist_screen::$13 ← (byte~) init_dist_screen::$12
Inferred type updated to byte for (unumber~) init_dist_screen::$16
Inversing boolean not [24] (bool~) bsearch16u::$12 ← (signed word) bsearch16u::result#0 != (signed byte) 0 from [23] (bool~) bsearch16u::$11 ← (signed word) bsearch16u::result#0 == (signed byte) 0
Inversing boolean not [31] (bool~) bsearch16u::$14 ← (signed word) bsearch16u::result#1 <= (signed byte) 0 from [30] (bool~) bsearch16u::$13 ← (signed word) bsearch16u::result#1 > (signed byte) 0
Inversing boolean not [25] (bool~) bsearch16u::$12 ← (signed word) bsearch16u::result#0 != (signed byte) 0 from [24] (bool~) bsearch16u::$11 ← (signed word) bsearch16u::result#0 == (signed byte) 0
Inversing boolean not [32] (bool~) bsearch16u::$14 ← (signed word) bsearch16u::result#1 <= (signed byte) 0 from [31] (bool~) bsearch16u::$13 ← (signed word) bsearch16u::result#1 > (signed byte) 0
Successful SSA optimization Pass2UnaryNotSimplification
Alias (byte*) HEAP_START#0 = (byte*) heap_head#0 (byte*) heap_head#43 (byte*) heap_head#38 (byte*) heap_head#34 (byte*) heap_head#30 (byte*) heap_head#29 (byte*) heap_head#25
Alias (byte*) HEAP_TOP#0 = (byte*) heap_head#0 (byte*) heap_head#43 (byte*) heap_head#38 (byte*) heap_head#34 (byte*) heap_head#30 (byte*) heap_head#29 (byte*) heap_head#25
Alias (byte*) malloc::mem#0 = (byte*~) malloc::$0
Alias (void*) malloc::return#0 = (void*) malloc::return#3 (void*) malloc::return#1
Alias (byte*) heap_head#1 = (byte*) heap_head#11 (byte*) heap_head#2
Alias (byte) bsearch16u::num#3 = (byte) bsearch16u::num#4 (byte) bsearch16u::num#8 (byte) bsearch16u::num#6
@ -2025,7 +2028,7 @@ Identical Phi Values (byte) init_font_hex::c#2 (byte) init_font_hex::c#5
Identical Phi Values (dword) print_dword_at::dw#1 (dword) print_dword_at::dw#0
Identical Phi Values (byte*) print_dword_at::at#1 (byte*) print_dword_at::at#0
Identical Phi Values (byte) NUM_SQUARES#14 (byte) NUM_SQUARES#0
Identical Phi Values (byte*) heap_head#21 (byte*) HEAP_START#0
Identical Phi Values (byte*) heap_head#21 (byte*) HEAP_TOP#0
Identical Phi Values (word*) SQUARES#21 (word*) SQUARES#0
Identical Phi Values (byte) NUM_SQUARES#1 (byte) NUM_SQUARES#11
Identical Phi Values (byte*) heap_head#14 (byte*) heap_head#17
@ -2048,27 +2051,27 @@ Identical Phi Values (word*) SQUARES#16 (word*) SQUARES#12
Successful SSA optimization Pass2IdenticalPhiElimination
Identical Phi Values (word*) SQUARES#9 (word*) SQUARES#18
Successful SSA optimization Pass2IdenticalPhiElimination
Identified duplicate assignment right side [162] (byte~) clock_start::$2 ← (byte) CIA_TIMER_CONTROL_STOP#0 | (byte) CIA_TIMER_CONTROL_CONTINUOUS#0
Identified duplicate assignment right side [169] (byte~) clock_start::$6 ← (byte) CIA_TIMER_CONTROL_START#0 | (byte) CIA_TIMER_CONTROL_CONTINUOUS#0
Identified duplicate assignment right side [163] (byte~) clock_start::$2 ← (byte) CIA_TIMER_CONTROL_STOP#0 | (byte) CIA_TIMER_CONTROL_CONTINUOUS#0
Identified duplicate assignment right side [170] (byte~) clock_start::$6 ← (byte) CIA_TIMER_CONTROL_START#0 | (byte) CIA_TIMER_CONTROL_CONTINUOUS#0
Successful SSA optimization Pass2DuplicateRValueIdentification
Simple Condition (bool~) bsearch16u::$5 [13] if((byte) bsearch16u::num#3>(byte) 0) goto bsearch16u::@7
Simple Condition (bool~) bsearch16u::$12 [25] if((signed word) bsearch16u::result#0!=(signed byte) 0) goto bsearch16u::@9
Simple Condition (bool~) bsearch16u::$0 [28] if(*((word*) bsearch16u::items#2)<=(word) bsearch16u::key#0) goto bsearch16u::@1
Simple Condition (bool~) bsearch16u::$14 [32] if((signed word) bsearch16u::result#0<=(signed byte) 0) goto bsearch16u::@10
Simple Condition (bool~) init_squares::$5 [77] if((byte) init_squares::i#1!=rangelast(0,init_squares::$2)) goto init_squares::@1
Simple Condition (bool~) init_font_hex::$3 [134] if((byte) init_font_hex::i#1!=rangelast(0,4)) goto init_font_hex::@3
Simple Condition (bool~) init_font_hex::$4 [144] if((byte) init_font_hex::c1#1!=rangelast(0,$f)) goto init_font_hex::@2
Simple Condition (bool~) init_font_hex::$5 [149] if((byte) init_font_hex::c#1!=rangelast(0,$f)) goto init_font_hex::@1
Simple Condition (bool~) init_dist_screen::$3 [296] if((byte) init_dist_screen::y2#0>=(byte) $18) goto init_dist_screen::@2
Simple Condition (bool~) init_dist_screen::$11 [317] if((byte) init_dist_screen::x2#0>=(byte) $27) goto init_dist_screen::@6
Simple Condition (bool~) init_dist_screen::$20 [347] if((byte) init_dist_screen::x#1<=(byte) $13) goto init_dist_screen::@5
Simple Condition (bool~) init_dist_screen::$21 [353] if((byte) init_dist_screen::y#1!=rangelast(0,$c)) goto init_dist_screen::@1
Simple Condition (bool~) bsearch16u::$5 [14] if((byte) bsearch16u::num#3>(byte) 0) goto bsearch16u::@7
Simple Condition (bool~) bsearch16u::$12 [26] if((signed word) bsearch16u::result#0!=(signed byte) 0) goto bsearch16u::@9
Simple Condition (bool~) bsearch16u::$0 [29] if(*((word*) bsearch16u::items#2)<=(word) bsearch16u::key#0) goto bsearch16u::@1
Simple Condition (bool~) bsearch16u::$14 [33] if((signed word) bsearch16u::result#0<=(signed byte) 0) goto bsearch16u::@10
Simple Condition (bool~) init_squares::$5 [78] if((byte) init_squares::i#1!=rangelast(0,init_squares::$2)) goto init_squares::@1
Simple Condition (bool~) init_font_hex::$3 [135] if((byte) init_font_hex::i#1!=rangelast(0,4)) goto init_font_hex::@3
Simple Condition (bool~) init_font_hex::$4 [145] if((byte) init_font_hex::c1#1!=rangelast(0,$f)) goto init_font_hex::@2
Simple Condition (bool~) init_font_hex::$5 [150] if((byte) init_font_hex::c#1!=rangelast(0,$f)) goto init_font_hex::@1
Simple Condition (bool~) init_dist_screen::$3 [297] if((byte) init_dist_screen::y2#0>=(byte) $18) goto init_dist_screen::@2
Simple Condition (bool~) init_dist_screen::$11 [318] if((byte) init_dist_screen::x2#0>=(byte) $27) goto init_dist_screen::@6
Simple Condition (bool~) init_dist_screen::$20 [348] if((byte) init_dist_screen::x#1<=(byte) $13) goto init_dist_screen::@5
Simple Condition (bool~) init_dist_screen::$21 [354] if((byte) init_dist_screen::y#1!=rangelast(0,$c)) goto init_dist_screen::@1
Successful SSA optimization Pass2ConditionalJumpSimplification
Constant right-side identified [41] (byte~) bsearch16u::$17 ← (byte) 1 * (const byte) SIZEOF_WORD
Constant right-side identified [48] (byte~) bsearch16u::$18 ← (byte) 1 * (const byte) SIZEOF_WORD
Constant right-side identified [152] (byte[]) FONT_HEX_PROTO#0 ← { (byte) 2, (byte) 5, (byte) 5, (byte) 5, (byte) 2, (byte) 6, (byte) 2, (byte) 2, (byte) 2, (byte) 7, (byte) 6, (byte) 1, (byte) 2, (byte) 4, (byte) 7, (byte) 6, (byte) 1, (byte) 2, (byte) 1, (byte) 6, (byte) 5, (byte) 5, (byte) 7, (byte) 1, (byte) 1, (byte) 7, (byte) 4, (byte) 6, (byte) 1, (byte) 6, (byte) 3, (byte) 4, (byte) 6, (byte) 5, (byte) 2, (byte) 7, (byte) 1, (byte) 1, (byte) 1, (byte) 1, (byte) 2, (byte) 5, (byte) 2, (byte) 5, (byte) 2, (byte) 2, (byte) 5, (byte) 3, (byte) 1, (byte) 1, (byte) 2, (byte) 5, (byte) 7, (byte) 5, (byte) 5, (byte) 6, (byte) 5, (byte) 6, (byte) 5, (byte) 6, (byte) 2, (byte) 5, (byte) 4, (byte) 5, (byte) 2, (byte) 6, (byte) 5, (byte) 5, (byte) 5, (byte) 6, (byte) 7, (byte) 4, (byte) 6, (byte) 4, (byte) 7, (byte) 7, (byte) 4, (byte) 6, (byte) 4, (byte) 4 }
Constant right-side identified [42] (byte~) bsearch16u::$17 ← (byte) 1 * (const byte) SIZEOF_WORD
Constant right-side identified [49] (byte~) bsearch16u::$18 ← (byte) 1 * (const byte) SIZEOF_WORD
Constant right-side identified [153] (byte[]) FONT_HEX_PROTO#0 ← { (byte) 2, (byte) 5, (byte) 5, (byte) 5, (byte) 2, (byte) 6, (byte) 2, (byte) 2, (byte) 2, (byte) 7, (byte) 6, (byte) 1, (byte) 2, (byte) 4, (byte) 7, (byte) 6, (byte) 1, (byte) 2, (byte) 1, (byte) 6, (byte) 5, (byte) 5, (byte) 7, (byte) 1, (byte) 1, (byte) 7, (byte) 4, (byte) 6, (byte) 1, (byte) 6, (byte) 3, (byte) 4, (byte) 6, (byte) 5, (byte) 2, (byte) 7, (byte) 1, (byte) 1, (byte) 1, (byte) 1, (byte) 2, (byte) 5, (byte) 2, (byte) 5, (byte) 2, (byte) 2, (byte) 5, (byte) 3, (byte) 1, (byte) 1, (byte) 2, (byte) 5, (byte) 7, (byte) 5, (byte) 5, (byte) 6, (byte) 5, (byte) 6, (byte) 5, (byte) 6, (byte) 2, (byte) 5, (byte) 4, (byte) 5, (byte) 2, (byte) 6, (byte) 5, (byte) 5, (byte) 5, (byte) 6, (byte) 7, (byte) 4, (byte) 6, (byte) 4, (byte) 7, (byte) 7, (byte) 4, (byte) 6, (byte) 4, (byte) 4 }
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant (const byte*) HEAP_START#0 = (byte*) 49152
Constant (const byte*) HEAP_TOP#0 = (byte*) 40960
Constant (const byte) bsearch16u::$17 = 1*SIZEOF_WORD
Constant (const byte) bsearch16u::$18 = 1*SIZEOF_WORD
Constant (const byte) NUM_SQUARES#0 = $ff
@ -2100,7 +2103,6 @@ Constant (const byte) init_dist_screen::y#0 = 0
Constant (const byte) init_dist_screen::x#0 = 0
Constant (const byte) init_dist_screen::xb#0 = $27
Successful SSA optimization Pass2ConstantIdentification
Constant (const byte*) malloc::mem#0 = HEAP_START#0
Constant (const byte*) init_font_hex::proto_hi#0 = FONT_HEX_PROTO#0
Constant (const byte*) init_font_hex::proto_lo#0 = FONT_HEX_PROTO#0
Constant (const byte*) init_font_hex::charset#1 = CHARSET#0
@ -2111,37 +2113,34 @@ Constant (const byte*) print_dword_at::at#0 = main::BASE_SCREEN#0
Successful SSA optimization Pass2ConstantIdentification
Constant (const byte*) print_word_at::at#0 = print_dword_at::at#0
Successful SSA optimization Pass2ConstantIdentification
Constant value identified (void*)malloc::mem#0 in [5] (void*) malloc::return#0 ← (void*)(const byte*) malloc::mem#0
Constant value identified (word)main::toD0181_screen#0 in [224] (word~) main::toD0181_$0#0 ← (word)(const byte*) main::toD0181_screen#0
Constant value identified (word)main::toD0181_gfx#0 in [228] (word~) main::toD0181_$4#0 ← (word)(const byte*) main::toD0181_gfx#0
Constant value identified (word)main::BASE_SCREEN#0 in [262] (word~) main::toD0182_$0#0 ← (word)(const byte*) main::BASE_SCREEN#0
Constant value identified (word)main::BASE_CHARSET#0 in [266] (word~) main::toD0182_$4#0 ← (word)(const byte*) main::BASE_CHARSET#0
Constant value identified (word)main::toD0181_screen#0 in [225] (word~) main::toD0181_$0#0 ← (word)(const byte*) main::toD0181_screen#0
Constant value identified (word)main::toD0181_gfx#0 in [229] (word~) main::toD0181_$4#0 ← (word)(const byte*) main::toD0181_gfx#0
Constant value identified (word)main::BASE_SCREEN#0 in [263] (word~) main::toD0182_$0#0 ← (word)(const byte*) main::BASE_SCREEN#0
Constant value identified (word)main::BASE_CHARSET#0 in [267] (word~) main::toD0182_$4#0 ← (word)(const byte*) main::BASE_CHARSET#0
Successful SSA optimization Pass2ConstantValues
Resolved ranged next value [132] init_font_hex::i#1 ← ++ init_font_hex::i#2 to ++
Resolved ranged comparison value [134] if(init_font_hex::i#1!=rangelast(0,4)) goto init_font_hex::@3 to (number) 5
Resolved ranged next value [142] init_font_hex::c1#1 ← ++ init_font_hex::c1#4 to ++
Resolved ranged comparison value [144] if(init_font_hex::c1#1!=rangelast(0,$f)) goto init_font_hex::@2 to (number) $10
Resolved ranged next value [147] init_font_hex::c#1 ← ++ init_font_hex::c#5 to ++
Resolved ranged comparison value [149] if(init_font_hex::c#1!=rangelast(0,$f)) goto init_font_hex::@1 to (number) $10
Resolved ranged next value [351] init_dist_screen::y#1 ← ++ init_dist_screen::y#10 to ++
Resolved ranged comparison value [353] if(init_dist_screen::y#1!=rangelast(0,$c)) goto init_dist_screen::@1 to (number) $d
Rewriting conditional comparison [347] if((byte) init_dist_screen::x#1<=(byte) $13) goto init_dist_screen::@5
Simplifying expression containing zero init_font_hex::charset#2 in [123] *((byte*) init_font_hex::charset#2 + (const byte) init_font_hex::idx#0) ← (byte) 0
Simplifying expression containing zero CIA_TIMER_CONTROL_CONTINUOUS#0 in [159] (byte~) clock_start::$0 ← (const byte) CIA_TIMER_CONTROL_STOP#0 | (const byte) CIA_TIMER_CONTROL_CONTINUOUS#0
Simplifying expression containing zero clock_start::$0 in [160] (byte~) clock_start::$1 ← (byte~) clock_start::$0 | (const byte) CIA_TIMER_CONTROL_A_COUNT_CYCLES#0
Simplifying expression containing zero CIA_TIMER_CONTROL_START#0 in [166] (byte~) clock_start::$4 ← (const byte) CIA_TIMER_CONTROL_START#0 | (const byte) CIA_TIMER_CONTROL_CONTINUOUS#0
Simplifying expression containing zero clock_start::$6 in [170] (byte~) clock_start::$7 ← (byte~) clock_start::$6 | (const byte) CIA_TIMER_CONTROL_A_COUNT_CYCLES#0
Resolved ranged next value [133] init_font_hex::i#1 ← ++ init_font_hex::i#2 to ++
Resolved ranged comparison value [135] if(init_font_hex::i#1!=rangelast(0,4)) goto init_font_hex::@3 to (number) 5
Resolved ranged next value [143] init_font_hex::c1#1 ← ++ init_font_hex::c1#4 to ++
Resolved ranged comparison value [145] if(init_font_hex::c1#1!=rangelast(0,$f)) goto init_font_hex::@2 to (number) $10
Resolved ranged next value [148] init_font_hex::c#1 ← ++ init_font_hex::c#5 to ++
Resolved ranged comparison value [150] if(init_font_hex::c#1!=rangelast(0,$f)) goto init_font_hex::@1 to (number) $10
Resolved ranged next value [352] init_dist_screen::y#1 ← ++ init_dist_screen::y#10 to ++
Resolved ranged comparison value [354] if(init_dist_screen::y#1!=rangelast(0,$c)) goto init_dist_screen::@1 to (number) $d
Rewriting conditional comparison [348] if((byte) init_dist_screen::x#1<=(byte) $13) goto init_dist_screen::@5
Simplifying expression containing zero init_font_hex::charset#2 in [124] *((byte*) init_font_hex::charset#2 + (const byte) init_font_hex::idx#0) ← (byte) 0
Simplifying expression containing zero CIA_TIMER_CONTROL_CONTINUOUS#0 in [160] (byte~) clock_start::$0 ← (const byte) CIA_TIMER_CONTROL_STOP#0 | (const byte) CIA_TIMER_CONTROL_CONTINUOUS#0
Simplifying expression containing zero clock_start::$0 in [161] (byte~) clock_start::$1 ← (byte~) clock_start::$0 | (const byte) CIA_TIMER_CONTROL_A_COUNT_CYCLES#0
Simplifying expression containing zero CIA_TIMER_CONTROL_START#0 in [167] (byte~) clock_start::$4 ← (const byte) CIA_TIMER_CONTROL_START#0 | (const byte) CIA_TIMER_CONTROL_CONTINUOUS#0
Simplifying expression containing zero clock_start::$6 in [171] (byte~) clock_start::$7 ← (byte~) clock_start::$6 | (const byte) CIA_TIMER_CONTROL_A_COUNT_CYCLES#0
Successful SSA optimization PassNSimplifyExpressionWithZero
Eliminating unused variable (byte) init_font_hex::idx#4 and assignment [67] (byte) init_font_hex::idx#4 ← ++ (byte) init_font_hex::idx#3
Eliminating unused variable (byte) init_font_hex::idx#4 and assignment [68] (byte) init_font_hex::idx#4 ← ++ (byte) init_font_hex::idx#3
Eliminating unused variable - keeping the phi block (byte*) heap_head#46
Eliminating unused constant (const byte) NUM_SQUARES#0
Eliminating unused constant (const word*) SQUARES#0
Eliminating unused constant (const byte) CIA_TIMER_CONTROL_STOP#0
Eliminating unused constant (const byte) CIA_TIMER_CONTROL_A_COUNT_CYCLES#0
Successful SSA optimization PassNEliminateUnusedVars
Eliminating unused variable (byte*) heap_head#1 and assignment [0] (byte*) heap_head#1 ← (const byte*) HEAP_START#0 + (word) malloc::size#0
Successful SSA optimization PassNEliminateUnusedVars
Eliminating unused variable (word) malloc::size#0 and assignment [21] (word) malloc::size#0 ← (const byte) NUM_SQUARES#3 * (const byte) SIZEOF_WORD
Eliminating unused variable (byte*) heap_head#1 and assignment [1] (byte*) heap_head#1 ← (byte*) malloc::mem#0
Successful SSA optimization PassNEliminateUnusedVars
Adding number conversion cast (unumber) 5 in if((byte) init_font_hex::i#1!=(number) 5) goto init_font_hex::@3
Adding number conversion cast (unumber) $10 in if((byte) init_font_hex::c1#1!=(number) $10) goto init_font_hex::@2
@ -2176,12 +2175,13 @@ Identical Phi Values (byte) init_font_hex::c#5 (byte) init_font_hex::c#6
Identical Phi Values (word*) SQUARES#18 (word*) SQUARES#1
Identical Phi Values (byte) NUM_SQUARES#35 (const byte) NUM_SQUARES#3
Successful SSA optimization Pass2IdenticalPhiElimination
Constant right-side identified [26] (byte~) init_squares::$2 ← (const byte) NUM_SQUARES#3 - (byte) 1
Constant right-side identified [53] (byte) init_font_hex::idx#1 ← ++ (const byte) init_font_hex::idx#0
Constant right-side identified [100] (byte*) print_word_at::at#1 ← (const byte*) print_dword_at::at#0 + (byte) 4
Constant right-side identified [147] (byte*) init_dist_screen::screen_bottomline#0 ← (const byte*) init_dist_screen::screen#0 + (word)(number) $28*(number) $18
Constant right-side identified [22] (word) malloc::size#0 ← (const byte) NUM_SQUARES#3 * (const byte) SIZEOF_WORD
Constant right-side identified [28] (byte~) init_squares::$2 ← (const byte) NUM_SQUARES#3 - (byte) 1
Constant right-side identified [55] (byte) init_font_hex::idx#1 ← ++ (const byte) init_font_hex::idx#0
Constant right-side identified [102] (byte*) print_word_at::at#1 ← (const byte*) print_dword_at::at#0 + (byte) 4
Constant right-side identified [149] (byte*) init_dist_screen::screen_bottomline#0 ← (const byte*) init_dist_screen::screen#0 + (word)(number) $28*(number) $18
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant (const void*) malloc::return#0 = (void*)malloc::mem#0
Constant (const word) malloc::size#0 = NUM_SQUARES#3*SIZEOF_WORD
Constant (const byte) init_squares::$2 = NUM_SQUARES#3-1
Constant (const byte) bsearch16u::num#2 = NUM_SQUARES#3
Constant (const byte) init_font_hex::idx#1 = ++init_font_hex::idx#0
@ -2194,15 +2194,9 @@ Constant (const word) main::toD0182_$0#0 = (word)main::BASE_SCREEN#0
Constant (const word) main::toD0182_$4#0 = (word)main::BASE_CHARSET#0
Constant (const byte*) init_dist_screen::screen_bottomline#0 = init_dist_screen::screen#0+(word)$28*$18
Successful SSA optimization Pass2ConstantIdentification
Constant (const void*) malloc::return#2 = malloc::return#0
Successful SSA optimization Pass2ConstantIdentification
Constant (const void*) init_squares::$1 = malloc::return#2
Successful SSA optimization Pass2ConstantIdentification
Constant value identified (word*)init_squares::$1 in [24] (word*) SQUARES#1 ← (word*)(const void*) init_squares::$1
Successful SSA optimization Pass2ConstantValues
Resolved ranged next value [33] init_squares::i#1 ← ++ init_squares::i#2 to ++
Resolved ranged comparison value [34] if(init_squares::i#1!=rangelast(0,init_squares::$2)) goto init_squares::@1 to (const byte) init_squares::$2+(number) 1
Simplifying expression containing zero CIA_TIMER_CONTROL_B_COUNT_UNDERFLOW_A#0 in [79] (byte~) clock_start::$3 ← (const byte) clock_start::$1 | (const byte) CIA_TIMER_CONTROL_B_COUNT_UNDERFLOW_A#0
Resolved ranged next value [35] init_squares::i#1 ← ++ init_squares::i#2 to ++
Resolved ranged comparison value [36] if(init_squares::i#1!=rangelast(0,init_squares::$2)) goto init_squares::@1 to (const byte) init_squares::$2+(number) 1
Simplifying expression containing zero CIA_TIMER_CONTROL_B_COUNT_UNDERFLOW_A#0 in [81] (byte~) clock_start::$3 ← (const byte) clock_start::$1 | (const byte) CIA_TIMER_CONTROL_B_COUNT_UNDERFLOW_A#0
Successful SSA optimization PassNSimplifyExpressionWithZero
Adding number conversion cast (unumber) init_squares::$2+1 in if((byte) init_squares::i#1!=(const byte) init_squares::$2+(number) 1) goto init_squares::@1
Adding number conversion cast (unumber) 1 in if((byte) init_squares::i#1!=(unumber)(const byte) init_squares::$2+(number) 1) goto init_squares::@1
@ -2212,13 +2206,14 @@ Simplifying constant integer cast 1
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (byte) 1
Successful SSA optimization PassNFinalizeNumberTypeConversions
Constant right-side identified [73] (byte~) clock_start::$5 ← (const byte) clock_start::$6 | (const byte) CIA_TIMER_CONTROL_B_COUNT_UNDERFLOW_A#0
Constant right-side identified [104] (word~) main::toD0181_$1#0 ← (const word) main::toD0181_$0#0 & (word) $3fff
Constant right-side identified [107] (byte~) main::toD0181_$5#0 ← > (const word) main::toD0181_$4#0
Constant right-side identified [120] (word~) main::toD0182_$1#0 ← (const word) main::toD0182_$0#0 & (word) $3fff
Constant right-side identified [123] (byte~) main::toD0182_$5#0 ← > (const word) main::toD0182_$4#0
Constant right-side identified [0] (byte*) malloc::mem#0 ← (const byte*) HEAP_TOP#0 - (const word) malloc::size#0
Constant right-side identified [77] (byte~) clock_start::$5 ← (const byte) clock_start::$6 | (const byte) CIA_TIMER_CONTROL_B_COUNT_UNDERFLOW_A#0
Constant right-side identified [108] (word~) main::toD0181_$1#0 ← (const word) main::toD0181_$0#0 & (word) $3fff
Constant right-side identified [111] (byte~) main::toD0181_$5#0 ← > (const word) main::toD0181_$4#0
Constant right-side identified [124] (word~) main::toD0182_$1#0 ← (const word) main::toD0182_$0#0 & (word) $3fff
Constant right-side identified [127] (byte~) main::toD0182_$5#0 ← > (const word) main::toD0182_$4#0
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant (const word*) SQUARES#1 = (word*)init_squares::$1
Constant (const byte*) malloc::mem#0 = HEAP_TOP#0-malloc::size#0
Constant (const byte) clock_start::$3 = CIA_TIMER_CONTROL_B_COUNT_UNDERFLOW_A#0
Constant (const byte) clock_start::$5 = clock_start::$6|CIA_TIMER_CONTROL_B_COUNT_UNDERFLOW_A#0
Constant (const word) main::toD0181_$1#0 = main::toD0181_$0#0&$3fff
@ -2226,29 +2221,39 @@ Constant (const byte) main::toD0181_$5#0 = >main::toD0181_$4#0
Constant (const word) main::toD0182_$1#0 = main::toD0182_$0#0&$3fff
Constant (const byte) main::toD0182_$5#0 = >main::toD0182_$4#0
Successful SSA optimization Pass2ConstantIdentification
Constant (const word*) init_squares::squares#0 = SQUARES#1
Constant (const word*) bsearch16u::items#1 = SQUARES#1
Successful SSA optimization Pass2ConstantIdentification
Constant right-side identified [99] (word~) main::toD0181_$2#0 ← (const word) main::toD0181_$1#0 * (byte) 4
Constant right-side identified [101] (byte~) main::toD0181_$6#0 ← (const byte) main::toD0181_$5#0 / (byte) 4
Constant right-side identified [113] (word~) main::toD0182_$2#0 ← (const word) main::toD0182_$1#0 * (byte) 4
Constant right-side identified [115] (byte~) main::toD0182_$6#0 ← (const byte) main::toD0182_$5#0 / (byte) 4
Constant value identified (void*)malloc::mem#0 in [1] (void*) malloc::return#0 ← (void*)(const byte*) malloc::mem#0
Successful SSA optimization Pass2ConstantValues
Constant right-side identified [105] (word~) main::toD0181_$2#0 ← (const word) main::toD0181_$1#0 * (byte) 4
Constant right-side identified [107] (byte~) main::toD0181_$6#0 ← (const byte) main::toD0181_$5#0 / (byte) 4
Constant right-side identified [119] (word~) main::toD0182_$2#0 ← (const word) main::toD0182_$1#0 * (byte) 4
Constant right-side identified [121] (byte~) main::toD0182_$6#0 ← (const byte) main::toD0182_$5#0 / (byte) 4
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant (const void*) malloc::return#0 = (void*)malloc::mem#0
Constant (const word) main::toD0181_$2#0 = main::toD0181_$1#0*4
Constant (const byte) main::toD0181_$6#0 = main::toD0181_$5#0/4
Constant (const word) main::toD0182_$2#0 = main::toD0182_$1#0*4
Constant (const byte) main::toD0182_$6#0 = main::toD0182_$5#0/4
Successful SSA optimization Pass2ConstantIdentification
Constant right-side identified [99] (byte~) main::toD0181_$3#0 ← > (const word) main::toD0181_$2#0
Constant right-side identified [100] (byte~) main::toD0181_$7#0 ← (const byte) main::toD0181_$6#0 & (byte) $f
Constant right-side identified [111] (byte~) main::toD0182_$3#0 ← > (const word) main::toD0182_$2#0
Constant right-side identified [112] (byte~) main::toD0182_$7#0 ← (const byte) main::toD0182_$6#0 & (byte) $f
Constant (const void*) malloc::return#2 = malloc::return#0
Successful SSA optimization Pass2ConstantIdentification
Constant (const void*) init_squares::$1 = malloc::return#2
Successful SSA optimization Pass2ConstantIdentification
Constant value identified (word*)init_squares::$1 in [24] (word*) SQUARES#1 ← (word*)(const void*) init_squares::$1
Successful SSA optimization Pass2ConstantValues
Constant right-side identified [102] (byte~) main::toD0181_$3#0 ← > (const word) main::toD0181_$2#0
Constant right-side identified [103] (byte~) main::toD0181_$7#0 ← (const byte) main::toD0181_$6#0 & (byte) $f
Constant right-side identified [114] (byte~) main::toD0182_$3#0 ← > (const word) main::toD0182_$2#0
Constant right-side identified [115] (byte~) main::toD0182_$7#0 ← (const byte) main::toD0182_$6#0 & (byte) $f
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant (const word*) SQUARES#1 = (word*)init_squares::$1
Constant (const byte) main::toD0181_$3#0 = >main::toD0181_$2#0
Constant (const byte) main::toD0181_$7#0 = main::toD0181_$6#0&$f
Constant (const byte) main::toD0182_$3#0 = >main::toD0182_$2#0
Constant (const byte) main::toD0182_$7#0 = main::toD0182_$6#0&$f
Successful SSA optimization Pass2ConstantIdentification
Constant (const word*) init_squares::squares#0 = SQUARES#1
Constant (const word*) bsearch16u::items#1 = SQUARES#1
Successful SSA optimization Pass2ConstantIdentification
Constant right-side identified [99] (byte) main::toD0181_return#0 ← (const byte) main::toD0181_$3#0 | (const byte) main::toD0181_$7#0
Constant right-side identified [109] (byte) main::toD0182_return#0 ← (const byte) main::toD0182_$3#0 | (const byte) main::toD0182_$7#0
Successful SSA optimization Pass2ConstantRValueConsolidation
@ -2329,7 +2334,6 @@ Constant inlined main::toD0181_$6#0 = >(word)(const byte*) CHARSET#0/(byte) 4
Constant inlined main::toD0181_$2#0 = (word)(const byte*) SCREEN#0&(word) $3fff*(byte) 4
Constant inlined main::toD0181_$4#0 = (word)(const byte*) CHARSET#0
Constant inlined main::toD0182_$1#0 = (word)(const byte*) main::BASE_SCREEN#0&(word) $3fff
Constant inlined malloc::mem#0 = (const byte*) HEAP_START#0
Constant inlined init_font_hex::c#0 = (byte) 0
Constant inlined init_squares::$1 = (const void*) malloc::return#0
Constant inlined print_word_at::at#1 = (const byte*) main::BASE_SCREEN#0+(byte) 4
@ -2812,7 +2816,7 @@ VARIABLE REGISTER WEIGHTS
(dword) CLOCKS_PER_INIT
(byte*) D018
(byte[]) FONT_HEX_PROTO
(byte*) HEAP_START
(byte*) HEAP_TOP
(byte) NUM_SQUARES
(byte*) SCREEN
(word*) SQUARES
@ -3205,8 +3209,8 @@ INITIAL ASM
.pc = $80d "Program"
// Global Constants & labels
.const SIZEOF_WORD = 2
// Start of the heap used by malloc()
.label HEAP_START = $c000
// Top of the heap used by malloc()
.label HEAP_TOP = $a000
.label D018 = $d018
// CIA #2 Timer A+B Value (32-bit)
.label CIA2_TIMER_AB = $dd04
@ -4109,7 +4113,9 @@ init_squares: {
// Allocates a block of size bytes of memory, returning a pointer to the beginning of the block.
// The content of the newly allocated block of memory is not initialized, remaining with indeterminate values.
malloc: {
.label return = HEAP_START
.const size = NUM_SQUARES*SIZEOF_WORD
.label mem = HEAP_TOP-size
.label return = mem
jmp breturn
// malloc::@return
breturn:
@ -4711,8 +4717,8 @@ ASSEMBLER BEFORE OPTIMIZATION
.pc = $80d "Program"
// Global Constants & labels
.const SIZEOF_WORD = 2
// Start of the heap used by malloc()
.label HEAP_START = $c000
// Top of the heap used by malloc()
.label HEAP_TOP = $a000
.label D018 = $d018
// CIA #2 Timer A+B Value (32-bit)
.label CIA2_TIMER_AB = $dd04
@ -5495,7 +5501,9 @@ init_squares: {
// Allocates a block of size bytes of memory, returning a pointer to the beginning of the block.
// The content of the newly allocated block of memory is not initialized, remaining with indeterminate values.
malloc: {
.label return = HEAP_START
.const size = NUM_SQUARES*SIZEOF_WORD
.label mem = HEAP_TOP-size
.label return = mem
jmp breturn
// malloc::@return
breturn:
@ -5897,8 +5905,8 @@ FINAL SYMBOL TABLE
(const byte*) D018#0 D018 = (byte*) 53272
(byte[]) FONT_HEX_PROTO
(const byte[]) FONT_HEX_PROTO#0 FONT_HEX_PROTO = { (byte) 2, (byte) 5, (byte) 5, (byte) 5, (byte) 2, (byte) 6, (byte) 2, (byte) 2, (byte) 2, (byte) 7, (byte) 6, (byte) 1, (byte) 2, (byte) 4, (byte) 7, (byte) 6, (byte) 1, (byte) 2, (byte) 1, (byte) 6, (byte) 5, (byte) 5, (byte) 7, (byte) 1, (byte) 1, (byte) 7, (byte) 4, (byte) 6, (byte) 1, (byte) 6, (byte) 3, (byte) 4, (byte) 6, (byte) 5, (byte) 2, (byte) 7, (byte) 1, (byte) 1, (byte) 1, (byte) 1, (byte) 2, (byte) 5, (byte) 2, (byte) 5, (byte) 2, (byte) 2, (byte) 5, (byte) 3, (byte) 1, (byte) 1, (byte) 2, (byte) 5, (byte) 7, (byte) 5, (byte) 5, (byte) 6, (byte) 5, (byte) 6, (byte) 5, (byte) 6, (byte) 2, (byte) 5, (byte) 4, (byte) 5, (byte) 2, (byte) 6, (byte) 5, (byte) 5, (byte) 5, (byte) 6, (byte) 7, (byte) 4, (byte) 6, (byte) 4, (byte) 7, (byte) 7, (byte) 4, (byte) 6, (byte) 4, (byte) 4 }
(byte*) HEAP_START
(const byte*) HEAP_START#0 HEAP_START = (byte*) 49152
(byte*) HEAP_TOP
(const byte*) HEAP_TOP#0 HEAP_TOP = (byte*) 40960
(byte) NUM_SQUARES
(const byte) NUM_SQUARES#3 NUM_SQUARES = (byte) $30
(byte*) SCREEN
@ -6090,9 +6098,11 @@ FINAL SYMBOL TABLE
(void*()) malloc((word) malloc::size)
(label) malloc::@return
(byte*) malloc::mem
(const byte*) malloc::mem#0 mem = (const byte*) HEAP_TOP#0-(const word) malloc::size#0
(void*) malloc::return
(const void*) malloc::return#0 return = (void*)(const byte*) HEAP_START#0
(const void*) malloc::return#0 return = (void*)(const byte*) malloc::mem#0
(word) malloc::size
(const word) malloc::size#0 size = (const byte) NUM_SQUARES#3*(const byte) SIZEOF_WORD
(void()) print_byte_at((byte) print_byte_at::b , (byte*) print_byte_at::at)
(byte~) print_byte_at::$0 reg byte a 4.0
(byte~) print_byte_at::$2 reg byte y 2.0
@ -6217,8 +6227,8 @@ Score: 203337
.pc = $80d "Program"
// Global Constants & labels
.const SIZEOF_WORD = 2
// Start of the heap used by malloc()
.label HEAP_START = $c000
// Top of the heap used by malloc()
.label HEAP_TOP = $a000
.label D018 = $d018
// CIA #2 Timer A+B Value (32-bit)
.label CIA2_TIMER_AB = $dd04
@ -6954,7 +6964,9 @@ init_squares: {
// Allocates a block of size bytes of memory, returning a pointer to the beginning of the block.
// The content of the newly allocated block of memory is not initialized, remaining with indeterminate values.
malloc: {
.label return = HEAP_START
.const size = NUM_SQUARES*SIZEOF_WORD
.label mem = HEAP_TOP-size
.label return = mem
// malloc::@return
// [131] return
rts

View File

@ -23,8 +23,8 @@
(const byte*) D018#0 D018 = (byte*) 53272
(byte[]) FONT_HEX_PROTO
(const byte[]) FONT_HEX_PROTO#0 FONT_HEX_PROTO = { (byte) 2, (byte) 5, (byte) 5, (byte) 5, (byte) 2, (byte) 6, (byte) 2, (byte) 2, (byte) 2, (byte) 7, (byte) 6, (byte) 1, (byte) 2, (byte) 4, (byte) 7, (byte) 6, (byte) 1, (byte) 2, (byte) 1, (byte) 6, (byte) 5, (byte) 5, (byte) 7, (byte) 1, (byte) 1, (byte) 7, (byte) 4, (byte) 6, (byte) 1, (byte) 6, (byte) 3, (byte) 4, (byte) 6, (byte) 5, (byte) 2, (byte) 7, (byte) 1, (byte) 1, (byte) 1, (byte) 1, (byte) 2, (byte) 5, (byte) 2, (byte) 5, (byte) 2, (byte) 2, (byte) 5, (byte) 3, (byte) 1, (byte) 1, (byte) 2, (byte) 5, (byte) 7, (byte) 5, (byte) 5, (byte) 6, (byte) 5, (byte) 6, (byte) 5, (byte) 6, (byte) 2, (byte) 5, (byte) 4, (byte) 5, (byte) 2, (byte) 6, (byte) 5, (byte) 5, (byte) 5, (byte) 6, (byte) 7, (byte) 4, (byte) 6, (byte) 4, (byte) 7, (byte) 7, (byte) 4, (byte) 6, (byte) 4, (byte) 4 }
(byte*) HEAP_START
(const byte*) HEAP_START#0 HEAP_START = (byte*) 49152
(byte*) HEAP_TOP
(const byte*) HEAP_TOP#0 HEAP_TOP = (byte*) 40960
(byte) NUM_SQUARES
(const byte) NUM_SQUARES#3 NUM_SQUARES = (byte) $30
(byte*) SCREEN
@ -216,9 +216,11 @@
(void*()) malloc((word) malloc::size)
(label) malloc::@return
(byte*) malloc::mem
(const byte*) malloc::mem#0 mem = (const byte*) HEAP_TOP#0-(const word) malloc::size#0
(void*) malloc::return
(const void*) malloc::return#0 return = (void*)(const byte*) HEAP_START#0
(const void*) malloc::return#0 return = (void*)(const byte*) malloc::mem#0
(word) malloc::size
(const word) malloc::size#0 size = (const byte) NUM_SQUARES#3*(const byte) SIZEOF_WORD
(void()) print_byte_at((byte) print_byte_at::b , (byte*) print_byte_at::at)
(byte~) print_byte_at::$0 reg byte a 4.0
(byte~) print_byte_at::$2 reg byte y 2.0

View File

@ -4,13 +4,16 @@
:BasicUpstart(bbegin)
.pc = $80d "Program"
.const SIZEOF_WORD = 2
// Start of the heap used by malloc()
.label HEAP_START = $c000
.const SIZEOF_BYTE = 1
// Top of the heap used by malloc()
.label HEAP_TOP = $a000
// The number of iterations performed during 16-bit CORDIC atan2 calculation
.const CORDIC_ITERATIONS_16 = $f
// The number of buckets in our bucket sort
.const NUM_BUCKETS = $30
.const NUM_SQUARES = $30
.label heap_head = $24
.label SQUARES = $37
.label SQUARES = $26
// Screen containing distance to center
.label SCREEN_DIST = 2
// Screen containing angle to center
@ -22,9 +25,9 @@ bbegin:
sta malloc.size
lda #>$3e8
sta malloc.size+1
lda #<HEAP_START
lda #<HEAP_TOP
sta heap_head
lda #>HEAP_START
lda #>HEAP_TOP
sta heap_head+1
jsr malloc
lda malloc.mem
@ -40,7 +43,7 @@ bbegin:
sta SCREEN_ANGLE
lda malloc.mem+1
sta SCREEN_ANGLE+1
lda #$80
lda #NUM_BUCKETS*SIZEOF_BYTE
sta malloc.size
lda #0
sta malloc.size+1
@ -61,6 +64,7 @@ main: {
jsr init_buckets
rts
}
//const word*[] BUCKETS = malloc(NUM_BUCKETS*sizeof(word*));
init_buckets: {
.label dist = 2
.label i1 = 4
@ -70,7 +74,7 @@ init_buckets: {
lda #0
sta (BUCKET_SIZES),y
iny
cpy #$80
cpy #NUM_BUCKETS-1+1
bne b1
// first find bucket sizes - by counting number of chars with each distance value
sta i1
@ -661,18 +665,18 @@ init_squares: {
// The content of the newly allocated block of memory is not initialized, remaining with indeterminate values.
// malloc(word zeropage($26) size)
malloc: {
.label mem = $37
.label mem = $26
.label size = $26
lda heap_head
sec
sbc mem
sta mem
lda heap_head+1
sbc mem+1
sta mem+1
lda heap_head
clc
adc size
lda mem
sta heap_head
lda heap_head+1
adc size+1
lda mem+1
sta heap_head+1
rts
}

View File

@ -47,7 +47,7 @@ init_buckets::@1: scope:[init_buckets] from init_buckets init_buckets::@1
[20] (byte) init_buckets::i#2 ← phi( init_buckets/(byte) 0 init_buckets::@1/(byte) init_buckets::i#1 )
[21] *((byte*)(void*) BUCKET_SIZES#0 + (byte) init_buckets::i#2) ← (byte) 0
[22] (byte) init_buckets::i#1 ← ++ (byte) init_buckets::i#2
[23] if((byte) init_buckets::i#1!=(byte) $80) goto init_buckets::@1
[23] if((byte) init_buckets::i#1!=(const byte) NUM_BUCKETS#0-(byte) 1+(byte) 1) goto init_buckets::@1
to:init_buckets::@2
init_buckets::@2: scope:[init_buckets] from init_buckets::@1
[24] (byte*) init_buckets::dist#0 ← (byte*)(void*) SCREEN_DIST#0
@ -369,10 +369,10 @@ init_squares::@return: scope:[init_squares] from init_squares::@1
[189] return
to:@return
malloc: scope:[malloc] from @1 @2 @4 init_squares
[190] (word) malloc::size#4 ← phi( @4/(word) $3e8 @1/(word) $3e8 @2/(byte) $80 init_squares/(const byte) NUM_SQUARES#3*(const byte) SIZEOF_WORD )
[190] (byte*) heap_head#13 ← phi( @4/(byte*) heap_head#1 @1/(const byte*) HEAP_START#0 @2/(byte*) heap_head#1 init_squares/(byte*) heap_head#1 )
[191] (byte*) malloc::mem#0 ← (byte*) heap_head#13
[192] (byte*) heap_head#1 ← (byte*) heap_head#13 + (word) malloc::size#4
[190] (word) malloc::size#4 ← phi( @4/(word) $3e8 @1/(word) $3e8 @2/(const byte) NUM_BUCKETS#0*(const byte) SIZEOF_BYTE init_squares/(const byte) NUM_SQUARES#3*(const byte) SIZEOF_WORD )
[190] (byte*) heap_head#13 ← phi( @4/(byte*) heap_head#1 @1/(const byte*) HEAP_TOP#0 @2/(byte*) heap_head#1 init_squares/(byte*) heap_head#1 )
[191] (byte*) malloc::mem#0 ← (byte*) heap_head#13 - (word) malloc::size#4
[192] (byte*) heap_head#1 ← (byte*) malloc::mem#0
to:malloc::@return
malloc::@return: scope:[malloc] from malloc
[193] return

View File

@ -7,7 +7,7 @@ Fixing pointer array-indexing *((word*) SQUARES + (byte) sqr::val)
Fixing pointer array-indexing *((word[CORDIC_ITERATIONS_16]) CORDIC_ATAN2_ANGLES_16 + (byte) atan2_16::i)
Fixing pointer array-indexing *((word[CORDIC_ITERATIONS_16]) CORDIC_ATAN2_ANGLES_16 + (byte) atan2_16::i)
Warning! Adding boolean cast to non-boolean sub-expression (byte) atan2_16::shift
Identified constant variable (byte*) HEAP_START
Identified constant variable (byte*) HEAP_TOP
Culled Empty Block (label) malloc::@1
Culled Empty Block (label) @1
Culled Empty Block (label) @2
@ -48,14 +48,15 @@ Culled Empty Block (label) init_dist_screen::@12
CONTROL FLOW GRAPH SSA
@begin: scope:[] from
(byte*) HEAP_START#0 ← ((byte*)) (number) $c000
(byte*) heap_head#0 ← (byte*) HEAP_START#0
(byte*) HEAP_TOP#0 ← ((byte*)) (number) $a000
(byte*) heap_head#0 ← (byte*) HEAP_TOP#0
to:@3
malloc: scope:[malloc] from @13 @8 @9 init_squares
(word) malloc::size#4 ← phi( @13/(word) malloc::size#2 @8/(word) malloc::size#1 @9/(word) malloc::size#3 init_squares/(word) malloc::size#0 )
(byte*) heap_head#13 ← phi( @13/(byte*) heap_head#5 @8/(byte*) heap_head#25 @9/(byte*) heap_head#26 init_squares/(byte*) heap_head#27 )
(byte*) malloc::mem#0 ← (byte*) heap_head#13
(byte*) heap_head#1 ← (byte*) heap_head#13 + (word) malloc::size#4
(byte*~) malloc::$0 ← (byte*) heap_head#13 - (word) malloc::size#4
(byte*) malloc::mem#0 ← (byte*~) malloc::$0
(byte*) heap_head#1 ← (byte*) malloc::mem#0
(void*) malloc::return#0 ← ((void*)) (byte*) malloc::mem#0
to:malloc::@return
malloc::@return: scope:[malloc] from malloc
@ -520,7 +521,9 @@ main::@return: scope:[main] from main::@3
(word*) SQUARES#33 ← phi( @14/(word*) SQUARES#36 )
(byte) NUM_SQUARES#22 ← phi( @14/(byte) NUM_SQUARES#25 )
(byte*) heap_head#26 ← phi( @14/(byte*) heap_head#6 )
(word) malloc::size#3 ← (number) $80
(byte) NUM_BUCKETS#0 ← (number) $30
(byte~) $2 ← (byte) NUM_BUCKETS#0 * (const byte) SIZEOF_BYTE
(word) malloc::size#3 ← (byte~) $2
call malloc
(void*) malloc::return#5 ← (void*) malloc::return#1
to:@15
@ -529,19 +532,20 @@ main::@return: scope:[main] from main::@3
(byte) NUM_SQUARES#21 ← phi( @9/(byte) NUM_SQUARES#22 )
(byte*) heap_head#21 ← phi( @9/(byte*) heap_head#2 )
(void*) malloc::return#10 ← phi( @9/(void*) malloc::return#5 )
(void*~) $2 ← (void*) malloc::return#10
(void*~) $3 ← (void*) malloc::return#10
(byte*) heap_head#9 ← (byte*) heap_head#21
(byte*) BUCKET_SIZES#0 ← ((byte*)) (void*~) $2
(byte[]) BUCKET_SIZES#0 ← ((byte*)) (void*~) $3
to:@12
init_buckets: scope:[init_buckets] from main::@2
(number~) init_buckets::$0 ← (byte) NUM_BUCKETS#0 - (number) 1
(byte) init_buckets::i#0 ← (byte) 0
to:init_buckets::@1
init_buckets::@1: scope:[init_buckets] from init_buckets init_buckets::@1
(byte) init_buckets::i#2 ← phi( init_buckets/(byte) init_buckets::i#0 init_buckets::@1/(byte) init_buckets::i#1 )
*((byte*) BUCKET_SIZES#0 + (byte) init_buckets::i#2) ← (number) 0
(byte) init_buckets::i#1 ← (byte) init_buckets::i#2 + rangenext(0,$7f)
(bool~) init_buckets::$0 ← (byte) init_buckets::i#1 != rangelast(0,$7f)
if((bool~) init_buckets::$0) goto init_buckets::@1
*((byte[]) BUCKET_SIZES#0 + (byte) init_buckets::i#2) ← (number) 0
(byte) init_buckets::i#1 ← (byte) init_buckets::i#2 + rangenext(0,init_buckets::$0)
(bool~) init_buckets::$1 ← (byte) init_buckets::i#1 != rangelast(0,init_buckets::$0)
if((bool~) init_buckets::$1) goto init_buckets::@1
to:init_buckets::@2
init_buckets::@2: scope:[init_buckets] from init_buckets::@1
(byte*) init_buckets::dist#0 ← (byte*) SCREEN_DIST#0
@ -550,11 +554,11 @@ init_buckets::@2: scope:[init_buckets] from init_buckets::@1
init_buckets::@3: scope:[init_buckets] from init_buckets::@2 init_buckets::@3
(word) init_buckets::i1#2 ← phi( init_buckets::@2/(word) init_buckets::i1#0 init_buckets::@3/(word) init_buckets::i1#1 )
(byte*) init_buckets::dist#2 ← phi( init_buckets::@2/(byte*) init_buckets::dist#0 init_buckets::@3/(byte*) init_buckets::dist#1 )
*((byte*) BUCKET_SIZES#0 + *((byte*) init_buckets::dist#2)) ← ++ *((byte*) BUCKET_SIZES#0 + *((byte*) init_buckets::dist#2))
*((byte[]) BUCKET_SIZES#0 + *((byte*) init_buckets::dist#2)) ← ++ *((byte[]) BUCKET_SIZES#0 + *((byte*) init_buckets::dist#2))
(byte*) init_buckets::dist#1 ← ++ (byte*) init_buckets::dist#2
(word) init_buckets::i1#1 ← (word) init_buckets::i1#2 + rangenext(0,$3e7)
(bool~) init_buckets::$1 ← (word) init_buckets::i1#1 != rangelast(0,$3e7)
if((bool~) init_buckets::$1) goto init_buckets::@3
(bool~) init_buckets::$2 ← (word) init_buckets::i1#1 != rangelast(0,$3e7)
if((bool~) init_buckets::$2) goto init_buckets::@3
to:init_buckets::@return
init_buckets::@return: scope:[init_buckets] from init_buckets::@3
return
@ -851,7 +855,8 @@ init_dist_screen::@return: scope:[init_dist_screen] from init_dist_screen::@11
SYMBOL TABLE SSA
(void*~) $0
(void*~) $1
(void*~) $2
(byte~) $2
(void*~) $3
(label) @12
(label) @13
(label) @14
@ -863,14 +868,16 @@ SYMBOL TABLE SSA
(label) @9
(label) @begin
(label) @end
(byte*) BUCKET_SIZES
(byte*) BUCKET_SIZES#0
(byte[]) BUCKET_SIZES
(byte[]) BUCKET_SIZES#0
(word[CORDIC_ITERATIONS_16#0]) CORDIC_ATAN2_ANGLES_16
(word[CORDIC_ITERATIONS_16#0]) CORDIC_ATAN2_ANGLES_16#0
(byte) CORDIC_ITERATIONS_16
(byte) CORDIC_ITERATIONS_16#0
(byte*) HEAP_START
(byte*) HEAP_START#0
(byte*) HEAP_TOP
(byte*) HEAP_TOP#0
(byte) NUM_BUCKETS
(byte) NUM_BUCKETS#0
(byte) NUM_SQUARES
(byte) NUM_SQUARES#0
(byte) NUM_SQUARES#1
@ -912,6 +919,7 @@ SYMBOL TABLE SSA
(byte*) SCREEN_ANGLE#0
(byte*) SCREEN_DIST
(byte*) SCREEN_DIST#0
(const byte) SIZEOF_BYTE = (byte) 1
(const byte) SIZEOF_WORD = (byte) 2
(word*) SQUARES
(word*) SQUARES#0
@ -1337,8 +1345,9 @@ SYMBOL TABLE SSA
(signed word) init_angle_screen::yw
(signed word) init_angle_screen::yw#0
(void()) init_buckets()
(bool~) init_buckets::$0
(number~) init_buckets::$0
(bool~) init_buckets::$1
(bool~) init_buckets::$2
(label) init_buckets::@1
(label) init_buckets::@2
(label) init_buckets::@3
@ -1512,6 +1521,7 @@ SYMBOL TABLE SSA
(label) main::@3
(label) main::@return
(void*()) malloc((word) malloc::size)
(byte*~) malloc::$0
(label) malloc::@return
(byte*) malloc::mem
(byte*) malloc::mem#0
@ -1611,8 +1621,10 @@ Adding number conversion cast (unumber) $8000 in (number~) atan2_16::$12 ← (nu
Adding number conversion cast (unumber) atan2_16::$12 in (number~) atan2_16::$12 ← (unumber)(number) $8000 - (word) atan2_16::angle#9
Adding number conversion cast (unumber) $3e8 in (word) malloc::size#1 ← (number) $3e8
Adding number conversion cast (unumber) $3e8 in (word) malloc::size#2 ← (number) $3e8
Adding number conversion cast (unumber) $80 in (word) malloc::size#3 ← (number) $80
Adding number conversion cast (unumber) 0 in *((byte*) BUCKET_SIZES#0 + (byte) init_buckets::i#2) ← (number) 0
Adding number conversion cast (unumber) $30 in (byte) NUM_BUCKETS#0 ← (number) $30
Adding number conversion cast (unumber) 1 in (number~) init_buckets::$0 ← (byte) NUM_BUCKETS#0 - (number) 1
Adding number conversion cast (unumber) init_buckets::$0 in (number~) init_buckets::$0 ← (byte) NUM_BUCKETS#0 - (unumber)(number) 1
Adding number conversion cast (unumber) 0 in *((byte[]) BUCKET_SIZES#0 + (byte) init_buckets::i#2) ← (number) 0
Adding number conversion cast (unumber) $28*$c in (byte*~) init_angle_screen::$0 ← (byte*) init_angle_screen::screen#1 + (number) $28*(number) $c
Adding number conversion cast (unumber) $28*$c in (byte*~) init_angle_screen::$1 ← (byte*) init_angle_screen::screen#1 + (number) $28*(number) $c
Adding number conversion cast (unumber) 0 in (byte) init_angle_screen::x#0 ← (number) 0
@ -1676,7 +1688,7 @@ Adding number conversion cast (unumber) $13 in (bool~) init_dist_screen::$20 ←
Adding number conversion cast (unumber) $28 in (byte*) init_dist_screen::screen_topline#1 ← (byte*) init_dist_screen::screen_topline#3 + (number) $28
Adding number conversion cast (unumber) $28 in (byte*) init_dist_screen::screen_bottomline#1 ← (byte*) init_dist_screen::screen_bottomline#3 - (number) $28
Successful SSA optimization PassNAddNumberTypeConversions
Inlining cast (byte*) HEAP_START#0 ← (byte*)(number) $c000
Inlining cast (byte*) HEAP_TOP#0 ← (byte*)(number) $a000
Inlining cast (void*) malloc::return#0 ← (void*)(byte*) malloc::mem#0
Inlining cast (signed word~) bsearch16u::$8 ← (signed word)(word) bsearch16u::key#1
Inlining cast (signed word~) bsearch16u::$9 ← (signed word)*((word*) bsearch16u::pivot#0)
@ -1690,9 +1702,9 @@ Inlining cast (word) malloc::size#1 ← (unumber)(number) $3e8
Inlining cast (byte*) SCREEN_DIST#0 ← (byte*)(void*~) $0
Inlining cast (word) malloc::size#2 ← (unumber)(number) $3e8
Inlining cast (byte*) SCREEN_ANGLE#0 ← (byte*)(void*~) $1
Inlining cast (word) malloc::size#3 ← (unumber)(number) $80
Inlining cast (byte*) BUCKET_SIZES#0 ← (byte*)(void*~) $2
Inlining cast *((byte*) BUCKET_SIZES#0 + (byte) init_buckets::i#2) ← (unumber)(number) 0
Inlining cast (byte) NUM_BUCKETS#0 ← (unumber)(number) $30
Inlining cast (byte[]) BUCKET_SIZES#0 ← (byte*)(void*~) $3
Inlining cast *((byte[]) BUCKET_SIZES#0 + (byte) init_buckets::i#2) ← (unumber)(number) 0
Inlining cast (byte) init_angle_screen::x#0 ← (unumber)(number) 0
Inlining cast (byte) init_angle_screen::xb#0 ← (unumber)(number) $27
Inlining cast (signed word~) init_angle_screen::$5 ← (signed word)(word~) init_angle_screen::$4
@ -1701,7 +1713,7 @@ Inlining cast (byte) NUM_SQUARES#3 ← (unumber)(number) $30
Inlining cast (byte) init_dist_screen::x#0 ← (unumber)(number) 0
Inlining cast (byte) init_dist_screen::xb#0 ← (unumber)(number) $27
Successful SSA optimization Pass2InlineCast
Simplifying constant pointer cast (byte*) 49152
Simplifying constant pointer cast (byte*) 40960
Simplifying constant integer cast 0
Simplifying constant integer cast 1
Simplifying constant integer cast 0
@ -1734,7 +1746,8 @@ Simplifying constant integer cast 0
Simplifying constant integer cast $8000
Simplifying constant integer cast $3e8
Simplifying constant integer cast $3e8
Simplifying constant integer cast $80
Simplifying constant integer cast $30
Simplifying constant integer cast 1
Simplifying constant integer cast 0
Simplifying constant integer cast 0
Simplifying constant integer cast $27
@ -1796,7 +1809,8 @@ Finalized signed number type (signed byte) 0
Finalized unsigned number type (word) $8000
Finalized unsigned number type (word) $3e8
Finalized unsigned number type (word) $3e8
Finalized unsigned number type (byte) $80
Finalized unsigned number type (byte) $30
Finalized unsigned number type (byte) 1
Finalized unsigned number type (byte) 0
Finalized unsigned number type (byte) 0
Finalized unsigned number type (byte) $27
@ -1831,6 +1845,7 @@ Inferred type updated to byte in (unumber~) init_squares::$3 ← (byte) init_squ
Inferred type updated to byte in (unumber~) init_squares::$4 ← (byte~) init_squares::$3 + (byte) 1
Inferred type updated to byte in (unumber~) atan2_16::$16 ← (byte) CORDIC_ITERATIONS_16#0 - (byte) 1
Inferred type updated to word in (unumber~) atan2_16::$12 ← (word) $8000 - (word) atan2_16::angle#9
Inferred type updated to byte in (unumber~) init_buckets::$0 ← (byte) NUM_BUCKETS#0 - (byte) 1
Inferred type updated to byte in (unumber~) init_angle_screen::$2 ← (byte) init_angle_screen::x#2 * (byte) 2
Inferred type updated to byte in (unumber~) init_angle_screen::$3 ← (byte) $27 - (byte~) init_angle_screen::$2
Inferred type updated to byte in (unumber~) init_angle_screen::$6 ← (byte) init_angle_screen::y#2 * (byte) 2
@ -1850,14 +1865,15 @@ Inferred type updated to byte in (unumber~) init_dist_screen::$15 ← (byte~) in
Inferred type updated to byte in (unumber~) init_dist_screen::$12 ← (byte) $27 - (byte) init_dist_screen::x2#2
Inferred type updated to byte in (unumber~) init_dist_screen::$13 ← (byte~) init_dist_screen::$12
Inferred type updated to byte for (unumber~) init_dist_screen::$16
Inversing boolean not [24] (bool~) bsearch16u::$12 ← (signed word) bsearch16u::result#0 != (signed byte) 0 from [23] (bool~) bsearch16u::$11 ← (signed word) bsearch16u::result#0 == (signed byte) 0
Inversing boolean not [31] (bool~) bsearch16u::$14 ← (signed word) bsearch16u::result#1 <= (signed byte) 0 from [30] (bool~) bsearch16u::$13 ← (signed word) bsearch16u::result#1 > (signed byte) 0
Inversing boolean not [132] (bool~) atan2_16::$18 ← (signed word) atan2_16::yi#3 != (signed byte) 0 from [131] (bool~) atan2_16::$17 ← (signed word) atan2_16::yi#3 == (signed byte) 0
Inversing boolean not [141] (bool~) atan2_16::$11 ← (signed word) atan2_16::x#4 >= (signed byte) 0 from [140] (bool~) atan2_16::$10 ← (signed word) atan2_16::x#4 < (signed byte) 0
Inversing boolean not [152] (bool~) atan2_16::$20 ← (byte) 0 == (byte) atan2_16::shift#4 from [151] (bool~) atan2_16::$25 ← (byte) 0 != (byte) atan2_16::shift#4
Inversing boolean not [176] (bool~) atan2_16::$14 ← (signed word) atan2_16::y#4 >= (signed byte) 0 from [175] (bool~) atan2_16::$13 ← (signed word) atan2_16::y#4 < (signed byte) 0
Inversing boolean not [25] (bool~) bsearch16u::$12 ← (signed word) bsearch16u::result#0 != (signed byte) 0 from [24] (bool~) bsearch16u::$11 ← (signed word) bsearch16u::result#0 == (signed byte) 0
Inversing boolean not [32] (bool~) bsearch16u::$14 ← (signed word) bsearch16u::result#1 <= (signed byte) 0 from [31] (bool~) bsearch16u::$13 ← (signed word) bsearch16u::result#1 > (signed byte) 0
Inversing boolean not [133] (bool~) atan2_16::$18 ← (signed word) atan2_16::yi#3 != (signed byte) 0 from [132] (bool~) atan2_16::$17 ← (signed word) atan2_16::yi#3 == (signed byte) 0
Inversing boolean not [142] (bool~) atan2_16::$11 ← (signed word) atan2_16::x#4 >= (signed byte) 0 from [141] (bool~) atan2_16::$10 ← (signed word) atan2_16::x#4 < (signed byte) 0
Inversing boolean not [153] (bool~) atan2_16::$20 ← (byte) 0 == (byte) atan2_16::shift#4 from [152] (bool~) atan2_16::$25 ← (byte) 0 != (byte) atan2_16::shift#4
Inversing boolean not [177] (bool~) atan2_16::$14 ← (signed word) atan2_16::y#4 >= (signed byte) 0 from [176] (bool~) atan2_16::$13 ← (signed word) atan2_16::y#4 < (signed byte) 0
Successful SSA optimization Pass2UnaryNotSimplification
Alias (byte*) HEAP_START#0 = (byte*) heap_head#0 (byte*) heap_head#37 (byte*) heap_head#34 (byte*) heap_head#25
Alias (byte*) HEAP_TOP#0 = (byte*) heap_head#0 (byte*) heap_head#37 (byte*) heap_head#34 (byte*) heap_head#25
Alias (byte*) malloc::mem#0 = (byte*~) malloc::$0
Alias (void*) malloc::return#0 = (void*) malloc::return#6 (void*) malloc::return#1
Alias (byte*) heap_head#1 = (byte*) heap_head#14 (byte*) heap_head#2
Alias (byte) bsearch16u::num#3 = (byte) bsearch16u::num#4 (byte) bsearch16u::num#8 (byte) bsearch16u::num#6
@ -1926,6 +1942,7 @@ Alias (byte*) heap_head#18 = (byte*) heap_head#6 (byte*) heap_head#26
Alias (byte) NUM_SQUARES#1 = (byte) NUM_SQUARES#9 (byte) NUM_SQUARES#18 (byte) NUM_SQUARES#15 (byte) NUM_SQUARES#10 (byte) NUM_SQUARES#2
Alias (byte*) heap_head#19 = (byte*) heap_head#7 (byte*) heap_head#35 (byte*) heap_head#30 (byte*) heap_head#20 (byte*) heap_head#8
Alias (word*) SQUARES#12 = (word*) SQUARES#3 (word*) SQUARES#26 (word*) SQUARES#22 (word*) SQUARES#13 (word*) SQUARES#4
Alias (word) malloc::size#3 = (byte~) $2
Alias (void*) malloc::return#10 = (void*) malloc::return#5
Alias (byte*) heap_head#21 = (byte*) heap_head#9 (byte*) heap_head#33
Alias (byte*) init_angle_screen::screen_topline#0 = (byte*~) init_angle_screen::$0
@ -2096,35 +2113,35 @@ Identical Phi Values (word*) SQUARES#9 (word*) SQUARES#18
Identical Phi Values (signed word) atan2_16::x#4 (signed word) atan2_16::x#17
Identical Phi Values (signed word) atan2_16::y#4 (signed word) atan2_16::y#19
Successful SSA optimization Pass2IdenticalPhiElimination
Simple Condition (bool~) bsearch16u::$5 [13] if((byte) bsearch16u::num#3>(byte) 0) goto bsearch16u::@7
Simple Condition (bool~) bsearch16u::$12 [25] if((signed word) bsearch16u::result#0!=(signed byte) 0) goto bsearch16u::@9
Simple Condition (bool~) bsearch16u::$0 [28] if(*((word*) bsearch16u::items#2)<=(word) bsearch16u::key#0) goto bsearch16u::@1
Simple Condition (bool~) bsearch16u::$14 [32] if((signed word) bsearch16u::result#0<=(signed byte) 0) goto bsearch16u::@10
Simple Condition (bool~) init_squares::$5 [77] if((byte) init_squares::i#1!=rangelast(0,init_squares::$2)) goto init_squares::@1
Simple Condition (bool~) atan2_16::$0 [110] if((signed word) atan2_16::y#0>=(signed byte) 0) goto atan2_16::@1
Simple Condition (bool~) atan2_16::$5 [119] if((signed word) atan2_16::x#0>=(signed byte) 0) goto atan2_16::@4
Simple Condition (bool~) atan2_16::$18 [133] if((signed word) atan2_16::yi#3!=(signed byte) 0) goto atan2_16::@16
Simple Condition (bool~) atan2_16::$11 [142] if((signed word) atan2_16::x#17>=(signed byte) 0) goto atan2_16::@7
Simple Condition (bool~) atan2_16::$19 [145] if((byte) atan2_16::shift#2>=(byte) 2) goto atan2_16::@19
Simple Condition (bool~) atan2_16::$20 [153] if((byte) 0==(byte) atan2_16::shift#2) goto atan2_16::@25
Simple Condition (bool~) atan2_16::$21 [156] if((signed word) atan2_16::yi#3>=(signed byte) 0) goto atan2_16::@26
Simple Condition (bool~) atan2_16::$22 [173] if((byte) atan2_16::i#1!=rangelast(0,atan2_16::$16)) goto atan2_16::@15
Simple Condition (bool~) atan2_16::$14 [177] if((signed word) atan2_16::y#19>=(signed byte) 0) goto atan2_16::@8
Simple Condition (bool~) init_buckets::$0 [234] if((byte) init_buckets::i#1!=rangelast(0,$7f)) goto init_buckets::@1
Simple Condition (bool~) init_buckets::$1 [242] if((word) init_buckets::i1#1!=rangelast(0,$3e7)) goto init_buckets::@3
Simple Condition (bool~) init_angle_screen::$15 [285] if((byte) init_angle_screen::x#1<=(byte) $13) goto init_angle_screen::@2
Simple Condition (bool~) init_angle_screen::$16 [291] if((byte) init_angle_screen::y#1!=rangelast(0,$c)) goto init_angle_screen::@1
Simple Condition (bool~) init_dist_screen::$3 [307] if((byte) init_dist_screen::y2#0>=(byte) $18) goto init_dist_screen::@2
Simple Condition (bool~) init_dist_screen::$11 [328] if((byte) init_dist_screen::x2#0>=(byte) $27) goto init_dist_screen::@6
Simple Condition (bool~) init_dist_screen::$20 [358] if((byte) init_dist_screen::x#1<=(byte) $13) goto init_dist_screen::@5
Simple Condition (bool~) init_dist_screen::$21 [364] if((byte) init_dist_screen::y#1!=rangelast(0,$c)) goto init_dist_screen::@1
Simple Condition (bool~) bsearch16u::$5 [14] if((byte) bsearch16u::num#3>(byte) 0) goto bsearch16u::@7
Simple Condition (bool~) bsearch16u::$12 [26] if((signed word) bsearch16u::result#0!=(signed byte) 0) goto bsearch16u::@9
Simple Condition (bool~) bsearch16u::$0 [29] if(*((word*) bsearch16u::items#2)<=(word) bsearch16u::key#0) goto bsearch16u::@1
Simple Condition (bool~) bsearch16u::$14 [33] if((signed word) bsearch16u::result#0<=(signed byte) 0) goto bsearch16u::@10
Simple Condition (bool~) init_squares::$5 [78] if((byte) init_squares::i#1!=rangelast(0,init_squares::$2)) goto init_squares::@1
Simple Condition (bool~) atan2_16::$0 [111] if((signed word) atan2_16::y#0>=(signed byte) 0) goto atan2_16::@1
Simple Condition (bool~) atan2_16::$5 [120] if((signed word) atan2_16::x#0>=(signed byte) 0) goto atan2_16::@4
Simple Condition (bool~) atan2_16::$18 [134] if((signed word) atan2_16::yi#3!=(signed byte) 0) goto atan2_16::@16
Simple Condition (bool~) atan2_16::$11 [143] if((signed word) atan2_16::x#17>=(signed byte) 0) goto atan2_16::@7
Simple Condition (bool~) atan2_16::$19 [146] if((byte) atan2_16::shift#2>=(byte) 2) goto atan2_16::@19
Simple Condition (bool~) atan2_16::$20 [154] if((byte) 0==(byte) atan2_16::shift#2) goto atan2_16::@25
Simple Condition (bool~) atan2_16::$21 [157] if((signed word) atan2_16::yi#3>=(signed byte) 0) goto atan2_16::@26
Simple Condition (bool~) atan2_16::$22 [174] if((byte) atan2_16::i#1!=rangelast(0,atan2_16::$16)) goto atan2_16::@15
Simple Condition (bool~) atan2_16::$14 [178] if((signed word) atan2_16::y#19>=(signed byte) 0) goto atan2_16::@8
Simple Condition (bool~) init_buckets::$1 [238] if((byte) init_buckets::i#1!=rangelast(0,init_buckets::$0)) goto init_buckets::@1
Simple Condition (bool~) init_buckets::$2 [246] if((word) init_buckets::i1#1!=rangelast(0,$3e7)) goto init_buckets::@3
Simple Condition (bool~) init_angle_screen::$15 [289] if((byte) init_angle_screen::x#1<=(byte) $13) goto init_angle_screen::@2
Simple Condition (bool~) init_angle_screen::$16 [295] if((byte) init_angle_screen::y#1!=rangelast(0,$c)) goto init_angle_screen::@1
Simple Condition (bool~) init_dist_screen::$3 [311] if((byte) init_dist_screen::y2#0>=(byte) $18) goto init_dist_screen::@2
Simple Condition (bool~) init_dist_screen::$11 [332] if((byte) init_dist_screen::x2#0>=(byte) $27) goto init_dist_screen::@6
Simple Condition (bool~) init_dist_screen::$20 [362] if((byte) init_dist_screen::x#1<=(byte) $13) goto init_dist_screen::@5
Simple Condition (bool~) init_dist_screen::$21 [368] if((byte) init_dist_screen::y#1!=rangelast(0,$c)) goto init_dist_screen::@1
Successful SSA optimization Pass2ConditionalJumpSimplification
Negating conditional jump and destination [173] if((byte) atan2_16::i#1==rangelast(0,atan2_16::$16)) goto atan2_16::@17
Negating conditional jump and destination [174] if((byte) atan2_16::i#1==rangelast(0,atan2_16::$16)) goto atan2_16::@17
Successful SSA optimization Pass2ConditionalJumpSequenceImprovement
Constant right-side identified [41] (byte~) bsearch16u::$17 ← (byte) 1 * (const byte) SIZEOF_WORD
Constant right-side identified [48] (byte~) bsearch16u::$18 ← (byte) 1 * (const byte) SIZEOF_WORD
Constant right-side identified [42] (byte~) bsearch16u::$17 ← (byte) 1 * (const byte) SIZEOF_WORD
Constant right-side identified [49] (byte~) bsearch16u::$18 ← (byte) 1 * (const byte) SIZEOF_WORD
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant (const byte*) HEAP_START#0 = (byte*) 49152
Constant (const byte*) HEAP_TOP#0 = (byte*) 40960
Constant (const byte) bsearch16u::$17 = 1*SIZEOF_WORD
Constant (const byte) bsearch16u::$18 = 1*SIZEOF_WORD
Constant (const byte) NUM_SQUARES#0 = $ff
@ -2139,7 +2156,7 @@ Constant (const word) atan2_16::angle#0 = 0
Constant (const byte) atan2_16::i#0 = 0
Constant (const word) malloc::size#1 = $3e8
Constant (const word) malloc::size#2 = $3e8
Constant (const word) malloc::size#3 = $80
Constant (const byte) NUM_BUCKETS#0 = $30
Constant (const byte) init_buckets::i#0 = 0
Constant (const word) init_buckets::i1#0 = 0
Constant (const byte) init_angle_screen::y#0 = 0
@ -2150,21 +2167,18 @@ Constant (const byte) init_dist_screen::y#0 = 0
Constant (const byte) init_dist_screen::x#0 = 0
Constant (const byte) init_dist_screen::xb#0 = $27
Successful SSA optimization Pass2ConstantIdentification
Resolved ranged next value [232] init_buckets::i#1 ← ++ init_buckets::i#2 to ++
Resolved ranged comparison value [234] if(init_buckets::i#1!=rangelast(0,$7f)) goto init_buckets::@1 to (number) $80
Resolved ranged next value [240] init_buckets::i1#1 ← ++ init_buckets::i1#2 to ++
Resolved ranged comparison value [242] if(init_buckets::i1#1!=rangelast(0,$3e7)) goto init_buckets::@3 to (number) $3e8
Resolved ranged next value [289] init_angle_screen::y#1 ← ++ init_angle_screen::y#4 to ++
Resolved ranged comparison value [291] if(init_angle_screen::y#1!=rangelast(0,$c)) goto init_angle_screen::@1 to (number) $d
Resolved ranged next value [362] init_dist_screen::y#1 ← ++ init_dist_screen::y#10 to ++
Resolved ranged comparison value [364] if(init_dist_screen::y#1!=rangelast(0,$c)) goto init_dist_screen::@1 to (number) $d
Rewriting conditional comparison [285] if((byte) init_angle_screen::x#1<=(byte) $13) goto init_angle_screen::@2
Rewriting conditional comparison [358] if((byte) init_dist_screen::x#1<=(byte) $13) goto init_dist_screen::@5
Resolved ranged next value [244] init_buckets::i1#1 ← ++ init_buckets::i1#2 to ++
Resolved ranged comparison value [246] if(init_buckets::i1#1!=rangelast(0,$3e7)) goto init_buckets::@3 to (number) $3e8
Resolved ranged next value [293] init_angle_screen::y#1 ← ++ init_angle_screen::y#4 to ++
Resolved ranged comparison value [295] if(init_angle_screen::y#1!=rangelast(0,$c)) goto init_angle_screen::@1 to (number) $d
Resolved ranged next value [366] init_dist_screen::y#1 ← ++ init_dist_screen::y#10 to ++
Resolved ranged comparison value [368] if(init_dist_screen::y#1!=rangelast(0,$c)) goto init_dist_screen::@1 to (number) $d
Rewriting conditional comparison [289] if((byte) init_angle_screen::x#1<=(byte) $13) goto init_angle_screen::@2
Rewriting conditional comparison [362] if((byte) init_dist_screen::x#1<=(byte) $13) goto init_dist_screen::@5
Eliminating unused variable - keeping the phi block (byte*) heap_head#43
Eliminating unused constant (const byte) NUM_SQUARES#0
Eliminating unused constant (const word*) SQUARES#0
Successful SSA optimization PassNEliminateUnusedVars
Adding number conversion cast (unumber) $80 in if((byte) init_buckets::i#1!=(number) $80) goto init_buckets::@1
Adding number conversion cast (unumber) $3e8 in if((word) init_buckets::i1#1!=(number) $3e8) goto init_buckets::@3
Adding number conversion cast (unumber) $13+1 in if((byte) init_angle_screen::x#1<(byte) $13+(number) 1) goto init_angle_screen::@2
Adding number conversion cast (unumber) 1 in if((byte) init_angle_screen::x#1<(unumber)(byte) $13+(number) 1) goto init_angle_screen::@2
@ -2173,7 +2187,6 @@ Adding number conversion cast (unumber) $13+1 in if((byte) init_dist_screen::x#1
Adding number conversion cast (unumber) 1 in if((byte) init_dist_screen::x#1<(unumber)(byte) $13+(number) 1) goto init_dist_screen::@5
Adding number conversion cast (unumber) $d in if((byte) init_dist_screen::y#1!=(number) $d) goto init_dist_screen::@1
Successful SSA optimization PassNAddNumberTypeConversions
Simplifying constant integer cast $80
Simplifying constant integer cast $3e8
Simplifying constant integer cast (byte~) init_angle_screen::$3
Simplifying constant integer cast (byte~) init_angle_screen::$6
@ -2184,7 +2197,6 @@ Simplifying constant integer cast (byte) $13+(unumber)(number) 1
Simplifying constant integer cast 1
Simplifying constant integer cast $d
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (byte) $80
Finalized unsigned number type (word) $3e8
Finalized unsigned number type (byte) 1
Finalized unsigned number type (byte) $d
@ -2204,28 +2216,39 @@ Successful SSA optimization Pass2IdenticalPhiElimination
Constant right-side identified [24] (word) malloc::size#0 ← (const byte) NUM_SQUARES#3 * (const byte) SIZEOF_WORD
Constant right-side identified [30] (byte~) init_squares::$2 ← (const byte) NUM_SQUARES#3 - (byte) 1
Constant right-side identified [60] (byte~) atan2_16::$16 ← (const byte) CORDIC_ITERATIONS_16#0 - (byte) 1
Constant right-side identified [107] (word) malloc::size#3 ← (const byte) NUM_BUCKETS#0 * (const byte) SIZEOF_BYTE
Constant right-side identified [112] (byte~) init_buckets::$0 ← (const byte) NUM_BUCKETS#0 - (byte) 1
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant (const word) malloc::size#0 = NUM_SQUARES#3*SIZEOF_WORD
Constant (const byte) init_squares::$2 = NUM_SQUARES#3-1
Constant (const byte) bsearch16u::num#2 = NUM_SQUARES#3
Constant (const byte) atan2_16::$16 = CORDIC_ITERATIONS_16#0-1
Constant (const word) malloc::size#3 = NUM_BUCKETS#0*SIZEOF_BYTE
Constant (const byte) init_buckets::$0 = NUM_BUCKETS#0-1
Successful SSA optimization Pass2ConstantIdentification
Resolved ranged next value [37] init_squares::i#1 ← ++ init_squares::i#2 to ++
Resolved ranged comparison value [38] if(init_squares::i#1!=rangelast(0,init_squares::$2)) goto init_squares::@1 to (const byte) init_squares::$2+(number) 1
Resolved ranged next value [85] atan2_16::i#1 ← ++ atan2_16::i#2 to ++
Resolved ranged comparison value [86] if(atan2_16::i#1==rangelast(0,atan2_16::$16)) goto atan2_16::@17 to (const byte) atan2_16::$16+(number) 1
Resolved ranged next value [115] init_buckets::i#1 ← ++ init_buckets::i#2 to ++
Resolved ranged comparison value [116] if(init_buckets::i#1!=rangelast(0,init_buckets::$0)) goto init_buckets::@1 to (const byte) init_buckets::$0+(number) 1
Adding number conversion cast (unumber) init_squares::$2+1 in if((byte) init_squares::i#1!=(const byte) init_squares::$2+(number) 1) goto init_squares::@1
Adding number conversion cast (unumber) 1 in if((byte) init_squares::i#1!=(unumber)(const byte) init_squares::$2+(number) 1) goto init_squares::@1
Adding number conversion cast (unumber) atan2_16::$16+1 in if((byte) atan2_16::i#1==(const byte) atan2_16::$16+(number) 1) goto atan2_16::@17
Adding number conversion cast (unumber) 1 in if((byte) atan2_16::i#1==(unumber)(const byte) atan2_16::$16+(number) 1) goto atan2_16::@17
Adding number conversion cast (unumber) init_buckets::$0+1 in if((byte) init_buckets::i#1!=(const byte) init_buckets::$0+(number) 1) goto init_buckets::@1
Adding number conversion cast (unumber) 1 in if((byte) init_buckets::i#1!=(unumber)(const byte) init_buckets::$0+(number) 1) goto init_buckets::@1
Successful SSA optimization PassNAddNumberTypeConversions
Simplifying constant integer cast (const byte) init_squares::$2+(unumber)(number) 1
Simplifying constant integer cast 1
Simplifying constant integer cast (const byte) atan2_16::$16+(unumber)(number) 1
Simplifying constant integer cast 1
Simplifying constant integer cast (const byte) init_buckets::$0+(unumber)(number) 1
Simplifying constant integer cast 1
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (byte) 1
Finalized unsigned number type (byte) 1
Finalized unsigned number type (byte) 1
Successful SSA optimization PassNFinalizeNumberTypeConversions
Inlining Noop Cast [3] (void*) malloc::return#0 ← (void*)(byte*) malloc::mem#0 keeping malloc::mem#0
Inlining Noop Cast [10] (signed word~) bsearch16u::$8 ← (signed word)(word) bsearch16u::key#0 keeping bsearch16u::key#0
@ -2239,7 +2262,7 @@ Successful SSA optimization Pass2NopCastInlining
Inlining Noop Cast [27] (word*) SQUARES#1 ← (word*)(void*~) init_squares::$1 keeping SQUARES#1
Inlining Noop Cast [92] (byte*) SCREEN_DIST#0 ← (byte*)(void*~) $0 keeping SCREEN_DIST#0
Inlining Noop Cast [96] (byte*) SCREEN_ANGLE#0 ← (byte*)(void*~) $1 keeping SCREEN_ANGLE#0
Inlining Noop Cast [106] (byte*) BUCKET_SIZES#0 ← (byte*)(void*~) $2 keeping BUCKET_SIZES#0
Inlining Noop Cast [106] (byte[]) BUCKET_SIZES#0 ← (byte*)(void*~) $3 keeping BUCKET_SIZES#0
Inlining Noop Cast [125] (signed word) init_angle_screen::xw#0 ← (signed word)(word~) init_angle_screen::$4 keeping init_angle_screen::xw#0
Inlining Noop Cast [128] (signed word) init_angle_screen::yw#0 ← (signed word)(word~) init_angle_screen::$7 keeping init_angle_screen::yw#0
Successful SSA optimization Pass2NopCastInlining
@ -2257,8 +2280,8 @@ Rewriting multiplication to use shift [164] (byte) init_dist_screen::x2#0 ← (b
Successful SSA optimization Pass2MultiplyToShiftRewriting
Inlining constant with var siblings (const word) malloc::size#1
Inlining constant with var siblings (const word) malloc::size#2
Inlining constant with var siblings (const word) malloc::size#3
Inlining constant with var siblings (const word) malloc::size#0
Inlining constant with var siblings (const word) malloc::size#3
Inlining constant with var siblings (const byte) bsearch16u::num#2
Inlining constant with var siblings (const word) init_squares::sqr#0
Inlining constant with var siblings (const byte) init_squares::i#0
@ -2272,7 +2295,8 @@ Inlining constant with var siblings (const byte) init_angle_screen::xb#0
Inlining constant with var siblings (const byte) init_dist_screen::y#0
Inlining constant with var siblings (const byte) init_dist_screen::x#0
Inlining constant with var siblings (const byte) init_dist_screen::xb#0
Constant inlined malloc::size#3 = (byte) $80
Constant inlined init_buckets::$0 = (const byte) NUM_BUCKETS#0-(byte) 1
Constant inlined malloc::size#3 = (const byte) NUM_BUCKETS#0*(const byte) SIZEOF_BYTE
Constant inlined init_buckets::i1#0 = (word) 0
Constant inlined malloc::size#2 = (word) $3e8
Constant inlined init_squares::sqr#0 = (byte) 0
@ -2402,7 +2426,8 @@ Coalesced [246] init_squares::squares#4 ← init_squares::squares#0
Coalesced [256] init_squares::sqr#3 ← init_squares::sqr#1
Coalesced [257] init_squares::squares#3 ← init_squares::squares#1
Coalesced [258] init_squares::i#3 ← init_squares::i#1
Coalesced down to 34 phi equivalence classes
Not coalescing [261] heap_head#1 ← malloc::mem#0
Coalesced down to 35 phi equivalence classes
Culled Empty Block (label) @3
Culled Empty Block (label) @6
Culled Empty Block (label) @16
@ -2519,7 +2544,7 @@ init_buckets::@1: scope:[init_buckets] from init_buckets init_buckets::@1
[20] (byte) init_buckets::i#2 ← phi( init_buckets/(byte) 0 init_buckets::@1/(byte) init_buckets::i#1 )
[21] *((byte*)(void*) BUCKET_SIZES#0 + (byte) init_buckets::i#2) ← (byte) 0
[22] (byte) init_buckets::i#1 ← ++ (byte) init_buckets::i#2
[23] if((byte) init_buckets::i#1!=(byte) $80) goto init_buckets::@1
[23] if((byte) init_buckets::i#1!=(const byte) NUM_BUCKETS#0-(byte) 1+(byte) 1) goto init_buckets::@1
to:init_buckets::@2
init_buckets::@2: scope:[init_buckets] from init_buckets::@1
[24] (byte*) init_buckets::dist#0 ← (byte*)(void*) SCREEN_DIST#0
@ -2841,10 +2866,10 @@ init_squares::@return: scope:[init_squares] from init_squares::@1
[189] return
to:@return
malloc: scope:[malloc] from @1 @2 @4 init_squares
[190] (word) malloc::size#4 ← phi( @4/(word) $3e8 @1/(word) $3e8 @2/(byte) $80 init_squares/(const byte) NUM_SQUARES#3*(const byte) SIZEOF_WORD )
[190] (byte*) heap_head#13 ← phi( @4/(byte*) heap_head#1 @1/(const byte*) HEAP_START#0 @2/(byte*) heap_head#1 init_squares/(byte*) heap_head#1 )
[191] (byte*) malloc::mem#0 ← (byte*) heap_head#13
[192] (byte*) heap_head#1 ← (byte*) heap_head#13 + (word) malloc::size#4
[190] (word) malloc::size#4 ← phi( @4/(word) $3e8 @1/(word) $3e8 @2/(const byte) NUM_BUCKETS#0*(const byte) SIZEOF_BYTE init_squares/(const byte) NUM_SQUARES#3*(const byte) SIZEOF_WORD )
[190] (byte*) heap_head#13 ← phi( @4/(byte*) heap_head#1 @1/(const byte*) HEAP_TOP#0 @2/(byte*) heap_head#1 init_squares/(byte*) heap_head#1 )
[191] (byte*) malloc::mem#0 ← (byte*) heap_head#13 - (word) malloc::size#4
[192] (byte*) heap_head#1 ← (byte*) malloc::mem#0
to:malloc::@return
malloc::@return: scope:[malloc] from malloc
[193] return
@ -2852,11 +2877,12 @@ malloc::@return: scope:[malloc] from malloc
VARIABLE REGISTER WEIGHTS
(byte*) BUCKET_SIZES
(byte[]) BUCKET_SIZES
(void*) BUCKET_SIZES#0 0.1111111111111111
(word[CORDIC_ITERATIONS_16#0]) CORDIC_ATAN2_ANGLES_16
(byte) CORDIC_ITERATIONS_16
(byte*) HEAP_START
(byte*) HEAP_TOP
(byte) NUM_BUCKETS
(byte) NUM_SQUARES
(byte*) SCREEN_ANGLE
(void*) SCREEN_ANGLE#0 0.2857142857142857
@ -2946,7 +2972,7 @@ VARIABLE REGISTER WEIGHTS
(word*~) bsearch16u::return#6 4.0
(byte*) heap_head
(byte*) heap_head#1 0.6153846153846154
(byte*) heap_head#13 5.0
(byte*) heap_head#13 8.0
(void()) init_angle_screen((byte*) init_angle_screen::screen)
(word~) init_angle_screen::$10 202.0
(byte~) init_angle_screen::$12 202.0
@ -3048,10 +3074,10 @@ VARIABLE REGISTER WEIGHTS
(void()) main()
(void*()) malloc((word) malloc::size)
(byte*) malloc::mem
(byte*) malloc::mem#0 0.2857142857142857
(byte*) malloc::mem#0 0.5714285714285714
(void*) malloc::return
(word) malloc::size
(word) malloc::size#4 1.0
(word) malloc::size#4 2.0
(word()) sqr((byte) sqr::val)
(byte~) sqr::$0 4.0
(word) sqr::return
@ -3318,10 +3344,13 @@ INITIAL ASM
.pc = $80d "Program"
// Global Constants & labels
.const SIZEOF_WORD = 2
// Start of the heap used by malloc()
.label HEAP_START = $c000
.const SIZEOF_BYTE = 1
// Top of the heap used by malloc()
.label HEAP_TOP = $a000
// The number of iterations performed during 16-bit CORDIC atan2 calculation
.const CORDIC_ITERATIONS_16 = $f
// The number of buckets in our bucket sort
.const NUM_BUCKETS = $30
.const NUM_SQUARES = $30
.label heap_head = $2e
.label SQUARES = $75
@ -3346,10 +3375,10 @@ malloc_from_b1:
sta malloc.size
lda #>$3e8
sta malloc.size+1
// [190] phi (byte*) heap_head#13 = (const byte*) HEAP_START#0 [phi:@1->malloc#1] -- pbuz1=pbuc1
lda #<HEAP_START
// [190] phi (byte*) heap_head#13 = (const byte*) HEAP_TOP#0 [phi:@1->malloc#1] -- pbuz1=pbuc1
lda #<HEAP_TOP
sta heap_head
lda #>HEAP_START
lda #>HEAP_TOP
sta heap_head+1
jsr malloc
jmp b4
@ -3386,8 +3415,8 @@ b2:
// [7] call malloc
// [190] phi from @2 to malloc [phi:@2->malloc]
malloc_from_b2:
// [190] phi (word) malloc::size#4 = (byte) $80 [phi:@2->malloc#0] -- vwuz1=vbuc1
lda #$80
// [190] phi (word) malloc::size#4 = (const byte) NUM_BUCKETS#0*(const byte) SIZEOF_BYTE [phi:@2->malloc#0] -- vwuz1=vbuc1
lda #NUM_BUCKETS*SIZEOF_BYTE
sta malloc.size
lda #0
sta malloc.size+1
@ -3450,6 +3479,7 @@ main: {
rts
}
// init_buckets
//const word*[] BUCKETS = malloc(NUM_BUCKETS*sizeof(word*));
init_buckets: {
.label i = 2
.label dist = 3
@ -3473,8 +3503,8 @@ init_buckets: {
sta (BUCKET_SIZES),y
// [22] (byte) init_buckets::i#1 ← ++ (byte) init_buckets::i#2 -- vbuz1=_inc_vbuz1
inc i
// [23] if((byte) init_buckets::i#1!=(byte) $80) goto init_buckets::@1 -- vbuz1_neq_vbuc1_then_la1
lda #$80
// [23] if((byte) init_buckets::i#1!=(const byte) NUM_BUCKETS#0-(byte) 1+(byte) 1) goto init_buckets::@1 -- vbuz1_neq_vbuc1_then_la1
lda #NUM_BUCKETS-1+1
cmp i
bne b1_from_b1
jmp b2
@ -4661,18 +4691,18 @@ init_squares: {
malloc: {
.label mem = $79
.label size = $30
// [191] (byte*) malloc::mem#0 ← (byte*) heap_head#13 -- pbuz1=pbuz2
// [191] (byte*) malloc::mem#0 ← (byte*) heap_head#13 - (word) malloc::size#4 -- pbuz1=pbuz2_minus_vwuz3
lda heap_head
sec
sbc size
sta mem
lda heap_head+1
sbc size+1
sta mem+1
// [192] (byte*) heap_head#1 ← (byte*) heap_head#13 + (word) malloc::size#4 -- pbuz1=pbuz1_plus_vwuz2
lda heap_head
clc
adc size
// [192] (byte*) heap_head#1 ← (byte*) malloc::mem#0 -- pbuz1=pbuz2
lda mem
sta heap_head
lda heap_head+1
adc size+1
lda mem+1
sta heap_head+1
jmp breturn
// malloc::@return
@ -4805,8 +4835,8 @@ Removing always clobbered register reg byte y as potential for zp ZP_BYTE:45 [ i
Statement [183] (word*) init_squares::squares#1 ← (word*) init_squares::squares#2 + (const byte) SIZEOF_WORD [ SQUARES#1 init_squares::sqr#2 init_squares::i#2 init_squares::squares#1 ] ( main:10::init_dist_screen:13::init_squares:106 [ SCREEN_DIST#0 SCREEN_ANGLE#0 BUCKET_SIZES#0 init_dist_screen::screen#0 SQUARES#1 init_squares::sqr#2 init_squares::i#2 init_squares::squares#1 ] ) always clobbers reg byte a
Statement [184] (byte~) init_squares::$3 ← (byte) init_squares::i#2 << (byte) 1 [ SQUARES#1 init_squares::sqr#2 init_squares::i#2 init_squares::squares#1 init_squares::$3 ] ( main:10::init_dist_screen:13::init_squares:106 [ SCREEN_DIST#0 SCREEN_ANGLE#0 BUCKET_SIZES#0 init_dist_screen::screen#0 SQUARES#1 init_squares::sqr#2 init_squares::i#2 init_squares::squares#1 init_squares::$3 ] ) always clobbers reg byte a
Statement [186] (word) init_squares::sqr#1 ← (word) init_squares::sqr#2 + (byte~) init_squares::$4 [ SQUARES#1 init_squares::i#2 init_squares::sqr#1 init_squares::squares#1 ] ( main:10::init_dist_screen:13::init_squares:106 [ SCREEN_DIST#0 SCREEN_ANGLE#0 BUCKET_SIZES#0 init_dist_screen::screen#0 SQUARES#1 init_squares::i#2 init_squares::sqr#1 init_squares::squares#1 ] ) always clobbers reg byte a
Statement [191] (byte*) malloc::mem#0 ← (byte*) heap_head#13 [ malloc::mem#0 heap_head#13 malloc::size#4 ] ( malloc:2 [ malloc::mem#0 heap_head#13 malloc::size#4 ] malloc:4 [ malloc::mem#0 heap_head#13 malloc::size#4 ] malloc:7 [ malloc::mem#0 heap_head#13 malloc::size#4 ] main:10::init_dist_screen:13::init_squares:106::malloc:178 [ SCREEN_DIST#0 SCREEN_ANGLE#0 BUCKET_SIZES#0 init_dist_screen::screen#0 malloc::mem#0 heap_head#13 malloc::size#4 ] ) always clobbers reg byte a
Statement [192] (byte*) heap_head#1 ← (byte*) heap_head#13 + (word) malloc::size#4 [ malloc::mem#0 heap_head#1 ] ( malloc:2 [ malloc::mem#0 heap_head#1 ] malloc:4 [ malloc::mem#0 heap_head#1 ] malloc:7 [ malloc::mem#0 heap_head#1 ] main:10::init_dist_screen:13::init_squares:106::malloc:178 [ SCREEN_DIST#0 SCREEN_ANGLE#0 BUCKET_SIZES#0 init_dist_screen::screen#0 malloc::mem#0 heap_head#1 ] ) always clobbers reg byte a
Statement [191] (byte*) malloc::mem#0 ← (byte*) heap_head#13 - (word) malloc::size#4 [ malloc::mem#0 ] ( malloc:2 [ malloc::mem#0 ] malloc:4 [ malloc::mem#0 ] malloc:7 [ malloc::mem#0 ] main:10::init_dist_screen:13::init_squares:106::malloc:178 [ SCREEN_DIST#0 SCREEN_ANGLE#0 BUCKET_SIZES#0 init_dist_screen::screen#0 malloc::mem#0 ] ) always clobbers reg byte a
Statement [192] (byte*) heap_head#1 ← (byte*) malloc::mem#0 [ malloc::mem#0 heap_head#1 ] ( malloc:2 [ malloc::mem#0 heap_head#1 ] malloc:4 [ malloc::mem#0 heap_head#1 ] malloc:7 [ malloc::mem#0 heap_head#1 ] main:10::init_dist_screen:13::init_squares:106::malloc:178 [ SCREEN_DIST#0 SCREEN_ANGLE#0 BUCKET_SIZES#0 init_dist_screen::screen#0 malloc::mem#0 heap_head#1 ] ) always clobbers reg byte a
Statement [3] (void*) SCREEN_DIST#0 ← (void*)(byte*) malloc::mem#0 [ SCREEN_DIST#0 heap_head#1 ] ( [ SCREEN_DIST#0 heap_head#1 ] ) always clobbers reg byte a
Statement [5] (void*) SCREEN_ANGLE#0 ← (void*)(byte*) malloc::mem#0 [ SCREEN_DIST#0 SCREEN_ANGLE#0 heap_head#1 ] ( [ SCREEN_DIST#0 SCREEN_ANGLE#0 heap_head#1 ] ) always clobbers reg byte a
Statement [8] (void*) BUCKET_SIZES#0 ← (void*)(byte*) malloc::mem#0 [ SCREEN_DIST#0 SCREEN_ANGLE#0 BUCKET_SIZES#0 heap_head#1 ] ( [ SCREEN_DIST#0 SCREEN_ANGLE#0 BUCKET_SIZES#0 heap_head#1 ] ) always clobbers reg byte a
@ -4908,8 +4938,8 @@ Statement [182] *((word*) init_squares::squares#2) ← (word) init_squares::sqr#
Statement [183] (word*) init_squares::squares#1 ← (word*) init_squares::squares#2 + (const byte) SIZEOF_WORD [ SQUARES#1 init_squares::sqr#2 init_squares::i#2 init_squares::squares#1 ] ( main:10::init_dist_screen:13::init_squares:106 [ SCREEN_DIST#0 SCREEN_ANGLE#0 BUCKET_SIZES#0 init_dist_screen::screen#0 SQUARES#1 init_squares::sqr#2 init_squares::i#2 init_squares::squares#1 ] ) always clobbers reg byte a
Statement [184] (byte~) init_squares::$3 ← (byte) init_squares::i#2 << (byte) 1 [ SQUARES#1 init_squares::sqr#2 init_squares::i#2 init_squares::squares#1 init_squares::$3 ] ( main:10::init_dist_screen:13::init_squares:106 [ SCREEN_DIST#0 SCREEN_ANGLE#0 BUCKET_SIZES#0 init_dist_screen::screen#0 SQUARES#1 init_squares::sqr#2 init_squares::i#2 init_squares::squares#1 init_squares::$3 ] ) always clobbers reg byte a
Statement [186] (word) init_squares::sqr#1 ← (word) init_squares::sqr#2 + (byte~) init_squares::$4 [ SQUARES#1 init_squares::i#2 init_squares::sqr#1 init_squares::squares#1 ] ( main:10::init_dist_screen:13::init_squares:106 [ SCREEN_DIST#0 SCREEN_ANGLE#0 BUCKET_SIZES#0 init_dist_screen::screen#0 SQUARES#1 init_squares::i#2 init_squares::sqr#1 init_squares::squares#1 ] ) always clobbers reg byte a
Statement [191] (byte*) malloc::mem#0 ← (byte*) heap_head#13 [ malloc::mem#0 heap_head#13 malloc::size#4 ] ( malloc:2 [ malloc::mem#0 heap_head#13 malloc::size#4 ] malloc:4 [ malloc::mem#0 heap_head#13 malloc::size#4 ] malloc:7 [ malloc::mem#0 heap_head#13 malloc::size#4 ] main:10::init_dist_screen:13::init_squares:106::malloc:178 [ SCREEN_DIST#0 SCREEN_ANGLE#0 BUCKET_SIZES#0 init_dist_screen::screen#0 malloc::mem#0 heap_head#13 malloc::size#4 ] ) always clobbers reg byte a
Statement [192] (byte*) heap_head#1 ← (byte*) heap_head#13 + (word) malloc::size#4 [ malloc::mem#0 heap_head#1 ] ( malloc:2 [ malloc::mem#0 heap_head#1 ] malloc:4 [ malloc::mem#0 heap_head#1 ] malloc:7 [ malloc::mem#0 heap_head#1 ] main:10::init_dist_screen:13::init_squares:106::malloc:178 [ SCREEN_DIST#0 SCREEN_ANGLE#0 BUCKET_SIZES#0 init_dist_screen::screen#0 malloc::mem#0 heap_head#1 ] ) always clobbers reg byte a
Statement [191] (byte*) malloc::mem#0 ← (byte*) heap_head#13 - (word) malloc::size#4 [ malloc::mem#0 ] ( malloc:2 [ malloc::mem#0 ] malloc:4 [ malloc::mem#0 ] malloc:7 [ malloc::mem#0 ] main:10::init_dist_screen:13::init_squares:106::malloc:178 [ SCREEN_DIST#0 SCREEN_ANGLE#0 BUCKET_SIZES#0 init_dist_screen::screen#0 malloc::mem#0 ] ) always clobbers reg byte a
Statement [192] (byte*) heap_head#1 ← (byte*) malloc::mem#0 [ malloc::mem#0 heap_head#1 ] ( malloc:2 [ malloc::mem#0 heap_head#1 ] malloc:4 [ malloc::mem#0 heap_head#1 ] malloc:7 [ malloc::mem#0 heap_head#1 ] main:10::init_dist_screen:13::init_squares:106::malloc:178 [ SCREEN_DIST#0 SCREEN_ANGLE#0 BUCKET_SIZES#0 init_dist_screen::screen#0 malloc::mem#0 heap_head#1 ] ) always clobbers reg byte a
Statement [3] (void*) SCREEN_DIST#0 ← (void*)(byte*) malloc::mem#0 [ SCREEN_DIST#0 heap_head#1 ] ( [ SCREEN_DIST#0 heap_head#1 ] ) always clobbers reg byte a
Statement [5] (void*) SCREEN_ANGLE#0 ← (void*)(byte*) malloc::mem#0 [ SCREEN_DIST#0 SCREEN_ANGLE#0 heap_head#1 ] ( [ SCREEN_DIST#0 SCREEN_ANGLE#0 heap_head#1 ] ) always clobbers reg byte a
Statement [8] (void*) BUCKET_SIZES#0 ← (void*)(byte*) malloc::mem#0 [ SCREEN_DIST#0 SCREEN_ANGLE#0 BUCKET_SIZES#0 heap_head#1 ] ( [ SCREEN_DIST#0 SCREEN_ANGLE#0 BUCKET_SIZES#0 heap_head#1 ] ) always clobbers reg byte a
@ -5010,8 +5040,8 @@ Statement [182] *((word*) init_squares::squares#2) ← (word) init_squares::sqr#
Statement [183] (word*) init_squares::squares#1 ← (word*) init_squares::squares#2 + (const byte) SIZEOF_WORD [ SQUARES#1 init_squares::sqr#2 init_squares::i#2 init_squares::squares#1 ] ( main:10::init_dist_screen:13::init_squares:106 [ SCREEN_DIST#0 SCREEN_ANGLE#0 BUCKET_SIZES#0 init_dist_screen::screen#0 SQUARES#1 init_squares::sqr#2 init_squares::i#2 init_squares::squares#1 ] ) always clobbers reg byte a
Statement [184] (byte~) init_squares::$3 ← (byte) init_squares::i#2 << (byte) 1 [ SQUARES#1 init_squares::sqr#2 init_squares::i#2 init_squares::squares#1 init_squares::$3 ] ( main:10::init_dist_screen:13::init_squares:106 [ SCREEN_DIST#0 SCREEN_ANGLE#0 BUCKET_SIZES#0 init_dist_screen::screen#0 SQUARES#1 init_squares::sqr#2 init_squares::i#2 init_squares::squares#1 init_squares::$3 ] ) always clobbers reg byte a
Statement [186] (word) init_squares::sqr#1 ← (word) init_squares::sqr#2 + (byte~) init_squares::$4 [ SQUARES#1 init_squares::i#2 init_squares::sqr#1 init_squares::squares#1 ] ( main:10::init_dist_screen:13::init_squares:106 [ SCREEN_DIST#0 SCREEN_ANGLE#0 BUCKET_SIZES#0 init_dist_screen::screen#0 SQUARES#1 init_squares::i#2 init_squares::sqr#1 init_squares::squares#1 ] ) always clobbers reg byte a
Statement [191] (byte*) malloc::mem#0 ← (byte*) heap_head#13 [ malloc::mem#0 heap_head#13 malloc::size#4 ] ( malloc:2 [ malloc::mem#0 heap_head#13 malloc::size#4 ] malloc:4 [ malloc::mem#0 heap_head#13 malloc::size#4 ] malloc:7 [ malloc::mem#0 heap_head#13 malloc::size#4 ] main:10::init_dist_screen:13::init_squares:106::malloc:178 [ SCREEN_DIST#0 SCREEN_ANGLE#0 BUCKET_SIZES#0 init_dist_screen::screen#0 malloc::mem#0 heap_head#13 malloc::size#4 ] ) always clobbers reg byte a
Statement [192] (byte*) heap_head#1 ← (byte*) heap_head#13 + (word) malloc::size#4 [ malloc::mem#0 heap_head#1 ] ( malloc:2 [ malloc::mem#0 heap_head#1 ] malloc:4 [ malloc::mem#0 heap_head#1 ] malloc:7 [ malloc::mem#0 heap_head#1 ] main:10::init_dist_screen:13::init_squares:106::malloc:178 [ SCREEN_DIST#0 SCREEN_ANGLE#0 BUCKET_SIZES#0 init_dist_screen::screen#0 malloc::mem#0 heap_head#1 ] ) always clobbers reg byte a
Statement [191] (byte*) malloc::mem#0 ← (byte*) heap_head#13 - (word) malloc::size#4 [ malloc::mem#0 ] ( malloc:2 [ malloc::mem#0 ] malloc:4 [ malloc::mem#0 ] malloc:7 [ malloc::mem#0 ] main:10::init_dist_screen:13::init_squares:106::malloc:178 [ SCREEN_DIST#0 SCREEN_ANGLE#0 BUCKET_SIZES#0 init_dist_screen::screen#0 malloc::mem#0 ] ) always clobbers reg byte a
Statement [192] (byte*) heap_head#1 ← (byte*) malloc::mem#0 [ malloc::mem#0 heap_head#1 ] ( malloc:2 [ malloc::mem#0 heap_head#1 ] malloc:4 [ malloc::mem#0 heap_head#1 ] malloc:7 [ malloc::mem#0 heap_head#1 ] main:10::init_dist_screen:13::init_squares:106::malloc:178 [ SCREEN_DIST#0 SCREEN_ANGLE#0 BUCKET_SIZES#0 init_dist_screen::screen#0 malloc::mem#0 heap_head#1 ] ) always clobbers reg byte a
Potential registers zp ZP_BYTE:2 [ init_buckets::i#2 init_buckets::i#1 ] : zp ZP_BYTE:2 , reg byte x , reg byte y ,
Potential registers zp ZP_WORD:3 [ init_buckets::dist#2 init_buckets::dist#0 init_buckets::dist#1 ] : zp ZP_WORD:3 ,
Potential registers zp ZP_WORD:5 [ init_buckets::i1#2 init_buckets::i1#1 ] : zp ZP_WORD:5 ,
@ -5099,8 +5129,8 @@ Uplift Scope [sqr] 338: zp ZP_BYTE:40 [ sqr::val#2 sqr::val#0 sqr::val#1 ] 202:
Uplift Scope [sqrt] 202: zp ZP_BYTE:95 [ sqrt::return#2 ] 103: zp ZP_WORD:93 [ sqrt::val#0 ] 34.33: zp ZP_BYTE:107 [ sqrt::return#0 ] 4: zp ZP_WORD:101 [ sqrt::found#0 ] 4: zp ZP_WORD:103 [ sqrt::$3 ] 2: zp ZP_WORD:105 [ sqrt::$1 ]
Uplift Scope [init_squares] 25.17: zp ZP_WORD:43 [ init_squares::squares#2 init_squares::squares#1 init_squares::squares#0 ] 22: zp ZP_BYTE:45 [ init_squares::i#2 init_squares::i#1 ] 22: zp ZP_BYTE:119 [ init_squares::$3 ] 22: zp ZP_BYTE:120 [ init_squares::$4 ] 13.93: zp ZP_WORD:41 [ init_squares::sqr#2 init_squares::sqr#1 ]
Uplift Scope [init_buckets] 34.33: zp ZP_WORD:3 [ init_buckets::dist#2 init_buckets::dist#0 init_buckets::dist#1 ] 33: zp ZP_BYTE:2 [ init_buckets::i#2 init_buckets::i#1 ] 23.83: zp ZP_WORD:5 [ init_buckets::i1#2 init_buckets::i1#1 ]
Uplift Scope [] 5.62: zp ZP_WORD:46 [ heap_head#13 heap_head#1 ] 0.29: zp ZP_WORD:52 [ SCREEN_ANGLE#0 ] 0.12: zp ZP_WORD:50 [ SCREEN_DIST#0 ] 0.11: zp ZP_WORD:54 [ BUCKET_SIZES#0 ] 0.03: zp ZP_WORD:117 [ SQUARES#1 ]
Uplift Scope [malloc] 1: zp ZP_WORD:48 [ malloc::size#4 ] 0.29: zp ZP_WORD:121 [ malloc::mem#0 ]
Uplift Scope [] 8.62: zp ZP_WORD:46 [ heap_head#13 heap_head#1 ] 0.29: zp ZP_WORD:52 [ SCREEN_ANGLE#0 ] 0.12: zp ZP_WORD:50 [ SCREEN_DIST#0 ] 0.11: zp ZP_WORD:54 [ BUCKET_SIZES#0 ] 0.03: zp ZP_WORD:117 [ SQUARES#1 ]
Uplift Scope [malloc] 2: zp ZP_WORD:48 [ malloc::size#4 ] 0.57: zp ZP_WORD:121 [ malloc::mem#0 ]
Uplift Scope [main]
Uplifting [atan2_16] best 1227262 combination reg byte y [ atan2_16::shift#2 atan2_16::shift#5 atan2_16::shift#1 ] zp ZP_WORD:24 [ atan2_16::yd#5 atan2_16::yd#3 atan2_16::yd#10 atan2_16::yd#1 atan2_16::yd#2 ] zp ZP_WORD:26 [ atan2_16::xd#5 atan2_16::xd#3 atan2_16::xd#10 atan2_16::xd#1 atan2_16::xd#2 ] zp ZP_WORD:19 [ atan2_16::angle#6 atan2_16::angle#12 atan2_16::angle#13 atan2_16::angle#2 atan2_16::angle#3 ] zp ZP_WORD:14 [ atan2_16::yi#3 atan2_16::yi#8 atan2_16::yi#0 atan2_16::yi#16 atan2_16::$2 atan2_16::yi#1 atan2_16::yi#2 ] zp ZP_WORD:16 [ atan2_16::xi#3 atan2_16::xi#8 atan2_16::xi#0 atan2_16::xi#13 atan2_16::$7 atan2_16::xi#1 atan2_16::xi#2 ] reg byte a [ atan2_16::$24 ] reg byte a [ atan2_16::$23 ] reg byte x [ atan2_16::i#2 atan2_16::i#1 ] zp ZP_WORD:69 [ atan2_16::return#2 ] zp ZP_WORD:21 [ atan2_16::return#0 atan2_16::angle#5 atan2_16::angle#11 atan2_16::angle#1 atan2_16::angle#4 ] zp ZP_WORD:65 [ atan2_16::x#0 ] zp ZP_WORD:67 [ atan2_16::y#0 ]
@ -5143,6 +5173,7 @@ Coalescing zero page register with common assignment [ zp ZP_WORD:3 [ init_bucke
Coalescing zero page register with common assignment [ zp ZP_WORD:8 [ init_angle_screen::screen_bottomline#5 init_angle_screen::screen_bottomline#0 init_angle_screen::screen_bottomline#1 ] ] with [ zp ZP_WORD:56 [ init_angle_screen::screen#0 ] ] - score: 1
Coalescing zero page register with common assignment [ zp ZP_WORD:19 [ atan2_16::angle#6 atan2_16::angle#12 atan2_16::angle#13 atan2_16::angle#2 atan2_16::angle#3 ] ] with [ zp ZP_WORD:21 [ atan2_16::return#0 atan2_16::angle#5 atan2_16::angle#11 atan2_16::angle#1 atan2_16::angle#4 ] ] - score: 1
Coalescing zero page register with common assignment [ zp ZP_WORD:37 [ bsearch16u::return#1 bsearch16u::return#6 bsearch16u::return#2 bsearch16u::items#2 bsearch16u::items#1 bsearch16u::items#8 bsearch16u::$2 bsearch16u::items#0 ] ] with [ zp ZP_WORD:99 [ bsearch16u::return#3 ] ] - score: 1
Coalescing zero page register with common assignment [ zp ZP_WORD:48 [ malloc::size#4 ] ] with [ zp ZP_WORD:121 [ malloc::mem#0 ] ] - score: 1
Coalescing zero page register with common assignment [ zp ZP_WORD:60 [ init_angle_screen::xw#0 ] ] with [ zp ZP_WORD:65 [ atan2_16::x#0 ] ] - score: 1
Coalescing zero page register with common assignment [ zp ZP_WORD:63 [ init_angle_screen::yw#0 ] ] with [ zp ZP_WORD:67 [ atan2_16::y#0 ] ] - score: 1
Coalescing zero page register with common assignment [ zp ZP_WORD:69 [ atan2_16::return#2 ] ] with [ zp ZP_WORD:71 [ init_angle_screen::angle_w#0 ] ] - score: 1
@ -5151,10 +5182,10 @@ Coalescing zero page register with common assignment [ zp ZP_WORD:87 [ sqr::retu
Coalescing zero page register with common assignment [ zp ZP_WORD:87 [ sqr::return#3 init_dist_screen::xds#0 ] ] with [ zp ZP_WORD:115 [ sqr::return#0 ] ] - score: 1
Coalescing zero page register with common assignment [ zp ZP_WORD:91 [ init_dist_screen::ds#0 ] ] with [ zp ZP_WORD:93 [ sqrt::val#0 ] ] - score: 1
Coalescing zero page register with common assignment [ zp ZP_WORD:101 [ sqrt::found#0 ] ] with [ zp ZP_WORD:103 [ sqrt::$3 ] ] - score: 1
Coalescing zero page register with common assignment [ zp ZP_WORD:117 [ SQUARES#1 ] ] with [ zp ZP_WORD:121 [ malloc::mem#0 ] ] - score: 1
Coalescing zero page register with common assignment [ zp ZP_WORD:8 [ init_angle_screen::screen_bottomline#5 init_angle_screen::screen_bottomline#0 init_angle_screen::screen_bottomline#1 init_angle_screen::screen#0 ] ] with [ zp ZP_WORD:52 [ SCREEN_ANGLE#0 ] ] - score: 1
Coalescing zero page register with common assignment [ zp ZP_WORD:19 [ atan2_16::angle#6 atan2_16::angle#12 atan2_16::angle#13 atan2_16::angle#2 atan2_16::angle#3 atan2_16::return#0 atan2_16::angle#5 atan2_16::angle#11 atan2_16::angle#1 atan2_16::angle#4 ] ] with [ zp ZP_WORD:69 [ atan2_16::return#2 init_angle_screen::angle_w#0 ] ] - score: 1
Coalescing zero page register with common assignment [ zp ZP_WORD:37 [ bsearch16u::return#1 bsearch16u::return#6 bsearch16u::return#2 bsearch16u::items#2 bsearch16u::items#1 bsearch16u::items#8 bsearch16u::$2 bsearch16u::items#0 bsearch16u::return#3 ] ] with [ zp ZP_WORD:101 [ sqrt::found#0 sqrt::$3 ] ] - score: 1
Coalescing zero page register with common assignment [ zp ZP_WORD:48 [ malloc::size#4 malloc::mem#0 ] ] with [ zp ZP_WORD:117 [ SQUARES#1 ] ] - score: 1
Coalescing zero page register with common assignment [ zp ZP_WORD:87 [ sqr::return#3 init_dist_screen::xds#0 sqr::return#0 ] ] with [ zp ZP_WORD:91 [ init_dist_screen::ds#0 sqrt::val#0 ] ] - score: 1
Coalescing zero page register with common assignment [ zp ZP_WORD:19 [ atan2_16::angle#6 atan2_16::angle#12 atan2_16::angle#13 atan2_16::angle#2 atan2_16::angle#3 atan2_16::return#0 atan2_16::angle#5 atan2_16::angle#11 atan2_16::angle#1 atan2_16::angle#4 atan2_16::return#2 init_angle_screen::angle_w#0 ] ] with [ zp ZP_WORD:73 [ init_angle_screen::$10 ] ] - score: 1
Coalescing zero page register with common assignment [ zp ZP_WORD:37 [ bsearch16u::return#1 bsearch16u::return#6 bsearch16u::return#2 bsearch16u::items#2 bsearch16u::items#1 bsearch16u::items#8 bsearch16u::$2 bsearch16u::items#0 bsearch16u::return#3 sqrt::found#0 sqrt::$3 ] ] with [ zp ZP_WORD:105 [ sqrt::$1 ] ] - score: 1
@ -5180,7 +5211,7 @@ Allocated (was zp ZP_WORD:37) zp ZP_WORD:30 [ bsearch16u::return#1 bsearch16u::r
Allocated (was zp ZP_WORD:41) zp ZP_WORD:32 [ init_squares::sqr#2 init_squares::sqr#1 ]
Allocated (was zp ZP_WORD:43) zp ZP_WORD:34 [ init_squares::squares#2 init_squares::squares#1 init_squares::squares#0 ]
Allocated (was zp ZP_WORD:46) zp ZP_WORD:36 [ heap_head#13 heap_head#1 ]
Allocated (was zp ZP_WORD:48) zp ZP_WORD:38 [ malloc::size#4 ]
Allocated (was zp ZP_WORD:48) zp ZP_WORD:38 [ malloc::size#4 malloc::mem#0 SQUARES#1 ]
Allocated (was zp ZP_WORD:54) zp ZP_WORD:40 [ BUCKET_SIZES#0 ]
Allocated (was zp ZP_WORD:60) zp ZP_WORD:42 [ init_angle_screen::xw#0 atan2_16::x#0 ]
Allocated (was zp ZP_WORD:63) zp ZP_WORD:44 [ init_angle_screen::yw#0 atan2_16::y#0 ]
@ -5189,7 +5220,6 @@ Allocated (was zp ZP_WORD:82) zp ZP_WORD:47 [ sqr::return#2 init_dist_screen::yd
Allocated (was zp ZP_WORD:87) zp ZP_WORD:49 [ sqr::return#3 init_dist_screen::xds#0 sqr::return#0 init_dist_screen::ds#0 sqrt::val#0 bsearch16u::key#0 ]
Allocated (was zp ZP_WORD:110) zp ZP_WORD:51 [ bsearch16u::pivot#0 ]
Allocated (was zp ZP_WORD:112) zp ZP_WORD:53 [ bsearch16u::result#0 ]
Allocated (was zp ZP_WORD:117) zp ZP_WORD:55 [ SQUARES#1 malloc::mem#0 ]
ASSEMBLER BEFORE OPTIMIZATION
// File Comments
@ -5201,13 +5231,16 @@ ASSEMBLER BEFORE OPTIMIZATION
.pc = $80d "Program"
// Global Constants & labels
.const SIZEOF_WORD = 2
// Start of the heap used by malloc()
.label HEAP_START = $c000
.const SIZEOF_BYTE = 1
// Top of the heap used by malloc()
.label HEAP_TOP = $a000
// The number of iterations performed during 16-bit CORDIC atan2 calculation
.const CORDIC_ITERATIONS_16 = $f
// The number of buckets in our bucket sort
.const NUM_BUCKETS = $30
.const NUM_SQUARES = $30
.label heap_head = $24
.label SQUARES = $37
.label SQUARES = $26
// Screen containing distance to center
.label SCREEN_DIST = 2
// Screen containing angle to center
@ -5229,10 +5262,10 @@ malloc_from_b1:
sta malloc.size
lda #>$3e8
sta malloc.size+1
// [190] phi (byte*) heap_head#13 = (const byte*) HEAP_START#0 [phi:@1->malloc#1] -- pbuz1=pbuc1
lda #<HEAP_START
// [190] phi (byte*) heap_head#13 = (const byte*) HEAP_TOP#0 [phi:@1->malloc#1] -- pbuz1=pbuc1
lda #<HEAP_TOP
sta heap_head
lda #>HEAP_START
lda #>HEAP_TOP
sta heap_head+1
jsr malloc
jmp b4
@ -5269,8 +5302,8 @@ b2:
// [7] call malloc
// [190] phi from @2 to malloc [phi:@2->malloc]
malloc_from_b2:
// [190] phi (word) malloc::size#4 = (byte) $80 [phi:@2->malloc#0] -- vwuz1=vbuc1
lda #$80
// [190] phi (word) malloc::size#4 = (const byte) NUM_BUCKETS#0*(const byte) SIZEOF_BYTE [phi:@2->malloc#0] -- vwuz1=vbuc1
lda #NUM_BUCKETS*SIZEOF_BYTE
sta malloc.size
lda #0
sta malloc.size+1
@ -5329,6 +5362,7 @@ main: {
rts
}
// init_buckets
//const word*[] BUCKETS = malloc(NUM_BUCKETS*sizeof(word*));
init_buckets: {
.label dist = 2
.label i1 = 4
@ -5349,8 +5383,8 @@ init_buckets: {
sta (BUCKET_SIZES),y
// [22] (byte) init_buckets::i#1 ← ++ (byte) init_buckets::i#2 -- vbuyy=_inc_vbuyy
iny
// [23] if((byte) init_buckets::i#1!=(byte) $80) goto init_buckets::@1 -- vbuyy_neq_vbuc1_then_la1
cpy #$80
// [23] if((byte) init_buckets::i#1!=(const byte) NUM_BUCKETS#0-(byte) 1+(byte) 1) goto init_buckets::@1 -- vbuyy_neq_vbuc1_then_la1
cpy #NUM_BUCKETS-1+1
bne b1_from_b1
jmp b2
// init_buckets::@2
@ -6390,20 +6424,20 @@ init_squares: {
// The content of the newly allocated block of memory is not initialized, remaining with indeterminate values.
// malloc(word zeropage($26) size)
malloc: {
.label mem = $37
.label mem = $26
.label size = $26
// [191] (byte*) malloc::mem#0 ← (byte*) heap_head#13 -- pbuz1=pbuz2
// [191] (byte*) malloc::mem#0 ← (byte*) heap_head#13 - (word) malloc::size#4 -- pbuz1=pbuz2_minus_vwuz1
lda heap_head
sec
sbc mem
sta mem
lda heap_head+1
sbc mem+1
sta mem+1
// [192] (byte*) heap_head#1 ← (byte*) heap_head#13 + (word) malloc::size#4 -- pbuz1=pbuz1_plus_vwuz2
lda heap_head
clc
adc size
// [192] (byte*) heap_head#1 ← (byte*) malloc::mem#0 -- pbuz1=pbuz2
lda mem
sta heap_head
lda heap_head+1
adc size+1
lda mem+1
sta heap_head+1
jmp breturn
// malloc::@return
@ -6637,9 +6671,9 @@ Removing instruction jmp b1
Succesful ASM optimization Pass5NextJumpElimination
Removing instruction lda #<0
Succesful ASM optimization Pass5UnnecesaryLoadElimination
Fixing long branch [322] beq b12 to bne
Fixing long branch [216] bpl b1 to bmi
Fixing long branch [228] bpl b4 to bmi
Fixing long branch [326] beq b12 to bne
Fixing long branch [220] bpl b1 to bmi
Fixing long branch [232] bpl b4 to bmi
FINAL SYMBOL TABLE
(label) @1
@ -6650,7 +6684,7 @@ FINAL SYMBOL TABLE
(label) @6
(label) @begin
(label) @end
(byte*) BUCKET_SIZES
(byte[]) BUCKET_SIZES
(void*) BUCKET_SIZES#0 BUCKET_SIZES zp ZP_WORD:40 0.1111111111111111
(word[CORDIC_ITERATIONS_16#0]) CORDIC_ATAN2_ANGLES_16
(const word[CORDIC_ITERATIONS_16#0]) CORDIC_ATAN2_ANGLES_16#0 CORDIC_ATAN2_ANGLES_16 = kickasm {{ .for (var i=0; i<CORDIC_ITERATIONS_16; i++)
@ -6658,17 +6692,20 @@ FINAL SYMBOL TABLE
}}
(byte) CORDIC_ITERATIONS_16
(const byte) CORDIC_ITERATIONS_16#0 CORDIC_ITERATIONS_16 = (byte) $f
(byte*) HEAP_START
(const byte*) HEAP_START#0 HEAP_START = (byte*) 49152
(byte*) HEAP_TOP
(const byte*) HEAP_TOP#0 HEAP_TOP = (byte*) 40960
(byte) NUM_BUCKETS
(const byte) NUM_BUCKETS#0 NUM_BUCKETS = (byte) $30
(byte) NUM_SQUARES
(const byte) NUM_SQUARES#3 NUM_SQUARES = (byte) $30
(byte*) SCREEN_ANGLE
(void*) SCREEN_ANGLE#0 SCREEN_ANGLE zp ZP_WORD:7 0.2857142857142857
(byte*) SCREEN_DIST
(void*) SCREEN_DIST#0 SCREEN_DIST zp ZP_WORD:2 0.11764705882352941
(const byte) SIZEOF_BYTE SIZEOF_BYTE = (byte) 1
(const byte) SIZEOF_WORD SIZEOF_WORD = (byte) 2
(word*) SQUARES
(void*) SQUARES#1 SQUARES zp ZP_WORD:55 0.03225806451612903
(void*) SQUARES#1 SQUARES zp ZP_WORD:38 0.03225806451612903
(word()) atan2_16((signed word) atan2_16::x , (signed word) atan2_16::y)
(signed word~) atan2_16::$2 $2 zp ZP_WORD:13 4.0
(byte~) atan2_16::$23 reg byte a 2002.0
@ -6783,7 +6820,7 @@ FINAL SYMBOL TABLE
(word*~) bsearch16u::return#6 return zp ZP_WORD:30 4.0
(byte*) heap_head
(byte*) heap_head#1 heap_head zp ZP_WORD:36 0.6153846153846154
(byte*) heap_head#13 heap_head zp ZP_WORD:36 5.0
(byte*) heap_head#13 heap_head zp ZP_WORD:36 8.0
(void()) init_angle_screen((byte*) init_angle_screen::screen)
(word~) init_angle_screen::$10 $10 zp ZP_WORD:17 202.0
(byte~) init_angle_screen::$12 reg byte a 202.0
@ -6915,10 +6952,10 @@ FINAL SYMBOL TABLE
(void*()) malloc((word) malloc::size)
(label) malloc::@return
(byte*) malloc::mem
(byte*) malloc::mem#0 mem zp ZP_WORD:55 0.2857142857142857
(byte*) malloc::mem#0 mem zp ZP_WORD:38 0.5714285714285714
(void*) malloc::return
(word) malloc::size
(word) malloc::size#4 size zp ZP_WORD:38 1.0
(word) malloc::size#4 size zp ZP_WORD:38 2.0
(word()) sqr((byte) sqr::val)
(byte~) sqr::$0 reg byte a 4.0
(label) sqr::@return
@ -6973,7 +7010,7 @@ zp ZP_WORD:32 [ init_squares::sqr#2 init_squares::sqr#1 ]
zp ZP_WORD:34 [ init_squares::squares#2 init_squares::squares#1 init_squares::squares#0 ]
reg byte x [ init_squares::i#2 init_squares::i#1 ]
zp ZP_WORD:36 [ heap_head#13 heap_head#1 ]
zp ZP_WORD:38 [ malloc::size#4 ]
zp ZP_WORD:38 [ malloc::size#4 malloc::mem#0 SQUARES#1 ]
zp ZP_WORD:40 [ BUCKET_SIZES#0 ]
reg byte a [ init_angle_screen::$2 ]
reg byte a [ init_angle_screen::$3 ]
@ -6998,7 +7035,6 @@ reg byte a [ bsearch16u::$16 ]
zp ZP_WORD:51 [ bsearch16u::pivot#0 ]
zp ZP_WORD:53 [ bsearch16u::result#0 ]
reg byte a [ sqr::$0 ]
zp ZP_WORD:55 [ SQUARES#1 malloc::mem#0 ]
reg byte a [ init_squares::$3 ]
reg byte a [ init_squares::$4 ]
@ -7015,13 +7051,16 @@ Score: 1093479
.pc = $80d "Program"
// Global Constants & labels
.const SIZEOF_WORD = 2
// Start of the heap used by malloc()
.label HEAP_START = $c000
.const SIZEOF_BYTE = 1
// Top of the heap used by malloc()
.label HEAP_TOP = $a000
// The number of iterations performed during 16-bit CORDIC atan2 calculation
.const CORDIC_ITERATIONS_16 = $f
// The number of buckets in our bucket sort
.const NUM_BUCKETS = $30
.const NUM_SQUARES = $30
.label heap_head = $24
.label SQUARES = $37
.label SQUARES = $26
// Screen containing distance to center
.label SCREEN_DIST = 2
// Screen containing angle to center
@ -7040,10 +7079,10 @@ bbegin:
sta malloc.size
lda #>$3e8
sta malloc.size+1
// [190] phi (byte*) heap_head#13 = (const byte*) HEAP_START#0 [phi:@1->malloc#1] -- pbuz1=pbuc1
lda #<HEAP_START
// [190] phi (byte*) heap_head#13 = (const byte*) HEAP_TOP#0 [phi:@1->malloc#1] -- pbuz1=pbuc1
lda #<HEAP_TOP
sta heap_head
lda #>HEAP_START
lda #>HEAP_TOP
sta heap_head+1
jsr malloc
// @4
@ -7071,18 +7110,18 @@ bbegin:
sta SCREEN_ANGLE+1
// [6] phi from @5 to @2 [phi:@5->@2]
// @2
// malloc(0x80)
// malloc(NUM_BUCKETS*sizeof(byte))
// [7] call malloc
// [190] phi from @2 to malloc [phi:@2->malloc]
// [190] phi (word) malloc::size#4 = (byte) $80 [phi:@2->malloc#0] -- vwuz1=vbuc1
lda #$80
// [190] phi (word) malloc::size#4 = (const byte) NUM_BUCKETS#0*(const byte) SIZEOF_BYTE [phi:@2->malloc#0] -- vwuz1=vbuc1
lda #NUM_BUCKETS*SIZEOF_BYTE
sta malloc.size
lda #0
sta malloc.size+1
// [190] phi (byte*) heap_head#13 = (byte*) heap_head#1 [phi:@2->malloc#1] -- register_copy
jsr malloc
// @6
// malloc(0x80)
// malloc(NUM_BUCKETS*sizeof(byte))
// [8] (void*) BUCKET_SIZES#0 ← (void*)(byte*) malloc::mem#0 -- pvoz1=pvoz2
lda malloc.mem
sta BUCKET_SIZES
@ -7123,6 +7162,7 @@ main: {
rts
}
// init_buckets
//const word*[] BUCKETS = malloc(NUM_BUCKETS*sizeof(word*));
init_buckets: {
.label dist = 2
.label i1 = 4
@ -7138,11 +7178,11 @@ init_buckets: {
// [21] *((byte*)(void*) BUCKET_SIZES#0 + (byte) init_buckets::i#2) ← (byte) 0 -- pbuz1_derefidx_vbuyy=vbuc1
lda #0
sta (BUCKET_SIZES),y
// for(byte i:0..0x7f)
// for(byte i:0..NUM_BUCKETS-1)
// [22] (byte) init_buckets::i#1 ← ++ (byte) init_buckets::i#2 -- vbuyy=_inc_vbuyy
iny
// [23] if((byte) init_buckets::i#1!=(byte) $80) goto init_buckets::@1 -- vbuyy_neq_vbuc1_then_la1
cpy #$80
// [23] if((byte) init_buckets::i#1!=(const byte) NUM_BUCKETS#0-(byte) 1+(byte) 1) goto init_buckets::@1 -- vbuyy_neq_vbuc1_then_la1
cpy #NUM_BUCKETS-1+1
bne b1
// init_buckets::@2
// dist = SCREEN_DIST
@ -7158,7 +7198,7 @@ init_buckets: {
// [25] phi (byte*) init_buckets::dist#2 = (byte*) init_buckets::dist#1 [phi:init_buckets::@3->init_buckets::@3#1] -- register_copy
// init_buckets::@3
b3:
// BUCKET_SIZES[*dist]++;
// BUCKET_SIZES[*dist++]++;
// [26] *((byte*)(void*) BUCKET_SIZES#0 + *((byte*) init_buckets::dist#2)) ← ++ *((byte*)(void*) BUCKET_SIZES#0 + *((byte*) init_buckets::dist#2)) -- pbuz1_derefidx__deref_pbuz2=_inc_pbuz1_derefidx__deref_pbuz2
ldy #0
lda (dist),y
@ -7167,13 +7207,12 @@ init_buckets: {
clc
adc #1
sta (BUCKET_SIZES),y
// dist++;
// [27] (byte*) init_buckets::dist#1 ← ++ (byte*) init_buckets::dist#2 -- pbuz1=_inc_pbuz1
inc dist
bne !+
inc dist+1
!:
// for( word i:0..999 )
// for( word i:0..999)
// [28] (word) init_buckets::i1#1 ← ++ (word) init_buckets::i1#2 -- vwuz1=_inc_vwuz1
inc i1
bne !+
@ -8148,22 +8187,22 @@ init_squares: {
// The content of the newly allocated block of memory is not initialized, remaining with indeterminate values.
// malloc(word zeropage($26) size)
malloc: {
.label mem = $37
.label mem = $26
.label size = $26
// mem = heap_head
// [191] (byte*) malloc::mem#0 ← (byte*) heap_head#13 -- pbuz1=pbuz2
// mem = heap_head-size
// [191] (byte*) malloc::mem#0 ← (byte*) heap_head#13 - (word) malloc::size#4 -- pbuz1=pbuz2_minus_vwuz1
lda heap_head
sec
sbc mem
sta mem
lda heap_head+1
sbc mem+1
sta mem+1
// heap_head+= size
// [192] (byte*) heap_head#1 ← (byte*) heap_head#13 + (word) malloc::size#4 -- pbuz1=pbuz1_plus_vwuz2
lda heap_head
clc
adc size
// heap_head = mem
// [192] (byte*) heap_head#1 ← (byte*) malloc::mem#0 -- pbuz1=pbuz2
lda mem
sta heap_head
lda heap_head+1
adc size+1
lda mem+1
sta heap_head+1
// malloc::@return
// }

View File

@ -6,7 +6,7 @@
(label) @6
(label) @begin
(label) @end
(byte*) BUCKET_SIZES
(byte[]) BUCKET_SIZES
(void*) BUCKET_SIZES#0 BUCKET_SIZES zp ZP_WORD:40 0.1111111111111111
(word[CORDIC_ITERATIONS_16#0]) CORDIC_ATAN2_ANGLES_16
(const word[CORDIC_ITERATIONS_16#0]) CORDIC_ATAN2_ANGLES_16#0 CORDIC_ATAN2_ANGLES_16 = kickasm {{ .for (var i=0; i<CORDIC_ITERATIONS_16; i++)
@ -14,17 +14,20 @@
}}
(byte) CORDIC_ITERATIONS_16
(const byte) CORDIC_ITERATIONS_16#0 CORDIC_ITERATIONS_16 = (byte) $f
(byte*) HEAP_START
(const byte*) HEAP_START#0 HEAP_START = (byte*) 49152
(byte*) HEAP_TOP
(const byte*) HEAP_TOP#0 HEAP_TOP = (byte*) 40960
(byte) NUM_BUCKETS
(const byte) NUM_BUCKETS#0 NUM_BUCKETS = (byte) $30
(byte) NUM_SQUARES
(const byte) NUM_SQUARES#3 NUM_SQUARES = (byte) $30
(byte*) SCREEN_ANGLE
(void*) SCREEN_ANGLE#0 SCREEN_ANGLE zp ZP_WORD:7 0.2857142857142857
(byte*) SCREEN_DIST
(void*) SCREEN_DIST#0 SCREEN_DIST zp ZP_WORD:2 0.11764705882352941
(const byte) SIZEOF_BYTE SIZEOF_BYTE = (byte) 1
(const byte) SIZEOF_WORD SIZEOF_WORD = (byte) 2
(word*) SQUARES
(void*) SQUARES#1 SQUARES zp ZP_WORD:55 0.03225806451612903
(void*) SQUARES#1 SQUARES zp ZP_WORD:38 0.03225806451612903
(word()) atan2_16((signed word) atan2_16::x , (signed word) atan2_16::y)
(signed word~) atan2_16::$2 $2 zp ZP_WORD:13 4.0
(byte~) atan2_16::$23 reg byte a 2002.0
@ -139,7 +142,7 @@
(word*~) bsearch16u::return#6 return zp ZP_WORD:30 4.0
(byte*) heap_head
(byte*) heap_head#1 heap_head zp ZP_WORD:36 0.6153846153846154
(byte*) heap_head#13 heap_head zp ZP_WORD:36 5.0
(byte*) heap_head#13 heap_head zp ZP_WORD:36 8.0
(void()) init_angle_screen((byte*) init_angle_screen::screen)
(word~) init_angle_screen::$10 $10 zp ZP_WORD:17 202.0
(byte~) init_angle_screen::$12 reg byte a 202.0
@ -271,10 +274,10 @@
(void*()) malloc((word) malloc::size)
(label) malloc::@return
(byte*) malloc::mem
(byte*) malloc::mem#0 mem zp ZP_WORD:55 0.2857142857142857
(byte*) malloc::mem#0 mem zp ZP_WORD:38 0.5714285714285714
(void*) malloc::return
(word) malloc::size
(word) malloc::size#4 size zp ZP_WORD:38 1.0
(word) malloc::size#4 size zp ZP_WORD:38 2.0
(word()) sqr((byte) sqr::val)
(byte~) sqr::$0 reg byte a 4.0
(label) sqr::@return
@ -329,7 +332,7 @@ zp ZP_WORD:32 [ init_squares::sqr#2 init_squares::sqr#1 ]
zp ZP_WORD:34 [ init_squares::squares#2 init_squares::squares#1 init_squares::squares#0 ]
reg byte x [ init_squares::i#2 init_squares::i#1 ]
zp ZP_WORD:36 [ heap_head#13 heap_head#1 ]
zp ZP_WORD:38 [ malloc::size#4 ]
zp ZP_WORD:38 [ malloc::size#4 malloc::mem#0 SQUARES#1 ]
zp ZP_WORD:40 [ BUCKET_SIZES#0 ]
reg byte a [ init_angle_screen::$2 ]
reg byte a [ init_angle_screen::$3 ]
@ -354,6 +357,5 @@ reg byte a [ bsearch16u::$16 ]
zp ZP_WORD:51 [ bsearch16u::pivot#0 ]
zp ZP_WORD:53 [ bsearch16u::result#0 ]
reg byte a [ sqr::$0 ]
zp ZP_WORD:55 [ SQUARES#1 malloc::mem#0 ]
reg byte a [ init_squares::$3 ]
reg byte a [ init_squares::$4 ]

View File

@ -3,8 +3,8 @@
:BasicUpstart(bbegin)
.pc = $80d "Program"
.const SIZEOF_WORD = 2
// Start of the heap used by malloc()
.label HEAP_START = $c000
// Top of the heap used by malloc()
.label HEAP_TOP = $a000
// The number of iterations performed during 16-bit CORDIC atan2 calculation
.const CORDIC_ITERATIONS_16 = $f
// Screen containing angle to center
@ -13,7 +13,7 @@
.const FILL_CHAR = '@'
.const NUM_SQUARES = $30
.label heap_head = $2c
.label SQUARES = $41
.label SQUARES = $2e
// Screen containing distance to center
.label SCREEN_DIST = $30
// Screen containing angle to center
@ -23,9 +23,9 @@ bbegin:
sta malloc.size
lda #>$3e8
sta malloc.size+1
lda #<HEAP_START
lda #<HEAP_TOP
sta heap_head
lda #>HEAP_START
lda #>HEAP_TOP
sta heap_head+1
jsr malloc
lda malloc.mem
@ -721,18 +721,18 @@ init_squares: {
// The content of the newly allocated block of memory is not initialized, remaining with indeterminate values.
// malloc(word zeropage($2e) size)
malloc: {
.label mem = $41
.label mem = $2e
.label size = $2e
lda heap_head
sec
sbc mem
sta mem
lda heap_head+1
sbc mem+1
sta mem+1
lda heap_head
clc
adc size
lda mem
sta heap_head
lda heap_head+1
adc size+1
lda mem+1
sta heap_head+1
rts
}

View File

@ -378,9 +378,9 @@ init_squares::@return: scope:[init_squares] from init_squares::@1
to:@return
malloc: scope:[malloc] from @1 @3 init_squares
[190] (word) malloc::size#3 ← phi( @3/(word) $3e8 @1/(word) $3e8 init_squares/(const byte) NUM_SQUARES#3*(const byte) SIZEOF_WORD )
[190] (byte*) heap_head#12 ← phi( @3/(byte*) heap_head#1 @1/(const byte*) HEAP_START#0 init_squares/(byte*) heap_head#1 )
[191] (byte*) malloc::mem#0 ← (byte*) heap_head#12
[192] (byte*) heap_head#1 ← (byte*) heap_head#12 + (word) malloc::size#3
[190] (byte*) heap_head#12 ← phi( @3/(byte*) heap_head#1 @1/(const byte*) HEAP_TOP#0 init_squares/(byte*) heap_head#1 )
[191] (byte*) malloc::mem#0 ← (byte*) heap_head#12 - (word) malloc::size#3
[192] (byte*) heap_head#1 ← (byte*) malloc::mem#0
to:malloc::@return
malloc::@return: scope:[malloc] from malloc
[193] return

View File

@ -7,7 +7,7 @@ Fixing pointer array-indexing *((word*) SQUARES + (byte) sqr::val)
Fixing pointer array-indexing *((word[CORDIC_ITERATIONS_16]) CORDIC_ATAN2_ANGLES_16 + (byte) atan2_16::i)
Fixing pointer array-indexing *((word[CORDIC_ITERATIONS_16]) CORDIC_ATAN2_ANGLES_16 + (byte) atan2_16::i)
Warning! Adding boolean cast to non-boolean sub-expression (byte) atan2_16::shift
Identified constant variable (byte*) HEAP_START
Identified constant variable (byte*) HEAP_TOP
Culled Empty Block (label) malloc::@1
Culled Empty Block (label) @1
Culled Empty Block (label) @2
@ -55,14 +55,15 @@ Culled Empty Block (label) init_dist_screen::@12
CONTROL FLOW GRAPH SSA
@begin: scope:[] from
(byte*) HEAP_START#0 ← ((byte*)) (number) $c000
(byte*) heap_head#0 ← (byte*) HEAP_START#0
(byte*) HEAP_TOP#0 ← ((byte*)) (number) $a000
(byte*) heap_head#0 ← (byte*) HEAP_TOP#0
to:@3
malloc: scope:[malloc] from @12 @8 init_squares
(word) malloc::size#3 ← phi( @12/(word) malloc::size#2 @8/(word) malloc::size#1 init_squares/(word) malloc::size#0 )
(byte*) heap_head#12 ← phi( @12/(byte*) heap_head#5 @8/(byte*) heap_head#23 init_squares/(byte*) heap_head#24 )
(byte*) malloc::mem#0 ← (byte*) heap_head#12
(byte*) heap_head#1 ← (byte*) heap_head#12 + (word) malloc::size#3
(byte*~) malloc::$0 ← (byte*) heap_head#12 - (word) malloc::size#3
(byte*) malloc::mem#0 ← (byte*~) malloc::$0
(byte*) heap_head#1 ← (byte*) malloc::mem#0
(void*) malloc::return#0 ← ((void*)) (byte*) malloc::mem#0
to:malloc::@return
malloc::@return: scope:[malloc] from malloc
@ -913,8 +914,8 @@ SYMBOL TABLE SSA
(byte) CORDIC_ITERATIONS_16#0
(byte) FILL_CHAR
(byte) FILL_CHAR#0
(byte*) HEAP_START
(byte*) HEAP_START#0
(byte*) HEAP_TOP
(byte*) HEAP_TOP#0
(byte) NUM_SQUARES
(byte) NUM_SQUARES#0
(byte) NUM_SQUARES#1
@ -1607,6 +1608,7 @@ SYMBOL TABLE SSA
(byte*) main::min_fill#5
(byte*) main::min_fill#6
(void*()) malloc((word) malloc::size)
(byte*~) malloc::$0
(label) malloc::@return
(byte*) malloc::mem
(byte*) malloc::mem#0
@ -1770,7 +1772,7 @@ Adding number conversion cast (unumber) $13 in (bool~) init_dist_screen::$20 ←
Adding number conversion cast (unumber) $28 in (byte*) init_dist_screen::screen_topline#1 ← (byte*) init_dist_screen::screen_topline#3 + (number) $28
Adding number conversion cast (unumber) $28 in (byte*) init_dist_screen::screen_bottomline#1 ← (byte*) init_dist_screen::screen_bottomline#3 - (number) $28
Successful SSA optimization PassNAddNumberTypeConversions
Inlining cast (byte*) HEAP_START#0 ← (byte*)(number) $c000
Inlining cast (byte*) HEAP_TOP#0 ← (byte*)(number) $a000
Inlining cast (void*) malloc::return#0 ← (void*)(byte*) malloc::mem#0
Inlining cast (signed word~) bsearch16u::$8 ← (signed word)(word) bsearch16u::key#1
Inlining cast (signed word~) bsearch16u::$9 ← (signed word)*((word*) bsearch16u::pivot#0)
@ -1794,7 +1796,7 @@ Inlining cast (byte) NUM_SQUARES#3 ← (unumber)(number) $30
Inlining cast (byte) init_dist_screen::x#0 ← (unumber)(number) 0
Inlining cast (byte) init_dist_screen::xb#0 ← (unumber)(number) $27
Successful SSA optimization Pass2InlineCast
Simplifying constant pointer cast (byte*) 49152
Simplifying constant pointer cast (byte*) 40960
Simplifying constant integer cast 0
Simplifying constant integer cast 1
Simplifying constant integer cast 0
@ -1948,17 +1950,18 @@ Inferred type updated to byte in (unumber~) init_dist_screen::$15 ← (byte~) in
Inferred type updated to byte in (unumber~) init_dist_screen::$12 ← (byte) $27 - (byte) init_dist_screen::x2#2
Inferred type updated to byte in (unumber~) init_dist_screen::$13 ← (byte~) init_dist_screen::$12
Inferred type updated to byte for (unumber~) init_dist_screen::$16
Inversing boolean not [24] (bool~) bsearch16u::$12 ← (signed word) bsearch16u::result#0 != (signed byte) 0 from [23] (bool~) bsearch16u::$11 ← (signed word) bsearch16u::result#0 == (signed byte) 0
Inversing boolean not [31] (bool~) bsearch16u::$14 ← (signed word) bsearch16u::result#1 <= (signed byte) 0 from [30] (bool~) bsearch16u::$13 ← (signed word) bsearch16u::result#1 > (signed byte) 0
Inversing boolean not [132] (bool~) atan2_16::$18 ← (signed word) atan2_16::yi#3 != (signed byte) 0 from [131] (bool~) atan2_16::$17 ← (signed word) atan2_16::yi#3 == (signed byte) 0
Inversing boolean not [141] (bool~) atan2_16::$11 ← (signed word) atan2_16::x#4 >= (signed byte) 0 from [140] (bool~) atan2_16::$10 ← (signed word) atan2_16::x#4 < (signed byte) 0
Inversing boolean not [152] (bool~) atan2_16::$20 ← (byte) 0 == (byte) atan2_16::shift#4 from [151] (bool~) atan2_16::$25 ← (byte) 0 != (byte) atan2_16::shift#4
Inversing boolean not [176] (bool~) atan2_16::$14 ← (signed word) atan2_16::y#4 >= (signed byte) 0 from [175] (bool~) atan2_16::$13 ← (signed word) atan2_16::y#4 < (signed byte) 0
Inversing boolean not [226] (bool~) main::$3 ← *((byte*) main::fill#2) == (byte) FILL_CHAR#0 from [225] (bool~) main::$2 ← *((byte*) main::fill#2) != (byte) FILL_CHAR#0
Inversing boolean not [239] (bool~) main::$5 ← (word) main::dist_angle#0 >= (word) main::min_dist_angle#2 from [238] (bool~) main::$4 ← (word) main::dist_angle#0 < (word) main::min_dist_angle#2
Inversing boolean not [246] (bool~) main::$9 ← (word) main::min_dist_angle#3 != (word) $ffff from [245] (bool~) main::$8 ← (word) main::min_dist_angle#3 == (word) $ffff
Inversing boolean not [25] (bool~) bsearch16u::$12 ← (signed word) bsearch16u::result#0 != (signed byte) 0 from [24] (bool~) bsearch16u::$11 ← (signed word) bsearch16u::result#0 == (signed byte) 0
Inversing boolean not [32] (bool~) bsearch16u::$14 ← (signed word) bsearch16u::result#1 <= (signed byte) 0 from [31] (bool~) bsearch16u::$13 ← (signed word) bsearch16u::result#1 > (signed byte) 0
Inversing boolean not [133] (bool~) atan2_16::$18 ← (signed word) atan2_16::yi#3 != (signed byte) 0 from [132] (bool~) atan2_16::$17 ← (signed word) atan2_16::yi#3 == (signed byte) 0
Inversing boolean not [142] (bool~) atan2_16::$11 ← (signed word) atan2_16::x#4 >= (signed byte) 0 from [141] (bool~) atan2_16::$10 ← (signed word) atan2_16::x#4 < (signed byte) 0
Inversing boolean not [153] (bool~) atan2_16::$20 ← (byte) 0 == (byte) atan2_16::shift#4 from [152] (bool~) atan2_16::$25 ← (byte) 0 != (byte) atan2_16::shift#4
Inversing boolean not [177] (bool~) atan2_16::$14 ← (signed word) atan2_16::y#4 >= (signed byte) 0 from [176] (bool~) atan2_16::$13 ← (signed word) atan2_16::y#4 < (signed byte) 0
Inversing boolean not [227] (bool~) main::$3 ← *((byte*) main::fill#2) == (byte) FILL_CHAR#0 from [226] (bool~) main::$2 ← *((byte*) main::fill#2) != (byte) FILL_CHAR#0
Inversing boolean not [240] (bool~) main::$5 ← (word) main::dist_angle#0 >= (word) main::min_dist_angle#2 from [239] (bool~) main::$4 ← (word) main::dist_angle#0 < (word) main::min_dist_angle#2
Inversing boolean not [247] (bool~) main::$9 ← (word) main::min_dist_angle#3 != (word) $ffff from [246] (bool~) main::$8 ← (word) main::min_dist_angle#3 == (word) $ffff
Successful SSA optimization Pass2UnaryNotSimplification
Alias (byte*) HEAP_START#0 = (byte*) heap_head#0 (byte*) heap_head#37 (byte*) heap_head#32 (byte*) heap_head#23
Alias (byte*) HEAP_TOP#0 = (byte*) heap_head#0 (byte*) heap_head#37 (byte*) heap_head#32 (byte*) heap_head#23
Alias (byte*) malloc::mem#0 = (byte*~) malloc::$0
Alias (void*) malloc::return#0 = (void*) malloc::return#5 (void*) malloc::return#1
Alias (byte*) heap_head#1 = (byte*) heap_head#13 (byte*) heap_head#2
Alias (byte) bsearch16u::num#3 = (byte) bsearch16u::num#4 (byte) bsearch16u::num#8 (byte) bsearch16u::num#6
@ -2233,37 +2236,37 @@ Identical Phi Values (byte) NUM_SQUARES#10 (byte) NUM_SQUARES#15
Identical Phi Values (byte*) heap_head#19 (byte*) heap_head#27
Identical Phi Values (word*) SQUARES#13 (word*) SQUARES#22
Successful SSA optimization Pass2IdenticalPhiElimination
Simple Condition (bool~) bsearch16u::$5 [13] if((byte) bsearch16u::num#3>(byte) 0) goto bsearch16u::@7
Simple Condition (bool~) bsearch16u::$12 [25] if((signed word) bsearch16u::result#0!=(signed byte) 0) goto bsearch16u::@9
Simple Condition (bool~) bsearch16u::$0 [28] if(*((word*) bsearch16u::items#2)<=(word) bsearch16u::key#0) goto bsearch16u::@1
Simple Condition (bool~) bsearch16u::$14 [32] if((signed word) bsearch16u::result#0<=(signed byte) 0) goto bsearch16u::@10
Simple Condition (bool~) init_squares::$5 [77] if((byte) init_squares::i#1!=rangelast(0,init_squares::$2)) goto init_squares::@1
Simple Condition (bool~) atan2_16::$0 [110] if((signed word) atan2_16::y#0>=(signed byte) 0) goto atan2_16::@1
Simple Condition (bool~) atan2_16::$5 [119] if((signed word) atan2_16::x#0>=(signed byte) 0) goto atan2_16::@4
Simple Condition (bool~) atan2_16::$18 [133] if((signed word) atan2_16::yi#3!=(signed byte) 0) goto atan2_16::@16
Simple Condition (bool~) atan2_16::$11 [142] if((signed word) atan2_16::x#17>=(signed byte) 0) goto atan2_16::@7
Simple Condition (bool~) atan2_16::$19 [145] if((byte) atan2_16::shift#2>=(byte) 2) goto atan2_16::@19
Simple Condition (bool~) atan2_16::$20 [153] if((byte) 0==(byte) atan2_16::shift#2) goto atan2_16::@25
Simple Condition (bool~) atan2_16::$21 [156] if((signed word) atan2_16::yi#3>=(signed byte) 0) goto atan2_16::@26
Simple Condition (bool~) atan2_16::$22 [173] if((byte) atan2_16::i#1!=rangelast(0,atan2_16::$16)) goto atan2_16::@15
Simple Condition (bool~) atan2_16::$14 [177] if((signed word) atan2_16::y#19>=(signed byte) 0) goto atan2_16::@8
Simple Condition (bool~) main::$3 [227] if(*((byte*) main::fill#2)==(byte) FILL_CHAR#0) goto main::@5
Simple Condition (bool~) main::$7 [234] if((byte*) main::fill#1<(byte*~) main::$6) goto main::@4
Simple Condition (bool~) main::$5 [240] if((word) main::dist_angle#0>=(word) main::min_dist_angle#2) goto main::@5
Simple Condition (bool~) main::$9 [247] if((word) main::min_dist_angle#3!=(word) $ffff) goto main::@12
Simple Condition (bool~) init_angle_screen::$15 [296] if((byte) init_angle_screen::x#1<=(byte) $13) goto init_angle_screen::@2
Simple Condition (bool~) init_angle_screen::$16 [302] if((byte) init_angle_screen::y#1!=rangelast(0,$c)) goto init_angle_screen::@1
Simple Condition (bool~) init_dist_screen::$3 [318] if((byte) init_dist_screen::y2#0>=(byte) $18) goto init_dist_screen::@2
Simple Condition (bool~) init_dist_screen::$11 [339] if((byte) init_dist_screen::x2#0>=(byte) $27) goto init_dist_screen::@6
Simple Condition (bool~) init_dist_screen::$20 [369] if((byte) init_dist_screen::x#1<=(byte) $13) goto init_dist_screen::@5
Simple Condition (bool~) init_dist_screen::$21 [375] if((byte) init_dist_screen::y#1!=rangelast(0,$c)) goto init_dist_screen::@1
Simple Condition (bool~) bsearch16u::$5 [14] if((byte) bsearch16u::num#3>(byte) 0) goto bsearch16u::@7
Simple Condition (bool~) bsearch16u::$12 [26] if((signed word) bsearch16u::result#0!=(signed byte) 0) goto bsearch16u::@9
Simple Condition (bool~) bsearch16u::$0 [29] if(*((word*) bsearch16u::items#2)<=(word) bsearch16u::key#0) goto bsearch16u::@1
Simple Condition (bool~) bsearch16u::$14 [33] if((signed word) bsearch16u::result#0<=(signed byte) 0) goto bsearch16u::@10
Simple Condition (bool~) init_squares::$5 [78] if((byte) init_squares::i#1!=rangelast(0,init_squares::$2)) goto init_squares::@1
Simple Condition (bool~) atan2_16::$0 [111] if((signed word) atan2_16::y#0>=(signed byte) 0) goto atan2_16::@1
Simple Condition (bool~) atan2_16::$5 [120] if((signed word) atan2_16::x#0>=(signed byte) 0) goto atan2_16::@4
Simple Condition (bool~) atan2_16::$18 [134] if((signed word) atan2_16::yi#3!=(signed byte) 0) goto atan2_16::@16
Simple Condition (bool~) atan2_16::$11 [143] if((signed word) atan2_16::x#17>=(signed byte) 0) goto atan2_16::@7
Simple Condition (bool~) atan2_16::$19 [146] if((byte) atan2_16::shift#2>=(byte) 2) goto atan2_16::@19
Simple Condition (bool~) atan2_16::$20 [154] if((byte) 0==(byte) atan2_16::shift#2) goto atan2_16::@25
Simple Condition (bool~) atan2_16::$21 [157] if((signed word) atan2_16::yi#3>=(signed byte) 0) goto atan2_16::@26
Simple Condition (bool~) atan2_16::$22 [174] if((byte) atan2_16::i#1!=rangelast(0,atan2_16::$16)) goto atan2_16::@15
Simple Condition (bool~) atan2_16::$14 [178] if((signed word) atan2_16::y#19>=(signed byte) 0) goto atan2_16::@8
Simple Condition (bool~) main::$3 [228] if(*((byte*) main::fill#2)==(byte) FILL_CHAR#0) goto main::@5
Simple Condition (bool~) main::$7 [235] if((byte*) main::fill#1<(byte*~) main::$6) goto main::@4
Simple Condition (bool~) main::$5 [241] if((word) main::dist_angle#0>=(word) main::min_dist_angle#2) goto main::@5
Simple Condition (bool~) main::$9 [248] if((word) main::min_dist_angle#3!=(word) $ffff) goto main::@12
Simple Condition (bool~) init_angle_screen::$15 [297] if((byte) init_angle_screen::x#1<=(byte) $13) goto init_angle_screen::@2
Simple Condition (bool~) init_angle_screen::$16 [303] if((byte) init_angle_screen::y#1!=rangelast(0,$c)) goto init_angle_screen::@1
Simple Condition (bool~) init_dist_screen::$3 [319] if((byte) init_dist_screen::y2#0>=(byte) $18) goto init_dist_screen::@2
Simple Condition (bool~) init_dist_screen::$11 [340] if((byte) init_dist_screen::x2#0>=(byte) $27) goto init_dist_screen::@6
Simple Condition (bool~) init_dist_screen::$20 [370] if((byte) init_dist_screen::x#1<=(byte) $13) goto init_dist_screen::@5
Simple Condition (bool~) init_dist_screen::$21 [376] if((byte) init_dist_screen::y#1!=rangelast(0,$c)) goto init_dist_screen::@1
Successful SSA optimization Pass2ConditionalJumpSimplification
Negating conditional jump and destination [173] if((byte) atan2_16::i#1==rangelast(0,atan2_16::$16)) goto atan2_16::@17
Negating conditional jump and destination [174] if((byte) atan2_16::i#1==rangelast(0,atan2_16::$16)) goto atan2_16::@17
Successful SSA optimization Pass2ConditionalJumpSequenceImprovement
Constant right-side identified [41] (byte~) bsearch16u::$17 ← (byte) 1 * (const byte) SIZEOF_WORD
Constant right-side identified [48] (byte~) bsearch16u::$18 ← (byte) 1 * (const byte) SIZEOF_WORD
Constant right-side identified [42] (byte~) bsearch16u::$17 ← (byte) 1 * (const byte) SIZEOF_WORD
Constant right-side identified [49] (byte~) bsearch16u::$18 ← (byte) 1 * (const byte) SIZEOF_WORD
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant (const byte*) HEAP_START#0 = (byte*) 49152
Constant (const byte*) HEAP_TOP#0 = (byte*) 40960
Constant (const byte) bsearch16u::$17 = 1*SIZEOF_WORD
Constant (const byte) bsearch16u::$18 = 1*SIZEOF_WORD
Constant (const byte) NUM_SQUARES#0 = $ff
@ -2292,14 +2295,14 @@ Successful SSA optimization Pass2ConstantIdentification
Constant (const byte*) main::fill#0 = SCREEN_FILL#0
Constant (const byte*) main::min_fill#0 = SCREEN_FILL#0
Successful SSA optimization Pass2ConstantIdentification
if() condition always true - replacing block destination [217] if(true) goto main::@2
if() condition always true - replacing block destination [218] if(true) goto main::@2
Successful SSA optimization Pass2ConstantIfs
Resolved ranged next value [300] init_angle_screen::y#1 ← ++ init_angle_screen::y#4 to ++
Resolved ranged comparison value [302] if(init_angle_screen::y#1!=rangelast(0,$c)) goto init_angle_screen::@1 to (number) $d
Resolved ranged next value [373] init_dist_screen::y#1 ← ++ init_dist_screen::y#10 to ++
Resolved ranged comparison value [375] if(init_dist_screen::y#1!=rangelast(0,$c)) goto init_dist_screen::@1 to (number) $d
Rewriting conditional comparison [296] if((byte) init_angle_screen::x#1<=(byte) $13) goto init_angle_screen::@2
Rewriting conditional comparison [369] if((byte) init_dist_screen::x#1<=(byte) $13) goto init_dist_screen::@5
Resolved ranged next value [301] init_angle_screen::y#1 ← ++ init_angle_screen::y#4 to ++
Resolved ranged comparison value [303] if(init_angle_screen::y#1!=rangelast(0,$c)) goto init_angle_screen::@1 to (number) $d
Resolved ranged next value [374] init_dist_screen::y#1 ← ++ init_dist_screen::y#10 to ++
Resolved ranged comparison value [376] if(init_dist_screen::y#1!=rangelast(0,$c)) goto init_dist_screen::@1 to (number) $d
Rewriting conditional comparison [297] if((byte) init_angle_screen::x#1<=(byte) $13) goto init_angle_screen::@2
Rewriting conditional comparison [370] if((byte) init_dist_screen::x#1<=(byte) $13) goto init_dist_screen::@5
Eliminating unused variable - keeping the phi block (byte) NUM_SQUARES#15
Eliminating unused variable - keeping the phi block (byte*) heap_head#27
Eliminating unused variable - keeping the phi block (word*) SQUARES#22
@ -2549,7 +2552,8 @@ Coalesced [252] init_squares::squares#4 ← init_squares::squares#0
Coalesced [262] init_squares::sqr#3 ← init_squares::sqr#1
Coalesced [263] init_squares::squares#3 ← init_squares::squares#1
Coalesced [264] init_squares::i#3 ← init_squares::i#1
Coalesced down to 37 phi equivalence classes
Not coalescing [267] heap_head#1 ← malloc::mem#0
Coalesced down to 38 phi equivalence classes
Culled Empty Block (label) @3
Culled Empty Block (label) @6
Culled Empty Block (label) @14
@ -3002,9 +3006,9 @@ init_squares::@return: scope:[init_squares] from init_squares::@1
to:@return
malloc: scope:[malloc] from @1 @3 init_squares
[190] (word) malloc::size#3 ← phi( @3/(word) $3e8 @1/(word) $3e8 init_squares/(const byte) NUM_SQUARES#3*(const byte) SIZEOF_WORD )
[190] (byte*) heap_head#12 ← phi( @3/(byte*) heap_head#1 @1/(const byte*) HEAP_START#0 init_squares/(byte*) heap_head#1 )
[191] (byte*) malloc::mem#0 ← (byte*) heap_head#12
[192] (byte*) heap_head#1 ← (byte*) heap_head#12 + (word) malloc::size#3
[190] (byte*) heap_head#12 ← phi( @3/(byte*) heap_head#1 @1/(const byte*) HEAP_TOP#0 init_squares/(byte*) heap_head#1 )
[191] (byte*) malloc::mem#0 ← (byte*) heap_head#12 - (word) malloc::size#3
[192] (byte*) heap_head#1 ← (byte*) malloc::mem#0
to:malloc::@return
malloc::@return: scope:[malloc] from malloc
[193] return
@ -3015,7 +3019,7 @@ VARIABLE REGISTER WEIGHTS
(word[CORDIC_ITERATIONS_16#0]) CORDIC_ATAN2_ANGLES_16
(byte) CORDIC_ITERATIONS_16
(byte) FILL_CHAR
(byte*) HEAP_START
(byte*) HEAP_TOP
(byte) NUM_SQUARES
(byte*) SCREEN_ANGLE
(void*) SCREEN_ANGLE#0 0.08695652173913043
@ -3106,7 +3110,7 @@ VARIABLE REGISTER WEIGHTS
(word*~) bsearch16u::return#6 4.0
(byte*) heap_head
(byte*) heap_head#1 0.6000000000000001
(byte*) heap_head#12 4.0
(byte*) heap_head#12 6.0
(void()) init_angle_screen((byte*) init_angle_screen::screen)
(word~) init_angle_screen::$10 202.0
(byte~) init_angle_screen::$12 202.0
@ -3220,10 +3224,10 @@ VARIABLE REGISTER WEIGHTS
(byte*) main::min_fill#5 50.5
(void*()) malloc((word) malloc::size)
(byte*) malloc::mem
(byte*) malloc::mem#0 0.3333333333333333
(byte*) malloc::mem#0 0.6666666666666666
(void*) malloc::return
(word) malloc::size
(word) malloc::size#3 1.0
(word) malloc::size#3 2.0
(word()) sqr((byte) sqr::val)
(byte~) sqr::$0 4.0
(word) sqr::return
@ -3495,8 +3499,8 @@ INITIAL ASM
.pc = $80d "Program"
// Global Constants & labels
.const SIZEOF_WORD = 2
// Start of the heap used by malloc()
.label HEAP_START = $c000
// Top of the heap used by malloc()
.label HEAP_TOP = $a000
// The number of iterations performed during 16-bit CORDIC atan2 calculation
.const CORDIC_ITERATIONS_16 = $f
// Screen containing angle to center
@ -3525,10 +3529,10 @@ malloc_from_b1:
sta malloc.size
lda #>$3e8
sta malloc.size+1
// [190] phi (byte*) heap_head#12 = (const byte*) HEAP_START#0 [phi:@1->malloc#1] -- pbuz1=pbuc1
lda #<HEAP_START
// [190] phi (byte*) heap_head#12 = (const byte*) HEAP_TOP#0 [phi:@1->malloc#1] -- pbuz1=pbuc1
lda #<HEAP_TOP
sta heap_head
lda #>HEAP_START
lda #>HEAP_TOP
sta heap_head+1
jsr malloc
jmp b3
@ -4882,18 +4886,18 @@ init_squares: {
malloc: {
.label mem = $7e
.label size = $37
// [191] (byte*) malloc::mem#0 ← (byte*) heap_head#12 -- pbuz1=pbuz2
// [191] (byte*) malloc::mem#0 ← (byte*) heap_head#12 - (word) malloc::size#3 -- pbuz1=pbuz2_minus_vwuz3
lda heap_head
sec
sbc size
sta mem
lda heap_head+1
sbc size+1
sta mem+1
// [192] (byte*) heap_head#1 ← (byte*) heap_head#12 + (word) malloc::size#3 -- pbuz1=pbuz1_plus_vwuz2
lda heap_head
clc
adc size
// [192] (byte*) heap_head#1 ← (byte*) malloc::mem#0 -- pbuz1=pbuz2
lda mem
sta heap_head
lda heap_head+1
adc size+1
lda mem+1
sta heap_head+1
jmp breturn
// malloc::@return
@ -5032,8 +5036,8 @@ Removing always clobbered register reg byte y as potential for zp ZP_BYTE:52 [ i
Statement [183] (word*) init_squares::squares#1 ← (word*) init_squares::squares#2 + (const byte) SIZEOF_WORD [ SQUARES#1 init_squares::sqr#2 init_squares::i#2 init_squares::squares#1 ] ( main:7::init_dist_screen:10::init_squares:106 [ SCREEN_DIST#0 SCREEN_ANGLE#0 init_dist_screen::screen#0 SQUARES#1 init_squares::sqr#2 init_squares::i#2 init_squares::squares#1 ] ) always clobbers reg byte a
Statement [184] (byte~) init_squares::$3 ← (byte) init_squares::i#2 << (byte) 1 [ SQUARES#1 init_squares::sqr#2 init_squares::i#2 init_squares::squares#1 init_squares::$3 ] ( main:7::init_dist_screen:10::init_squares:106 [ SCREEN_DIST#0 SCREEN_ANGLE#0 init_dist_screen::screen#0 SQUARES#1 init_squares::sqr#2 init_squares::i#2 init_squares::squares#1 init_squares::$3 ] ) always clobbers reg byte a
Statement [186] (word) init_squares::sqr#1 ← (word) init_squares::sqr#2 + (byte~) init_squares::$4 [ SQUARES#1 init_squares::i#2 init_squares::sqr#1 init_squares::squares#1 ] ( main:7::init_dist_screen:10::init_squares:106 [ SCREEN_DIST#0 SCREEN_ANGLE#0 init_dist_screen::screen#0 SQUARES#1 init_squares::i#2 init_squares::sqr#1 init_squares::squares#1 ] ) always clobbers reg byte a
Statement [191] (byte*) malloc::mem#0 ← (byte*) heap_head#12 [ malloc::mem#0 heap_head#12 malloc::size#3 ] ( malloc:2 [ malloc::mem#0 heap_head#12 malloc::size#3 ] malloc:4 [ malloc::mem#0 heap_head#12 malloc::size#3 ] main:7::init_dist_screen:10::init_squares:106::malloc:178 [ SCREEN_DIST#0 SCREEN_ANGLE#0 init_dist_screen::screen#0 malloc::mem#0 heap_head#12 malloc::size#3 ] ) always clobbers reg byte a
Statement [192] (byte*) heap_head#1 ← (byte*) heap_head#12 + (word) malloc::size#3 [ malloc::mem#0 heap_head#1 ] ( malloc:2 [ malloc::mem#0 heap_head#1 ] malloc:4 [ malloc::mem#0 heap_head#1 ] main:7::init_dist_screen:10::init_squares:106::malloc:178 [ SCREEN_DIST#0 SCREEN_ANGLE#0 init_dist_screen::screen#0 malloc::mem#0 heap_head#1 ] ) always clobbers reg byte a
Statement [191] (byte*) malloc::mem#0 ← (byte*) heap_head#12 - (word) malloc::size#3 [ malloc::mem#0 ] ( malloc:2 [ malloc::mem#0 ] malloc:4 [ malloc::mem#0 ] main:7::init_dist_screen:10::init_squares:106::malloc:178 [ SCREEN_DIST#0 SCREEN_ANGLE#0 init_dist_screen::screen#0 malloc::mem#0 ] ) always clobbers reg byte a
Statement [192] (byte*) heap_head#1 ← (byte*) malloc::mem#0 [ malloc::mem#0 heap_head#1 ] ( malloc:2 [ malloc::mem#0 heap_head#1 ] malloc:4 [ malloc::mem#0 heap_head#1 ] main:7::init_dist_screen:10::init_squares:106::malloc:178 [ SCREEN_DIST#0 SCREEN_ANGLE#0 init_dist_screen::screen#0 malloc::mem#0 heap_head#1 ] ) always clobbers reg byte a
Statement [3] (void*) SCREEN_DIST#0 ← (void*)(byte*) malloc::mem#0 [ SCREEN_DIST#0 heap_head#1 ] ( [ SCREEN_DIST#0 heap_head#1 ] ) always clobbers reg byte a
Statement [5] (void*) SCREEN_ANGLE#0 ← (void*)(byte*) malloc::mem#0 [ SCREEN_DIST#0 SCREEN_ANGLE#0 heap_head#1 ] ( [ SCREEN_DIST#0 SCREEN_ANGLE#0 heap_head#1 ] ) always clobbers reg byte a
Statement [9] (byte*) init_dist_screen::screen#0 ← (byte*)(void*) SCREEN_DIST#0 [ SCREEN_DIST#0 SCREEN_ANGLE#0 init_dist_screen::screen#0 heap_head#1 ] ( main:7 [ SCREEN_DIST#0 SCREEN_ANGLE#0 init_dist_screen::screen#0 heap_head#1 ] ) always clobbers reg byte a
@ -5142,8 +5146,8 @@ Statement [182] *((word*) init_squares::squares#2) ← (word) init_squares::sqr#
Statement [183] (word*) init_squares::squares#1 ← (word*) init_squares::squares#2 + (const byte) SIZEOF_WORD [ SQUARES#1 init_squares::sqr#2 init_squares::i#2 init_squares::squares#1 ] ( main:7::init_dist_screen:10::init_squares:106 [ SCREEN_DIST#0 SCREEN_ANGLE#0 init_dist_screen::screen#0 SQUARES#1 init_squares::sqr#2 init_squares::i#2 init_squares::squares#1 ] ) always clobbers reg byte a
Statement [184] (byte~) init_squares::$3 ← (byte) init_squares::i#2 << (byte) 1 [ SQUARES#1 init_squares::sqr#2 init_squares::i#2 init_squares::squares#1 init_squares::$3 ] ( main:7::init_dist_screen:10::init_squares:106 [ SCREEN_DIST#0 SCREEN_ANGLE#0 init_dist_screen::screen#0 SQUARES#1 init_squares::sqr#2 init_squares::i#2 init_squares::squares#1 init_squares::$3 ] ) always clobbers reg byte a
Statement [186] (word) init_squares::sqr#1 ← (word) init_squares::sqr#2 + (byte~) init_squares::$4 [ SQUARES#1 init_squares::i#2 init_squares::sqr#1 init_squares::squares#1 ] ( main:7::init_dist_screen:10::init_squares:106 [ SCREEN_DIST#0 SCREEN_ANGLE#0 init_dist_screen::screen#0 SQUARES#1 init_squares::i#2 init_squares::sqr#1 init_squares::squares#1 ] ) always clobbers reg byte a
Statement [191] (byte*) malloc::mem#0 ← (byte*) heap_head#12 [ malloc::mem#0 heap_head#12 malloc::size#3 ] ( malloc:2 [ malloc::mem#0 heap_head#12 malloc::size#3 ] malloc:4 [ malloc::mem#0 heap_head#12 malloc::size#3 ] main:7::init_dist_screen:10::init_squares:106::malloc:178 [ SCREEN_DIST#0 SCREEN_ANGLE#0 init_dist_screen::screen#0 malloc::mem#0 heap_head#12 malloc::size#3 ] ) always clobbers reg byte a
Statement [192] (byte*) heap_head#1 ← (byte*) heap_head#12 + (word) malloc::size#3 [ malloc::mem#0 heap_head#1 ] ( malloc:2 [ malloc::mem#0 heap_head#1 ] malloc:4 [ malloc::mem#0 heap_head#1 ] main:7::init_dist_screen:10::init_squares:106::malloc:178 [ SCREEN_DIST#0 SCREEN_ANGLE#0 init_dist_screen::screen#0 malloc::mem#0 heap_head#1 ] ) always clobbers reg byte a
Statement [191] (byte*) malloc::mem#0 ← (byte*) heap_head#12 - (word) malloc::size#3 [ malloc::mem#0 ] ( malloc:2 [ malloc::mem#0 ] malloc:4 [ malloc::mem#0 ] main:7::init_dist_screen:10::init_squares:106::malloc:178 [ SCREEN_DIST#0 SCREEN_ANGLE#0 init_dist_screen::screen#0 malloc::mem#0 ] ) always clobbers reg byte a
Statement [192] (byte*) heap_head#1 ← (byte*) malloc::mem#0 [ malloc::mem#0 heap_head#1 ] ( malloc:2 [ malloc::mem#0 heap_head#1 ] malloc:4 [ malloc::mem#0 heap_head#1 ] main:7::init_dist_screen:10::init_squares:106::malloc:178 [ SCREEN_DIST#0 SCREEN_ANGLE#0 init_dist_screen::screen#0 malloc::mem#0 heap_head#1 ] ) always clobbers reg byte a
Statement [3] (void*) SCREEN_DIST#0 ← (void*)(byte*) malloc::mem#0 [ SCREEN_DIST#0 heap_head#1 ] ( [ SCREEN_DIST#0 heap_head#1 ] ) always clobbers reg byte a
Statement [5] (void*) SCREEN_ANGLE#0 ← (void*)(byte*) malloc::mem#0 [ SCREEN_DIST#0 SCREEN_ANGLE#0 heap_head#1 ] ( [ SCREEN_DIST#0 SCREEN_ANGLE#0 heap_head#1 ] ) always clobbers reg byte a
Statement [9] (byte*) init_dist_screen::screen#0 ← (byte*)(void*) SCREEN_DIST#0 [ SCREEN_DIST#0 SCREEN_ANGLE#0 init_dist_screen::screen#0 heap_head#1 ] ( main:7 [ SCREEN_DIST#0 SCREEN_ANGLE#0 init_dist_screen::screen#0 heap_head#1 ] ) always clobbers reg byte a
@ -5251,8 +5255,8 @@ Statement [182] *((word*) init_squares::squares#2) ← (word) init_squares::sqr#
Statement [183] (word*) init_squares::squares#1 ← (word*) init_squares::squares#2 + (const byte) SIZEOF_WORD [ SQUARES#1 init_squares::sqr#2 init_squares::i#2 init_squares::squares#1 ] ( main:7::init_dist_screen:10::init_squares:106 [ SCREEN_DIST#0 SCREEN_ANGLE#0 init_dist_screen::screen#0 SQUARES#1 init_squares::sqr#2 init_squares::i#2 init_squares::squares#1 ] ) always clobbers reg byte a
Statement [184] (byte~) init_squares::$3 ← (byte) init_squares::i#2 << (byte) 1 [ SQUARES#1 init_squares::sqr#2 init_squares::i#2 init_squares::squares#1 init_squares::$3 ] ( main:7::init_dist_screen:10::init_squares:106 [ SCREEN_DIST#0 SCREEN_ANGLE#0 init_dist_screen::screen#0 SQUARES#1 init_squares::sqr#2 init_squares::i#2 init_squares::squares#1 init_squares::$3 ] ) always clobbers reg byte a
Statement [186] (word) init_squares::sqr#1 ← (word) init_squares::sqr#2 + (byte~) init_squares::$4 [ SQUARES#1 init_squares::i#2 init_squares::sqr#1 init_squares::squares#1 ] ( main:7::init_dist_screen:10::init_squares:106 [ SCREEN_DIST#0 SCREEN_ANGLE#0 init_dist_screen::screen#0 SQUARES#1 init_squares::i#2 init_squares::sqr#1 init_squares::squares#1 ] ) always clobbers reg byte a
Statement [191] (byte*) malloc::mem#0 ← (byte*) heap_head#12 [ malloc::mem#0 heap_head#12 malloc::size#3 ] ( malloc:2 [ malloc::mem#0 heap_head#12 malloc::size#3 ] malloc:4 [ malloc::mem#0 heap_head#12 malloc::size#3 ] main:7::init_dist_screen:10::init_squares:106::malloc:178 [ SCREEN_DIST#0 SCREEN_ANGLE#0 init_dist_screen::screen#0 malloc::mem#0 heap_head#12 malloc::size#3 ] ) always clobbers reg byte a
Statement [192] (byte*) heap_head#1 ← (byte*) heap_head#12 + (word) malloc::size#3 [ malloc::mem#0 heap_head#1 ] ( malloc:2 [ malloc::mem#0 heap_head#1 ] malloc:4 [ malloc::mem#0 heap_head#1 ] main:7::init_dist_screen:10::init_squares:106::malloc:178 [ SCREEN_DIST#0 SCREEN_ANGLE#0 init_dist_screen::screen#0 malloc::mem#0 heap_head#1 ] ) always clobbers reg byte a
Statement [191] (byte*) malloc::mem#0 ← (byte*) heap_head#12 - (word) malloc::size#3 [ malloc::mem#0 ] ( malloc:2 [ malloc::mem#0 ] malloc:4 [ malloc::mem#0 ] main:7::init_dist_screen:10::init_squares:106::malloc:178 [ SCREEN_DIST#0 SCREEN_ANGLE#0 init_dist_screen::screen#0 malloc::mem#0 ] ) always clobbers reg byte a
Statement [192] (byte*) heap_head#1 ← (byte*) malloc::mem#0 [ malloc::mem#0 heap_head#1 ] ( malloc:2 [ malloc::mem#0 heap_head#1 ] malloc:4 [ malloc::mem#0 heap_head#1 ] main:7::init_dist_screen:10::init_squares:106::malloc:178 [ SCREEN_DIST#0 SCREEN_ANGLE#0 init_dist_screen::screen#0 malloc::mem#0 heap_head#1 ] ) always clobbers reg byte a
Potential registers zp ZP_WORD:2 [ main::fill#2 main::fill#1 ] : zp ZP_WORD:2 ,
Potential registers zp ZP_WORD:4 [ main::dist#2 main::dist#0 main::dist#1 ] : zp ZP_WORD:4 ,
Potential registers zp ZP_WORD:6 [ main::angle#2 main::angle#0 main::angle#1 ] : zp ZP_WORD:6 ,
@ -5342,8 +5346,8 @@ Uplift Scope [main] 588: zp ZP_WORD:12 [ main::min_dist_angle#3 main::min_dist_a
Uplift Scope [sqr] 338: zp ZP_BYTE:47 [ sqr::val#2 sqr::val#0 sqr::val#1 ] 202: zp ZP_WORD:92 [ sqr::return#3 ] 28.5: zp ZP_WORD:120 [ sqr::return#0 ] 22: zp ZP_WORD:87 [ sqr::return#2 ] 4: zp ZP_BYTE:119 [ sqr::$0 ]
Uplift Scope [sqrt] 202: zp ZP_BYTE:100 [ sqrt::return#2 ] 103: zp ZP_WORD:98 [ sqrt::val#0 ] 34.33: zp ZP_BYTE:112 [ sqrt::return#0 ] 4: zp ZP_WORD:106 [ sqrt::found#0 ] 4: zp ZP_WORD:108 [ sqrt::$3 ] 2: zp ZP_WORD:110 [ sqrt::$1 ]
Uplift Scope [init_squares] 25.17: zp ZP_WORD:50 [ init_squares::squares#2 init_squares::squares#1 init_squares::squares#0 ] 22: zp ZP_BYTE:52 [ init_squares::i#2 init_squares::i#1 ] 22: zp ZP_BYTE:124 [ init_squares::$3 ] 22: zp ZP_BYTE:125 [ init_squares::$4 ] 13.93: zp ZP_WORD:48 [ init_squares::sqr#2 init_squares::sqr#1 ]
Uplift Scope [] 4.6: zp ZP_WORD:53 [ heap_head#12 heap_head#1 ] 0.09: zp ZP_WORD:59 [ SCREEN_ANGLE#0 ] 0.08: zp ZP_WORD:57 [ SCREEN_DIST#0 ] 0.03: zp ZP_WORD:122 [ SQUARES#1 ]
Uplift Scope [malloc] 1: zp ZP_WORD:55 [ malloc::size#3 ] 0.33: zp ZP_WORD:126 [ malloc::mem#0 ]
Uplift Scope [] 6.6: zp ZP_WORD:53 [ heap_head#12 heap_head#1 ] 0.09: zp ZP_WORD:59 [ SCREEN_ANGLE#0 ] 0.08: zp ZP_WORD:57 [ SCREEN_DIST#0 ] 0.03: zp ZP_WORD:122 [ SQUARES#1 ]
Uplift Scope [malloc] 2: zp ZP_WORD:55 [ malloc::size#3 ] 0.67: zp ZP_WORD:126 [ malloc::mem#0 ]
Uplifting [atan2_16] best 1247286 combination reg byte y [ atan2_16::shift#2 atan2_16::shift#5 atan2_16::shift#1 ] zp ZP_WORD:31 [ atan2_16::yd#5 atan2_16::yd#3 atan2_16::yd#10 atan2_16::yd#1 atan2_16::yd#2 ] zp ZP_WORD:33 [ atan2_16::xd#5 atan2_16::xd#3 atan2_16::xd#10 atan2_16::xd#1 atan2_16::xd#2 ] zp ZP_WORD:26 [ atan2_16::angle#6 atan2_16::angle#12 atan2_16::angle#13 atan2_16::angle#2 atan2_16::angle#3 ] zp ZP_WORD:21 [ atan2_16::yi#3 atan2_16::yi#8 atan2_16::yi#0 atan2_16::yi#16 atan2_16::$2 atan2_16::yi#1 atan2_16::yi#2 ] zp ZP_WORD:23 [ atan2_16::xi#3 atan2_16::xi#8 atan2_16::xi#0 atan2_16::xi#13 atan2_16::$7 atan2_16::xi#1 atan2_16::xi#2 ] reg byte a [ atan2_16::$24 ] reg byte a [ atan2_16::$23 ] reg byte x [ atan2_16::i#2 atan2_16::i#1 ] zp ZP_WORD:74 [ atan2_16::return#2 ] zp ZP_WORD:28 [ atan2_16::return#0 atan2_16::angle#5 atan2_16::angle#11 atan2_16::angle#1 atan2_16::angle#4 ] zp ZP_WORD:70 [ atan2_16::x#0 ] zp ZP_WORD:72 [ atan2_16::y#0 ]
Limited combination testing to 100 combinations of 144 possible.
@ -5383,6 +5387,7 @@ Uplifting [init_dist_screen] best 1220276 combination zp ZP_BYTE:35 [ init_dist_
Coalescing zero page register with common assignment [ zp ZP_WORD:15 [ init_angle_screen::screen_bottomline#5 init_angle_screen::screen_bottomline#0 init_angle_screen::screen_bottomline#1 ] ] with [ zp ZP_WORD:61 [ init_angle_screen::screen#0 ] ] - score: 1
Coalescing zero page register with common assignment [ zp ZP_WORD:26 [ atan2_16::angle#6 atan2_16::angle#12 atan2_16::angle#13 atan2_16::angle#2 atan2_16::angle#3 ] ] with [ zp ZP_WORD:28 [ atan2_16::return#0 atan2_16::angle#5 atan2_16::angle#11 atan2_16::angle#1 atan2_16::angle#4 ] ] - score: 1
Coalescing zero page register with common assignment [ zp ZP_WORD:44 [ bsearch16u::return#1 bsearch16u::return#6 bsearch16u::return#2 bsearch16u::items#2 bsearch16u::items#1 bsearch16u::items#8 bsearch16u::$2 bsearch16u::items#0 ] ] with [ zp ZP_WORD:104 [ bsearch16u::return#3 ] ] - score: 1
Coalescing zero page register with common assignment [ zp ZP_WORD:55 [ malloc::size#3 ] ] with [ zp ZP_WORD:126 [ malloc::mem#0 ] ] - score: 1
Coalescing zero page register with common assignment [ zp ZP_WORD:65 [ init_angle_screen::xw#0 ] ] with [ zp ZP_WORD:70 [ atan2_16::x#0 ] ] - score: 1
Coalescing zero page register with common assignment [ zp ZP_WORD:68 [ init_angle_screen::yw#0 ] ] with [ zp ZP_WORD:72 [ atan2_16::y#0 ] ] - score: 1
Coalescing zero page register with common assignment [ zp ZP_WORD:74 [ atan2_16::return#2 ] ] with [ zp ZP_WORD:76 [ init_angle_screen::angle_w#0 ] ] - score: 1
@ -5391,9 +5396,9 @@ Coalescing zero page register with common assignment [ zp ZP_WORD:92 [ sqr::retu
Coalescing zero page register with common assignment [ zp ZP_WORD:92 [ sqr::return#3 init_dist_screen::xds#0 ] ] with [ zp ZP_WORD:120 [ sqr::return#0 ] ] - score: 1
Coalescing zero page register with common assignment [ zp ZP_WORD:96 [ init_dist_screen::ds#0 ] ] with [ zp ZP_WORD:98 [ sqrt::val#0 ] ] - score: 1
Coalescing zero page register with common assignment [ zp ZP_WORD:106 [ sqrt::found#0 ] ] with [ zp ZP_WORD:108 [ sqrt::$3 ] ] - score: 1
Coalescing zero page register with common assignment [ zp ZP_WORD:122 [ SQUARES#1 ] ] with [ zp ZP_WORD:126 [ malloc::mem#0 ] ] - score: 1
Coalescing zero page register with common assignment [ zp ZP_WORD:26 [ atan2_16::angle#6 atan2_16::angle#12 atan2_16::angle#13 atan2_16::angle#2 atan2_16::angle#3 atan2_16::return#0 atan2_16::angle#5 atan2_16::angle#11 atan2_16::angle#1 atan2_16::angle#4 ] ] with [ zp ZP_WORD:74 [ atan2_16::return#2 init_angle_screen::angle_w#0 ] ] - score: 1
Coalescing zero page register with common assignment [ zp ZP_WORD:44 [ bsearch16u::return#1 bsearch16u::return#6 bsearch16u::return#2 bsearch16u::items#2 bsearch16u::items#1 bsearch16u::items#8 bsearch16u::$2 bsearch16u::items#0 bsearch16u::return#3 ] ] with [ zp ZP_WORD:106 [ sqrt::found#0 sqrt::$3 ] ] - score: 1
Coalescing zero page register with common assignment [ zp ZP_WORD:55 [ malloc::size#3 malloc::mem#0 ] ] with [ zp ZP_WORD:122 [ SQUARES#1 ] ] - score: 1
Coalescing zero page register with common assignment [ zp ZP_WORD:92 [ sqr::return#3 init_dist_screen::xds#0 sqr::return#0 ] ] with [ zp ZP_WORD:96 [ init_dist_screen::ds#0 sqrt::val#0 ] ] - score: 1
Coalescing zero page register with common assignment [ zp ZP_WORD:26 [ atan2_16::angle#6 atan2_16::angle#12 atan2_16::angle#13 atan2_16::angle#2 atan2_16::angle#3 atan2_16::return#0 atan2_16::angle#5 atan2_16::angle#11 atan2_16::angle#1 atan2_16::angle#4 atan2_16::return#2 init_angle_screen::angle_w#0 ] ] with [ zp ZP_WORD:78 [ init_angle_screen::$10 ] ] - score: 1
Coalescing zero page register with common assignment [ zp ZP_WORD:44 [ bsearch16u::return#1 bsearch16u::return#6 bsearch16u::return#2 bsearch16u::items#2 bsearch16u::items#1 bsearch16u::items#8 bsearch16u::$2 bsearch16u::items#0 bsearch16u::return#3 sqrt::found#0 sqrt::$3 ] ] with [ zp ZP_WORD:110 [ sqrt::$1 ] ] - score: 1
@ -5410,7 +5415,7 @@ Allocated (was zp ZP_WORD:44) zp ZP_WORD:38 [ bsearch16u::return#1 bsearch16u::r
Allocated (was zp ZP_WORD:48) zp ZP_WORD:40 [ init_squares::sqr#2 init_squares::sqr#1 ]
Allocated (was zp ZP_WORD:50) zp ZP_WORD:42 [ init_squares::squares#2 init_squares::squares#1 init_squares::squares#0 ]
Allocated (was zp ZP_WORD:53) zp ZP_WORD:44 [ heap_head#12 heap_head#1 ]
Allocated (was zp ZP_WORD:55) zp ZP_WORD:46 [ malloc::size#3 ]
Allocated (was zp ZP_WORD:55) zp ZP_WORD:46 [ malloc::size#3 malloc::mem#0 SQUARES#1 ]
Allocated (was zp ZP_WORD:57) zp ZP_WORD:48 [ SCREEN_DIST#0 ]
Allocated (was zp ZP_WORD:59) zp ZP_WORD:50 [ SCREEN_ANGLE#0 ]
Allocated (was zp ZP_WORD:65) zp ZP_WORD:52 [ init_angle_screen::xw#0 atan2_16::x#0 ]
@ -5420,7 +5425,6 @@ Allocated (was zp ZP_WORD:87) zp ZP_WORD:57 [ sqr::return#2 init_dist_screen::yd
Allocated (was zp ZP_WORD:92) zp ZP_WORD:59 [ sqr::return#3 init_dist_screen::xds#0 sqr::return#0 init_dist_screen::ds#0 sqrt::val#0 bsearch16u::key#0 ]
Allocated (was zp ZP_WORD:115) zp ZP_WORD:61 [ bsearch16u::pivot#0 ]
Allocated (was zp ZP_WORD:117) zp ZP_WORD:63 [ bsearch16u::result#0 ]
Allocated (was zp ZP_WORD:122) zp ZP_WORD:65 [ SQUARES#1 malloc::mem#0 ]
ASSEMBLER BEFORE OPTIMIZATION
// File Comments
@ -5431,8 +5435,8 @@ ASSEMBLER BEFORE OPTIMIZATION
.pc = $80d "Program"
// Global Constants & labels
.const SIZEOF_WORD = 2
// Start of the heap used by malloc()
.label HEAP_START = $c000
// Top of the heap used by malloc()
.label HEAP_TOP = $a000
// The number of iterations performed during 16-bit CORDIC atan2 calculation
.const CORDIC_ITERATIONS_16 = $f
// Screen containing angle to center
@ -5441,7 +5445,7 @@ ASSEMBLER BEFORE OPTIMIZATION
.const FILL_CHAR = '@'
.const NUM_SQUARES = $30
.label heap_head = $2c
.label SQUARES = $41
.label SQUARES = $2e
// Screen containing distance to center
.label SCREEN_DIST = $30
// Screen containing angle to center
@ -5461,10 +5465,10 @@ malloc_from_b1:
sta malloc.size
lda #>$3e8
sta malloc.size+1
// [190] phi (byte*) heap_head#12 = (const byte*) HEAP_START#0 [phi:@1->malloc#1] -- pbuz1=pbuc1
lda #<HEAP_START
// [190] phi (byte*) heap_head#12 = (const byte*) HEAP_TOP#0 [phi:@1->malloc#1] -- pbuz1=pbuc1
lda #<HEAP_TOP
sta heap_head
lda #>HEAP_START
lda #>HEAP_TOP
sta heap_head+1
jsr malloc
jmp b3
@ -6676,20 +6680,20 @@ init_squares: {
// The content of the newly allocated block of memory is not initialized, remaining with indeterminate values.
// malloc(word zeropage($2e) size)
malloc: {
.label mem = $41
.label mem = $2e
.label size = $2e
// [191] (byte*) malloc::mem#0 ← (byte*) heap_head#12 -- pbuz1=pbuz2
// [191] (byte*) malloc::mem#0 ← (byte*) heap_head#12 - (word) malloc::size#3 -- pbuz1=pbuz2_minus_vwuz1
lda heap_head
sec
sbc mem
sta mem
lda heap_head+1
sbc mem+1
sta mem+1
// [192] (byte*) heap_head#1 ← (byte*) heap_head#12 + (word) malloc::size#3 -- pbuz1=pbuz1_plus_vwuz2
lda heap_head
clc
adc size
// [192] (byte*) heap_head#1 ← (byte*) malloc::mem#0 -- pbuz1=pbuz2
lda mem
sta heap_head
lda heap_head+1
adc size+1
lda mem+1
sta heap_head+1
jmp breturn
// malloc::@return
@ -6932,8 +6936,8 @@ FINAL SYMBOL TABLE
(const byte) CORDIC_ITERATIONS_16#0 CORDIC_ITERATIONS_16 = (byte) $f
(byte) FILL_CHAR
(const byte) FILL_CHAR#0 FILL_CHAR = (byte) '@'
(byte*) HEAP_START
(const byte*) HEAP_START#0 HEAP_START = (byte*) 49152
(byte*) HEAP_TOP
(const byte*) HEAP_TOP#0 HEAP_TOP = (byte*) 40960
(byte) NUM_SQUARES
(const byte) NUM_SQUARES#3 NUM_SQUARES = (byte) $30
(byte*) SCREEN_ANGLE
@ -6944,7 +6948,7 @@ FINAL SYMBOL TABLE
(const byte*) SCREEN_FILL#0 SCREEN_FILL = (byte*) 1024
(const byte) SIZEOF_WORD SIZEOF_WORD = (byte) 2
(word*) SQUARES
(void*) SQUARES#1 SQUARES zp ZP_WORD:65 0.03225806451612903
(void*) SQUARES#1 SQUARES zp ZP_WORD:46 0.03225806451612903
(word()) atan2_16((signed word) atan2_16::x , (signed word) atan2_16::y)
(signed word~) atan2_16::$2 $2 zp ZP_WORD:21 4.0
(byte~) atan2_16::$23 reg byte a 2002.0
@ -7059,7 +7063,7 @@ FINAL SYMBOL TABLE
(word*~) bsearch16u::return#6 return zp ZP_WORD:38 4.0
(byte*) heap_head
(byte*) heap_head#1 heap_head zp ZP_WORD:44 0.6000000000000001
(byte*) heap_head#12 heap_head zp ZP_WORD:44 4.0
(byte*) heap_head#12 heap_head zp ZP_WORD:44 6.0
(void()) init_angle_screen((byte*) init_angle_screen::screen)
(word~) init_angle_screen::$10 $10 zp ZP_WORD:25 202.0
(byte~) init_angle_screen::$12 reg byte a 202.0
@ -7208,10 +7212,10 @@ FINAL SYMBOL TABLE
(void*()) malloc((word) malloc::size)
(label) malloc::@return
(byte*) malloc::mem
(byte*) malloc::mem#0 mem zp ZP_WORD:65 0.3333333333333333
(byte*) malloc::mem#0 mem zp ZP_WORD:46 0.6666666666666666
(void*) malloc::return
(word) malloc::size
(word) malloc::size#3 size zp ZP_WORD:46 1.0
(word) malloc::size#3 size zp ZP_WORD:46 2.0
(word()) sqr((byte) sqr::val)
(byte~) sqr::$0 reg byte a 4.0
(label) sqr::@return
@ -7269,7 +7273,7 @@ zp ZP_WORD:40 [ init_squares::sqr#2 init_squares::sqr#1 ]
zp ZP_WORD:42 [ init_squares::squares#2 init_squares::squares#1 init_squares::squares#0 ]
reg byte x [ init_squares::i#2 init_squares::i#1 ]
zp ZP_WORD:44 [ heap_head#12 heap_head#1 ]
zp ZP_WORD:46 [ malloc::size#3 ]
zp ZP_WORD:46 [ malloc::size#3 malloc::mem#0 SQUARES#1 ]
zp ZP_WORD:48 [ SCREEN_DIST#0 ]
zp ZP_WORD:50 [ SCREEN_ANGLE#0 ]
reg byte a [ init_angle_screen::$2 ]
@ -7295,7 +7299,6 @@ reg byte a [ bsearch16u::$16 ]
zp ZP_WORD:61 [ bsearch16u::pivot#0 ]
zp ZP_WORD:63 [ bsearch16u::result#0 ]
reg byte a [ sqr::$0 ]
zp ZP_WORD:65 [ SQUARES#1 malloc::mem#0 ]
reg byte a [ init_squares::$3 ]
reg byte a [ init_squares::$4 ]
@ -7311,8 +7314,8 @@ Score: 1112146
.pc = $80d "Program"
// Global Constants & labels
.const SIZEOF_WORD = 2
// Start of the heap used by malloc()
.label HEAP_START = $c000
// Top of the heap used by malloc()
.label HEAP_TOP = $a000
// The number of iterations performed during 16-bit CORDIC atan2 calculation
.const CORDIC_ITERATIONS_16 = $f
// Screen containing angle to center
@ -7321,7 +7324,7 @@ Score: 1112146
.const FILL_CHAR = '@'
.const NUM_SQUARES = $30
.label heap_head = $2c
.label SQUARES = $41
.label SQUARES = $2e
// Screen containing distance to center
.label SCREEN_DIST = $30
// Screen containing angle to center
@ -7338,10 +7341,10 @@ bbegin:
sta malloc.size
lda #>$3e8
sta malloc.size+1
// [190] phi (byte*) heap_head#12 = (const byte*) HEAP_START#0 [phi:@1->malloc#1] -- pbuz1=pbuc1
lda #<HEAP_START
// [190] phi (byte*) heap_head#12 = (const byte*) HEAP_TOP#0 [phi:@1->malloc#1] -- pbuz1=pbuc1
lda #<HEAP_TOP
sta heap_head
lda #>HEAP_START
lda #>HEAP_TOP
sta heap_head+1
jsr malloc
// @3
@ -8510,22 +8513,22 @@ init_squares: {
// The content of the newly allocated block of memory is not initialized, remaining with indeterminate values.
// malloc(word zeropage($2e) size)
malloc: {
.label mem = $41
.label mem = $2e
.label size = $2e
// mem = heap_head
// [191] (byte*) malloc::mem#0 ← (byte*) heap_head#12 -- pbuz1=pbuz2
// mem = heap_head-size
// [191] (byte*) malloc::mem#0 ← (byte*) heap_head#12 - (word) malloc::size#3 -- pbuz1=pbuz2_minus_vwuz1
lda heap_head
sec
sbc mem
sta mem
lda heap_head+1
sbc mem+1
sta mem+1
// heap_head+= size
// [192] (byte*) heap_head#1 ← (byte*) heap_head#12 + (word) malloc::size#3 -- pbuz1=pbuz1_plus_vwuz2
lda heap_head
clc
adc size
// heap_head = mem
// [192] (byte*) heap_head#1 ← (byte*) malloc::mem#0 -- pbuz1=pbuz2
lda mem
sta heap_head
lda heap_head+1
adc size+1
lda mem+1
sta heap_head+1
// malloc::@return
// }

View File

@ -12,8 +12,8 @@
(const byte) CORDIC_ITERATIONS_16#0 CORDIC_ITERATIONS_16 = (byte) $f
(byte) FILL_CHAR
(const byte) FILL_CHAR#0 FILL_CHAR = (byte) '@'
(byte*) HEAP_START
(const byte*) HEAP_START#0 HEAP_START = (byte*) 49152
(byte*) HEAP_TOP
(const byte*) HEAP_TOP#0 HEAP_TOP = (byte*) 40960
(byte) NUM_SQUARES
(const byte) NUM_SQUARES#3 NUM_SQUARES = (byte) $30
(byte*) SCREEN_ANGLE
@ -24,7 +24,7 @@
(const byte*) SCREEN_FILL#0 SCREEN_FILL = (byte*) 1024
(const byte) SIZEOF_WORD SIZEOF_WORD = (byte) 2
(word*) SQUARES
(void*) SQUARES#1 SQUARES zp ZP_WORD:65 0.03225806451612903
(void*) SQUARES#1 SQUARES zp ZP_WORD:46 0.03225806451612903
(word()) atan2_16((signed word) atan2_16::x , (signed word) atan2_16::y)
(signed word~) atan2_16::$2 $2 zp ZP_WORD:21 4.0
(byte~) atan2_16::$23 reg byte a 2002.0
@ -139,7 +139,7 @@
(word*~) bsearch16u::return#6 return zp ZP_WORD:38 4.0
(byte*) heap_head
(byte*) heap_head#1 heap_head zp ZP_WORD:44 0.6000000000000001
(byte*) heap_head#12 heap_head zp ZP_WORD:44 4.0
(byte*) heap_head#12 heap_head zp ZP_WORD:44 6.0
(void()) init_angle_screen((byte*) init_angle_screen::screen)
(word~) init_angle_screen::$10 $10 zp ZP_WORD:25 202.0
(byte~) init_angle_screen::$12 reg byte a 202.0
@ -288,10 +288,10 @@
(void*()) malloc((word) malloc::size)
(label) malloc::@return
(byte*) malloc::mem
(byte*) malloc::mem#0 mem zp ZP_WORD:65 0.3333333333333333
(byte*) malloc::mem#0 mem zp ZP_WORD:46 0.6666666666666666
(void*) malloc::return
(word) malloc::size
(word) malloc::size#3 size zp ZP_WORD:46 1.0
(word) malloc::size#3 size zp ZP_WORD:46 2.0
(word()) sqr((byte) sqr::val)
(byte~) sqr::$0 reg byte a 4.0
(label) sqr::@return
@ -349,7 +349,7 @@ zp ZP_WORD:40 [ init_squares::sqr#2 init_squares::sqr#1 ]
zp ZP_WORD:42 [ init_squares::squares#2 init_squares::squares#1 init_squares::squares#0 ]
reg byte x [ init_squares::i#2 init_squares::i#1 ]
zp ZP_WORD:44 [ heap_head#12 heap_head#1 ]
zp ZP_WORD:46 [ malloc::size#3 ]
zp ZP_WORD:46 [ malloc::size#3 malloc::mem#0 SQUARES#1 ]
zp ZP_WORD:48 [ SCREEN_DIST#0 ]
zp ZP_WORD:50 [ SCREEN_ANGLE#0 ]
reg byte a [ init_angle_screen::$2 ]
@ -375,6 +375,5 @@ reg byte a [ bsearch16u::$16 ]
zp ZP_WORD:61 [ bsearch16u::pivot#0 ]
zp ZP_WORD:63 [ bsearch16u::result#0 ]
reg byte a [ sqr::$0 ]
zp ZP_WORD:65 [ SQUARES#1 malloc::mem#0 ]
reg byte a [ init_squares::$3 ]
reg byte a [ init_squares::$4 ]