1
0
mirror of https://gitlab.com/camelot/kickc.git synced 2025-02-21 22:29:07 +00:00

Added plasma with unrolled inner loop for ~50fps.

This commit is contained in:
jespergravgaard 2019-04-08 09:00:48 +02:00
parent 7b23951eb2
commit 41029fec17
12 changed files with 8247 additions and 0 deletions

View File

@ -129,6 +129,14 @@ public class Pass2ConstantAdditionElimination extends Pass2SsaOptimization {
assignment.setrValue1(new ConstantBinary(const1, Operators.PLUS, consolidated));
getLog().append("Consolidated constant in assignment " + assignment.getlValue());
return true;
} else {
// Check if the constant is zero
ConstantLiteral constantLiteral = ((ConstantValue) assignment.getrValue1()).calculateLiteral(getScope());
if(constantLiteral.getValue().equals(new Long(0))) {
getLog().append("Removed zero-constant in assignment " + assignment.getlValue());
assignment.setrValue1(null);
assignment.setOperator(null);
}
}
} else if(assignment.getrValue1() instanceof VariableRef && assignment.getrValue2() instanceof ConstantValue) {
VariableRef variable = (VariableRef) assignment.getrValue1();
@ -140,6 +148,15 @@ public class Pass2ConstantAdditionElimination extends Pass2SsaOptimization {
// Handling of negative consolidated numbers?
getLog().append("Consolidated constant in assignment " + assignment.getlValue());
return true;
} else {
// Check if the constant is zero
ConstantLiteral constantLiteral = ((ConstantValue) assignment.getrValue2()).calculateLiteral(getScope());
if(constantLiteral.getValue().equals(new Long(0))) {
getLog().append("Removed zero-constant in assignment " + assignment.getlValue());
assignment.setrValue2(assignment.getrValue1());
assignment.setOperator(null);
assignment.setrValue1(null);
}
}
}
return false;

View File

