1
0
mirror of https://gitlab.com/camelot/kickc.git synced 2024-11-20 02:32:36 +00:00

Added fire sample from CC65. (~100.000 cycles per update in KickC vs ~300.000 in CC65). Fixed tests. Added some signed fragments.

This commit is contained in:
jespergravgaard 2019-04-08 20:54:23 +02:00
parent b2a0b629e3
commit 44a5f66a7c
32 changed files with 5364 additions and 126 deletions

View File

@ -0,0 +1 @@
// No operation needed

View File

@ -0,0 +1,4 @@
lda {z2}
sta {z1}
lda {z2}+1
sta {z1}+1

View File

@ -0,0 +1,4 @@
lda {z2}
sta {z1}
lda {z2}+1
sta {z1}+1

View File

@ -0,0 +1 @@
// No operation needed

View File

@ -0,0 +1,4 @@
lda {z2}
sta {z1}
lda {z2}+1
sta {z1}+1

View File

@ -0,0 +1,4 @@
clc
lda ({z1}),y
ldy #{c1}
adc ({z1}),y

View File

@ -0,0 +1,2 @@
clc
adc ({z1}),y

View File

@ -0,0 +1,4 @@
lsr
lsr
lsr
lsr

View File

@ -0,0 +1,4 @@
clc
lda ({z1}),y
ldy #{c1}
adc ({z1}),y

View File

@ -0,0 +1,2 @@
clc
adc ({z1}),y

View File

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

View File

@ -175,6 +175,11 @@ public class CompileLog {
this.verboseFragmentLog = verboseFragmentLog;
}
public CompileLog verboseFragmentLog() {
setVerboseFragmentLog(true);
return this;
}
public boolean isVerboseAsmOptimize() {
return verboseAsmOptimize;
}

View File