@ -32,6 +32,16 @@ public class TestPrograms {
public TestPrograms() {
}
@Test
public void testPlus0() throws IOException, URISyntaxException {
compileAndCompare("plus-0");
}
@Test
public void testPlasma2() throws IOException, URISyntaxException {
compileAndCompare("examples/plasma/plasma-unroll");
}
@Test
public void testPlasma() throws IOException, URISyntaxException {
compileAndCompare("examples/plasma/plasma");

View File

@ -0,0 +1,91 @@
// A KickC version of the plasma routine from the CC65 samples
// This version has an unrolled inner loop to reach ~50FPS
// (w)2001 by groepaz/hitmen
// Cleanup and porting to CC65 by Ullrich von Bassewitz.
// Ported to KickC by Jesper Gravgaard.
// Original source https://github.com/cc65/cc65/blob/master/samples/plasma.c
import "c64"
import "print"
import "sid"
const byte* SCREEN1 = $2800;
const byte* CHARSET = $2000;
const byte* SINTABLE = $1f00;
kickasm(pc SINTABLE) {{
.for(var i=0;i<$100;i++)
.byte round(127.5+127.5*sin(toRadians(360*i/256)))
}}
void main() {
asm { sei }
*BORDERCOL = BLUE;
*BGCOL = BLUE;
for(byte* col : COLS..COLS+1000) *col = BLACK;
makecharset(CHARSET);
*D018 = toD018(SCREEN1, CHARSET);
while(true) {
// Show single-buffered plasma
doplasma(SCREEN1);
}
}
// Plasma state variables
byte c1A = 0;
byte c1B = 0;
byte c2A = 0;
byte c2B = 0;
// Render plasma to the passed screen
void doplasma(byte* screen) {
byte[40] xbuf;
byte[25] ybuf;
byte c1a = c1A;
byte c1b = c1B;
for (byte i = 0; i < 25; ++i) {
ybuf[i] = (SINTABLE[c1a] + SINTABLE[c1b]);
c1a += 4;
c1b += 9;
}
c1A += 3;
c1B -= 5;
byte c2a = c2A;
byte c2b = c2B;
for (byte i = 0; i < 40; ++i) {
xbuf[i] = (SINTABLE[c2a] + SINTABLE[c2b]);
c2a += 3;
c2b += 7;
}
c2A += 2;
c2B -= 3;
for (byte i = 0; i < 40; ++i) {
inline for (byte ii = 0; ii < 25; ++ii) {
(screen+ii*40)[i] = (xbuf[i] + ybuf[ii]);
}
}
}
// Make a plasma-friendly charset where the chars are randomly filled
void makecharset(byte* charset) {
const byte[8] bittab = { 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80 };
sid_rnd_init();
print_cls();
for (word c = 0; c < 0x100; ++c) {
byte s = SINTABLE[<c];
for ( byte i = 0; i < 8; ++i){
byte b = 0;
for (byte ii = 0; ii < 8; ++ii) {
if ((sid_rnd() & 0xFF) > s) {
b |= bittab[ii];
}
}
charset[(c<<3) + i] = b;
}
if ((c & 0x07) == 0) {
print_char('.');
}
}
}

14
src/test/kc/plus-0.kc Normal file
View File

@ -0,0 +1,14 @@
// Tests elimination of plus 0
void main() {
fill((byte*)$400,'a');
fill((byte*)$2000,'b');
}
void fill(byte* screen, byte ch) {
for(byte i: 0..39) {
inline for( byte j: 0..2 ) {
(screen+j*40)[i] = ch;
}
}
}

View File

@ -0,0 +1,401 @@
// A KickC version of the plasma routine from the CC65 samples
// This version has an unrolled inner loop to reach ~50FPS
// (w)2001 by groepaz/hitmen
// Cleanup and porting to CC65 by Ullrich von Bassewitz.
// Ported to KickC by Jesper Gravgaard.
// Original source https://github.com/cc65/cc65/blob/master/samples/plasma.c
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
.label BORDERCOL = $d020
.label BGCOL = $d021
.label D018 = $d018
// Color Ram
.label COLS = $d800
// The colors of the C64
.const BLACK = 0
.const BLUE = 6
.label print_line_cursor = $400
// SID registers for random number generation
.label SID_VOICE3_FREQ = $d40e
.label SID_VOICE3_CONTROL = $d412
.const SID_CONTROL_NOISE = $80
.label SID_VOICE3_OSC = $d41b
.label SCREEN1 = $2800
.label CHARSET = $2000
.label SINTABLE = $1f00
.label print_char_cursor = $b
.label c1A = 4
.label c1B = 5
.label c2A = 6
.label c2B = 7
main: {
.const toD0181_return = (>(SCREEN1&$3fff)<<2)|(>CHARSET)>>2&$f
.label col = 2
sei
lda #BLUE
sta BORDERCOL
sta BGCOL
lda #<COLS
sta col
lda #>COLS
sta col+1
b1:
lda #BLACK
ldy #0
sta (col),y
inc col
bne !+
inc col+1
!:
lda col+1
cmp #>COLS+$3e8+1
bne b1
lda col
cmp #<COLS+$3e8+1
bne b1
jsr makecharset
lda #toD0181_return
sta D018
lda #0
sta c2B
sta c2A
sta c1B
sta c1A
b4:
jsr doplasma
jmp b4
}
// Render plasma to the passed screen
doplasma: {
.label c1a = 8
.label c1b = 9
.label i = $a
.label c2a = 8
.label c2b = 9
.label i1 = $a
lda c1A
sta c1a
lda c1B
sta c1b
lda #0
sta i
b1:
ldy c1a
lda SINTABLE,y
ldy c1b
clc
adc SINTABLE,y
ldy i
sta ybuf,y
lax c1a
axs #-[4]
stx c1a
lax c1b
axs #-[9]
stx c1b
inc i
lda i
cmp #$19
bcc b1
lax c1A
axs #-[3]
stx c1A
lax c1B
axs #5
stx c1B
lda c2A
sta c2a
lda c2B
sta c2b
lda #0
sta i1
b3:
ldy c2a
lda SINTABLE,y
ldy c2b
clc
adc SINTABLE,y
ldy i1
sta xbuf,y
lax c2a
axs #-[3]
stx c2a
lax c2b
axs #-[7]
stx c2b
inc i1
lda i1
cmp #$28
bcc b3
lda c2A
clc
adc #2
sta c2A
lax c2B
axs #3
stx c2B
ldx #0
b6:
lda xbuf,x
clc
adc ybuf
sta SCREEN1,x
lda xbuf,x
clc
adc ybuf+1
sta SCREEN1+1*$28,x
lda xbuf,x
clc
adc ybuf+2
sta SCREEN1+2*$28,x
lda xbuf,x
clc
adc ybuf+3
sta SCREEN1+3*$28,x
lda xbuf,x
clc
adc ybuf+4
sta SCREEN1+4*$28,x
lda xbuf,x
clc
adc ybuf+5
sta SCREEN1+5*$28,x
lda xbuf,x
clc
adc ybuf+6
sta SCREEN1+6*$28,x
lda xbuf,x
clc
adc ybuf+7
sta SCREEN1+7*$28,x
lda xbuf,x
clc
adc ybuf+8
sta SCREEN1+8*$28,x
lda xbuf,x
clc
adc ybuf+9
sta SCREEN1+9*$28,x
lda xbuf,x
clc
adc ybuf+$a
sta SCREEN1+$a*$28,x
lda xbuf,x
clc
adc ybuf+$b
sta SCREEN1+$b*$28,x
lda xbuf,x
clc
adc ybuf+$c
sta SCREEN1+$c*$28,x
lda xbuf,x
clc
adc ybuf+$d
sta SCREEN1+$d*$28,x
lda xbuf,x
clc
adc ybuf+$e
sta SCREEN1+$e*$28,x
lda xbuf,x
clc
adc ybuf+$f
sta SCREEN1+$f*$28,x
lda xbuf,x
clc
adc ybuf+$10
sta SCREEN1+$10*$28,x
lda xbuf,x
clc
adc ybuf+$11
sta SCREEN1+$11*$28,x
lda xbuf,x
clc
adc ybuf+$12
sta SCREEN1+$12*$28,x
lda xbuf,x
clc
adc ybuf+$13
sta SCREEN1+$13*$28,x
lda xbuf,x
clc
adc ybuf+$14
sta SCREEN1+$14*$28,x
lda xbuf,x
clc
adc ybuf+$15
sta SCREEN1+$15*$28,x
lda xbuf,x
clc
adc ybuf+$16
sta SCREEN1+$16*$28,x
lda xbuf,x
clc
adc ybuf+$17
sta SCREEN1+$17*$28,x
lda xbuf,x
clc
adc ybuf+$18
sta SCREEN1+$18*$28,x
inx
cpx #$28
bcs !b6+
jmp b6
!b6:
rts
xbuf: .fill $28, 0
ybuf: .fill $19, 0
}
// Make a plasma-friendly charset where the chars are randomly filled
makecharset: {
.label _4 = 6
.label _8 = $d
.label _9 = $d
.label s = 5
.label i = 4
.label c = 2
jsr sid_rnd_init
jsr print_cls
lda #<print_line_cursor
sta print_char_cursor
lda #>print_line_cursor
sta print_char_cursor+1
lda #0
sta c
sta c+1
b1:
lda c
tay
lda SINTABLE,y
sta s
lda #0
sta i
b2:
ldy #0
ldx #0
b3:
jsr sid_rnd
and #$ff
sta _4
lda s
cmp _4
bcs b4
tya
ora bittab,x
tay
b4:
inx
cpx #8
bcc b3
lda c
asl
sta _8
lda c+1
rol
sta _8+1
asl _8
rol _8+1
asl _8
rol _8+1
lda i
clc
adc _9
sta _9
bcc !+
inc _9+1
!:
tya
sta !v++1
lda #<CHARSET
clc
adc _9
sta !a++1
lda #>CHARSET
adc _9+1
sta !a++2
!v:
lda #0
!a:
sta CHARSET
inc i
lda i
cmp #8
bcc b2
lda c
and #7
cmp #0
bne b9
jsr print_char
b9:
inc c
bne !+
inc c+1
!:
lda c+1
cmp #>$100
bcc b1
bne !+
lda c
cmp #<$100
bcs !b1+
jmp b1
!b1:
!:
rts
bittab: .byte 1, 2, 4, 8, $10, $20, $40, $80
}
// Print a single char
print_char: {
.const ch = '.'
lda #ch
ldy #0
sta (print_char_cursor),y
inc print_char_cursor
bne !+
inc print_char_cursor+1
!:
rts
}
// Get a random number from the SID voice 3,
// Must be initialized with sid_rnd_init()
sid_rnd: {
lda SID_VOICE3_OSC
rts
}
// Clear the screen. Also resets current line/char cursor.
print_cls: {
.label sc = 2
lda #<print_line_cursor
sta sc
lda #>print_line_cursor
sta sc+1
b1:
lda #' '
ldy #0
sta (sc),y
inc sc
bne !+
inc sc+1
!:
lda sc+1
cmp #>print_line_cursor+$3e8
bne b1
lda sc
cmp #<print_line_cursor+$3e8
bne b1
rts
}
// Initialize SID voice 3 for random number generation
sid_rnd_init: {
lda #<$ffff
sta SID_VOICE3_FREQ
lda #>$ffff
sta SID_VOICE3_FREQ+1
lda #SID_CONTROL_NOISE
sta SID_VOICE3_CONTROL
rts
}
.pc = SINTABLE "SINTABLE"
.for(var i=0;i<$100;i++)
.byte round(127.5+127.5*sin(toRadians(360*i/256)))

View File

@ -0,0 +1,282 @@
@begin: scope:[] from
[0] phi()
to:@1
@1: scope:[] from @begin
kickasm(location (const byte*) SINTABLE#0) {{ .for(var i=0;i<$100;i++)
.byte round(127.5+127.5*sin(toRadians(360*i/256)))
}}
to:@2
@2: scope:[] from @1
[2] phi()
[3] call main
to:@end
@end: scope:[] from @2
[4] phi()
main: scope:[main] from @2
asm { sei }
[6] *((const byte*) BORDERCOL#0) ← (const byte) BLUE#0
[7] *((const byte*) BGCOL#0) ← (const byte) BLUE#0
to:main::@1
main::@1: scope:[main] from main main::@1
[8] (byte*) main::col#2 ← phi( main/(const byte*) COLS#0 main::@1/(byte*) main::col#1 )
[9] *((byte*) main::col#2) ← (const byte) BLACK#0
[10] (byte*) main::col#1 ← ++ (byte*) main::col#2
[11] if((byte*) main::col#1!=(byte*)(const byte*) COLS#0+(word/signed word/dword/signed dword) $3e8+(byte/signed byte/word/signed word/dword/signed dword) 1) goto main::@1
to:main::@2
main::@2: scope:[main] from main::@1
[12] phi()
[13] call makecharset
to:main::toD0181
main::toD0181: scope:[main] from main::@2
[14] phi()
to:main::@5
main::@5: scope:[main] from main::toD0181
[15] *((const byte*) D018#0) ← (const byte) main::toD0181_return#0
to:main::@3
main::@3: scope:[main] from main::@4 main::@5
[16] (byte) c2B#1 ← phi( main::@4/(byte) c2B#3 main::@5/(byte/signed byte/word/signed word/dword/signed dword) 0 )
[16] (byte) c2A#1 ← phi( main::@4/(byte) c2A#3 main::@5/(byte/signed byte/word/signed word/dword/signed dword) 0 )
[16] (byte) c1B#1 ← phi( main::@4/(byte) c1B#3 main::@5/(byte/signed byte/word/signed word/dword/signed dword) 0 )
[16] (byte) c1A#1 ← phi( main::@4/(byte) c1A#3 main::@5/(byte/signed byte/word/signed word/dword/signed dword) 0 )
to:main::@4
main::@4: scope:[main] from main::@3
[17] phi()
[18] call doplasma
to:main::@3
doplasma: scope:[doplasma] from main::@4
[19] (byte) doplasma::c1a#0 ← (byte) c1A#1
[20] (byte) doplasma::c1b#0 ← (byte) c1B#1
to:doplasma::@1
doplasma::@1: scope:[doplasma] from doplasma doplasma::@1
[21] (byte) doplasma::i#2 ← phi( doplasma/(byte/signed byte/word/signed word/dword/signed dword) 0 doplasma::@1/(byte) doplasma::i#1 )
[21] (byte) doplasma::c1b#2 ← phi( doplasma/(byte) doplasma::c1b#0 doplasma::@1/(byte) doplasma::c1b#1 )
[21] (byte) doplasma::c1a#2 ← phi( doplasma/(byte) doplasma::c1a#0 doplasma::@1/(byte) doplasma::c1a#1 )
[22] (byte~) doplasma::$0 ← *((const byte*) SINTABLE#0 + (byte) doplasma::c1a#2) + *((const byte*) SINTABLE#0 + (byte) doplasma::c1b#2)
[23] *((const byte[$19]) doplasma::ybuf#0 + (byte) doplasma::i#2) ← (byte~) doplasma::$0
[24] (byte) doplasma::c1a#1 ← (byte) doplasma::c1a#2 + (byte/signed byte/word/signed word/dword/signed dword) 4
[25] (byte) doplasma::c1b#1 ← (byte) doplasma::c1b#2 + (byte/signed byte/word/signed word/dword/signed dword) 9
[26] (byte) doplasma::i#1 ← ++ (byte) doplasma::i#2
[27] if((byte) doplasma::i#1<(byte/signed byte/word/signed word/dword/signed dword) $19) goto doplasma::@1
to:doplasma::@2
doplasma::@2: scope:[doplasma] from doplasma::@1
[28] (byte) c1A#3 ← (byte) c1A#1 + (byte/signed byte/word/signed word/dword/signed dword) 3
[29] (byte) c1B#3 ← (byte) c1B#1 - (byte/signed byte/word/signed word/dword/signed dword) 5
[30] (byte) doplasma::c2a#0 ← (byte) c2A#1
[31] (byte) doplasma::c2b#0 ← (byte) c2B#1
to:doplasma::@3
doplasma::@3: scope:[doplasma] from doplasma::@2 doplasma::@3
[32] (byte) doplasma::i1#2 ← phi( doplasma::@2/(byte/signed byte/word/signed word/dword/signed dword) 0 doplasma::@3/(byte) doplasma::i1#1 )
[32] (byte) doplasma::c2b#2 ← phi( doplasma::@2/(byte) doplasma::c2b#0 doplasma::@3/(byte) doplasma::c2b#1 )
[32] (byte) doplasma::c2a#2 ← phi( doplasma::@2/(byte) doplasma::c2a#0 doplasma::@3/(byte) doplasma::c2a#1 )
[33] (byte~) doplasma::$2 ← *((const byte*) SINTABLE#0 + (byte) doplasma::c2a#2) + *((const byte*) SINTABLE#0 + (byte) doplasma::c2b#2)
[34] *((const byte[$28]) doplasma::xbuf#0 + (byte) doplasma::i1#2) ← (byte~) doplasma::$2
[35] (byte) doplasma::c2a#1 ← (byte) doplasma::c2a#2 + (byte/signed byte/word/signed word/dword/signed dword) 3
[36] (byte) doplasma::c2b#1 ← (byte) doplasma::c2b#2 + (byte/signed byte/word/signed word/dword/signed dword) 7
[37] (byte) doplasma::i1#1 ← ++ (byte) doplasma::i1#2
[38] if((byte) doplasma::i1#1<(byte/signed byte/word/signed word/dword/signed dword) $28) goto doplasma::@3
to:doplasma::@4
doplasma::@4: scope:[doplasma] from doplasma::@3
[39] (byte) c2A#3 ← (byte) c2A#1 + (byte/signed byte/word/signed word/dword/signed dword) 2
[40] (byte) c2B#3 ← (byte) c2B#1 - (byte/signed byte/word/signed word/dword/signed dword) 3
to:doplasma::@5
doplasma::@5: scope:[doplasma] from doplasma::@4 doplasma::@7
[41] (byte) doplasma::i2#4 ← phi( doplasma::@4/(byte/signed byte/word/signed word/dword/signed dword) 0 doplasma::@7/(byte) doplasma::i2#1 )
to:doplasma::@6
doplasma::@6: scope:[doplasma] from doplasma::@5
[42] (byte~) doplasma::$6 ← *((const byte[$28]) doplasma::xbuf#0 + (byte) doplasma::i2#4) + *((const byte[$19]) doplasma::ybuf#0)
[43] *((const byte*) SCREEN1#0 + (byte) doplasma::i2#4) ← (byte~) doplasma::$6
to:doplasma::@6_1
doplasma::@6_1: scope:[doplasma] from doplasma::@6
[44] (byte~) doplasma::$11 ← *((const byte[$28]) doplasma::xbuf#0 + (byte) doplasma::i2#4) + *((const byte[$19]) doplasma::ybuf#0+(byte/signed byte/word/signed word/dword/signed dword) 1)
[45] *((const byte*) SCREEN1#0+(byte/signed byte/word/signed word/dword/signed dword) 1*(byte/signed byte/word/signed word/dword/signed dword) $28 + (byte) doplasma::i2#4) ← (byte~) doplasma::$11
to:doplasma::@6_2
doplasma::@6_2: scope:[doplasma] from doplasma::@6_1
[46] (byte~) doplasma::$14 ← *((const byte[$28]) doplasma::xbuf#0 + (byte) doplasma::i2#4) + *((const byte[$19]) doplasma::ybuf#0+(byte/signed byte/word/signed word/dword/signed dword) 2)
[47] *((const byte*) SCREEN1#0+(byte/signed byte/word/signed word/dword/signed dword) 2*(byte/signed byte/word/signed word/dword/signed dword) $28 + (byte) doplasma::i2#4) ← (byte~) doplasma::$14
to:doplasma::@6_3
doplasma::@6_3: scope:[doplasma] from doplasma::@6_2
[48] (byte~) doplasma::$17 ← *((const byte[$28]) doplasma::xbuf#0 + (byte) doplasma::i2#4) + *((const byte[$19]) doplasma::ybuf#0+(byte/signed byte/word/signed word/dword/signed dword) 3)
[49] *((const byte*) SCREEN1#0+(byte/signed byte/word/signed word/dword/signed dword) 3*(byte/signed byte/word/signed word/dword/signed dword) $28 + (byte) doplasma::i2#4) ← (byte~) doplasma::$17
to:doplasma::@6_4
doplasma::@6_4: scope:[doplasma] from doplasma::@6_3
[50] (byte~) doplasma::$20 ← *((const byte[$28]) doplasma::xbuf#0 + (byte) doplasma::i2#4) + *((const byte[$19]) doplasma::ybuf#0+(byte/signed byte/word/signed word/dword/signed dword) 4)
[51] *((const byte*) SCREEN1#0+(byte/signed byte/word/signed word/dword/signed dword) 4*(byte/signed byte/word/signed word/dword/signed dword) $28 + (byte) doplasma::i2#4) ← (byte~) doplasma::$20
to:doplasma::@6_5
doplasma::@6_5: scope:[doplasma] from doplasma::@6_4
[52] (byte~) doplasma::$23 ← *((const byte[$28]) doplasma::xbuf#0 + (byte) doplasma::i2#4) + *((const byte[$19]) doplasma::ybuf#0+(byte/signed byte/word/signed word/dword/signed dword) 5)
[53] *((const byte*) SCREEN1#0+(byte/signed byte/word/signed word/dword/signed dword) 5*(byte/signed byte/word/signed word/dword/signed dword) $28 + (byte) doplasma::i2#4) ← (byte~) doplasma::$23
to:doplasma::@6_6
doplasma::@6_6: scope:[doplasma] from doplasma::@6_5
[54] (byte~) doplasma::$26 ← *((const byte[$28]) doplasma::xbuf#0 + (byte) doplasma::i2#4) + *((const byte[$19]) doplasma::ybuf#0+(byte/signed byte/word/signed word/dword/signed dword) 6)
[55] *((const byte*) SCREEN1#0+(byte/signed byte/word/signed word/dword/signed dword) 6*(byte/signed byte/word/signed word/dword/signed dword) $28 + (byte) doplasma::i2#4) ← (byte~) doplasma::$26
to:doplasma::@6_7
doplasma::@6_7: scope:[doplasma] from doplasma::@6_6
[56] (byte~) doplasma::$29 ← *((const byte[$28]) doplasma::xbuf#0 + (byte) doplasma::i2#4) + *((const byte[$19]) doplasma::ybuf#0+(byte/signed byte/word/signed word/dword/signed dword) 7)
[57] *((const byte*) SCREEN1#0+(byte/signed byte/word/signed word/dword/signed dword) 7*(byte/signed byte/word/signed word/dword/signed dword) $28 + (byte) doplasma::i2#4) ← (byte~) doplasma::$29
to:doplasma::@6_8
doplasma::@6_8: scope:[doplasma] from doplasma::@6_7
[58] (byte~) doplasma::$32 ← *((const byte[$28]) doplasma::xbuf#0 + (byte) doplasma::i2#4) + *((const byte[$19]) doplasma::ybuf#0+(byte/signed byte/word/signed word/dword/signed dword) 8)
[59] *((const byte*) SCREEN1#0+(byte/signed byte/word/signed word/dword/signed dword) 8*(byte/signed byte/word/signed word/dword/signed dword) $28 + (byte) doplasma::i2#4) ← (byte~) doplasma::$32
to:doplasma::@6_9
doplasma::@6_9: scope:[doplasma] from doplasma::@6_8
[60] (byte~) doplasma::$35 ← *((const byte[$28]) doplasma::xbuf#0 + (byte) doplasma::i2#4) + *((const byte[$19]) doplasma::ybuf#0+(byte/signed byte/word/signed word/dword/signed dword) 9)
[61] *((const byte*) SCREEN1#0+(byte/signed byte/word/signed word/dword/signed dword) 9*(byte/signed byte/word/signed word/dword/signed dword) $28 + (byte) doplasma::i2#4) ← (byte~) doplasma::$35
to:doplasma::@6_10
doplasma::@6_10: scope:[doplasma] from doplasma::@6_9
[62] (byte~) doplasma::$38 ← *((const byte[$28]) doplasma::xbuf#0 + (byte) doplasma::i2#4) + *((const byte[$19]) doplasma::ybuf#0+(byte/signed byte/word/signed word/dword/signed dword) $a)
[63] *((const byte*) SCREEN1#0+(byte/signed byte/word/signed word/dword/signed dword) $a*(byte/signed byte/word/signed word/dword/signed dword) $28 + (byte) doplasma::i2#4) ← (byte~) doplasma::$38
to:doplasma::@6_11
doplasma::@6_11: scope:[doplasma] from doplasma::@6_10
[64] (byte~) doplasma::$41 ← *((const byte[$28]) doplasma::xbuf#0 + (byte) doplasma::i2#4) + *((const byte[$19]) doplasma::ybuf#0+(byte/signed byte/word/signed word/dword/signed dword) $b)
[65] *((const byte*) SCREEN1#0+(byte/signed byte/word/signed word/dword/signed dword) $b*(byte/signed byte/word/signed word/dword/signed dword) $28 + (byte) doplasma::i2#4) ← (byte~) doplasma::$41
to:doplasma::@6_12
doplasma::@6_12: scope:[doplasma] from doplasma::@6_11
[66] (byte~) doplasma::$44 ← *((const byte[$28]) doplasma::xbuf#0 + (byte) doplasma::i2#4) + *((const byte[$19]) doplasma::ybuf#0+(byte/signed byte/word/signed word/dword/signed dword) $c)
[67] *((const byte*) SCREEN1#0+(byte/signed byte/word/signed word/dword/signed dword) $c*(byte/signed byte/word/signed word/dword/signed dword) $28 + (byte) doplasma::i2#4) ← (byte~) doplasma::$44
to:doplasma::@6_13
doplasma::@6_13: scope:[doplasma] from doplasma::@6_12
[68] (byte~) doplasma::$47 ← *((const byte[$28]) doplasma::xbuf#0 + (byte) doplasma::i2#4) + *((const byte[$19]) doplasma::ybuf#0+(byte/signed byte/word/signed word/dword/signed dword) $d)
[69] *((const byte*) SCREEN1#0+(byte/signed byte/word/signed word/dword/signed dword) $d*(byte/signed byte/word/signed word/dword/signed dword) $28 + (byte) doplasma::i2#4) ← (byte~) doplasma::$47
to:doplasma::@6_14
doplasma::@6_14: scope:[doplasma] from doplasma::@6_13
[70] (byte~) doplasma::$50 ← *((const byte[$28]) doplasma::xbuf#0 + (byte) doplasma::i2#4) + *((const byte[$19]) doplasma::ybuf#0+(byte/signed byte/word/signed word/dword/signed dword) $e)
[71] *((const byte*) SCREEN1#0+(byte/signed byte/word/signed word/dword/signed dword) $e*(byte/signed byte/word/signed word/dword/signed dword) $28 + (byte) doplasma::i2#4) ← (byte~) doplasma::$50
to:doplasma::@6_15
doplasma::@6_15: scope:[doplasma] from doplasma::@6_14
[72] (byte~) doplasma::$53 ← *((const byte[$28]) doplasma::xbuf#0 + (byte) doplasma::i2#4) + *((const byte[$19]) doplasma::ybuf#0+(byte/signed byte/word/signed word/dword/signed dword) $f)
[73] *((const byte*) SCREEN1#0+(byte/signed byte/word/signed word/dword/signed dword) $f*(byte/signed byte/word/signed word/dword/signed dword) $28 + (byte) doplasma::i2#4) ← (byte~) doplasma::$53
to:doplasma::@6_16
doplasma::@6_16: scope:[doplasma] from doplasma::@6_15
[74] (byte~) doplasma::$56 ← *((const byte[$28]) doplasma::xbuf#0 + (byte) doplasma::i2#4) + *((const byte[$19]) doplasma::ybuf#0+(byte/signed byte/word/signed word/dword/signed dword) $10)
[75] *((const byte*) SCREEN1#0+(byte/signed byte/word/signed word/dword/signed dword) $10*(byte/signed byte/word/signed word/dword/signed dword) $28 + (byte) doplasma::i2#4) ← (byte~) doplasma::$56
to:doplasma::@6_17
doplasma::@6_17: scope:[doplasma] from doplasma::@6_16
[76] (byte~) doplasma::$59 ← *((const byte[$28]) doplasma::xbuf#0 + (byte) doplasma::i2#4) + *((const byte[$19]) doplasma::ybuf#0+(byte/signed byte/word/signed word/dword/signed dword) $11)
[77] *((const byte*) SCREEN1#0+(byte/signed byte/word/signed word/dword/signed dword) $11*(byte/signed byte/word/signed word/dword/signed dword) $28 + (byte) doplasma::i2#4) ← (byte~) doplasma::$59
to:doplasma::@6_18
doplasma::@6_18: scope:[doplasma] from doplasma::@6_17
[78] (byte~) doplasma::$62 ← *((const byte[$28]) doplasma::xbuf#0 + (byte) doplasma::i2#4) + *((const byte[$19]) doplasma::ybuf#0+(byte/signed byte/word/signed word/dword/signed dword) $12)
[79] *((const byte*) SCREEN1#0+(byte/signed byte/word/signed word/dword/signed dword) $12*(byte/signed byte/word/signed word/dword/signed dword) $28 + (byte) doplasma::i2#4) ← (byte~) doplasma::$62
to:doplasma::@6_19
doplasma::@6_19: scope:[doplasma] from doplasma::@6_18
[80] (byte~) doplasma::$65 ← *((const byte[$28]) doplasma::xbuf#0 + (byte) doplasma::i2#4) + *((const byte[$19]) doplasma::ybuf#0+(byte/signed byte/word/signed word/dword/signed dword) $13)
[81] *((const byte*) SCREEN1#0+(byte/signed byte/word/signed word/dword/signed dword) $13*(byte/signed byte/word/signed word/dword/signed dword) $28 + (byte) doplasma::i2#4) ← (byte~) doplasma::$65
to:doplasma::@6_20
doplasma::@6_20: scope:[doplasma] from doplasma::@6_19
[82] (byte~) doplasma::$68 ← *((const byte[$28]) doplasma::xbuf#0 + (byte) doplasma::i2#4) + *((const byte[$19]) doplasma::ybuf#0+(byte/signed byte/word/signed word/dword/signed dword) $14)
[83] *((const byte*) SCREEN1#0+(byte/signed byte/word/signed word/dword/signed dword) $14*(byte/signed byte/word/signed word/dword/signed dword) $28 + (byte) doplasma::i2#4) ← (byte~) doplasma::$68
to:doplasma::@6_21
doplasma::@6_21: scope:[doplasma] from doplasma::@6_20
[84] (byte~) doplasma::$71 ← *((const byte[$28]) doplasma::xbuf#0 + (byte) doplasma::i2#4) + *((const byte[$19]) doplasma::ybuf#0+(byte/signed byte/word/signed word/dword/signed dword) $15)
[85] *((const byte*) SCREEN1#0+(byte/signed byte/word/signed word/dword/signed dword) $15*(byte/signed byte/word/signed word/dword/signed dword) $28 + (byte) doplasma::i2#4) ← (byte~) doplasma::$71
to:doplasma::@6_22
doplasma::@6_22: scope:[doplasma] from doplasma::@6_21
[86] (byte~) doplasma::$74 ← *((const byte[$28]) doplasma::xbuf#0 + (byte) doplasma::i2#4) + *((const byte[$19]) doplasma::ybuf#0+(byte/signed byte/word/signed word/dword/signed dword) $16)
[87] *((const byte*) SCREEN1#0+(byte/signed byte/word/signed word/dword/signed dword) $16*(byte/signed byte/word/signed word/dword/signed dword) $28 + (byte) doplasma::i2#4) ← (byte~) doplasma::$74
to:doplasma::@6_23
doplasma::@6_23: scope:[doplasma] from doplasma::@6_22
[88] (byte~) doplasma::$77 ← *((const byte[$28]) doplasma::xbuf#0 + (byte) doplasma::i2#4) + *((const byte[$19]) doplasma::ybuf#0+(byte/signed byte/word/signed word/dword/signed dword) $17)
[89] *((const byte*) SCREEN1#0+(byte/signed byte/word/signed word/dword/signed dword) $17*(byte/signed byte/word/signed word/dword/signed dword) $28 + (byte) doplasma::i2#4) ← (byte~) doplasma::$77
to:doplasma::@6_24
doplasma::@6_24: scope:[doplasma] from doplasma::@6_23
[90] (byte~) doplasma::$80 ← *((const byte[$28]) doplasma::xbuf#0 + (byte) doplasma::i2#4) + *((const byte[$19]) doplasma::ybuf#0+(byte/signed byte/word/signed word/dword/signed dword) $18)
[91] *((const byte*) SCREEN1#0+(byte/signed byte/word/signed word/dword/signed dword) $18*(byte/signed byte/word/signed word/dword/signed dword) $28 + (byte) doplasma::i2#4) ← (byte~) doplasma::$80
to:doplasma::@7
doplasma::@7: scope:[doplasma] from doplasma::@6_24
[92] (byte) doplasma::i2#1 ← ++ (byte) doplasma::i2#4
[93] if((byte) doplasma::i2#1<(byte/signed byte/word/signed word/dword/signed dword) $28) goto doplasma::@5
to:doplasma::@return
doplasma::@return: scope:[doplasma] from doplasma::@7
[94] return
to:@return
makecharset: scope:[makecharset] from main::@2
[95] phi()
[96] call sid_rnd_init
to:makecharset::@10
makecharset::@10: scope:[makecharset] from makecharset
[97] phi()
[98] call print_cls
to:makecharset::@1
makecharset::@1: scope:[makecharset] from makecharset::@10 makecharset::@9
[99] (byte*) print_char_cursor#45 ← phi( makecharset::@10/(const byte*) print_line_cursor#0 makecharset::@9/(byte*) print_char_cursor#18 )
[99] (word) makecharset::c#2 ← phi( makecharset::@10/(byte/signed byte/word/signed word/dword/signed dword) 0 makecharset::@9/(word) makecharset::c#1 )
[100] (byte~) makecharset::$2 ← < (word) makecharset::c#2
[101] (byte) makecharset::s#0 ← *((const byte*) SINTABLE#0 + (byte~) makecharset::$2)
to:makecharset::@2
makecharset::@2: scope:[makecharset] from makecharset::@1 makecharset::@6
[102] (byte) makecharset::i#7 ← phi( makecharset::@1/(byte/signed byte/word/signed word/dword/signed dword) 0 makecharset::@6/(byte) makecharset::i#1 )
to:makecharset::@3
makecharset::@3: scope:[makecharset] from makecharset::@2 makecharset::@4
[103] (byte) makecharset::b#2 ← phi( makecharset::@2/(byte/signed byte/word/signed word/dword/signed dword) 0 makecharset::@4/(byte) makecharset::b#3 )
[103] (byte) makecharset::ii#2 ← phi( makecharset::@2/(byte/signed byte/word/signed word/dword/signed dword) 0 makecharset::@4/(byte) makecharset::ii#1 )
[104] call sid_rnd
[105] (byte) sid_rnd::return#2 ← (byte) sid_rnd::return#0
to:makecharset::@11
makecharset::@11: scope:[makecharset] from makecharset::@3
[106] (byte~) makecharset::$3 ← (byte) sid_rnd::return#2
[107] (byte~) makecharset::$4 ← (byte~) makecharset::$3 & (byte/word/signed word/dword/signed dword) $ff
[108] if((byte~) makecharset::$4<=(byte) makecharset::s#0) goto makecharset::@4
to:makecharset::@5
makecharset::@5: scope:[makecharset] from makecharset::@11
[109] (byte) makecharset::b#1 ← (byte) makecharset::b#2 | *((const byte[8]) makecharset::bittab#0 + (byte) makecharset::ii#2)
to:makecharset::@4
makecharset::@4: scope:[makecharset] from makecharset::@11 makecharset::@5
[110] (byte) makecharset::b#3 ← phi( makecharset::@11/(byte) makecharset::b#2 makecharset::@5/(byte) makecharset::b#1 )
[111] (byte) makecharset::ii#1 ← ++ (byte) makecharset::ii#2
[112] if((byte) makecharset::ii#1<(byte/signed byte/word/signed word/dword/signed dword) 8) goto makecharset::@3
to:makecharset::@6
makecharset::@6: scope:[makecharset] from makecharset::@4
[113] (word~) makecharset::$8 ← (word) makecharset::c#2 << (byte/signed byte/word/signed word/dword/signed dword) 3
[114] (word~) makecharset::$9 ← (word~) makecharset::$8 + (byte) makecharset::i#7
[115] *((const byte*) CHARSET#0 + (word~) makecharset::$9) ← (byte) makecharset::b#3
[116] (byte) makecharset::i#1 ← ++ (byte) makecharset::i#7
[117] if((byte) makecharset::i#1<(byte/signed byte/word/signed word/dword/signed dword) 8) goto makecharset::@2
to:makecharset::@7
makecharset::@7: scope:[makecharset] from makecharset::@6
[118] (byte/word~) makecharset::$11 ← (word) makecharset::c#2 & (byte/signed byte/word/signed word/dword/signed dword) 7
[119] if((byte/word~) makecharset::$11!=(byte/signed byte/word/signed word/dword/signed dword) 0) goto makecharset::@9
to:makecharset::@8
makecharset::@8: scope:[makecharset] from makecharset::@7
[120] phi()
[121] call print_char
to:makecharset::@9
makecharset::@9: scope:[makecharset] from makecharset::@7 makecharset::@8
[122] (byte*) print_char_cursor#18 ← phi( makecharset::@8/(byte*) print_char_cursor#1 makecharset::@7/(byte*) print_char_cursor#45 )
[123] (word) makecharset::c#1 ← ++ (word) makecharset::c#2
[124] if((word) makecharset::c#1<(word/signed word/dword/signed dword) $100) goto makecharset::@1
to:makecharset::@return
makecharset::@return: scope:[makecharset] from makecharset::@9
[125] return
to:@return
print_char: scope:[print_char] from makecharset::@8
[126] *((byte*) print_char_cursor#45) ← (const byte) print_char::ch#0
[127] (byte*) print_char_cursor#1 ← ++ (byte*) print_char_cursor#45
to:print_char::@return
print_char::@return: scope:[print_char] from print_char
[128] return
to:@return
sid_rnd: scope:[sid_rnd] from makecharset::@3
[129] (byte) sid_rnd::return#0 ← *((const byte*) SID_VOICE3_OSC#0)
to:sid_rnd::@return
sid_rnd::@return: scope:[sid_rnd] from sid_rnd
[130] return
to:@return
print_cls: scope:[print_cls] from makecharset::@10
[131] phi()
to:print_cls::@1
print_cls::@1: scope:[print_cls] from print_cls print_cls::@1
[132] (byte*) print_cls::sc#2 ← phi( print_cls/(const byte*) print_line_cursor#0 print_cls::@1/(byte*) print_cls::sc#1 )
[133] *((byte*) print_cls::sc#2) ← (byte) ' '
[134] (byte*) print_cls::sc#1 ← ++ (byte*) print_cls::sc#2
[135] if((byte*) print_cls::sc#1!=(const byte*) print_line_cursor#0+(word/signed word/dword/signed dword) $3e8) goto print_cls::@1
to:print_cls::@return
print_cls::@return: scope:[print_cls] from print_cls::@1
[136] return
to:@return
sid_rnd_init: scope:[sid_rnd_init] from makecharset
[137] *((const word*) SID_VOICE3_FREQ#0) ← (word/dword/signed dword) $ffff
[138] *((const byte*) SID_VOICE3_CONTROL#0) ← (const byte) SID_CONTROL_NOISE#0
to:sid_rnd_init::@return
sid_rnd_init::@return: scope:[sid_rnd_init] from sid_rnd_init
[139] return
to:@return

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,346 @@
(label) @1
(label) @2
(label) @begin
(label) @end
(byte*) BGCOL
(const byte*) BGCOL#0 BGCOL = ((byte*))(word/dword/signed dword) $d021
(byte*) BGCOL1
(byte*) BGCOL2
(byte*) BGCOL3
(byte*) BGCOL4
(byte) BLACK
(const byte) BLACK#0 BLACK = (byte/signed byte/word/signed word/dword/signed dword) 0
(byte) BLUE
(const byte) BLUE#0 BLUE = (byte/signed byte/word/signed word/dword/signed dword) 6
(byte*) BORDERCOL
(const byte*) BORDERCOL#0 BORDERCOL = ((byte*))(word/dword/signed dword) $d020
(byte) BROWN
(byte*) CHARGEN
(byte*) CHARSET
(const byte*) CHARSET#0 CHARSET = ((byte*))(word/signed word/dword/signed dword) $2000
(byte*) CIA1_INTERRUPT
(byte*) CIA1_PORT_A
(byte*) CIA1_PORT_A_DDR
(byte*) CIA1_PORT_B
(byte*) CIA1_PORT_B_DDR
(byte*) CIA2_INTERRUPT
(byte*) CIA2_PORT_A
(byte*) CIA2_PORT_A_DDR
(byte*) CIA2_PORT_B
(byte*) CIA2_PORT_B_DDR
(byte) CIA_INTERRUPT_CLEAR
(byte*) COLS
(const byte*) COLS#0 COLS = ((byte*))(word/dword/signed dword) $d800
(byte) CYAN
(byte*) D011
(byte*) D016
(byte*) D018
(const byte*) D018#0 D018 = ((byte*))(word/dword/signed dword) $d018
(byte) DARK_GREY
(byte) GREEN
(byte) GREY
(void()**) HARDWARE_IRQ
(byte) IRQ_COLLISION_BG
(byte) IRQ_COLLISION_SPRITE
(byte*) IRQ_ENABLE
(byte) IRQ_LIGHTPEN
(byte) IRQ_RASTER
(byte*) IRQ_STATUS
(void()**) KERNEL_IRQ
(byte*) LIGHTPEN_X
(byte*) LIGHTPEN_Y
(byte) LIGHT_BLUE
(byte) LIGHT_GREEN
(byte) LIGHT_GREY
(byte) ORANGE
(byte) PINK
(byte*) PROCPORT
(byte) PROCPORT_BASIC_KERNEL_IO
(byte*) PROCPORT_DDR
(byte) PROCPORT_DDR_MEMORY_MASK
(byte) PROCPORT_KERNEL_IO
(byte) PROCPORT_RAM_ALL
(byte) PROCPORT_RAM_CHARROM
(byte) PROCPORT_RAM_IO
(byte) PURPLE
(byte*) RASTER
(byte) RED
(byte*) SCREEN1
(const byte*) SCREEN1#0 SCREEN1 = ((byte*))(word/signed word/dword/signed dword) $2800
(byte) SID_CONTROL_GATE
(byte) SID_CONTROL_NOISE
(const byte) SID_CONTROL_NOISE#0 SID_CONTROL_NOISE = (byte/word/signed word/dword/signed dword) $80
(byte) SID_CONTROL_PULSE
(byte) SID_CONTROL_RING
(byte) SID_CONTROL_SAWTOOTH
(byte) SID_CONTROL_SYNC
(byte) SID_CONTROL_TEST
(byte) SID_CONTROL_TRIANGLE
(byte*) SID_VOICE3_CONTROL
(const byte*) SID_VOICE3_CONTROL#0 SID_VOICE3_CONTROL = ((byte*))(word/dword/signed dword) $d412
(word*) SID_VOICE3_FREQ
(const word*) SID_VOICE3_FREQ#0 SID_VOICE3_FREQ = ((word*))(word/dword/signed dword) $d40e
(byte*) SID_VOICE3_FREQ_HIGH
(byte*) SID_VOICE3_FREQ_LOW
(byte*) SID_VOICE3_OSC
(const byte*) SID_VOICE3_OSC#0 SID_VOICE3_OSC = ((byte*))(word/dword/signed dword) $d41b
(byte*) SINTABLE
(const byte*) SINTABLE#0 SINTABLE = ((byte*))(word/signed word/dword/signed dword) $1f00
(byte*) SPRITES_COLS
(byte*) SPRITES_ENABLE
(byte*) SPRITES_EXPAND_X
(byte*) SPRITES_EXPAND_Y
(byte*) SPRITES_MC
(byte*) SPRITES_MC1
(byte*) SPRITES_MC2
(byte*) SPRITES_PRIORITY
(byte*) SPRITES_XMSB
(byte*) SPRITES_XPOS
(byte*) SPRITES_YPOS
(word) SPRITE_PTRS
(byte) VIC_BMM
(byte*) VIC_CONTROL
(byte*) VIC_CONTROL2
(byte) VIC_CSEL
(byte) VIC_DEN
(byte) VIC_ECM
(byte) VIC_MCM
(byte*) VIC_MEMORY
(byte) VIC_RSEL
(byte) VIC_RST8
(byte) WHITE
(byte) YELLOW
(byte) c1A
(byte) c1A#1 c1A zp ZP_BYTE:4 1.3636363636363638
(byte) c1A#3 c1A zp ZP_BYTE:4 0.1911764705882353
(byte) c1B
(byte) c1B#1 c1B zp ZP_BYTE:5 1.25
(byte) c1B#3 c1B zp ZP_BYTE:5 0.19402985074626866
(byte) c2A
(byte) c2A#1 c2A zp ZP_BYTE:6 0.6818181818181819
(byte) c2A#3 c2A zp ZP_BYTE:6 0.22807017543859648
(byte) c2B
(byte) c2B#1 c2B zp ZP_BYTE:7 0.6521739130434783
(byte) c2B#3 c2B zp ZP_BYTE:7 0.23214285714285715
(void()) doplasma((byte*) doplasma::screen)
(byte~) doplasma::$0 reg byte a 202.0
(byte~) doplasma::$11 reg byte a 202.0
(byte~) doplasma::$14 reg byte a 202.0
(byte~) doplasma::$17 reg byte a 202.0
(byte~) doplasma::$2 reg byte a 202.0
(byte~) doplasma::$20 reg byte a 202.0
(byte~) doplasma::$23 reg byte a 202.0
(byte~) doplasma::$26 reg byte a 202.0
(byte~) doplasma::$29 reg byte a 202.0
(byte~) doplasma::$32 reg byte a 202.0
(byte~) doplasma::$35 reg byte a 202.0
(byte~) doplasma::$38 reg byte a 202.0
(byte~) doplasma::$41 reg byte a 202.0
(byte~) doplasma::$44 reg byte a 202.0
(byte~) doplasma::$47 reg byte a 202.0
(byte~) doplasma::$50 reg byte a 202.0
(byte~) doplasma::$53 reg byte a 202.0
(byte~) doplasma::$56 reg byte a 202.0
(byte~) doplasma::$59 reg byte a 202.0
(byte~) doplasma::$6 reg byte a 202.0
(byte~) doplasma::$62 reg byte a 202.0
(byte~) doplasma::$65 reg byte a 202.0
(byte~) doplasma::$68 reg byte a 202.0
(byte~) doplasma::$71 reg byte a 202.0
(byte~) doplasma::$74 reg byte a 202.0
(byte~) doplasma::$77 reg byte a 202.0
(byte~) doplasma::$80 reg byte a 202.0
(label) doplasma::@1
(label) doplasma::@2
(label) doplasma::@3
(label) doplasma::@4
(label) doplasma::@5
(label) doplasma::@6
(label) doplasma::@6_1
(label) doplasma::@6_10
(label) doplasma::@6_11
(label) doplasma::@6_12
(label) doplasma::@6_13
(label) doplasma::@6_14
(label) doplasma::@6_15
(label) doplasma::@6_16
(label) doplasma::@6_17
(label) doplasma::@6_18
(label) doplasma::@6_19
(label) doplasma::@6_2
(label) doplasma::@6_20
(label) doplasma::@6_21
(label) doplasma::@6_22
(label) doplasma::@6_23
(label) doplasma::@6_24
(label) doplasma::@6_3
(label) doplasma::@6_4
(label) doplasma::@6_5
(label) doplasma::@6_6
(label) doplasma::@6_7
(label) doplasma::@6_8
(label) doplasma::@6_9
(label) doplasma::@7
(label) doplasma::@return
(byte) doplasma::c1a
(byte) doplasma::c1a#0 c1a zp ZP_BYTE:8 2.0
(byte) doplasma::c1a#1 c1a zp ZP_BYTE:8 50.5
(byte) doplasma::c1a#2 c1a zp ZP_BYTE:8 101.66666666666666
(byte) doplasma::c1b
(byte) doplasma::c1b#0 c1b zp ZP_BYTE:9 4.0
(byte) doplasma::c1b#1 c1b zp ZP_BYTE:9 67.33333333333333
(byte) doplasma::c1b#2 c1b zp ZP_BYTE:9 76.25
(byte) doplasma::c2a
(byte) doplasma::c2a#0 c2a zp ZP_BYTE:8 2.0
(byte) doplasma::c2a#1 c2a zp ZP_BYTE:8 50.5
(byte) doplasma::c2a#2 c2a zp ZP_BYTE:8 101.66666666666666
(byte) doplasma::c2b
(byte) doplasma::c2b#0 c2b zp ZP_BYTE:9 4.0
(byte) doplasma::c2b#1 c2b zp ZP_BYTE:9 67.33333333333333
(byte) doplasma::c2b#2 c2b zp ZP_BYTE:9 76.25
(byte) doplasma::i
(byte) doplasma::i#1 i zp ZP_BYTE:10 151.5
(byte) doplasma::i#2 i zp ZP_BYTE:10 60.599999999999994
(byte) doplasma::i1
(byte) doplasma::i1#1 i1 zp ZP_BYTE:10 151.5
(byte) doplasma::i1#2 i1 zp ZP_BYTE:10 60.599999999999994
(byte) doplasma::i2
(byte) doplasma::i2#1 reg byte x 151.5
(byte) doplasma::i2#4 reg byte x 102.98039215686288
(byte) doplasma::ii
(byte*) doplasma::screen
(byte[$28]) doplasma::xbuf
(const byte[$28]) doplasma::xbuf#0 xbuf = { fill( $28, 0) }
(byte[$19]) doplasma::ybuf
(const byte[$19]) doplasma::ybuf#0 ybuf = { fill( $19, 0) }
(void()) main()
(label) main::@1
(label) main::@2
(label) main::@3
(label) main::@4
(label) main::@5
(byte*) main::col
(byte*) main::col#1 col zp ZP_WORD:2 16.5
(byte*) main::col#2 col zp ZP_WORD:2 16.5
(label) main::toD0181
(word~) main::toD0181_$0
(word~) main::toD0181_$1
(word~) main::toD0181_$2
(byte~) main::toD0181_$3
(word~) main::toD0181_$4
(byte~) main::toD0181_$5
(byte~) main::toD0181_$6
(byte~) main::toD0181_$7
(byte~) main::toD0181_$8
(byte*) main::toD0181_gfx
(byte) main::toD0181_return
(const byte) main::toD0181_return#0 toD0181_return = >((word))(const byte*) SCREEN1#0&(word/signed word/dword/signed dword) $3fff<<(byte/signed byte/word/signed word/dword/signed dword) 2|>((word))(const byte*) CHARSET#0>>(byte/signed byte/word/signed word/dword/signed dword) 2&(byte/signed byte/word/signed word/dword/signed dword) $f
(byte*) main::toD0181_screen
(void()) makecharset((byte*) makecharset::charset)
(byte/word~) makecharset::$11 reg byte a 22.0
(byte~) makecharset::$2 reg byte a 22.0
(byte~) makecharset::$3 reg byte a 2002.0
(byte~) makecharset::$4 $4 zp ZP_BYTE:6 2002.0
(word~) makecharset::$8 $8 zp ZP_WORD:13 202.0
(word~) makecharset::$9 $9 zp ZP_WORD:13 202.0
(label) makecharset::@1
(label) makecharset::@10
(label) makecharset::@11
(label) makecharset::@2
(label) makecharset::@3
(label) makecharset::@4
(label) makecharset::@5
(label) makecharset::@6
(label) makecharset::@7
(label) makecharset::@8
(label) makecharset::@9
(label) makecharset::@return
(byte) makecharset::b
(byte) makecharset::b#1 reg byte y 2002.0
(byte) makecharset::b#2 reg byte y 500.5
(byte) makecharset::b#3 reg byte y 620.8
(byte[8]) makecharset::bittab
(const byte[8]) makecharset::bittab#0 bittab = { (byte/signed byte/word/signed word/dword/signed dword) 1, (byte/signed byte/word/signed word/dword/signed dword) 2, (byte/signed byte/word/signed word/dword/signed dword) 4, (byte/signed byte/word/signed word/dword/signed dword) 8, (byte/signed byte/word/signed word/dword/signed dword) $10, (byte/signed byte/word/signed word/dword/signed dword) $20, (byte/signed byte/word/signed word/dword/signed dword) $40, (byte/word/signed word/dword/signed dword) $80 }
(word) makecharset::c
(word) makecharset::c#1 c zp ZP_WORD:2 16.5
(word) makecharset::c#2 c zp ZP_WORD:2 6.041666666666666
(byte*) makecharset::charset
(byte) makecharset::i
(byte) makecharset::i#1 i zp ZP_BYTE:4 151.5
(byte) makecharset::i#7 i zp ZP_BYTE:4 21.642857142857142
(byte) makecharset::ii
(byte) makecharset::ii#1 reg byte x 1501.5
(byte) makecharset::ii#2 reg byte x 375.375
(byte) makecharset::s
(byte) makecharset::s#0 s zp ZP_BYTE:5 59.529411764705884
(void()) print_char((byte) print_char::ch)
(label) print_char::@return
(byte) print_char::ch
(const byte) print_char::ch#0 ch = (byte) '.'
(byte*) print_char_cursor
(byte*) print_char_cursor#1 print_char_cursor zp ZP_WORD:11 4.333333333333333
(byte*) print_char_cursor#18 print_char_cursor zp ZP_WORD:11 11.0
(byte*) print_char_cursor#45 print_char_cursor zp ZP_WORD:11 1.1304347826086956
(void()) print_cls()
(label) print_cls::@1
(label) print_cls::@return
(byte*) print_cls::sc
(byte*) print_cls::sc#1 sc zp ZP_WORD:2 16.5
(byte*) print_cls::sc#2 sc zp ZP_WORD:2 16.5
(byte[]) print_hextab
(byte*) print_line_cursor
(const byte*) print_line_cursor#0 print_line_cursor = ((byte*))(word/signed word/dword/signed dword) $400
(byte*) print_screen
(byte()) sid_rnd()
(label) sid_rnd::@return
(byte) sid_rnd::return
(byte) sid_rnd::return#0 reg byte a 334.33333333333337
(byte) sid_rnd::return#2 reg byte a 2002.0
(void()) sid_rnd_init()
(label) sid_rnd_init::@return
zp ZP_WORD:2 [ main::col#2 main::col#1 makecharset::c#2 makecharset::c#1 print_cls::sc#2 print_cls::sc#1 ]
zp ZP_BYTE:4 [ c1A#1 c1A#3 makecharset::i#7 makecharset::i#1 ]
zp ZP_BYTE:5 [ c1B#1 c1B#3 makecharset::s#0 ]
zp ZP_BYTE:6 [ c2A#1 c2A#3 makecharset::$4 ]
zp ZP_BYTE:7 [ c2B#1 c2B#3 ]
zp ZP_BYTE:8 [ doplasma::c1a#2 doplasma::c1a#0 doplasma::c1a#1 doplasma::c2a#2 doplasma::c2a#0 doplasma::c2a#1 ]
zp ZP_BYTE:9 [ doplasma::c1b#2 doplasma::c1b#0 doplasma::c1b#1 doplasma::c2b#2 doplasma::c2b#0 doplasma::c2b#1 ]
zp ZP_BYTE:10 [ doplasma::i#2 doplasma::i#1 doplasma::i1#2 doplasma::i1#1 ]
reg byte x [ doplasma::i2#4 doplasma::i2#1 ]
zp ZP_WORD:11 [ print_char_cursor#45 print_char_cursor#18 print_char_cursor#1 ]
reg byte x [ makecharset::ii#2 makecharset::ii#1 ]
reg byte y [ makecharset::b#2 makecharset::b#3 makecharset::b#1 ]
reg byte a [ doplasma::$0 ]
reg byte a [ doplasma::$2 ]
reg byte a [ doplasma::$6 ]
reg byte a [ doplasma::$11 ]
reg byte a [ doplasma::$14 ]
reg byte a [ doplasma::$17 ]
reg byte a [ doplasma::$20 ]
reg byte a [ doplasma::$23 ]
reg byte a [ doplasma::$26 ]
reg byte a [ doplasma::$29 ]
reg byte a [ doplasma::$32 ]
reg byte a [ doplasma::$35 ]
reg byte a [ doplasma::$38 ]
reg byte a [ doplasma::$41 ]
reg byte a [ doplasma::$44 ]
reg byte a [ doplasma::$47 ]
reg byte a [ doplasma::$50 ]
reg byte a [ doplasma::$53 ]
reg byte a [ doplasma::$56 ]
reg byte a [ doplasma::$59 ]
reg byte a [ doplasma::$62 ]
reg byte a [ doplasma::$65 ]
reg byte a [ doplasma::$68 ]
reg byte a [ doplasma::$71 ]
reg byte a [ doplasma::$74 ]
reg byte a [ doplasma::$77 ]
reg byte a [ doplasma::$80 ]
reg byte a [ makecharset::$2 ]
reg byte a [ sid_rnd::return#2 ]
reg byte a [ makecharset::$3 ]
zp ZP_WORD:13 [ makecharset::$8 makecharset::$9 ]
reg byte a [ makecharset::$11 ]
reg byte a [ sid_rnd::return#0 ]

51
src/test/ref/plus-0.asm Normal file
View File

@ -0,0 +1,51 @@
// Tests elimination of plus 0
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
main: {
ldx #'a'
lda #<$400
sta fill.screen
lda #>$400
sta fill.screen+1
jsr fill
ldx #'b'
lda #<$2000
sta fill.screen
lda #>$2000
sta fill.screen+1
jsr fill
rts
}
// fill(byte* zeropage(2) screen, byte register(X) ch)
fill: {
.label screen = 2
.label _5 = 4
.label _7 = 4
ldy #0
b2:
txa
sta (screen),y
lda #1*$28
clc
adc screen
sta _5
lda #0
adc screen+1
sta _5+1
txa
sta (_5),y
lda #2*$28
clc
adc screen
sta _7
lda #0
adc screen+1
sta _7+1
txa
sta (_7),y
iny
cpy #$28
bne b2
rts
}

45
src/test/ref/plus-0.cfg Normal file
View File

@ -0,0 +1,45 @@
@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()
[5] call fill
to:main::@1
main::@1: scope:[main] from main
[6] phi()
[7] call fill
to:main::@return
main::@return: scope:[main] from main::@1
[8] return
to:@return
fill: scope:[fill] from main main::@1
[9] (byte) fill::ch#4 ← phi( main/(byte) 'a' main::@1/(byte) 'b' )
[9] (byte*) fill::screen#4 ← phi( main/((byte*))(word/signed word/dword/signed dword) $400 main::@1/((byte*))(word/signed word/dword/signed dword) $2000 )
to:fill::@1
fill::@1: scope:[fill] from fill fill::@3
[10] (byte) fill::i#4 ← phi( fill/(byte/signed byte/word/signed word/dword/signed dword) 0 fill::@3/(byte) fill::i#1 )
to:fill::@2
fill::@2: scope:[fill] from fill::@1
[11] *((byte*) fill::screen#4 + (byte) fill::i#4) ← (byte) fill::ch#4
to:fill::@2_1
fill::@2_1: scope:[fill] from fill::@2
[12] (byte*~) fill::$5 ← (byte*) fill::screen#4 + (byte/signed byte/word/signed word/dword/signed dword) 1*(byte/signed byte/word/signed word/dword/signed dword) $28
[13] *((byte*~) fill::$5 + (byte) fill::i#4) ← (byte) fill::ch#4
to:fill::@2_2
fill::@2_2: scope:[fill] from fill::@2_1
[14] (byte*~) fill::$7 ← (byte*) fill::screen#4 + (byte/signed byte/word/signed word/dword/signed dword) 2*(byte/signed byte/word/signed word/dword/signed dword) $28
[15] *((byte*~) fill::$7 + (byte) fill::i#4) ← (byte) fill::ch#4
to:fill::@3
fill::@3: scope:[fill] from fill::@2_2
[16] (byte) fill::i#1 ← ++ (byte) fill::i#4
[17] if((byte) fill::i#1!=(byte/signed byte/word/signed word/dword/signed dword) $28) goto fill::@1
to:fill::@return
fill::@return: scope:[fill] from fill::@3
[18] return
to:@return

765
src/test/ref/plus-0.log Normal file
View File

@ -0,0 +1,765 @@
CONTROL FLOW GRAPH SSA
@begin: scope:[] from
to:@2
main: scope:[main] from @2
(byte*~) main::$0 ← ((byte*)) (word/signed word/dword/signed dword) $400
(byte*) fill::screen#0 ← (byte*~) main::$0
(byte) fill::ch#0 ← (byte) 'a'
call fill
to:main::@1
main::@1: scope:[main] from main
(byte*~) main::$2 ← ((byte*)) (word/signed word/dword/signed dword) $2000
(byte*) fill::screen#1 ← (byte*~) main::$2
(byte) fill::ch#1 ← (byte) 'b'
call fill
to:main::@2
main::@2: scope:[main] from main::@1
to:main::@return
main::@return: scope:[main] from main::@2
return
to:@return
fill: scope:[fill] from main main::@1
(byte) fill::ch#4 ← phi( main/(byte) fill::ch#0 main::@1/(byte) fill::ch#1 )
(byte*) fill::screen#4 ← phi( main/(byte*) fill::screen#0 main::@1/(byte*) fill::screen#1 )
(byte) fill::i#0 ← (byte/signed byte/word/signed word/dword/signed dword) 0
to:fill::@1
fill::@1: scope:[fill] from fill fill::@3
(byte) fill::i#4 ← phi( fill/(byte) fill::i#0 fill::@3/(byte) fill::i#1 )
(byte) fill::ch#3 ← phi( fill/(byte) fill::ch#4 fill::@3/(byte) fill::ch#5 )
(byte*) fill::screen#3 ← phi( fill/(byte*) fill::screen#4 fill::@3/(byte*) fill::screen#5 )
(byte) fill::j#0 ← (byte/signed byte/word/signed word/dword/signed dword) 0
to:fill::@2
fill::@2: scope:[fill] from fill::@1 fill::@2
(byte) fill::i#2 ← phi( fill::@1/(byte) fill::i#4 fill::@2/(byte) fill::i#2 )
(byte) fill::ch#2 ← phi( fill::@1/(byte) fill::ch#3 fill::@2/(byte) fill::ch#2 )
(byte*) fill::screen#2 ← phi( fill::@1/(byte*) fill::screen#3 fill::@2/(byte*) fill::screen#2 )
(byte) fill::j#2 ← phi( fill::@1/(byte) fill::j#0 fill::@2/(byte) fill::j#1 )
(byte/signed word/word/dword/signed dword~) fill::$0 ← (byte) fill::j#2 * (byte/signed byte/word/signed word/dword/signed dword) $28
(byte*~) fill::$1 ← (byte*) fill::screen#2 + (byte/signed word/word/dword/signed dword~) fill::$0
*((byte*~) fill::$1 + (byte) fill::i#2) ← (byte) fill::ch#2
(byte) fill::j#1 ← (byte) fill::j#2 + rangenext(0,2)
(bool~) fill::$2 ← (byte) fill::j#1 != rangelast(0,2)
unroll if((bool~) fill::$2) goto fill::@2
to:fill::@3
fill::@3: scope:[fill] from fill::@2
(byte) fill::ch#5 ← phi( fill::@2/(byte) fill::ch#2 )
(byte*) fill::screen#5 ← phi( fill::@2/(byte*) fill::screen#2 )
(byte) fill::i#3 ← phi( fill::@2/(byte) fill::i#2 )
(byte) fill::i#1 ← (byte) fill::i#3 + rangenext(0,$27)
(bool~) fill::$3 ← (byte) fill::i#1 != rangelast(0,$27)
if((bool~) fill::$3) goto fill::@1
to:fill::@return
fill::@return: scope:[fill] from fill::@3
return
to:@return
@2: scope:[] from @begin
call main
to:@3
@3: scope:[] from @2
to:@end
@end: scope:[] from @3
SYMBOL TABLE SSA
(label) @2
(label) @3
(label) @begin
(label) @end
(void()) fill((byte*) fill::screen , (byte) fill::ch)
(byte/signed word/word/dword/signed dword~) fill::$0
(byte*~) fill::$1
(bool~) fill::$2
(bool~) fill::$3
(label) fill::@1
(label) fill::@2
(label) fill::@3
(label) fill::@return
(byte) fill::ch
(byte) fill::ch#0
(byte) fill::ch#1
(byte) fill::ch#2
(byte) fill::ch#3
(byte) fill::ch#4
(byte) fill::ch#5
(byte) fill::i
(byte) fill::i#0
(byte) fill::i#1
(byte) fill::i#2
(byte) fill::i#3
(byte) fill::i#4
(byte) fill::j
(byte) fill::j#0
(byte) fill::j#1
(byte) fill::j#2
(byte*) fill::screen
(byte*) fill::screen#0
(byte*) fill::screen#1
(byte*) fill::screen#2
(byte*) fill::screen#3
(byte*) fill::screen#4
(byte*) fill::screen#5
(void()) main()
(byte*~) main::$0
(byte*~) main::$2
(label) main::@1
(label) main::@2
(label) main::@return
Culled Empty Block (label) main::@2
Culled Empty Block (label) @3
Successful SSA optimization Pass2CullEmptyBlocks
Alias (byte*) fill::screen#0 = (byte*~) main::$0
Alias (byte*) fill::screen#1 = (byte*~) main::$2
Alias (byte) fill::i#2 = (byte) fill::i#3
Alias (byte*) fill::screen#2 = (byte*) fill::screen#5
Alias (byte) fill::ch#2 = (byte) fill::ch#5
Successful SSA optimization Pass2AliasElimination
Self Phi Eliminated (byte*) fill::screen#2
Self Phi Eliminated (byte) fill::ch#2
Self Phi Eliminated (byte) fill::i#2
Successful SSA optimization Pass2SelfPhiElimination
Redundant Phi (byte*) fill::screen#2 (byte*) fill::screen#3
Redundant Phi (byte) fill::ch#2 (byte) fill::ch#3
Redundant Phi (byte) fill::i#2 (byte) fill::i#4
Successful SSA optimization Pass2RedundantPhiElimination
Simple Condition (bool~) fill::$2 [19] unroll if((byte) fill::j#1!=rangelast(0,2)) goto fill::@2
Simple Condition (bool~) fill::$3 [23] if((byte) fill::i#1!=rangelast(0,$27)) goto fill::@1
Successful SSA optimization Pass2ConditionalJumpSimplification
Constant (const byte*) fill::screen#0 = ((byte*))$400
Constant (const byte) fill::ch#0 = 'a'
Constant (const byte*) fill::screen#1 = ((byte*))$2000
Constant (const byte) fill::ch#1 = 'b'
Constant (const byte) fill::i#0 = 0
Constant (const byte) fill::j#0 = 0
Successful SSA optimization Pass2ConstantIdentification
Resolved ranged next value fill::j#1 ← ++ fill::j#2 to ++
Resolved ranged comparison value unroll if(fill::j#1!=rangelast(0,2)) goto fill::@2 to (byte/signed byte/word/signed word/dword/signed dword) 3
Resolved ranged next value fill::i#1 ← ++ fill::i#4 to ++
Resolved ranged comparison value if(fill::i#1!=rangelast(0,$27)) goto fill::@1 to (byte/signed byte/word/signed word/dword/signed dword) $28
Self Phi Eliminated (byte*) fill::screen#3
Self Phi Eliminated (byte) fill::ch#3
Successful SSA optimization Pass2SelfPhiElimination
Redundant Phi (byte*) fill::screen#3 (byte*) fill::screen#4
Redundant Phi (byte) fill::ch#3 (byte) fill::ch#4
Successful SSA optimization Pass2RedundantPhiElimination
Unrolling loop Loop head: fill::@2 tails: fill::@2 blocks: fill::@2
Successful SSA optimization Pass2LoopUnroll
Redundant Phi (byte) fill::j#2 (const byte) fill::j#0
Successful SSA optimization Pass2RedundantPhiElimination
Constant (const byte/signed word/word/dword/signed dword) fill::$0 = fill::j#0*$28
Constant (const byte) fill::j#1 = ++fill::j#0
Successful SSA optimization Pass2ConstantIdentification
Removed zero-constant in assignment fill::$1
if() condition always true - replacing block destination [7] if((const byte) fill::j#1!=(byte/signed byte/word/signed word/dword/signed dword) 3) goto fill::@2_1
Successful SSA optimization Pass2ConstantIfs
Successful SSA optimization PassNEliminateUnusedVars
Alias (byte*) fill::screen#4 = (byte*~) fill::$1
Successful SSA optimization Pass2AliasElimination
Unrolling loop Loop head: fill::@2_1 tails: fill::@2_1 blocks: fill::@2_1
Successful SSA optimization Pass2LoopUnroll
Redundant Phi (byte) fill::j#3 (const byte) fill::j#1
Successful SSA optimization Pass2RedundantPhiElimination
Constant (const byte/signed word/word/dword/signed dword) fill::$4 = fill::j#1*$28
Constant (const byte) fill::j#4 = ++fill::j#1
Successful SSA optimization Pass2ConstantIdentification
if() condition always true - replacing block destination [9] if((const byte) fill::j#4!=(byte/signed byte/word/signed word/dword/signed dword) 3) goto fill::@2_2
Successful SSA optimization Pass2ConstantIfs
Unrolling loop Loop head: fill::@2_2 tails: fill::@2_2 blocks: fill::@2_2
Successful SSA optimization Pass2LoopUnroll
Redundant Phi (byte) fill::j#5 (const byte) fill::j#4
Successful SSA optimization Pass2RedundantPhiElimination
Constant (const byte/signed word/word/dword/signed dword) fill::$6 = fill::j#4*$28
Constant (const byte) fill::j#6 = ++fill::j#4
Successful SSA optimization Pass2ConstantIdentification
Removing PHI-reference to removed block (fill::@2_2) in block fill::@2_3
if() condition always false - eliminating [11] if((const byte) fill::j#6!=(byte/signed byte/word/signed word/dword/signed dword) 3) goto fill::@2_3
Successful SSA optimization Pass2ConstantIfs
Successful SSA optimization PassNEliminateUnusedVars
Eliminating variable (byte) fill::j#7 from unused block fill::@2_3
Eliminating variable (byte/signed word/word/dword/signed dword~) fill::$8 from unused block fill::@2_3
Eliminating variable (byte*~) fill::$9 from unused block fill::@2_3
Eliminating variable (byte) fill::j#8 from unused block fill::@2_3
Removing unused block fill::@2_3
Successful SSA optimization Pass2EliminateUnusedBlocks
Inlining constant with var siblings (const byte*) fill::screen#0
Inlining constant with var siblings (const byte) fill::ch#0
Inlining constant with var siblings (const byte*) fill::screen#1
Inlining constant with var siblings (const byte) fill::ch#1
Inlining constant with var siblings (const byte) fill::i#0
Inlining constant with different constant siblings (const byte) fill::j#0
Inlining constant with different constant siblings (const byte) fill::j#1
Inlining constant with different constant siblings (const byte) fill::j#4
Constant inlined fill::j#4 = ++++(byte/signed byte/word/signed word/dword/signed dword) 0
Constant inlined fill::ch#0 = (byte) 'a'
Constant inlined fill::screen#1 = ((byte*))(word/signed word/dword/signed dword) $2000
Constant inlined fill::screen#0 = ((byte*))(word/signed word/dword/signed dword) $400
Constant inlined fill::i#0 = (byte/signed byte/word/signed word/dword/signed dword) 0
Constant inlined fill::$6 = ++++(byte/signed byte/word/signed word/dword/signed dword) 0*(byte/signed byte/word/signed word/dword/signed dword) $28
Constant inlined fill::ch#1 = (byte) 'b'
Constant inlined fill::j#1 = ++(byte/signed byte/word/signed word/dword/signed dword) 0
Constant inlined fill::$4 = ++(byte/signed byte/word/signed word/dword/signed dword) 0*(byte/signed byte/word/signed word/dword/signed dword) $28
Constant inlined fill::j#0 = (byte/signed byte/word/signed word/dword/signed dword) 0
Successful SSA optimization Pass2ConstantInlining
Simplifying constant integer increment ++0
Simplifying constant integer increment ++0
Successful SSA optimization Pass2ConstantSimplification
Simplifying constant integer increment ++1
Successful SSA optimization Pass2ConstantSimplification
Added new block during phi lifting fill::@5(between fill::@3 and fill::@1)
Adding NOP phi() at start of @begin
Adding NOP phi() at start of @2
Adding NOP phi() at start of @end
Adding NOP phi() at start of main
Adding NOP phi() at start of main::@1
CALL GRAPH
Calls in [] to main:2
Calls in [main] to fill:5 fill:7
Created 3 initial phi equivalence classes
Coalesced [19] fill::i#5 ← fill::i#1
Coalesced down to 3 phi equivalence classes
Culled Empty Block (label) fill::@5
Renumbering block @2 to @1
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
Adding NOP phi() at start of main::@1
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()
[5] call fill
to:main::@1
main::@1: scope:[main] from main
[6] phi()
[7] call fill
to:main::@return
main::@return: scope:[main] from main::@1
[8] return
to:@return
fill: scope:[fill] from main main::@1
[9] (byte) fill::ch#4 ← phi( main/(byte) 'a' main::@1/(byte) 'b' )
[9] (byte*) fill::screen#4 ← phi( main/((byte*))(word/signed word/dword/signed dword) $400 main::@1/((byte*))(word/signed word/dword/signed dword) $2000 )
to:fill::@1
fill::@1: scope:[fill] from fill fill::@3
[10] (byte) fill::i#4 ← phi( fill/(byte/signed byte/word/signed word/dword/signed dword) 0 fill::@3/(byte) fill::i#1 )
to:fill::@2
fill::@2: scope:[fill] from fill::@1
[11] *((byte*) fill::screen#4 + (byte) fill::i#4) ← (byte) fill::ch#4
to:fill::@2_1
fill::@2_1: scope:[fill] from fill::@2
[12] (byte*~) fill::$5 ← (byte*) fill::screen#4 + (byte/signed byte/word/signed word/dword/signed dword) 1*(byte/signed byte/word/signed word/dword/signed dword) $28
[13] *((byte*~) fill::$5 + (byte) fill::i#4) ← (byte) fill::ch#4
to:fill::@2_2
fill::@2_2: scope:[fill] from fill::@2_1
[14] (byte*~) fill::$7 ← (byte*) fill::screen#4 + (byte/signed byte/word/signed word/dword/signed dword) 2*(byte/signed byte/word/signed word/dword/signed dword) $28
[15] *((byte*~) fill::$7 + (byte) fill::i#4) ← (byte) fill::ch#4
to:fill::@3
fill::@3: scope:[fill] from fill::@2_2
[16] (byte) fill::i#1 ← ++ (byte) fill::i#4
[17] if((byte) fill::i#1!=(byte/signed byte/word/signed word/dword/signed dword) $28) goto fill::@1
to:fill::@return
fill::@return: scope:[fill] from fill::@3
[18] return
to:@return
VARIABLE REGISTER WEIGHTS
(void()) fill((byte*) fill::screen , (byte) fill::ch)
(byte*~) fill::$5 22.0
(byte*~) fill::$7 22.0
(byte) fill::ch
(byte) fill::ch#4 3.666666666666667
(byte) fill::i
(byte) fill::i#1 16.5
(byte) fill::i#4 9.166666666666666
(byte) fill::j
(byte*) fill::screen
(byte*) fill::screen#4 3.666666666666667
(void()) main()
Initial phi equivalence classes
[ fill::screen#4 ]
[ fill::ch#4 ]
[ fill::i#4 fill::i#1 ]
Added variable fill::$5 to zero page equivalence class [ fill::$5 ]
Added variable fill::$7 to zero page equivalence class [ fill::$7 ]
Complete equivalence classes
[ fill::screen#4 ]
[ fill::ch#4 ]
[ fill::i#4 fill::i#1 ]
[ fill::$5 ]
[ fill::$7 ]
Allocated zp ZP_WORD:2 [ fill::screen#4 ]
Allocated zp ZP_BYTE:4 [ fill::ch#4 ]
Allocated zp ZP_BYTE:5 [ fill::i#4 fill::i#1 ]
Allocated zp ZP_WORD:6 [ fill::$5 ]
Allocated zp ZP_WORD:8 [ fill::$7 ]
INITIAL ASM
//SEG0 File Comments
// Tests elimination of plus 0
//SEG1 Basic Upstart
.pc = $801 "Basic"
:BasicUpstart(bbegin)
.pc = $80d "Program"
//SEG2 Global Constants & labels
//SEG3 @begin
bbegin:
//SEG4 [1] phi from @begin to @1 [phi:@begin->@1]
b1_from_bbegin:
jmp b1
//SEG5 @1
b1:
//SEG6 [2] call main
//SEG7 [4] phi from @1 to main [phi:@1->main]
main_from_b1:
jsr main
//SEG8 [3] phi from @1 to @end [phi:@1->@end]
bend_from_b1:
jmp bend
//SEG9 @end
bend:
//SEG10 main
main: {
//SEG11 [5] call fill
//SEG12 [9] phi from main to fill [phi:main->fill]
fill_from_main:
//SEG13 [9] phi (byte) fill::ch#4 = (byte) 'a' [phi:main->fill#0] -- vbuz1=vbuc1
lda #'a'
sta fill.ch
//SEG14 [9] phi (byte*) fill::screen#4 = ((byte*))(word/signed word/dword/signed dword) $400 [phi:main->fill#1] -- pbuz1=pbuc1
lda #<$400
sta fill.screen
lda #>$400
sta fill.screen+1
jsr fill
//SEG15 [6] phi from main to main::@1 [phi:main->main::@1]
b1_from_main:
jmp b1
//SEG16 main::@1
b1:
//SEG17 [7] call fill
//SEG18 [9] phi from main::@1 to fill [phi:main::@1->fill]
fill_from_b1:
//SEG19 [9] phi (byte) fill::ch#4 = (byte) 'b' [phi:main::@1->fill#0] -- vbuz1=vbuc1
lda #'b'
sta fill.ch
//SEG20 [9] phi (byte*) fill::screen#4 = ((byte*))(word/signed word/dword/signed dword) $2000 [phi:main::@1->fill#1] -- pbuz1=pbuc1
lda #<$2000
sta fill.screen
lda #>$2000
sta fill.screen+1
jsr fill
jmp breturn
//SEG21 main::@return
breturn:
//SEG22 [8] return
rts
}
//SEG23 fill
// fill(byte* zeropage(2) screen, byte zeropage(4) ch)
fill: {
.label i = 5
.label screen = 2
.label ch = 4
.label _5 = 6
.label _7 = 8
//SEG24 [10] phi from fill to fill::@1 [phi:fill->fill::@1]
b1_from_fill:
//SEG25 [10] phi (byte) fill::i#4 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:fill->fill::@1#0] -- vbuz1=vbuc1
lda #0
sta i
jmp b1
//SEG26 [10] phi from fill::@3 to fill::@1 [phi:fill::@3->fill::@1]
b1_from_b3:
//SEG27 [10] phi (byte) fill::i#4 = (byte) fill::i#1 [phi:fill::@3->fill::@1#0] -- register_copy
jmp b1
//SEG28 fill::@1
b1:
jmp b2
//SEG29 fill::@2
b2:
//SEG30 [11] *((byte*) fill::screen#4 + (byte) fill::i#4) ← (byte) fill::ch#4 -- pbuz1_derefidx_vbuz2=vbuz3
lda ch
ldy i
sta (screen),y
jmp b2_1
//SEG31 fill::@2_1
b2_1:
//SEG32 [12] (byte*~) fill::$5 ← (byte*) fill::screen#4 + (byte/signed byte/word/signed word/dword/signed dword) 1*(byte/signed byte/word/signed word/dword/signed dword) $28 -- pbuz1=pbuz2_plus_vbuc1
lda #1*$28
clc
adc screen
sta _5
lda #0
adc screen+1
sta _5+1
//SEG33 [13] *((byte*~) fill::$5 + (byte) fill::i#4) ← (byte) fill::ch#4 -- pbuz1_derefidx_vbuz2=vbuz3
lda ch
ldy i
sta (_5),y
jmp b2_2
//SEG34 fill::@2_2
b2_2:
//SEG35 [14] (byte*~) fill::$7 ← (byte*) fill::screen#4 + (byte/signed byte/word/signed word/dword/signed dword) 2*(byte/signed byte/word/signed word/dword/signed dword) $28 -- pbuz1=pbuz2_plus_vbuc1
lda #2*$28
clc
adc screen
sta _7
lda #0
adc screen+1
sta _7+1
//SEG36 [15] *((byte*~) fill::$7 + (byte) fill::i#4) ← (byte) fill::ch#4 -- pbuz1_derefidx_vbuz2=vbuz3
lda ch
ldy i
sta (_7),y
jmp b3
//SEG37 fill::@3
b3:
//SEG38 [16] (byte) fill::i#1 ← ++ (byte) fill::i#4 -- vbuz1=_inc_vbuz1
inc i
//SEG39 [17] if((byte) fill::i#1!=(byte/signed byte/word/signed word/dword/signed dword) $28) goto fill::@1 -- vbuz1_neq_vbuc1_then_la1
lda #$28
cmp i
bne b1_from_b3
jmp breturn
//SEG40 fill::@return
breturn:
//SEG41 [18] return
rts
}
REGISTER UPLIFT POTENTIAL REGISTERS
Statement [12] (byte*~) fill::$5 ← (byte*) fill::screen#4 + (byte/signed byte/word/signed word/dword/signed dword) 1*(byte/signed byte/word/signed word/dword/signed dword) $28 [ fill::screen#4 fill::ch#4 fill::i#4 fill::$5 ] ( main:2::fill:5 [ fill::screen#4 fill::ch#4 fill::i#4 fill::$5 ] main:2::fill:7 [ fill::screen#4 fill::ch#4 fill::i#4 fill::$5 ] ) always clobbers reg byte a
Removing always clobbered register reg byte a as potential for zp ZP_BYTE:4 [ fill::ch#4 ]
Removing always clobbered register reg byte a as potential for zp ZP_BYTE:5 [ fill::i#4 fill::i#1 ]
Statement [13] *((byte*~) fill::$5 + (byte) fill::i#4) ← (byte) fill::ch#4 [ fill::screen#4 fill::ch#4 fill::i#4 ] ( main:2::fill:5 [ fill::screen#4 fill::ch#4 fill::i#4 ] main:2::fill:7 [ fill::screen#4 fill::ch#4 fill::i#4 ] ) always clobbers reg byte a
Statement [14] (byte*~) fill::$7 ← (byte*) fill::screen#4 + (byte/signed byte/word/signed word/dword/signed dword) 2*(byte/signed byte/word/signed word/dword/signed dword) $28 [ fill::screen#4 fill::ch#4 fill::i#4 fill::$7 ] ( main:2::fill:5 [ fill::screen#4 fill::ch#4 fill::i#4 fill::$7 ] main:2::fill:7 [ fill::screen#4 fill::ch#4 fill::i#4 fill::$7 ] ) always clobbers reg byte a
Statement [15] *((byte*~) fill::$7 + (byte) fill::i#4) ← (byte) fill::ch#4 [ fill::screen#4 fill::ch#4 fill::i#4 ] ( main:2::fill:5 [ fill::screen#4 fill::ch#4 fill::i#4 ] main:2::fill:7 [ fill::screen#4 fill::ch#4 fill::i#4 ] ) always clobbers reg byte a
Statement [11] *((byte*) fill::screen#4 + (byte) fill::i#4) ← (byte) fill::ch#4 [ fill::screen#4 fill::ch#4 fill::i#4 ] ( main:2::fill:5 [ fill::screen#4 fill::ch#4 fill::i#4 ] main:2::fill:7 [ fill::screen#4 fill::ch#4 fill::i#4 ] ) always clobbers reg byte a
Statement [12] (byte*~) fill::$5 ← (byte*) fill::screen#4 + (byte/signed byte/word/signed word/dword/signed dword) 1*(byte/signed byte/word/signed word/dword/signed dword) $28 [ fill::screen#4 fill::ch#4 fill::i#4 fill::$5 ] ( main:2::fill:5 [ fill::screen#4 fill::ch#4 fill::i#4 fill::$5 ] main:2::fill:7 [ fill::screen#4 fill::ch#4 fill::i#4 fill::$5 ] ) always clobbers reg byte a
Statement [13] *((byte*~) fill::$5 + (byte) fill::i#4) ← (byte) fill::ch#4 [ fill::screen#4 fill::ch#4 fill::i#4 ] ( main:2::fill:5 [ fill::screen#4 fill::ch#4 fill::i#4 ] main:2::fill:7 [ fill::screen#4 fill::ch#4 fill::i#4 ] ) always clobbers reg byte a
Statement [14] (byte*~) fill::$7 ← (byte*) fill::screen#4 + (byte/signed byte/word/signed word/dword/signed dword) 2*(byte/signed byte/word/signed word/dword/signed dword) $28 [ fill::screen#4 fill::ch#4 fill::i#4 fill::$7 ] ( main:2::fill:5 [ fill::screen#4 fill::ch#4 fill::i#4 fill::$7 ] main:2::fill:7 [ fill::screen#4 fill::ch#4 fill::i#4 fill::$7 ] ) always clobbers reg byte a
Statement [15] *((byte*~) fill::$7 + (byte) fill::i#4) ← (byte) fill::ch#4 [ fill::screen#4 fill::ch#4 fill::i#4 ] ( main:2::fill:5 [ fill::screen#4 fill::ch#4 fill::i#4 ] main:2::fill:7 [ fill::screen#4 fill::ch#4 fill::i#4 ] ) always clobbers reg byte a
Potential registers zp ZP_WORD:2 [ fill::screen#4 ] : zp ZP_WORD:2 ,
Potential registers zp ZP_BYTE:4 [ fill::ch#4 ] : zp ZP_BYTE:4 , reg byte x , reg byte y ,
Potential registers zp ZP_BYTE:5 [ fill::i#4 fill::i#1 ] : zp ZP_BYTE:5 , reg byte x , reg byte y ,
Potential registers zp ZP_WORD:6 [ fill::$5 ] : zp ZP_WORD:6 ,
Potential registers zp ZP_WORD:8 [ fill::$7 ] : zp ZP_WORD:8 ,
REGISTER UPLIFT SCOPES
Uplift Scope [fill] 25.67: zp ZP_BYTE:5 [ fill::i#4 fill::i#1 ] 22: zp ZP_WORD:6 [ fill::$5 ] 22: zp ZP_WORD:8 [ fill::$7 ] 3.67: zp ZP_WORD:2 [ fill::screen#4 ] 3.67: zp ZP_BYTE:4 [ fill::ch#4 ]
Uplift Scope [main]
Uplift Scope []
Uplifting [fill] best 961 combination reg byte y [ fill::i#4 fill::i#1 ] zp ZP_WORD:6 [ fill::$5 ] zp ZP_WORD:8 [ fill::$7 ] zp ZP_WORD:2 [ fill::screen#4 ] reg byte x [ fill::ch#4 ]
Uplifting [main] best 961 combination
Uplifting [] best 961 combination
Coalescing zero page register [ zp ZP_WORD:6 [ fill::$5 ] ] with [ zp ZP_WORD:8 [ fill::$7 ] ]
Allocated (was zp ZP_WORD:6) zp ZP_WORD:4 [ fill::$5 fill::$7 ]
ASSEMBLER BEFORE OPTIMIZATION
//SEG0 File Comments
// Tests elimination of plus 0
//SEG1 Basic Upstart
.pc = $801 "Basic"
:BasicUpstart(bbegin)
.pc = $80d "Program"
//SEG2 Global Constants & labels
//SEG3 @begin
bbegin:
//SEG4 [1] phi from @begin to @1 [phi:@begin->@1]
b1_from_bbegin:
jmp b1
//SEG5 @1
b1:
//SEG6 [2] call main
//SEG7 [4] phi from @1 to main [phi:@1->main]
main_from_b1:
jsr main
//SEG8 [3] phi from @1 to @end [phi:@1->@end]
bend_from_b1:
jmp bend
//SEG9 @end
bend:
//SEG10 main
main: {
//SEG11 [5] call fill
//SEG12 [9] phi from main to fill [phi:main->fill]
fill_from_main:
//SEG13 [9] phi (byte) fill::ch#4 = (byte) 'a' [phi:main->fill#0] -- vbuxx=vbuc1
ldx #'a'
//SEG14 [9] phi (byte*) fill::screen#4 = ((byte*))(word/signed word/dword/signed dword) $400 [phi:main->fill#1] -- pbuz1=pbuc1
lda #<$400
sta fill.screen
lda #>$400
sta fill.screen+1
jsr fill
//SEG15 [6] phi from main to main::@1 [phi:main->main::@1]
b1_from_main:
jmp b1
//SEG16 main::@1
b1:
//SEG17 [7] call fill
//SEG18 [9] phi from main::@1 to fill [phi:main::@1->fill]
fill_from_b1:
//SEG19 [9] phi (byte) fill::ch#4 = (byte) 'b' [phi:main::@1->fill#0] -- vbuxx=vbuc1
ldx #'b'
//SEG20 [9] phi (byte*) fill::screen#4 = ((byte*))(word/signed word/dword/signed dword) $2000 [phi:main::@1->fill#1] -- pbuz1=pbuc1
lda #<$2000
sta fill.screen
lda #>$2000
sta fill.screen+1
jsr fill
jmp breturn
//SEG21 main::@return
breturn:
//SEG22 [8] return
rts
}
//SEG23 fill
// fill(byte* zeropage(2) screen, byte register(X) ch)
fill: {
.label screen = 2
.label _5 = 4
.label _7 = 4
//SEG24 [10] phi from fill to fill::@1 [phi:fill->fill::@1]
b1_from_fill:
//SEG25 [10] phi (byte) fill::i#4 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:fill->fill::@1#0] -- vbuyy=vbuc1
ldy #0
jmp b1
//SEG26 [10] phi from fill::@3 to fill::@1 [phi:fill::@3->fill::@1]
b1_from_b3:
//SEG27 [10] phi (byte) fill::i#4 = (byte) fill::i#1 [phi:fill::@3->fill::@1#0] -- register_copy
jmp b1
//SEG28 fill::@1
b1:
jmp b2
//SEG29 fill::@2
b2:
//SEG30 [11] *((byte*) fill::screen#4 + (byte) fill::i#4) ← (byte) fill::ch#4 -- pbuz1_derefidx_vbuyy=vbuxx
txa
sta (screen),y
jmp b2_1
//SEG31 fill::@2_1
b2_1:
//SEG32 [12] (byte*~) fill::$5 ← (byte*) fill::screen#4 + (byte/signed byte/word/signed word/dword/signed dword) 1*(byte/signed byte/word/signed word/dword/signed dword) $28 -- pbuz1=pbuz2_plus_vbuc1
lda #1*$28
clc
adc screen
sta _5
lda #0
adc screen+1
sta _5+1
//SEG33 [13] *((byte*~) fill::$5 + (byte) fill::i#4) ← (byte) fill::ch#4 -- pbuz1_derefidx_vbuyy=vbuxx
txa
sta (_5),y
jmp b2_2
//SEG34 fill::@2_2
b2_2:
//SEG35 [14] (byte*~) fill::$7 ← (byte*) fill::screen#4 + (byte/signed byte/word/signed word/dword/signed dword) 2*(byte/signed byte/word/signed word/dword/signed dword) $28 -- pbuz1=pbuz2_plus_vbuc1
lda #2*$28
clc
adc screen
sta _7
lda #0
adc screen+1
sta _7+1
//SEG36 [15] *((byte*~) fill::$7 + (byte) fill::i#4) ← (byte) fill::ch#4 -- pbuz1_derefidx_vbuyy=vbuxx
txa
sta (_7),y
jmp b3
//SEG37 fill::@3
b3:
//SEG38 [16] (byte) fill::i#1 ← ++ (byte) fill::i#4 -- vbuyy=_inc_vbuyy
iny
//SEG39 [17] if((byte) fill::i#1!=(byte/signed byte/word/signed word/dword/signed dword) $28) goto fill::@1 -- vbuyy_neq_vbuc1_then_la1
cpy #$28
bne b1_from_b3
jmp breturn
//SEG40 fill::@return
breturn:
//SEG41 [18] return
rts
}
ASSEMBLER OPTIMIZATIONS
Removing instruction jmp b1
Removing instruction jmp bend
Removing instruction jmp b1
Removing instruction jmp breturn
Removing instruction jmp b1
Removing instruction jmp b2
Removing instruction jmp b2_1
Removing instruction jmp b2_2
Removing instruction jmp b3
Removing instruction jmp breturn
Succesful ASM optimization Pass5NextJumpElimination
Replacing label b1 with b2
Replacing label b1_from_b3 with b2
Removing instruction b1_from_bbegin:
Removing instruction b1:
Removing instruction main_from_b1:
Removing instruction bend_from_b1:
Removing instruction b1_from_main:
Removing instruction fill_from_b1:
Removing instruction b1_from_b3:
Removing instruction b1:
Succesful ASM optimization Pass5RedundantLabelElimination
Removing instruction bend:
Removing instruction fill_from_main:
Removing instruction b1:
Removing instruction breturn:
Removing instruction b1_from_fill:
Removing instruction b2_1:
Removing instruction b2_2:
Removing instruction b3:
Removing instruction breturn:
Succesful ASM optimization Pass5UnusedLabelElimination
Updating BasicUpstart to call main directly
Removing instruction jsr main
Succesful ASM optimization Pass5SkipBegin
Removing instruction jmp b2
Succesful ASM optimization Pass5NextJumpElimination
Removing instruction bbegin:
Succesful ASM optimization Pass5UnusedLabelElimination
FINAL SYMBOL TABLE
(label) @1
(label) @begin
(label) @end
(void()) fill((byte*) fill::screen , (byte) fill::ch)
(byte*~) fill::$5 $5 zp ZP_WORD:4 22.0
(byte*~) fill::$7 $7 zp ZP_WORD:4 22.0
(label) fill::@1
(label) fill::@2
(label) fill::@2_1
(label) fill::@2_2
(label) fill::@3
(label) fill::@return
(byte) fill::ch
(byte) fill::ch#4 reg byte x 3.666666666666667
(byte) fill::i
(byte) fill::i#1 reg byte y 16.5
(byte) fill::i#4 reg byte y 9.166666666666666
(byte) fill::j
(byte*) fill::screen
(byte*) fill::screen#4 screen zp ZP_WORD:2 3.666666666666667
(void()) main()
(label) main::@1
(label) main::@return
zp ZP_WORD:2 [ fill::screen#4 ]
reg byte x [ fill::ch#4 ]
reg byte y [ fill::i#4 fill::i#1 ]
zp ZP_WORD:4 [ fill::$5 fill::$7 ]
FINAL ASSEMBLER
Score: 733
//SEG0 File Comments
// Tests elimination of plus 0
//SEG1 Basic Upstart
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
//SEG2 Global Constants & labels
//SEG3 @begin
//SEG4 [1] phi from @begin to @1 [phi:@begin->@1]
//SEG5 @1
//SEG6 [2] call main
//SEG7 [4] phi from @1 to main [phi:@1->main]
//SEG8 [3] phi from @1 to @end [phi:@1->@end]
//SEG9 @end
//SEG10 main
main: {
//SEG11 [5] call fill
//SEG12 [9] phi from main to fill [phi:main->fill]
//SEG13 [9] phi (byte) fill::ch#4 = (byte) 'a' [phi:main->fill#0] -- vbuxx=vbuc1
ldx #'a'
//SEG14 [9] phi (byte*) fill::screen#4 = ((byte*))(word/signed word/dword/signed dword) $400 [phi:main->fill#1] -- pbuz1=pbuc1
lda #<$400
sta fill.screen
lda #>$400
sta fill.screen+1
jsr fill
//SEG15 [6] phi from main to main::@1 [phi:main->main::@1]
//SEG16 main::@1
//SEG17 [7] call fill
//SEG18 [9] phi from main::@1 to fill [phi:main::@1->fill]
//SEG19 [9] phi (byte) fill::ch#4 = (byte) 'b' [phi:main::@1->fill#0] -- vbuxx=vbuc1
ldx #'b'
//SEG20 [9] phi (byte*) fill::screen#4 = ((byte*))(word/signed word/dword/signed dword) $2000 [phi:main::@1->fill#1] -- pbuz1=pbuc1
lda #<$2000
sta fill.screen
lda #>$2000
sta fill.screen+1
jsr fill
//SEG21 main::@return
//SEG22 [8] return
rts
}
//SEG23 fill
// fill(byte* zeropage(2) screen, byte register(X) ch)
fill: {
.label screen = 2
.label _5 = 4
.label _7 = 4
//SEG24 [10] phi from fill to fill::@1 [phi:fill->fill::@1]
//SEG25 [10] phi (byte) fill::i#4 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:fill->fill::@1#0] -- vbuyy=vbuc1
ldy #0
//SEG26 [10] phi from fill::@3 to fill::@1 [phi:fill::@3->fill::@1]
//SEG27 [10] phi (byte) fill::i#4 = (byte) fill::i#1 [phi:fill::@3->fill::@1#0] -- register_copy
//SEG28 fill::@1
//SEG29 fill::@2
b2:
//SEG30 [11] *((byte*) fill::screen#4 + (byte) fill::i#4) ← (byte) fill::ch#4 -- pbuz1_derefidx_vbuyy=vbuxx
txa
sta (screen),y
//SEG31 fill::@2_1
//SEG32 [12] (byte*~) fill::$5 ← (byte*) fill::screen#4 + (byte/signed byte/word/signed word/dword/signed dword) 1*(byte/signed byte/word/signed word/dword/signed dword) $28 -- pbuz1=pbuz2_plus_vbuc1
lda #1*$28
clc
adc screen
sta _5
lda #0
adc screen+1
sta _5+1
//SEG33 [13] *((byte*~) fill::$5 + (byte) fill::i#4) ← (byte) fill::ch#4 -- pbuz1_derefidx_vbuyy=vbuxx
txa
sta (_5),y
//SEG34 fill::@2_2
//SEG35 [14] (byte*~) fill::$7 ← (byte*) fill::screen#4 + (byte/signed byte/word/signed word/dword/signed dword) 2*(byte/signed byte/word/signed word/dword/signed dword) $28 -- pbuz1=pbuz2_plus_vbuc1
lda #2*$28
clc
adc screen
sta _7
lda #0
adc screen+1
sta _7+1
//SEG36 [15] *((byte*~) fill::$7 + (byte) fill::i#4) ← (byte) fill::ch#4 -- pbuz1_derefidx_vbuyy=vbuxx
txa
sta (_7),y
//SEG37 fill::@3
//SEG38 [16] (byte) fill::i#1 ← ++ (byte) fill::i#4 -- vbuyy=_inc_vbuyy
iny
//SEG39 [17] if((byte) fill::i#1!=(byte/signed byte/word/signed word/dword/signed dword) $28) goto fill::@1 -- vbuyy_neq_vbuc1_then_la1
cpy #$28
bne b2
//SEG40 fill::@return
//SEG41 [18] return
rts
}

28
src/test/ref/plus-0.sym Normal file
View File

@ -0,0 +1,28 @@
(label) @1
(label) @begin
(label) @end
(void()) fill((byte*) fill::screen , (byte) fill::ch)
(byte*~) fill::$5 $5 zp ZP_WORD:4 22.0
(byte*~) fill::$7 $7 zp ZP_WORD:4 22.0
(label) fill::@1
(label) fill::@2
(label) fill::@2_1
(label) fill::@2_2
(label) fill::@3
(label) fill::@return
(byte) fill::ch
(byte) fill::ch#4 reg byte x 3.666666666666667
(byte) fill::i
(byte) fill::i#1 reg byte y 16.5
(byte) fill::i#4 reg byte y 9.166666666666666
(byte) fill::j
(byte*) fill::screen
(byte*) fill::screen#4 screen zp ZP_WORD:2 3.666666666666667
(void()) main()
(label) main::@1
(label) main::@return
zp ZP_WORD:2 [ fill::screen#4 ]
reg byte x [ fill::ch#4 ]
reg byte y [ fill::i#4 fill::i#1 ]
zp ZP_WORD:4 [ fill::$5 fill::$7 ]