@ -425,9 +425,9 @@ class AsmFragmentTemplateSynthesisRule {
// Rewrite Assignments to *C1 from A
synths.add(new AsmFragmentTemplateSynthesisRule("_deref_pb(.)c1=(.*)", null, null, "vb$1aa=$2", "sta {c1}", null));
// Rewrite Assignments to *Z1 from A
synths.add(new AsmFragmentTemplateSynthesisRule("_deref_pbuz1=(.*)", twoZ1, null, "vbuaa=$1", "ldy #0\n" + "sta ({z1}),y", mapZ));
synths.add(new AsmFragmentTemplateSynthesisRule("_deref_pb(.)z1=(.*)", twoZ1, null, "vb$1aa=$2", "ldy #0\n" + "sta ({z1}),y", mapZ));
// Rewrite Assignments to *Z1 from A
synths.add(new AsmFragmentTemplateSynthesisRule("_deref_pbuz1=(.*z1.*)", null, null, "vbuaa=$1", "ldy #0\n" + "sta ({z1}),y", null));
synths.add(new AsmFragmentTemplateSynthesisRule("_deref_pb(.)z1=(.*z1.*)", null, null, "vb$1aa=$2", "ldy #0\n" + "sta ({z1}),y", null));
// Rewrite _deref_pb.z1_ to _vb.aa_ (if no other Z1s)
synths.add(new AsmFragmentTemplateSynthesisRule("(.*)_deref_pb(.)z1(.*)", twoZ1+"|"+rvalAa+"|"+rvalYy+"|"+ lvalDerefZ1, "ldy #0\n"+"lda ({z1}),y", "$1vb$2aa$3", null, mapZ));

View File

@ -549,11 +549,11 @@ public class AsmFragmentTemplateSynthesizer {
}
public class UnknownFragmentException extends RuntimeException {
public static class UnknownFragmentException extends RuntimeException {
private String signature;
UnknownFragmentException(String signature) {
public UnknownFragmentException(String signature) {
super("Fragment not found " + signature);
this.signature = signature;
}

View File

@ -22,6 +22,8 @@ public class OperatorCastPtr extends OperatorUnary {
public ConstantLiteral calculateLiteral(ConstantLiteral value) {
if(value instanceof ConstantInteger) {
return new ConstantPointer(((ConstantInteger) value).getInteger(), elementType);
} else if(value instanceof ConstantPointer) {
return new ConstantPointer(((ConstantPointer) value).getLocation(), elementType);
}
throw new CompileError("Calculation not implemented " + getOperator() + " " + value);
}

View File

@ -652,27 +652,30 @@ public class Pass4CodeGeneration {
}
/**
* Generate ASM code for an ASM fragment instance ()
* Generate ASM code for an ASM fragment instance
* @param asm The ASM program to generate into
* @param asmFragmentInstanceSpecFactory The ASM fragment instance specification factory
*/
private void generateAsm(AsmProgram asm, AsmFragmentInstanceSpecFactory asmFragmentInstanceSpecFactory) {
String initialSignature = asmFragmentInstanceSpecFactory.getAsmFragmentInstanceSpec().getSignature();
AsmFragmentInstanceSpec asmFragmentInstanceSpec = asmFragmentInstanceSpecFactory.getAsmFragmentInstanceSpec();
AsmFragmentInstance asmFragmentInstance = null;
StringBuffer fragmentVariationsTried = new StringBuffer();
while(asmFragmentInstance==null) {
try {
asmFragmentInstance = AsmFragmentTemplateSynthesizer.getFragmentInstance(asmFragmentInstanceSpec, program.getLog());
} catch(AsmFragmentTemplateSynthesizer.UnknownFragmentException e) {
// Unknown fragment - keep looking through alternative ASM fragment instance specs until we have tried them all
String signature = asmFragmentInstanceSpec.getSignature();
fragmentVariationsTried.append(signature).append(" ");
if(asmFragmentInstanceSpec.hasNextVariation()) {
String signature = asmFragmentInstanceSpec.getSignature();
asmFragmentInstanceSpec.nextVariation();
if(program.getLog().isVerboseFragmentLog()) {
program.getLog().append("Fragment not found "+signature+". Attempting another variation "+asmFragmentInstanceSpec.getSignature());
}
} else {
// No more variations available - fail with an error
throw e;
throw new AsmFragmentTemplateSynthesizer.UnknownFragmentException("Fragment not found "+initialSignature+". Attempted variations "+fragmentVariationsTried);
}
}
}

View File

@ -32,6 +32,11 @@ public class TestPrograms {
public TestPrograms() {
}
@Test
public void testFire() throws IOException, URISyntaxException {
compileAndCompare("examples/fire/fire");
}
@Test
public void testCTypes() throws IOException, URISyntaxException {
compileAndCompare("c-types");

View File

@ -0,0 +1,85 @@
// A KickC version of the fire routine from the CC65 samples
// (w)2002 by groepaz/hitmen
// Cleanup and porting to CC65 by Ullrich von Bassewitz and Greg King .
// Ported to KickC by Jesper Gravgaard.
// Original source https://github.com/cc65/cc65/blob/master/samples/fire.c
import "c64"
import "sid"
unsigned char* SCREEN1 = 0x3800;
unsigned char* SCREEN2 = 0x3c00;
unsigned char* BUFFER = 0x4000;
unsigned char* CHARSET = 0x3000;
void main() {
asm { sei }
*BORDERCOL = BLACK;
*BGCOL = BLACK;
fillscreen(BUFFER, 00);
fillscreen(SCREEN1, 00);
fillscreen(SCREEN2, 00);
fillscreen(COLS, YELLOW);
sid_rnd_init();
makecharset(CHARSET);
// Show double-buffered fire
while(true) {
fire(SCREEN1);
*D018 = toD018(SCREEN1, CHARSET);
fire(SCREEN2);
*D018 = toD018(SCREEN2, CHARSET);
}
}
// Animate the fire on the passe screen. Uses BUFFER to store the current values.
void fire(unsigned char* screenbase) {
// Average characters from below the current character (24 lines)
unsigned char* screen = screenbase;
unsigned char* buffer = BUFFER;
while (buffer != (BUFFER + (24 * 40))) {
unsigned char c = ( buffer[40-1] + buffer[40-1] + buffer[40] + buffer[41] ) >> 2;
if (c > 2) {
c -= 3;
}
*screen = *buffer = c;
++screen;
++buffer;
}
// Add one new random line at the bottom
screen = (screenbase + (24 * 40));
buffer = (BUFFER + (24 * 40));
while(buffer != (BUFFER+(25*40))) {
*screen++ = *buffer++ = 0x30 + (sid_rnd()) >> 4;
}
}
// Make a fire-friendly charset in chars $00-$3f of the passed charset
void makecharset(byte* charset) {
const unsigned char[8] bittab = { 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80 };
for (unsigned char *font = charset; font != (charset+(1*8)); ++font)
*font = 0x00;
for (unsigned char *font = (charset+(64*8)); font != (charset+(256*8)); ++font)
*font = 0xff;
for (unsigned char c = 0; c < 0x40; ++c) {
unsigned char bc = 0;
for (unsigned char i = 0; i < 8; i++){
unsigned char b = 0;
for (unsigned char ii = 0; ii < 8; ii++) {
bc += c;
if (bc > 0x3f) {
bc = bc - 0x40;
b += bittab[(ii + (i & 1)) & 0x7];
}
}
(charset + (1 * 8)) [(((unsigned short)c) << 3) + i] = b;
}
}
}
// Fill a screen (1000 bytes) with a specific byte
void fillscreen(unsigned char* screen, unsigned char fill) {
for( unsigned word i : 0..999) {
*screen++ = fill;
}
}

View File

@ -0,0 +1,27 @@
// SID registers for random number generation
const word* SID_VOICE3_FREQ = $d40e;
const byte* SID_VOICE3_FREQ_LOW = $d40e;
const byte* SID_VOICE3_FREQ_HIGH = $d40f;
const byte* SID_VOICE3_CONTROL = $d412;
const byte SID_CONTROL_NOISE = $80;
const byte SID_CONTROL_PULSE = $40;
const byte SID_CONTROL_SAWTOOTH = $20;
const byte SID_CONTROL_TRIANGLE = $10;
const byte SID_CONTROL_TEST = $08;
const byte SID_CONTROL_RING = $04;
const byte SID_CONTROL_SYNC = $02;
const byte SID_CONTROL_GATE = $01;
const byte* SID_VOICE3_OSC = $d41b;
// Initialize SID voice 3 for random number generation
void sid_rnd_init() {
*SID_VOICE3_FREQ = $ffff;
*SID_VOICE3_CONTROL = SID_CONTROL_NOISE;
}
// Get a random number from the SID voice 3,
// Must be initialized with sid_rnd_init()
byte sid_rnd() {
return *SID_VOICE3_OSC;
}

View File

@ -1,12 +1,12 @@
byte* SCREEN = $0400;
byte char = 'a';
byte ch = 'a';
byte num = 1;
byte[] str = "bc"+"d"+'e';
byte[] nums = { 2, 3, 4, 5};
void main() {
SCREEN[0] = char;
SCREEN[0] = ch;
SCREEN[2] = num;
for(byte i : 0..3) {
SCREEN[4+i] = str[i];

View File

@ -1,19 +1,19 @@
byte* SCREEN= $400;
byte line = $40;
byte char = line;
byte ch = line;
void main() {
ln();
char++;
ch++;
ln();
char++;
ch++;
ln();
*SCREEN = char;
*SCREEN = ch;
}
void ln() {
line = line + $2;
char = line;
ch = line;
}

View File

@ -0,0 +1,338 @@
// A KickC version of the fire routine from the CC65 samples
// (w)2002 by groepaz/hitmen
// Cleanup and porting to CC65 by Ullrich von Bassewitz and Greg King .
// Ported to KickC by Jesper Gravgaard.
// Original source https://github.com/cc65/cc65/blob/master/samples/fire.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 YELLOW = 7
// 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 = $3800
.label SCREEN2 = $3c00
.label BUFFER = $4000
.label CHARSET = $3000
main: {
.const toD0181_return = (>(SCREEN1&$3fff)<<2)|(>CHARSET)>>2&$f
.const toD0182_return = (>(SCREEN2&$3fff)<<2)|(>CHARSET)>>2&$f
sei
lda #BLACK
sta BORDERCOL
sta BGCOL
lda #<BUFFER
sta fillscreen.screen
lda #>BUFFER
sta fillscreen.screen+1
ldx #0
jsr fillscreen
lda #<SCREEN1
sta fillscreen.screen
lda #>SCREEN1
sta fillscreen.screen+1
ldx #0
jsr fillscreen
lda #<SCREEN2
sta fillscreen.screen
lda #>SCREEN2
sta fillscreen.screen+1
ldx #0
jsr fillscreen
lda #<COLS
sta fillscreen.screen
lda #>COLS
sta fillscreen.screen+1
ldx #YELLOW
jsr fillscreen
jsr sid_rnd_init
jsr makecharset
b1:
lda #<SCREEN1
sta fire.screen
lda #>SCREEN1
sta fire.screen+1
jsr fire
lda #toD0181_return
sta D018
lda #<SCREEN2
sta fire.screen
lda #>SCREEN2
sta fire.screen+1
jsr fire
lda #toD0182_return
sta D018
jmp b1
}
// Animate the fire on the passe screen. Uses BUFFER to store the current values.
fire: {
.label screen = 2
.label screen_2 = 6
.label buffer = 4
.label screen_4 = 6
.label screen_11 = 6
lda screen
sta screen_11
lda screen+1
sta screen_11+1
lda #<BUFFER
sta buffer
lda #>BUFFER
sta buffer+1
b1:
lda buffer+1
cmp #>BUFFER+$18*$28
bne b2
lda buffer
cmp #<BUFFER+$18*$28
bne b2
clc
lda screen
adc #<$18*$28
sta screen
lda screen+1
adc #>$18*$28
sta screen+1
lda #<BUFFER+$18*$28
sta buffer
lda #>BUFFER+$18*$28
sta buffer+1
b6:
lda buffer+1
cmp #>BUFFER+$19*$28
bne b7
lda buffer
cmp #<BUFFER+$19*$28
bne b7
rts
b7:
jsr sid_rnd
lsr
lsr
lsr
lsr
clc
adc #$30
ldy #0
sta (buffer),y
lda (buffer),y
sta (screen),y
inc screen
bne !+
inc screen+1
!:
inc buffer
bne !+
inc buffer+1
!:
jmp b6
b2:
ldy #$28-1
clc
lda (buffer),y
adc (buffer),y
ldy #$28
clc
adc (buffer),y
ldy #$29
clc
adc (buffer),y
lsr
lsr
cmp #2
bcc b4
beq b4
sec
sbc #3
b4:
ldy #0
sta (buffer),y
lda (buffer),y
sta (screen_4),y
inc screen_2
bne !+
inc screen_2+1
!:
inc buffer
bne !+
inc buffer+1
!:
jmp b1
}
// Get a random number from the SID voice 3,
// Must be initialized with sid_rnd_init()
sid_rnd: {
lda SID_VOICE3_OSC
rts
}
// Make a fire-friendly charset in chars $00-$3f of the passed charset
makecharset: {
.label _13 = $b
.label _17 = 2
.label _18 = 2
.label _19 = 2
.label font = 2
.label font1 = 2
.label ii = $a
.label i = 9
.label c = 8
lda #<CHARSET
sta font
lda #>CHARSET
sta font+1
b1:
lda #0
tay
sta (font),y
inc font
bne !+
inc font+1
!:
lda font+1
cmp #>CHARSET+1*8
bne b1
lda font
cmp #<CHARSET+1*8
bne b1
lda #<CHARSET+$40*8
sta font1
lda #>CHARSET+$40*8
sta font1+1
b2:
lda #$ff
ldy #0
sta (font1),y
inc font1
bne !+
inc font1+1
!:
lda font1+1
cmp #>CHARSET+$100*8
bne b2
lda font1
cmp #<CHARSET+$100*8
bne b2
lda #0
sta c
b3:
lda #0
sta i
tax
b4:
ldy #0
tya
sta ii
b5:
txa
clc
adc c
tax
cpx #$3f
bcc b6
beq b6
txa
axs #$40
lda #1
and i
clc
adc ii
and #7
sta _13
tya
ldy _13
clc
adc bittab,y
tay
b6:
inc ii
lda ii
cmp #8
bcc b5
lda c
sta _17
lda #0
sta _17+1
asl _18
rol _18+1
asl _18
rol _18+1
asl _18
rol _18+1
lda i
clc
adc _19
sta _19
bcc !+
inc _19+1
!:
tya
sta !v++1
lda #<CHARSET+1*8
clc
adc _19
sta !a++1
lda #>CHARSET+1*8
adc _19+1
sta !a++2
!v:
lda #0
!a:
sta CHARSET+1*8
inc i
lda i
cmp #8
bcc b4
inc c
lda c
cmp #$40
bcc b3
rts
bittab: .byte 1, 2, 4, 8, $10, $20, $40, $80
}
// 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
}
// Fill a screen (1000 bytes) with a specific byte
// fillscreen(byte* zeropage(2) screen, byte register(X) fill)
fillscreen: {
.label screen = 2
.label i = 4
lda #0
sta i
sta i+1
b1:
txa
ldy #0
sta (screen),y
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
}

View File

@ -0,0 +1,188 @@
@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
asm { sei }
[5] *((const byte*) BORDERCOL#0) ← (const byte) BLACK#0
[6] *((const byte*) BGCOL#0) ← (const byte) BLACK#0
[7] call fillscreen
to:main::@4
main::@4: scope:[main] from main
[8] phi()
[9] call fillscreen
to:main::@5
main::@5: scope:[main] from main::@4
[10] phi()
[11] call fillscreen
to:main::@6
main::@6: scope:[main] from main::@5
[12] phi()
[13] call fillscreen
to:main::@7
main::@7: scope:[main] from main::@6
[14] phi()
[15] call sid_rnd_init
to:main::@8
main::@8: scope:[main] from main::@7
[16] phi()
[17] call makecharset
to:main::@1
main::@1: scope:[main] from main::@3 main::@8
[18] phi()
[19] call fire
to:main::toD0181
main::toD0181: scope:[main] from main::@1
[20] phi()
to:main::@2
main::@2: scope:[main] from main::toD0181
[21] *((const byte*) D018#0) ← (const byte) main::toD0181_return#0
[22] call fire
to:main::toD0182
main::toD0182: scope:[main] from main::@2
[23] phi()
to:main::@3
main::@3: scope:[main] from main::toD0182
[24] *((const byte*) D018#0) ← (const byte) main::toD0182_return#0
to:main::@1
fire: scope:[fire] from main::@1 main::@2
[25] (byte*) fire::screen#0 ← phi( main::@1/(const byte*) SCREEN1#0 main::@2/(const byte*) SCREEN2#0 )
[26] (byte*~) fire::screen#11 ← (byte*) fire::screen#0
to:fire::@1
fire::@1: scope:[fire] from fire fire::@4
[27] (byte*) fire::screen#4 ← phi( fire/(byte*~) fire::screen#11 fire::@4/(byte*) fire::screen#2 )
[27] (byte*) fire::buffer#4 ← phi( fire/(const byte*) BUFFER#0 fire::@4/(byte*) fire::buffer#2 )
[28] if((byte*) fire::buffer#4!=(const byte*) BUFFER#0+(byte/signed byte/word/signed word/dword/signed dword) $18*(byte/signed byte/word/signed word/dword/signed dword) $28) goto fire::@2
to:fire::@3
fire::@3: scope:[fire] from fire::@1
[29] (byte*) fire::screen#1 ← (byte*) fire::screen#0 + (byte/signed byte/word/signed word/dword/signed dword) $18*(byte/signed byte/word/signed word/dword/signed dword) $28
to:fire::@6
fire::@6: scope:[fire] from fire::@3 fire::@8
[30] (byte*) fire::screen#10 ← phi( fire::@8/(byte*) fire::screen#3 fire::@3/(byte*) fire::screen#1 )
[30] (byte*) fire::buffer#10 ← phi( fire::@8/(byte*) fire::buffer#3 fire::@3/(const byte*) BUFFER#0+(byte/signed byte/word/signed word/dword/signed dword) $18*(byte/signed byte/word/signed word/dword/signed dword) $28 )
[31] if((byte*) fire::buffer#10!=(const byte*) BUFFER#0+(byte/signed byte/word/signed word/dword/signed dword) $19*(byte/signed byte/word/signed word/dword/signed dword) $28) goto fire::@7
to:fire::@return
fire::@return: scope:[fire] from fire::@6
[32] return
to:@return
fire::@7: scope:[fire] from fire::@6
[33] phi()
[34] call sid_rnd
[35] (byte) sid_rnd::return#2 ← (byte) sid_rnd::return#0
to:fire::@8
fire::@8: scope:[fire] from fire::@7
[36] (byte~) fire::$18 ← (byte) sid_rnd::return#2
[37] (byte~) fire::$19 ← (byte~) fire::$18 >> (byte/signed byte/word/signed word/dword/signed dword) 4
[38] (byte/signed word/word/dword/signed dword~) fire::$20 ← (byte/signed byte/word/signed word/dword/signed dword) $30 + (byte~) fire::$19
[39] *((byte*) fire::buffer#10) ← (byte/signed word/word/dword/signed dword~) fire::$20
[40] *((byte*) fire::screen#10) ← *((byte*) fire::buffer#10)
[41] (byte*) fire::screen#3 ← ++ (byte*) fire::screen#10
[42] (byte*) fire::buffer#3 ← ++ (byte*) fire::buffer#10
to:fire::@6
fire::@2: scope:[fire] from fire::@1
[43] (byte~) fire::$9 ← *((byte*) fire::buffer#4 + (byte/signed byte/word/signed word/dword/signed dword) $28-(byte/signed byte/word/signed word/dword/signed dword) 1) + *((byte*) fire::buffer#4 + (byte/signed byte/word/signed word/dword/signed dword) $28-(byte/signed byte/word/signed word/dword/signed dword) 1)
[44] (byte~) fire::$10 ← (byte~) fire::$9 + *((byte*) fire::buffer#4 + (byte/signed byte/word/signed word/dword/signed dword) $28)
[45] (byte~) fire::$11 ← (byte~) fire::$10 + *((byte*) fire::buffer#4 + (byte/signed byte/word/signed word/dword/signed dword) $29)
[46] (byte) fire::c#0 ← (byte~) fire::$11 >> (byte/signed byte/word/signed word/dword/signed dword) 2
[47] if((byte) fire::c#0<=(byte/signed byte/word/signed word/dword/signed dword) 2) goto fire::@4
to:fire::@5
fire::@5: scope:[fire] from fire::@2
[48] (byte) fire::c#1 ← (byte) fire::c#0 - (byte/signed byte/word/signed word/dword/signed dword) 3
to:fire::@4
fire::@4: scope:[fire] from fire::@2 fire::@5
[49] (byte) fire::c#2 ← phi( fire::@2/(byte) fire::c#0 fire::@5/(byte) fire::c#1 )
[50] *((byte*) fire::buffer#4) ← (byte) fire::c#2
[51] *((byte*) fire::screen#4) ← *((byte*) fire::buffer#4)
[52] (byte*) fire::screen#2 ← ++ (byte*) fire::screen#4
[53] (byte*) fire::buffer#2 ← ++ (byte*) fire::buffer#4
to:fire::@1
sid_rnd: scope:[sid_rnd] from fire::@7
[54] (byte) sid_rnd::return#0 ← *((const byte*) SID_VOICE3_OSC#0)
to:sid_rnd::@return
sid_rnd::@return: scope:[sid_rnd] from sid_rnd
[55] return
to:@return
makecharset: scope:[makecharset] from main::@8
[56] phi()
to:makecharset::@1
makecharset::@1: scope:[makecharset] from makecharset makecharset::@1
[57] (byte*) makecharset::font#2 ← phi( makecharset/(const byte*) CHARSET#0 makecharset::@1/(byte*) makecharset::font#1 )
[58] *((byte*) makecharset::font#2) ← (byte/signed byte/word/signed word/dword/signed dword) 0
[59] (byte*) makecharset::font#1 ← ++ (byte*) makecharset::font#2
[60] if((byte*) makecharset::font#1!=(const byte*) CHARSET#0+(byte/signed byte/word/signed word/dword/signed dword) 1*(byte/signed byte/word/signed word/dword/signed dword) 8) goto makecharset::@1
to:makecharset::@2
makecharset::@2: scope:[makecharset] from makecharset::@1 makecharset::@2
[61] (byte*) makecharset::font1#2 ← phi( makecharset::@1/(const byte*) CHARSET#0+(byte/signed byte/word/signed word/dword/signed dword) $40*(byte/signed byte/word/signed word/dword/signed dword) 8 makecharset::@2/(byte*) makecharset::font1#1 )
[62] *((byte*) makecharset::font1#2) ← (byte/word/signed word/dword/signed dword) $ff
[63] (byte*) makecharset::font1#1 ← ++ (byte*) makecharset::font1#2
[64] if((byte*) makecharset::font1#1!=(const byte*) CHARSET#0+(word/signed word/dword/signed dword) $100*(byte/signed byte/word/signed word/dword/signed dword) 8) goto makecharset::@2
to:makecharset::@3
makecharset::@3: scope:[makecharset] from makecharset::@2 makecharset::@9
[65] (byte) makecharset::c#7 ← phi( makecharset::@9/(byte) makecharset::c#1 makecharset::@2/(byte/signed byte/word/signed word/dword/signed dword) 0 )
to:makecharset::@4
makecharset::@4: scope:[makecharset] from makecharset::@3 makecharset::@8
[66] (byte) makecharset::i#6 ← phi( makecharset::@8/(byte) makecharset::i#1 makecharset::@3/(byte/signed byte/word/signed word/dword/signed dword) 0 )
[66] (byte) makecharset::bc#5 ← phi( makecharset::@8/(byte) makecharset::bc#6 makecharset::@3/(byte/signed byte/word/signed word/dword/signed dword) 0 )
to:makecharset::@5
makecharset::@5: scope:[makecharset] from makecharset::@4 makecharset::@6
[67] (byte) makecharset::b#2 ← phi( makecharset::@4/(byte/signed byte/word/signed word/dword/signed dword) 0 makecharset::@6/(byte) makecharset::b#3 )
[67] (byte) makecharset::ii#2 ← phi( makecharset::@4/(byte/signed byte/word/signed word/dword/signed dword) 0 makecharset::@6/(byte) makecharset::ii#1 )
[67] (byte) makecharset::bc#3 ← phi( makecharset::@4/(byte) makecharset::bc#5 makecharset::@6/(byte) makecharset::bc#6 )
[68] (byte) makecharset::bc#1 ← (byte) makecharset::bc#3 + (byte) makecharset::c#7
[69] if((byte) makecharset::bc#1<=(byte/signed byte/word/signed word/dword/signed dword) $3f) goto makecharset::@6
to:makecharset::@7
makecharset::@7: scope:[makecharset] from makecharset::@5
[70] (byte) makecharset::bc#2 ← (byte) makecharset::bc#1 - (byte/signed byte/word/signed word/dword/signed dword) $40
[71] (byte~) makecharset::$11 ← (byte) makecharset::i#6 & (byte/signed byte/word/signed word/dword/signed dword) 1
[72] (byte~) makecharset::$12 ← (byte) makecharset::ii#2 + (byte~) makecharset::$11
[73] (byte~) makecharset::$13 ← (byte~) makecharset::$12 & (byte/signed byte/word/signed word/dword/signed dword) 7
[74] (byte) makecharset::b#1 ← (byte) makecharset::b#2 + *((const byte[8]) makecharset::bittab#0 + (byte~) makecharset::$13)
to:makecharset::@6
makecharset::@6: scope:[makecharset] from makecharset::@5 makecharset::@7
[75] (byte) makecharset::b#3 ← phi( makecharset::@5/(byte) makecharset::b#2 makecharset::@7/(byte) makecharset::b#1 )
[75] (byte) makecharset::bc#6 ← phi( makecharset::@5/(byte) makecharset::bc#1 makecharset::@7/(byte) makecharset::bc#2 )
[76] (byte) makecharset::ii#1 ← ++ (byte) makecharset::ii#2
[77] if((byte) makecharset::ii#1<(byte/signed byte/word/signed word/dword/signed dword) 8) goto makecharset::@5
to:makecharset::@8
makecharset::@8: scope:[makecharset] from makecharset::@6
[78] (word~) makecharset::$17 ← ((word)) (byte) makecharset::c#7
[79] (word~) makecharset::$18 ← (word~) makecharset::$17 << (byte/signed byte/word/signed word/dword/signed dword) 3
[80] (word~) makecharset::$19 ← (word~) makecharset::$18 + (byte) makecharset::i#6
[81] *((const byte*) CHARSET#0+(byte/signed byte/word/signed word/dword/signed dword) 1*(byte/signed byte/word/signed word/dword/signed dword) 8 + (word~) makecharset::$19) ← (byte) makecharset::b#3
[82] (byte) makecharset::i#1 ← ++ (byte) makecharset::i#6
[83] if((byte) makecharset::i#1<(byte/signed byte/word/signed word/dword/signed dword) 8) goto makecharset::@4
to:makecharset::@9
makecharset::@9: scope:[makecharset] from makecharset::@8
[84] (byte) makecharset::c#1 ← ++ (byte) makecharset::c#7
[85] if((byte) makecharset::c#1<(byte/signed byte/word/signed word/dword/signed dword) $40) goto makecharset::@3
to:makecharset::@return
makecharset::@return: scope:[makecharset] from makecharset::@9
[86] return
to:@return
sid_rnd_init: scope:[sid_rnd_init] from main::@7
[87] *((const word*) SID_VOICE3_FREQ#0) ← (word/dword/signed dword) $ffff
[88] *((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
[89] return
to:@return
fillscreen: scope:[fillscreen] from main main::@4 main::@5 main::@6
[90] (byte*) fillscreen::screen#6 ← phi( main/(const byte*) BUFFER#0 main::@5/(const byte*) SCREEN2#0 main::@6/(const byte*) COLS#0 main::@4/(const byte*) SCREEN1#0 )
[90] (byte) fillscreen::fill#5 ← phi( main/(byte/signed byte/word/signed word/dword/signed dword) 0 main::@5/(byte/signed byte/word/signed word/dword/signed dword) 0 main::@6/(const byte) YELLOW#0 main::@4/(byte/signed byte/word/signed word/dword/signed dword) 0 )
to:fillscreen::@1
fillscreen::@1: scope:[fillscreen] from fillscreen fillscreen::@1
[91] (word) fillscreen::i#2 ← phi( fillscreen/(byte/signed byte/word/signed word/dword/signed dword) 0 fillscreen::@1/(word) fillscreen::i#1 )
[91] (byte*) fillscreen::screen#5 ← phi( fillscreen/(byte*) fillscreen::screen#6 fillscreen::@1/(byte*) fillscreen::screen#4 )
[92] *((byte*) fillscreen::screen#5) ← (byte) fillscreen::fill#5
[93] (byte*) fillscreen::screen#4 ← ++ (byte*) fillscreen::screen#5
[94] (word) fillscreen::i#1 ← ++ (word) fillscreen::i#2
[95] if((word) fillscreen::i#1!=(word/signed word/dword/signed dword) $3e8) goto fillscreen::@1
to:fillscreen::@return
fillscreen::@return: scope:[fillscreen] from fillscreen::@1
[96] return
to:@return

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,270 @@
(label) @1
(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
(byte*) BORDERCOL
(const byte*) BORDERCOL#0 BORDERCOL = ((byte*))(word/dword/signed dword) $d020
(byte) BROWN
(byte*) BUFFER
(const byte*) BUFFER#0 BUFFER = ((byte*))(word/signed word/dword/signed dword) $4000
(byte*) CHARGEN
(byte*) CHARSET
(const byte*) CHARSET#0 CHARSET = ((byte*))(word/signed word/dword/signed dword) $3000
(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) $3800
(byte*) SCREEN2
(const byte*) SCREEN2#0 SCREEN2 = ((byte*))(word/signed word/dword/signed dword) $3c00
(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*) 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
(const byte) YELLOW#0 YELLOW = (byte/signed byte/word/signed word/dword/signed dword) 7
(void()) fillscreen((byte*) fillscreen::screen , (byte) fillscreen::fill)
(label) fillscreen::@1
(label) fillscreen::@return
(byte) fillscreen::fill
(byte) fillscreen::fill#5 reg byte x 1.8333333333333333
(word) fillscreen::i
(word) fillscreen::i#1 i zp ZP_WORD:4 16.5
(word) fillscreen::i#2 i zp ZP_WORD:4 7.333333333333333
(byte*) fillscreen::screen
(byte*) fillscreen::screen#4 screen zp ZP_WORD:2 7.333333333333333
(byte*) fillscreen::screen#5 screen zp ZP_WORD:2 17.5
(byte*) fillscreen::screen#6 screen zp ZP_WORD:2 2.0
(void()) fire((byte*) fire::screenbase)
(byte~) fire::$10 reg byte a 202.0
(byte~) fire::$11 reg byte a 202.0
(byte~) fire::$18 reg byte a 202.0
(byte~) fire::$19 reg byte a 202.0
(byte/signed word/word/dword/signed dword~) fire::$20 reg byte a 202.0
(byte~) fire::$9 reg byte a 202.0
(label) fire::@1
(label) fire::@2
(label) fire::@3
(label) fire::@4
(label) fire::@5
(label) fire::@6
(label) fire::@7
(label) fire::@8
(label) fire::@return
(byte*) fire::buffer
(byte*) fire::buffer#10 buffer zp ZP_WORD:4 45.90909090909091
(byte*) fire::buffer#2 buffer zp ZP_WORD:4 202.0
(byte*) fire::buffer#3 buffer zp ZP_WORD:4 202.0
(byte*) fire::buffer#4 buffer zp ZP_WORD:4 75.75
(byte) fire::c
(byte) fire::c#0 reg byte a 202.0
(byte) fire::c#1 reg byte a 202.0
(byte) fire::c#2 reg byte a 303.0
(byte*) fire::screen
(byte*) fire::screen#0 screen zp ZP_WORD:2 0.26666666666666666
(byte*) fire::screen#1 screen zp ZP_WORD:2 4.0
(byte*) fire::screen#10 screen zp ZP_WORD:2 30.5
(byte*~) fire::screen#11 screen#11 zp ZP_WORD:6 4.0
(byte*) fire::screen#2 screen#2 zp ZP_WORD:6 101.0
(byte*) fire::screen#3 screen zp ZP_WORD:2 101.0
(byte*) fire::screen#4 screen#4 zp ZP_WORD:6 27.727272727272727
(byte*) fire::screenbase
(void()) main()
(label) main::@1
(label) main::@2
(label) main::@3
(label) main::@4
(label) main::@5
(label) main::@6
(label) main::@7
(label) main::@8
(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
(label) main::toD0182
(word~) main::toD0182_$0
(word~) main::toD0182_$1
(word~) main::toD0182_$2
(byte~) main::toD0182_$3
(word~) main::toD0182_$4
(byte~) main::toD0182_$5
(byte~) main::toD0182_$6
(byte~) main::toD0182_$7
(byte~) main::toD0182_$8
(byte*) main::toD0182_gfx
(byte) main::toD0182_return
(const byte) main::toD0182_return#0 toD0182_return = >((word))(const byte*) SCREEN2#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::toD0182_screen
(void()) makecharset((byte*) makecharset::charset)
(byte~) makecharset::$11 reg byte a 2002.0
(byte~) makecharset::$12 reg byte a 2002.0
(byte~) makecharset::$13 $13 zp ZP_BYTE:11 2002.0
(word~) makecharset::$17 $17 zp ZP_WORD:2 202.0
(word~) makecharset::$18 $18 zp ZP_WORD:2 202.0
(word~) makecharset::$19 $19 zp ZP_WORD:2 202.0
(label) makecharset::@1
(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 429.0
(byte) makecharset::b#3 reg byte y 517.3333333333334
(byte) makecharset::bc
(byte) makecharset::bc#1 reg byte x 2002.0
(byte) makecharset::bc#2 reg byte x 400.4
(byte) makecharset::bc#3 reg byte x 2103.0
(byte) makecharset::bc#5 reg byte x 202.0
(byte) makecharset::bc#6 reg byte x 344.8888888888889
(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 }
(byte) makecharset::c
(byte) makecharset::c#1 c zp ZP_BYTE:8 16.5
(byte) makecharset::c#7 c zp ZP_BYTE:8 59.15789473684211
(byte*) makecharset::charset
(byte*) makecharset::font
(byte*) makecharset::font#1 font zp ZP_WORD:2 16.5
(byte*) makecharset::font#2 font zp ZP_WORD:2 16.5
(byte*) makecharset::font1
(byte*) makecharset::font1#1 font1 zp ZP_WORD:2 16.5
(byte*) makecharset::font1#2 font1 zp ZP_WORD:2 16.5
(byte) makecharset::i
(byte) makecharset::i#1 i zp ZP_BYTE:9 151.5
(byte) makecharset::i#6 i zp ZP_BYTE:9 81.5
(byte) makecharset::ii
(byte) makecharset::ii#1 ii zp ZP_BYTE:10 1501.5
(byte) makecharset::ii#2 ii zp ZP_BYTE:10 333.6666666666667
(byte()) sid_rnd()
(label) sid_rnd::@return
(byte) sid_rnd::return
(byte) sid_rnd::return#0 reg byte a 34.33333333333333
(byte) sid_rnd::return#2 reg byte a 202.0
(void()) sid_rnd_init()
(label) sid_rnd_init::@return
zp ZP_WORD:2 [ fire::screen#0 fire::screen#10 fire::screen#3 fire::screen#1 makecharset::font#2 makecharset::font#1 makecharset::font1#2 makecharset::font1#1 fillscreen::screen#5 fillscreen::screen#6 fillscreen::screen#4 makecharset::$17 makecharset::$18 makecharset::$19 ]
zp ZP_WORD:4 [ fire::buffer#4 fire::buffer#2 fire::buffer#10 fire::buffer#3 fillscreen::i#2 fillscreen::i#1 ]
zp ZP_WORD:6 [ fire::screen#4 fire::screen#11 fire::screen#2 ]
reg byte a [ fire::c#2 fire::c#0 fire::c#1 ]
zp ZP_BYTE:8 [ makecharset::c#7 makecharset::c#1 ]
zp ZP_BYTE:9 [ makecharset::i#6 makecharset::i#1 ]
reg byte x [ makecharset::bc#3 makecharset::bc#5 makecharset::bc#6 makecharset::bc#1 makecharset::bc#2 ]
zp ZP_BYTE:10 [ makecharset::ii#2 makecharset::ii#1 ]
reg byte y [ makecharset::b#2 makecharset::b#3 makecharset::b#1 ]
reg byte x [ fillscreen::fill#5 ]
reg byte a [ sid_rnd::return#2 ]
reg byte a [ fire::$18 ]
reg byte a [ fire::$19 ]
reg byte a [ fire::$20 ]
reg byte a [ fire::$9 ]
reg byte a [ fire::$10 ]
reg byte a [ fire::$11 ]
reg byte a [ sid_rnd::return#0 ]
reg byte a [ makecharset::$11 ]
reg byte a [ makecharset::$12 ]
zp ZP_BYTE:11 [ makecharset::$13 ]

View File

@ -2,10 +2,10 @@
:BasicUpstart(main)
.pc = $80d "Program"
.label SCREEN = $400
.const char = 'a'
.const ch = 'a'
.const num = 1
main: {
lda #char
lda #ch
sta SCREEN
lda #num
sta SCREEN+2

View File

@ -8,7 +8,7 @@
@end: scope:[] from @1
[3] phi()
main: scope:[main] from @1
[4] *((const byte*) SCREEN#0) ← (const byte) char#0
[4] *((const byte*) SCREEN#0) ← (const byte) ch#0
[5] *((const byte*) SCREEN#0+(byte/signed byte/word/signed word/dword/signed dword) 2) ← (const byte) num#0
to:main::@1
main::@1: scope:[main] from main main::@1

View File

@ -1,11 +1,11 @@
Identified constant variable (byte*) SCREEN
Identified constant variable (byte) char
Identified constant variable (byte) ch
Identified constant variable (byte) num
CONTROL FLOW GRAPH SSA
@begin: scope:[] from
(byte*) SCREEN#0 ← ((byte*)) (word/signed word/dword/signed dword) $400
(byte) char#0 ← (byte) 'a'
(byte) ch#0 ← (byte) 'a'
(byte) num#0 ← (byte/signed byte/word/signed word/dword/signed dword) 1
(string~) $0 ← (const string) $2 + (const string) $3
(string~) $1 ← (string~) $0 + (byte) 'e'
@ -13,7 +13,7 @@ CONTROL FLOW GRAPH SSA
(byte[]) nums#0 ← { (byte/signed byte/word/signed word/dword/signed dword) 2, (byte/signed byte/word/signed word/dword/signed dword) 3, (byte/signed byte/word/signed word/dword/signed dword) 4, (byte/signed byte/word/signed word/dword/signed dword) 5 }
to:@1
main: scope:[main] from @1
*((byte*) SCREEN#0 + (byte/signed byte/word/signed word/dword/signed dword) 0) ← (byte) char#0
*((byte*) SCREEN#0 + (byte/signed byte/word/signed word/dword/signed dword) 0) ← (byte) ch#0
*((byte*) SCREEN#0 + (byte/signed byte/word/signed word/dword/signed dword) 2) ← (byte) num#0
(byte) main::i#0 ← (byte/signed byte/word/signed word/dword/signed dword) 0
to:main::@1
@ -48,8 +48,8 @@ SYMBOL TABLE SSA
(label) @end
(byte*) SCREEN
(byte*) SCREEN#0
(byte) char
(byte) char#0
(byte) ch
(byte) ch#0
(void()) main()
(byte/signed word/word/dword/signed dword~) main::$0
(byte/signed word/word/dword/signed dword~) main::$1
@ -74,7 +74,7 @@ Successful SSA optimization Pass2AliasElimination
Simple Condition (bool~) main::$2 [17] if((byte) main::i#1!=rangelast(0,3)) goto main::@1
Successful SSA optimization Pass2ConditionalJumpSimplification
Constant (const byte*) SCREEN#0 = ((byte*))$400
Constant (const byte) char#0 = 'a'
Constant (const byte) ch#0 = 'a'
Constant (const byte) num#0 = 1
Constant (const string) $0 = "bc"+"d"
Constant (const byte[]) nums#0 = { 2, 3, 4, 5 }
@ -124,7 +124,7 @@ FINAL CONTROL FLOW GRAPH
@end: scope:[] from @1
[3] phi()
main: scope:[main] from @1
[4] *((const byte*) SCREEN#0) ← (const byte) char#0
[4] *((const byte*) SCREEN#0) ← (const byte) ch#0
[5] *((const byte*) SCREEN#0+(byte/signed byte/word/signed word/dword/signed dword) 2) ← (const byte) num#0
to:main::@1
main::@1: scope:[main] from main main::@1
@ -141,7 +141,7 @@ main::@return: scope:[main] from main::@1
VARIABLE REGISTER WEIGHTS
(byte*) SCREEN
(byte) char
(byte) ch
(void()) main()
(byte) main::i
(byte) main::i#1 16.5
@ -164,7 +164,7 @@ INITIAL ASM
.pc = $80d "Program"
//SEG2 Global Constants & labels
.label SCREEN = $400
.const char = 'a'
.const ch = 'a'
.const num = 1
//SEG3 @begin
bbegin:
@ -183,8 +183,8 @@ bend:
//SEG9 main
main: {
.label i = 2
//SEG10 [4] *((const byte*) SCREEN#0) ← (const byte) char#0 -- _deref_pbuc1=vbuc2
lda #char
//SEG10 [4] *((const byte*) SCREEN#0) ← (const byte) ch#0 -- _deref_pbuc1=vbuc2
lda #ch
sta SCREEN
//SEG11 [5] *((const byte*) SCREEN#0+(byte/signed byte/word/signed word/dword/signed dword) 2) ← (const byte) num#0 -- _deref_pbuc1=vbuc2
lda #num
@ -225,12 +225,12 @@ main: {
str: .text "bc"+"d"+'e'
REGISTER UPLIFT POTENTIAL REGISTERS
Statement [4] *((const byte*) SCREEN#0) ← (const byte) char#0 [ ] ( main:2 [ ] ) always clobbers reg byte a
Statement [4] *((const byte*) SCREEN#0) ← (const byte) ch#0 [ ] ( main:2 [ ] ) always clobbers reg byte a
Statement [5] *((const byte*) SCREEN#0+(byte/signed byte/word/signed word/dword/signed dword) 2) ← (const byte) num#0 [ ] ( main:2 [ ] ) always clobbers reg byte a
Statement [7] *((const byte*) SCREEN#0+(byte/signed byte/word/signed word/dword/signed dword) 4 + (byte) main::i#2) ← *((const byte[]) str#0 + (byte) main::i#2) [ main::i#2 ] ( main:2 [ main::i#2 ] ) always clobbers reg byte a
Removing always clobbered register reg byte a as potential for zp ZP_BYTE:2 [ main::i#2 main::i#1 ]
Statement [8] *((const byte*) SCREEN#0+(byte/signed byte/word/signed word/dword/signed dword) 9 + (byte) main::i#2) ← *((const byte[]) nums#0 + (byte) main::i#2) [ main::i#2 ] ( main:2 [ main::i#2 ] ) always clobbers reg byte a
Statement [4] *((const byte*) SCREEN#0) ← (const byte) char#0 [ ] ( main:2 [ ] ) always clobbers reg byte a
Statement [4] *((const byte*) SCREEN#0) ← (const byte) ch#0 [ ] ( main:2 [ ] ) always clobbers reg byte a
Statement [5] *((const byte*) SCREEN#0+(byte/signed byte/word/signed word/dword/signed dword) 2) ← (const byte) num#0 [ ] ( main:2 [ ] ) always clobbers reg byte a
Statement [7] *((const byte*) SCREEN#0+(byte/signed byte/word/signed word/dword/signed dword) 4 + (byte) main::i#2) ← *((const byte[]) str#0 + (byte) main::i#2) [ main::i#2 ] ( main:2 [ main::i#2 ] ) always clobbers reg byte a
Statement [8] *((const byte*) SCREEN#0+(byte/signed byte/word/signed word/dword/signed dword) 9 + (byte) main::i#2) ← *((const byte[]) nums#0 + (byte) main::i#2) [ main::i#2 ] ( main:2 [ main::i#2 ] ) always clobbers reg byte a
@ -251,7 +251,7 @@ ASSEMBLER BEFORE OPTIMIZATION
.pc = $80d "Program"
//SEG2 Global Constants & labels
.label SCREEN = $400
.const char = 'a'
.const ch = 'a'
.const num = 1
//SEG3 @begin
bbegin:
@ -269,8 +269,8 @@ bend_from_b1:
bend:
//SEG9 main
main: {
//SEG10 [4] *((const byte*) SCREEN#0) ← (const byte) char#0 -- _deref_pbuc1=vbuc2
lda #char
//SEG10 [4] *((const byte*) SCREEN#0) ← (const byte) ch#0 -- _deref_pbuc1=vbuc2
lda #ch
sta SCREEN
//SEG11 [5] *((const byte*) SCREEN#0+(byte/signed byte/word/signed word/dword/signed dword) 2) ← (const byte) num#0 -- _deref_pbuc1=vbuc2
lda #num
@ -336,8 +336,8 @@ FINAL SYMBOL TABLE
(label) @end
(byte*) SCREEN
(const byte*) SCREEN#0 SCREEN = ((byte*))(word/signed word/dword/signed dword) $400
(byte) char
(const byte) char#0 char = (byte) 'a'
(byte) ch
(const byte) ch#0 ch = (byte) 'a'
(void()) main()
(label) main::@1
(label) main::@return
@ -364,7 +364,7 @@ Score: 293
.pc = $80d "Program"
//SEG2 Global Constants & labels
.label SCREEN = $400
.const char = 'a'
.const ch = 'a'
.const num = 1
//SEG3 @begin
//SEG4 [1] phi from @begin to @1 [phi:@begin->@1]
@ -374,8 +374,8 @@ Score: 293
//SEG8 @end
//SEG9 main
main: {
//SEG10 [4] *((const byte*) SCREEN#0) ← (const byte) char#0 -- _deref_pbuc1=vbuc2
lda #char
//SEG10 [4] *((const byte*) SCREEN#0) ← (const byte) ch#0 -- _deref_pbuc1=vbuc2
lda #ch
sta SCREEN
//SEG11 [5] *((const byte*) SCREEN#0+(byte/signed byte/word/signed word/dword/signed dword) 2) ← (const byte) num#0 -- _deref_pbuc1=vbuc2
lda #num

View File

@ -3,8 +3,8 @@
(label) @end
(byte*) SCREEN
(const byte*) SCREEN#0 SCREEN = ((byte*))(word/signed word/dword/signed dword) $400
(byte) char
(const byte) char#0 char = (byte) 'a'
(byte) ch
(const byte) ch#0 ch = (byte) 'a'
(void()) main()
(label) main::@1
(label) main::@return

View File

@ -12,11 +12,11 @@ main: scope:[main] from @1
[5] call ln
to:main::@1
main::@1: scope:[main] from main
[6] (byte) char#2 ← ++ (byte) line#13
[6] (byte) ch#2 ← ++ (byte) line#13
[7] call ln
to:main::@2
main::@2: scope:[main] from main::@1
[8] (byte) char#4 ← ++ (byte) line#13
[8] (byte) ch#4 ← ++ (byte) line#13
[9] call ln
to:main::@3
main::@3: scope:[main] from main::@2

View File

@ -4,66 +4,66 @@ CONTROL FLOW GRAPH SSA
@begin: scope:[] from
(byte*) SCREEN#0 ← ((byte*)) (word/signed word/dword/signed dword) $400
(byte) line#0 ← (byte/signed byte/word/signed word/dword/signed dword) $40
(byte) char#0 ← (byte) line#0
(byte) ch#0 ← (byte) line#0
to:@2
main: scope:[main] from @2
(byte) char#16 ← phi( @2/(byte) char#17 )
(byte) ch#16 ← phi( @2/(byte) ch#17 )
(byte) line#15 ← phi( @2/(byte) line#16 )
call ln
to:main::@1
main::@1: scope:[main] from main
(byte) char#10 ← phi( main/(byte) char#8 )
(byte) ch#10 ← phi( main/(byte) ch#8 )
(byte) line#8 ← phi( main/(byte) line#6 )
(byte) line#1 ← (byte) line#8
(byte) char#1 ← (byte) char#10
(byte) char#2 ← ++ (byte) char#1
(byte) ch#1 ← (byte) ch#10
(byte) ch#2 ← ++ (byte) ch#1
call ln
to:main::@2
main::@2: scope:[main] from main::@1
(byte) char#11 ← phi( main::@1/(byte) char#8 )
(byte) ch#11 ← phi( main::@1/(byte) ch#8 )
(byte) line#9 ← phi( main::@1/(byte) line#6 )
(byte) line#2 ← (byte) line#9
(byte) char#3 ← (byte) char#11
(byte) char#4 ← ++ (byte) char#3
(byte) ch#3 ← (byte) ch#11
(byte) ch#4 ← ++ (byte) ch#3
call ln
to:main::@3
main::@3: scope:[main] from main::@2
(byte) char#12 ← phi( main::@2/(byte) char#8 )
(byte) ch#12 ← phi( main::@2/(byte) ch#8 )
(byte) line#10 ← phi( main::@2/(byte) line#6 )
(byte) line#3 ← (byte) line#10
(byte) char#5 ← (byte) char#12
*((byte*) SCREEN#0) ← (byte) char#5
(byte) ch#5 ← (byte) ch#12
*((byte*) SCREEN#0) ← (byte) ch#5
to:main::@return
main::@return: scope:[main] from main::@3
(byte) char#13 ← phi( main::@3/(byte) char#5 )
(byte) ch#13 ← phi( main::@3/(byte) ch#5 )
(byte) line#11 ← phi( main::@3/(byte) line#3 )
(byte) line#4 ← (byte) line#11
(byte) char#6 ← (byte) char#13
(byte) ch#6 ← (byte) ch#13
return
to:@return
ln: scope:[ln] from main main::@1 main::@2
(byte) line#12 ← phi( main/(byte) line#15 main::@1/(byte) line#1 main::@2/(byte) line#2 )
(byte/signed word/word/dword/signed dword~) ln::$0 ← (byte) line#12 + (byte/signed byte/word/signed word/dword/signed dword) 2
(byte) line#5 ← (byte/signed word/word/dword/signed dword~) ln::$0
(byte) char#7 ← (byte) line#5
(byte) ch#7 ← (byte) line#5
to:ln::@return
ln::@return: scope:[ln] from ln
(byte) char#14 ← phi( ln/(byte) char#7 )
(byte) ch#14 ← phi( ln/(byte) ch#7 )
(byte) line#13 ← phi( ln/(byte) line#5 )
(byte) line#6 ← (byte) line#13
(byte) char#8 ← (byte) char#14
(byte) ch#8 ← (byte) ch#14
return
to:@return
@2: scope:[] from @begin
(byte) char#17 ← phi( @begin/(byte) char#0 )
(byte) ch#17 ← phi( @begin/(byte) ch#0 )
(byte) line#16 ← phi( @begin/(byte) line#0 )
call main
to:@3
@3: scope:[] from @2
(byte) char#15 ← phi( @2/(byte) char#6 )
(byte) ch#15 ← phi( @2/(byte) ch#6 )
(byte) line#14 ← phi( @2/(byte) line#4 )
(byte) line#7 ← (byte) line#14
(byte) char#9 ← (byte) char#15
(byte) ch#9 ← (byte) ch#15
to:@end
@end: scope:[] from @3
@ -74,25 +74,25 @@ SYMBOL TABLE SSA
(label) @end
(byte*) SCREEN
(byte*) SCREEN#0
(byte) char
(byte) char#0
(byte) char#1
(byte) char#10
(byte) char#11
(byte) char#12
(byte) char#13
(byte) char#14
(byte) char#15
(byte) char#16
(byte) char#17
(byte) char#2
(byte) char#3
(byte) char#4
(byte) char#5
(byte) char#6
(byte) char#7
(byte) char#8
(byte) char#9
(byte) ch
(byte) ch#0
(byte) ch#1
(byte) ch#10
(byte) ch#11
(byte) ch#12
(byte) ch#13
(byte) ch#14
(byte) ch#15
(byte) ch#16
(byte) ch#17
(byte) ch#2
(byte) ch#3
(byte) ch#4
(byte) ch#5
(byte) ch#6
(byte) ch#7
(byte) ch#8
(byte) ch#9
(byte) line
(byte) line#0
(byte) line#1
@ -120,27 +120,27 @@ SYMBOL TABLE SSA
(label) main::@3
(label) main::@return
Alias (byte) line#0 = (byte) char#0 (byte) line#16 (byte) char#17
Alias (byte) line#0 = (byte) ch#0 (byte) line#16 (byte) ch#17
Alias (byte) line#1 = (byte) line#8
Alias (byte) char#1 = (byte) char#10
Alias (byte) ch#1 = (byte) ch#10
Alias (byte) line#2 = (byte) line#9
Alias (byte) char#11 = (byte) char#3
Alias (byte) ch#11 = (byte) ch#3
Alias (byte) line#10 = (byte) line#3 (byte) line#11 (byte) line#4
Alias (byte) char#12 = (byte) char#5 (byte) char#13 (byte) char#6
Alias (byte) line#13 = (byte) line#5 (byte/signed word/word/dword/signed dword~) ln::$0 (byte) char#7 (byte) char#14 (byte) line#6 (byte) char#8
Alias (byte) ch#12 = (byte) ch#5 (byte) ch#13 (byte) ch#6
Alias (byte) line#13 = (byte) line#5 (byte/signed word/word/dword/signed dword~) ln::$0 (byte) ch#7 (byte) ch#14 (byte) line#6 (byte) ch#8
Alias (byte) line#14 = (byte) line#7
Alias (byte) char#15 = (byte) char#9
Alias (byte) ch#15 = (byte) ch#9
Successful SSA optimization Pass2AliasElimination
Redundant Phi (byte) line#15 (byte) line#0
Redundant Phi (byte) char#16 (byte) line#0
Redundant Phi (byte) ch#16 (byte) line#0
Redundant Phi (byte) line#1 (byte) line#13
Redundant Phi (byte) char#1 (byte) line#13
Redundant Phi (byte) ch#1 (byte) line#13
Redundant Phi (byte) line#2 (byte) line#13
Redundant Phi (byte) char#11 (byte) line#13
Redundant Phi (byte) ch#11 (byte) line#13
Redundant Phi (byte) line#10 (byte) line#13
Redundant Phi (byte) char#12 (byte) line#13
Redundant Phi (byte) ch#12 (byte) line#13
Redundant Phi (byte) line#14 (byte) line#10
Redundant Phi (byte) char#15 (byte) char#12
Redundant Phi (byte) ch#15 (byte) ch#12
Successful SSA optimization Pass2RedundantPhiElimination
Constant (const byte*) SCREEN#0 = ((byte*))$400
Constant (const byte) line#0 = $40
@ -183,11 +183,11 @@ main: scope:[main] from @1
[5] call ln
to:main::@1
main::@1: scope:[main] from main
[6] (byte) char#2 ← ++ (byte) line#13
[6] (byte) ch#2 ← ++ (byte) line#13
[7] call ln
to:main::@2
main::@2: scope:[main] from main::@1
[8] (byte) char#4 ← ++ (byte) line#13
[8] (byte) ch#4 ← ++ (byte) line#13
[9] call ln
to:main::@3
main::@3: scope:[main] from main::@2
@ -207,9 +207,9 @@ ln::@return: scope:[ln] from ln
VARIABLE REGISTER WEIGHTS
(byte*) SCREEN
(byte) char
(byte) char#2 20.0
(byte) char#4 20.0
(byte) ch
(byte) ch#2 20.0
(byte) ch#4 20.0
(byte) line
(byte) line#12 6.0
(byte) line#13 1.714285714285714
@ -218,15 +218,15 @@ VARIABLE REGISTER WEIGHTS
Initial phi equivalence classes
[ line#12 line#13 ]
Added variable char#2 to zero page equivalence class [ char#2 ]
Added variable char#4 to zero page equivalence class [ char#4 ]
Added variable ch#2 to zero page equivalence class [ ch#2 ]
Added variable ch#4 to zero page equivalence class [ ch#4 ]
Complete equivalence classes
[ line#12 line#13 ]
[ char#2 ]
[ char#4 ]
[ ch#2 ]
[ ch#4 ]
Allocated zp ZP_BYTE:2 [ line#12 line#13 ]
Allocated zp ZP_BYTE:3 [ char#2 ]
Allocated zp ZP_BYTE:4 [ char#4 ]
Allocated zp ZP_BYTE:3 [ ch#2 ]
Allocated zp ZP_BYTE:4 [ ch#4 ]
INITIAL ASM
//SEG0 File Comments
@ -236,8 +236,8 @@ INITIAL ASM
.pc = $80d "Program"
//SEG2 Global Constants & labels
.label SCREEN = $400
.label char = 3
.label char_4 = 4
.label ch = 3
.label ch_4 = 4
.label line = 2
//SEG3 @begin
bbegin:
@ -267,10 +267,10 @@ main: {
jmp b1
//SEG14 main::@1
b1:
//SEG15 [6] (byte) char#2 ← ++ (byte) line#13 -- vbuz1=_inc_vbuz2
//SEG15 [6] (byte) ch#2 ← ++ (byte) line#13 -- vbuz1=_inc_vbuz2
ldy line
iny
sty char
sty ch
//SEG16 [7] call ln
//SEG17 [12] phi from main::@1 to ln [phi:main::@1->ln]
ln_from_b1:
@ -279,10 +279,10 @@ main: {
jmp b2
//SEG19 main::@2
b2:
//SEG20 [8] (byte) char#4 ← ++ (byte) line#13 -- vbuz1=_inc_vbuz2
//SEG20 [8] (byte) ch#4 ← ++ (byte) line#13 -- vbuz1=_inc_vbuz2
ldy line
iny
sty char_4
sty ch_4
//SEG21 [9] call ln
//SEG22 [12] phi from main::@2 to ln [phi:main::@2->ln]
ln_from_b2:
@ -316,15 +316,15 @@ ln: {
REGISTER UPLIFT POTENTIAL REGISTERS
Potential registers zp ZP_BYTE:2 [ line#12 line#13 ] : zp ZP_BYTE:2 , reg byte a , reg byte x , reg byte y ,
Potential registers zp ZP_BYTE:3 [ char#2 ] : zp ZP_BYTE:3 , reg byte a , reg byte x , reg byte y ,
Potential registers zp ZP_BYTE:4 [ char#4 ] : zp ZP_BYTE:4 , reg byte a , reg byte x , reg byte y ,
Potential registers zp ZP_BYTE:3 [ ch#2 ] : zp ZP_BYTE:3 , reg byte a , reg byte x , reg byte y ,
Potential registers zp ZP_BYTE:4 [ ch#4 ] : zp ZP_BYTE:4 , reg byte a , reg byte x , reg byte y ,
REGISTER UPLIFT SCOPES
Uplift Scope [] 20: zp ZP_BYTE:3 [ char#2 ] 20: zp ZP_BYTE:4 [ char#4 ] 7.71: zp ZP_BYTE:2 [ line#12 line#13 ]
Uplift Scope [] 20: zp ZP_BYTE:3 [ ch#2 ] 20: zp ZP_BYTE:4 [ ch#4 ] 7.71: zp ZP_BYTE:2 [ line#12 line#13 ]
Uplift Scope [main]
Uplift Scope [ln]
Uplifting [] best 75 combination reg byte x [ char#2 ] reg byte x [ char#4 ] reg byte a [ line#12 line#13 ]
Uplifting [] best 75 combination reg byte x [ ch#2 ] reg byte x [ ch#4 ] reg byte a [ line#12 line#13 ]
Uplifting [main] best 75 combination
Uplifting [ln] best 75 combination
@ -363,7 +363,7 @@ main: {
jmp b1
//SEG14 main::@1
b1:
//SEG15 [6] (byte) char#2 ← ++ (byte) line#13 -- vbuxx=_inc_vbuaa
//SEG15 [6] (byte) ch#2 ← ++ (byte) line#13 -- vbuxx=_inc_vbuaa
tax
inx
//SEG16 [7] call ln
@ -374,7 +374,7 @@ main: {
jmp b2
//SEG19 main::@2
b2:
//SEG20 [8] (byte) char#4 ← ++ (byte) line#13 -- vbuxx=_inc_vbuaa
//SEG20 [8] (byte) ch#4 ← ++ (byte) line#13 -- vbuxx=_inc_vbuaa
tax
inx
//SEG21 [9] call ln
@ -441,9 +441,9 @@ FINAL SYMBOL TABLE
(label) @end
(byte*) SCREEN
(const byte*) SCREEN#0 SCREEN = ((byte*))(word/signed word/dword/signed dword) $400
(byte) char
(byte) char#2 reg byte x 20.0
(byte) char#4 reg byte x 20.0
(byte) ch
(byte) ch#2 reg byte x 20.0
(byte) ch#4 reg byte x 20.0
(byte) line
(byte) line#12 reg byte a 6.0
(byte) line#13 reg byte a 1.714285714285714
@ -456,8 +456,8 @@ FINAL SYMBOL TABLE
(label) main::@return
reg byte a [ line#12 line#13 ]
reg byte x [ char#2 ]
reg byte x [ char#4 ]
reg byte x [ ch#2 ]
reg byte x [ ch#4 ]
FINAL ASSEMBLER
@ -485,7 +485,7 @@ main: {
lda #$40
jsr ln
//SEG14 main::@1
//SEG15 [6] (byte) char#2 ← ++ (byte) line#13 -- vbuxx=_inc_vbuaa
//SEG15 [6] (byte) ch#2 ← ++ (byte) line#13 -- vbuxx=_inc_vbuaa
tax
inx
//SEG16 [7] call ln
@ -493,7 +493,7 @@ main: {
//SEG18 [12] phi (byte) line#12 = (byte) line#13 [phi:main::@1->ln#0] -- register_copy
jsr ln
//SEG19 main::@2
//SEG20 [8] (byte) char#4 ← ++ (byte) line#13 -- vbuxx=_inc_vbuaa
//SEG20 [8] (byte) ch#4 ← ++ (byte) line#13 -- vbuxx=_inc_vbuaa
tax
inx
//SEG21 [9] call ln

View File

@ -3,9 +3,9 @@
(label) @end
(byte*) SCREEN
(const byte*) SCREEN#0 SCREEN = ((byte*))(word/signed word/dword/signed dword) $400
(byte) char
(byte) char#2 reg byte x 20.0
(byte) char#4 reg byte x 20.0
(byte) ch
(byte) ch#2 reg byte x 20.0
(byte) ch#4 reg byte x 20.0
(byte) line
(byte) line#12 reg byte a 6.0
(byte) line#13 reg byte a 1.714285714285714
@ -18,5 +18,5 @@
(label) main::@return
reg byte a [ line#12 line#13 ]
reg byte x [ char#2 ]
reg byte x [ char#4 ]
reg byte x [ ch#2 ]
reg byte x [ ch#4 ]