1
0
mirror of https://gitlab.com/camelot/kickc.git synced 2024-06-29 09:29:31 +00:00

Added complex test for function pointers. Closes #121

This commit is contained in:
jespergravgaard 2021-08-01 23:27:59 +02:00
parent f2f9b79ece
commit 9bcda2cb67
43 changed files with 5528 additions and 2184 deletions

View File

@ -2414,6 +2414,8 @@ public class Pass0GenerateStatementSequence extends KickCParserBaseVisitor<Objec
result = addIntermediateVar().getRef();
addStatement(new StatementCallPointer((LValue) result, procedurePointer, parameters, new StatementSource(ctx), ensureUnusedComments(getCommentsSymbol(ctx))));
consumeExpr(procedurePointer);
Label afterCallLabel = getCurrentScope().addLabelIntermediate();
addStatement(new StatementLabel(afterCallLabel.getRef(), new StatementSource(ctx), Comment.NO_COMMENTS));
}
for(RValue parameter : parameters) {
consumeExpr(parameter);

View File

@ -1,5 +1,6 @@
package dk.camelot64.kickc.passes;
import dk.camelot64.kickc.model.CompileError;
import dk.camelot64.kickc.model.ControlFlowBlock;
import dk.camelot64.kickc.model.Program;
import dk.camelot64.kickc.model.statements.Statement;
@ -64,6 +65,8 @@ public class Pass2ConstantCallPointerIdentification extends Pass2SsaOptimization
*/
private void replacePointerCall(StatementCallExecute callPointer, ProcedureRef constProcedureRef, ControlFlowBlock block) {
callPointer.setProcedure(constProcedureRef);
if(block.getCallSuccessor()!=null)
throw new CompileError("Internal error! Block has two calls!", callPointer);
block.setCallSuccessor(constProcedureRef.getLabelRef());
final Procedure procedure = getScope().getProcedure(constProcedureRef);
procedure.setCallingConvention(Procedure.CallingConvention.STACK_CALL);

View File

@ -3156,6 +3156,11 @@ public class TestProgramsFast extends TestPrograms {
compileAndCompare("ternary-1.c");
}
@Test
public void testFunctionPointerAdvanced1() throws IOException {
compileAndCompare("function-pointer-advanced-1.c");
}
@Test
public void testPointerPointer3() throws IOException {
compileAndCompare("pointer-pointer-3.c");

View File

@ -0,0 +1,79 @@
// Tests calling advanced functions pointers (with multiple parameters and a return value)
char INPUT[] = { 2, 1, 3, 4, 6, 5 };
char sum(char a, char b);
void cout(char c);
void ln();
void print(char i);
__ma char* line = (char*)0x400;
char idx = 0;
void main() {
for(char i=0;i<sizeof(INPUT);i++) {
print(INPUT[i]);
cout(' ');
}
ln();
exec(&sum);
ln();
exec(&min);
ln();
exec(&max);
ln();
exec(&xor);
}
void exec( char (*collect)(char,char)) {
cout(' ');
cout(' ');
cout(' ');
char out = INPUT[0];
for(char i=1;i<sizeof(INPUT);i++) {
out = (*collect)(out,INPUT[i]);
print(out);
cout(' ');
}
}
char sum(char a, char b) {
return a+b;
}
char max(char a, char b) {
if(a>b)
return a;
else
return b;
}
char min(char a, char b) {
if(a<b)
return a;
else
return b;
}
char xor(char a, char b) {
return a^b;
}
void cout(char c) {
line[idx++] = c;
}
void ln() {
line += 40;
idx = 0;
}
char HEX[] = "0123456789abcdef";
void print(char i) {
cout(HEX[i>>4]);
cout(HEX[i&0x0f]);
}

View File

@ -4,11 +4,13 @@ main: scope:[main] from
[0] phi()
[1] callexecute *musicInit
to:main::@1
main::@1: scope:[main] from main main::@1 main::@2
main::@1: scope:[main] from main main::@1 main::@3
[2] if(*((byte*)VICII+OFFSET_STRUCT_MOS6569_VICII_RASTER)!=$fd) goto main::@1
to:main::@2
main::@2: scope:[main] from main::@1
[3] *((byte*)VICII+OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR) = ++ *((byte*)VICII+OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR)
[4] callexecute *musicPlay
to:main::@3
main::@3: scope:[main] from main::@2
[5] *((byte*)VICII+OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR) = -- *((byte*)VICII+OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR)
to:main::@1

View File

@ -9,17 +9,19 @@ void main()
main: scope:[main] from __start::@1
callexecute *musicInit
to:main::@1
main::@1: scope:[main] from main main::@1 main::@2
main::@1: scope:[main] from main main::@1 main::@3
main::$1 = *((byte*)VICII+OFFSET_STRUCT_MOS6569_VICII_RASTER) != $fd
if(main::$1) goto main::@1
to:main::@2
main::@2: scope:[main] from main::@1
*((byte*)VICII+OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR) = ++ *((byte*)VICII+OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR)
callexecute *musicPlay
to:main::@3
main::@3: scope:[main] from main::@2
*((byte*)VICII+OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR) = -- *((byte*)VICII+OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR)
if(true) goto main::@1
to:main::@return
main::@return: scope:[main] from main::@2
main::@return: scope:[main] from main::@3
return
to:@return
@ -90,12 +92,14 @@ main: scope:[main] from
[0] phi()
[1] callexecute *musicInit
to:main::@1
main::@1: scope:[main] from main main::@1 main::@2
main::@1: scope:[main] from main main::@1 main::@3
[2] if(*((byte*)VICII+OFFSET_STRUCT_MOS6569_VICII_RASTER)!=$fd) goto main::@1
to:main::@2
main::@2: scope:[main] from main::@1
[3] *((byte*)VICII+OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR) = ++ *((byte*)VICII+OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR)
[4] callexecute *musicPlay
to:main::@3
main::@3: scope:[main] from main::@2
[5] *((byte*)VICII+OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR) = -- *((byte*)VICII+OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR)
to:main::@1
@ -117,11 +121,11 @@ Uplift Scope [MOS6581_SID]
Uplift Scope [main]
Uplift Scope []
Uplifting [MOS6526_CIA] best 1369 combination
Uplifting [MOS6569_VICII] best 1369 combination
Uplifting [MOS6581_SID] best 1369 combination
Uplifting [main] best 1369 combination
Uplifting [] best 1369 combination
Uplifting [MOS6526_CIA] best 1399 combination
Uplifting [MOS6569_VICII] best 1399 combination
Uplifting [MOS6581_SID] best 1399 combination
Uplifting [main] best 1399 combination
Uplifting [] best 1399 combination
ASSEMBLER BEFORE OPTIMIZATION
// File Comments
@ -173,6 +177,9 @@ main: {
// [4] callexecute *musicPlay
// Play the music
jsr musicPlay
jmp __b3
// main::@3
__b3:
// [5] *((byte*)VICII+OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR) = -- *((byte*)VICII+OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR) -- _deref_pbuc1=_dec__deref_pbuc1
dec VICII+OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR
jmp __b1
@ -189,8 +196,10 @@ MUSIC:
ASSEMBLER OPTIMIZATIONS
Removing instruction jmp __b1
Removing instruction jmp __b2
Removing instruction jmp __b3
Succesful ASM optimization Pass5NextJumpElimination
Removing instruction __b2:
Removing instruction __b3:
Succesful ASM optimization Pass5UnusedLabelElimination
FINAL SYMBOL TABLE
@ -259,6 +268,7 @@ main: {
// [4] callexecute *musicPlay
// Play the music
jsr musicPlay
// main::@3
// (VICII->BORDER_COLOR)--;
// [5] *((byte*)VICII+OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR) = -- *((byte*)VICII+OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR) -- _deref_pbuc1=_dec__deref_pbuc1
dec VICII+OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR

View File

@ -3,10 +3,12 @@ __interrupt(rom_sys_c64) void irq_play()
irq_play: scope:[irq_play] from
[0] *((byte*)VICII+OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR) = ++ *((byte*)VICII+OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR)
[1] callexecute *musicPlay
to:irq_play::@1
irq_play::@1: scope:[irq_play] from irq_play
[2] *((byte*)VICII+OFFSET_STRUCT_MOS6569_VICII_IRQ_STATUS) = IRQ_RASTER
[3] *((byte*)VICII+OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR) = -- *((byte*)VICII+OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR)
to:irq_play::@return
irq_play::@return: scope:[irq_play] from irq_play
irq_play::@return: scope:[irq_play] from irq_play::@1
[4] return
to:@return
@ -14,6 +16,8 @@ void main()
main: scope:[main] from
asm { sei }
[6] callexecute *musicInit
to:main::@1
main::@1: scope:[main] from main
[7] *((byte*)CIA1+OFFSET_STRUCT_MOS6526_CIA_INTERRUPT) = CIA_INTERRUPT_CLEAR
[8] *((byte*)VICII+OFFSET_STRUCT_MOS6569_VICII_CONTROL1) = *((byte*)VICII+OFFSET_STRUCT_MOS6569_VICII_CONTROL1) & $7f
[9] *((byte*)VICII+OFFSET_STRUCT_MOS6569_VICII_RASTER) = $fd
@ -21,6 +25,6 @@ main: scope:[main] from
[11] *KERNEL_IRQ = &irq_play
asm { cli }
to:main::@return
main::@return: scope:[main] from main
main::@return: scope:[main] from main::@1
[13] return
to:@return

View File

@ -10,6 +10,8 @@ void main()
main: scope:[main] from __start::@1
asm { sei }
callexecute *musicInit
to:main::@1
main::@1: scope:[main] from main
*((byte*)CIA1+OFFSET_STRUCT_MOS6526_CIA_INTERRUPT) = CIA_INTERRUPT_CLEAR
*((byte*)VICII+OFFSET_STRUCT_MOS6569_VICII_CONTROL1) = *((byte*)VICII+OFFSET_STRUCT_MOS6569_VICII_CONTROL1) & $7f
*((byte*)VICII+OFFSET_STRUCT_MOS6569_VICII_RASTER) = $fd
@ -17,7 +19,7 @@ main: scope:[main] from __start::@1
*KERNEL_IRQ = &irq_play
asm { cli }
to:main::@return
main::@return: scope:[main] from main
main::@return: scope:[main] from main::@1
return
to:@return
@ -25,10 +27,12 @@ __interrupt(rom_sys_c64) void irq_play()
irq_play: scope:[irq_play] from
*((byte*)VICII+OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR) = ++ *((byte*)VICII+OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR)
callexecute *musicPlay
to:irq_play::@1
irq_play::@1: scope:[irq_play] from irq_play
*((byte*)VICII+OFFSET_STRUCT_MOS6569_VICII_IRQ_STATUS) = IRQ_RASTER
*((byte*)VICII+OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR) = -- *((byte*)VICII+OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR)
to:irq_play::@return
irq_play::@return: scope:[irq_play] from irq_play
irq_play::@return: scope:[irq_play] from irq_play::@1
return
to:@return
@ -106,10 +110,12 @@ __interrupt(rom_sys_c64) void irq_play()
irq_play: scope:[irq_play] from
[0] *((byte*)VICII+OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR) = ++ *((byte*)VICII+OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR)
[1] callexecute *musicPlay
to:irq_play::@1
irq_play::@1: scope:[irq_play] from irq_play
[2] *((byte*)VICII+OFFSET_STRUCT_MOS6569_VICII_IRQ_STATUS) = IRQ_RASTER
[3] *((byte*)VICII+OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR) = -- *((byte*)VICII+OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR)
to:irq_play::@return
irq_play::@return: scope:[irq_play] from irq_play
irq_play::@return: scope:[irq_play] from irq_play::@1
[4] return
to:@return
@ -117,6 +123,8 @@ void main()
main: scope:[main] from
asm { sei }
[6] callexecute *musicInit
to:main::@1
main::@1: scope:[main] from main
[7] *((byte*)CIA1+OFFSET_STRUCT_MOS6526_CIA_INTERRUPT) = CIA_INTERRUPT_CLEAR
[8] *((byte*)VICII+OFFSET_STRUCT_MOS6569_VICII_CONTROL1) = *((byte*)VICII+OFFSET_STRUCT_MOS6569_VICII_CONTROL1) & $7f
[9] *((byte*)VICII+OFFSET_STRUCT_MOS6569_VICII_RASTER) = $fd
@ -124,7 +132,7 @@ main: scope:[main] from
[11] *KERNEL_IRQ = &irq_play
asm { cli }
to:main::@return
main::@return: scope:[main] from main
main::@return: scope:[main] from main::@1
[13] return
to:@return
@ -153,12 +161,12 @@ Uplift Scope [main]
Uplift Scope [irq_play]
Uplift Scope []
Uplifting [MOS6526_CIA] best 116 combination
Uplifting [MOS6569_VICII] best 116 combination
Uplifting [MOS6581_SID] best 116 combination
Uplifting [main] best 116 combination
Uplifting [irq_play] best 116 combination
Uplifting [] best 116 combination
Uplifting [MOS6526_CIA] best 122 combination
Uplifting [MOS6569_VICII] best 122 combination
Uplifting [MOS6581_SID] best 122 combination
Uplifting [main] best 122 combination
Uplifting [irq_play] best 122 combination
Uplifting [] best 122 combination
ASSEMBLER BEFORE OPTIMIZATION
// File Comments
@ -215,6 +223,9 @@ irq_play: {
// [1] callexecute *musicPlay
// Play SID
jsr musicPlay
jmp __b1
// irq_play::@1
__b1:
// [2] *((byte*)VICII+OFFSET_STRUCT_MOS6569_VICII_IRQ_STATUS) = IRQ_RASTER -- _deref_pbuc1=vbuc2
// Acknowledge the IRQ
lda #IRQ_RASTER
@ -235,6 +246,9 @@ main: {
sei
// [6] callexecute *musicInit
jsr musicInit
jmp __b1
// main::@1
__b1:
// [7] *((byte*)CIA1+OFFSET_STRUCT_MOS6526_CIA_INTERRUPT) = CIA_INTERRUPT_CLEAR -- _deref_pbuc1=vbuc2
// Disable CIA 1 Timer IRQ
lda #CIA_INTERRUPT_CLEAR
@ -275,10 +289,14 @@ MUSIC:
ASSEMBLER OPTIMIZATIONS
Removing instruction jmp __b1
Removing instruction jmp __breturn
Removing instruction jmp __b1
Removing instruction jmp __breturn
Succesful ASM optimization Pass5NextJumpElimination
Removing instruction __b1:
Removing instruction __breturn:
Removing instruction __b1:
Removing instruction __breturn:
Succesful ASM optimization Pass5UnusedLabelElimination
@ -363,6 +381,7 @@ irq_play: {
// [1] callexecute *musicPlay
// Play SID
jsr musicPlay
// irq_play::@1
// VICII->IRQ_STATUS = IRQ_RASTER
// [2] *((byte*)VICII+OFFSET_STRUCT_MOS6569_VICII_IRQ_STATUS) = IRQ_RASTER -- _deref_pbuc1=vbuc2
// Acknowledge the IRQ
@ -386,6 +405,7 @@ main: {
// (*musicInit)()
// [6] callexecute *musicInit
jsr musicInit
// main::@1
// CIA1->INTERRUPT = CIA_INTERRUPT_CLEAR
// [7] *((byte*)CIA1+OFFSET_STRUCT_MOS6526_CIA_INTERRUPT) = CIA_INTERRUPT_CLEAR -- _deref_pbuc1=vbuc2
// Disable CIA 1 Timer IRQ

View File

@ -106,10 +106,10 @@ irq: {
// char raster = VICII->RASTER
// Wait for the next raster line
lda VICII+OFFSET_STRUCT_MOS6569_VICII_RASTER
__b1:
__b2:
// while(VICII->RASTER==raster)
cmp VICII+OFFSET_STRUCT_MOS6569_VICII_RASTER
beq __b1
beq __b2
// (VICII->BORDER_COLOR)--;
dec VICII+OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR
// }
@ -206,24 +206,24 @@ main: {
// Enable IRQ
cli
ldx #0
__b1:
__b2:
// MUSIC[mem_destroy_i++]++;
inc MUSIC,x
inx
ldy #0
// Show unmapped MUSIC memory
__b2:
__b3:
// for(char i=0;i<240;i++)
cpy #$f0
bcc __b3
jmp __b1
__b3:
bcc __b4
jmp __b2
__b4:
// DEFAULT_SCREEN[i] = MUSIC[i]
lda MUSIC,y
sta DEFAULT_SCREEN,y
// for(char i=0;i<240;i++)
iny
jmp __b2
jmp __b3
}
// Remap a single 8K memory block in the 64K address space of the 6502 to point somewhere else in the first 1MB memory space of the MEGA65.
// All the other 8K memory blocks will not be mapped and will point to their own address in the lowest 64K of the MEGA65 memory.

View File

@ -4,116 +4,122 @@ irq: scope:[irq] from
[0] *((byte*)VICII+OFFSET_STRUCT_MOS6569_VICII_IRQ_STATUS) = IRQ_RASTER
[1] *((byte*)VICII+OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR) = ++ *((byte*)VICII+OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR)
[2] call memoryRemapBlock
to:irq::@3
irq::@3: scope:[irq] from irq
to:irq::@4
irq::@4: scope:[irq] from irq
[3] phi()
[4] callexecute *musicPlay
[5] call memoryRemap
to:irq::@4
irq::@4: scope:[irq] from irq::@3
[6] irq::raster#0 = *((byte*)VICII+OFFSET_STRUCT_MOS6569_VICII_RASTER)
to:irq::@1
irq::@1: scope:[irq] from irq::@1 irq::@4
[7] if(*((byte*)VICII+OFFSET_STRUCT_MOS6569_VICII_RASTER)==irq::raster#0) goto irq::@1
irq::@1: scope:[irq] from irq::@4
[5] phi()
[6] call memoryRemap
to:irq::@5
irq::@5: scope:[irq] from irq::@1
[7] irq::raster#0 = *((byte*)VICII+OFFSET_STRUCT_MOS6569_VICII_RASTER)
to:irq::@2
irq::@2: scope:[irq] from irq::@1
[8] *((byte*)VICII+OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR) = -- *((byte*)VICII+OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR)
irq::@2: scope:[irq] from irq::@2 irq::@5
[8] if(*((byte*)VICII+OFFSET_STRUCT_MOS6569_VICII_RASTER)==irq::raster#0) goto irq::@2
to:irq::@3
irq::@3: scope:[irq] from irq::@2
[9] *((byte*)VICII+OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR) = -- *((byte*)VICII+OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR)
to:irq::@return
irq::@return: scope:[irq] from irq::@2
[9] return
irq::@return: scope:[irq] from irq::@3
[10] return
to:@return
void main()
main: scope:[main] from
asm { sei }
[11] call memoryRemap
to:main::@4
main::@4: scope:[main] from main
[12] *((byte*)VICIII+OFFSET_STRUCT_MOS4569_VICIII_KEY) = $47
[13] *((byte*)VICIII+OFFSET_STRUCT_MOS4569_VICIII_KEY) = $53
[14] *((byte*)VICIV+OFFSET_STRUCT_MEGA65_VICIV_CONTROLB) = *((byte*)VICIV+OFFSET_STRUCT_MEGA65_VICIV_CONTROLB) | $40
[15] *((byte*)VICIV+OFFSET_STRUCT_MEGA65_VICIV_CONTROLC) = *((byte*)VICIV+OFFSET_STRUCT_MEGA65_VICIV_CONTROLC) | $40
[16] *PROCPORT_DDR = PROCPORT_DDR_MEMORY_MASK
[17] *PROCPORT = PROCPORT_RAM_IO
[18] *((byte*)VICIV+OFFSET_STRUCT_MEGA65_VICIV_SIDBDRWD_LO) = 1
[19] call memcpy_dma4
[12] call memoryRemap
to:main::@5
main::@5: scope:[main] from main::@4
[20] phi()
[21] call memoryRemapBlock
main::@5: scope:[main] from main
[13] *((byte*)VICIII+OFFSET_STRUCT_MOS4569_VICIII_KEY) = $47
[14] *((byte*)VICIII+OFFSET_STRUCT_MOS4569_VICIII_KEY) = $53
[15] *((byte*)VICIV+OFFSET_STRUCT_MEGA65_VICIV_CONTROLB) = *((byte*)VICIV+OFFSET_STRUCT_MEGA65_VICIV_CONTROLB) | $40
[16] *((byte*)VICIV+OFFSET_STRUCT_MEGA65_VICIV_CONTROLC) = *((byte*)VICIV+OFFSET_STRUCT_MEGA65_VICIV_CONTROLC) | $40
[17] *PROCPORT_DDR = PROCPORT_DDR_MEMORY_MASK
[18] *PROCPORT = PROCPORT_RAM_IO
[19] *((byte*)VICIV+OFFSET_STRUCT_MEGA65_VICIV_SIDBDRWD_LO) = 1
[20] call memcpy_dma4
to:main::@6
main::@6: scope:[main] from main::@5
asm { lda#0 }
[23] callexecute *musicInit
[24] call memoryRemap
[21] phi()
[22] call memoryRemapBlock
to:main::@7
main::@7: scope:[main] from main::@6
[25] *((byte*)CIA1+OFFSET_STRUCT_MOS6526_CIA_INTERRUPT) = CIA_INTERRUPT_CLEAR
[26] *((byte*)VICII+OFFSET_STRUCT_MOS6569_VICII_RASTER) = $ff
[27] *((byte*)VICII+OFFSET_STRUCT_MOS6569_VICII_CONTROL1) = *((byte*)VICII+OFFSET_STRUCT_MOS6569_VICII_CONTROL1) & $7f
[28] *((byte*)VICII+OFFSET_STRUCT_MOS6569_VICII_IRQ_ENABLE) = IRQ_RASTER
[29] *HARDWARE_IRQ = &irq
asm { lda#0 }
[24] callexecute *musicInit
to:main::@1
main::@1: scope:[main] from main::@7
[25] phi()
[26] call memoryRemap
to:main::@8
main::@8: scope:[main] from main::@1
[27] *((byte*)CIA1+OFFSET_STRUCT_MOS6526_CIA_INTERRUPT) = CIA_INTERRUPT_CLEAR
[28] *((byte*)VICII+OFFSET_STRUCT_MOS6569_VICII_RASTER) = $ff
[29] *((byte*)VICII+OFFSET_STRUCT_MOS6569_VICII_CONTROL1) = *((byte*)VICII+OFFSET_STRUCT_MOS6569_VICII_CONTROL1) & $7f
[30] *((byte*)VICII+OFFSET_STRUCT_MOS6569_VICII_IRQ_ENABLE) = IRQ_RASTER
[31] *HARDWARE_IRQ = &irq
asm { cli }
to:main::@1
main::@1: scope:[main] from main::@2 main::@7
[31] main::mem_destroy_i#2 = phi( main::@2/main::mem_destroy_i#1, main::@7/0 )
[32] MUSIC[main::mem_destroy_i#2] = ++ MUSIC[main::mem_destroy_i#2]
[33] main::mem_destroy_i#1 = ++ main::mem_destroy_i#2
to:main::@2
main::@2: scope:[main] from main::@1 main::@3
[34] main::i#2 = phi( main::@1/0, main::@3/main::i#1 )
[35] if(main::i#2<$f0) goto main::@3
to:main::@1
main::@3: scope:[main] from main::@2
[36] DEFAULT_SCREEN[main::i#2] = MUSIC[main::i#2]
[37] main::i#1 = ++ main::i#2
main::@2: scope:[main] from main::@3 main::@8
[33] main::mem_destroy_i#2 = phi( main::@3/main::mem_destroy_i#1, main::@8/0 )
[34] MUSIC[main::mem_destroy_i#2] = ++ MUSIC[main::mem_destroy_i#2]
[35] main::mem_destroy_i#1 = ++ main::mem_destroy_i#2
to:main::@3
main::@3: scope:[main] from main::@2 main::@4
[36] main::i#2 = phi( main::@2/0, main::@4/main::i#1 )
[37] if(main::i#2<$f0) goto main::@4
to:main::@2
main::@4: scope:[main] from main::@3
[38] DEFAULT_SCREEN[main::i#2] = MUSIC[main::i#2]
[39] main::i#1 = ++ main::i#2
to:main::@3
void memoryRemapBlock(byte memoryRemapBlock::blockPage , word memoryRemapBlock::memoryPage)
memoryRemapBlock: scope:[memoryRemapBlock] from irq main::@5
[38] phi()
[39] call memoryRemap
memoryRemapBlock: scope:[memoryRemapBlock] from irq main::@6
[40] phi()
[41] call memoryRemap
to:memoryRemapBlock::@return
memoryRemapBlock::@return: scope:[memoryRemapBlock] from memoryRemapBlock
[40] return
[42] return
to:@return
void memoryRemap(byte memoryRemap::remapBlocks , word memoryRemap::lowerPageOffset , word memoryRemap::upperPageOffset)
memoryRemap: scope:[memoryRemap] from irq::@3 main main::@6 memoryRemapBlock
[41] memoryRemap::upperPageOffset#4 = phi( irq::@3/0, main/0, main::@6/0, memoryRemapBlock/memoryRemapBlock::pageOffset#0 )
[41] memoryRemap::remapBlocks#4 = phi( irq::@3/0, main/0, main::@6/0, memoryRemapBlock/memoryRemapBlock::blockBits#0 )
[41] memoryRemap::lowerPageOffset#4 = phi( irq::@3/0, main/0, main::@6/0, memoryRemapBlock/memoryRemapBlock::pageOffset#0 )
[42] memoryRemap::aVal = byte0 memoryRemap::lowerPageOffset#4
[43] memoryRemap::$1 = memoryRemap::remapBlocks#4 << 4
[44] memoryRemap::$2 = byte1 memoryRemap::lowerPageOffset#4
[45] memoryRemap::$3 = memoryRemap::$2 & $f
[46] memoryRemap::xVal = memoryRemap::$1 | memoryRemap::$3
[47] memoryRemap::yVal = byte0 memoryRemap::upperPageOffset#4
[48] memoryRemap::$6 = memoryRemap::remapBlocks#4 & $f0
[49] memoryRemap::$7 = byte1 memoryRemap::upperPageOffset#4
[50] memoryRemap::$8 = memoryRemap::$7 & $f
[51] memoryRemap::zVal = memoryRemap::$6 | memoryRemap::$8
memoryRemap: scope:[memoryRemap] from irq::@1 main main::@1 memoryRemapBlock
[43] memoryRemap::upperPageOffset#4 = phi( irq::@1/0, main/0, main::@1/0, memoryRemapBlock/memoryRemapBlock::pageOffset#0 )
[43] memoryRemap::remapBlocks#4 = phi( irq::@1/0, main/0, main::@1/0, memoryRemapBlock/memoryRemapBlock::blockBits#0 )
[43] memoryRemap::lowerPageOffset#4 = phi( irq::@1/0, main/0, main::@1/0, memoryRemapBlock/memoryRemapBlock::pageOffset#0 )
[44] memoryRemap::aVal = byte0 memoryRemap::lowerPageOffset#4
[45] memoryRemap::$1 = memoryRemap::remapBlocks#4 << 4
[46] memoryRemap::$2 = byte1 memoryRemap::lowerPageOffset#4
[47] memoryRemap::$3 = memoryRemap::$2 & $f
[48] memoryRemap::xVal = memoryRemap::$1 | memoryRemap::$3
[49] memoryRemap::yVal = byte0 memoryRemap::upperPageOffset#4
[50] memoryRemap::$6 = memoryRemap::remapBlocks#4 & $f0
[51] memoryRemap::$7 = byte1 memoryRemap::upperPageOffset#4
[52] memoryRemap::$8 = memoryRemap::$7 & $f
[53] memoryRemap::zVal = memoryRemap::$6 | memoryRemap::$8
asm { ldaaVal ldxxVal ldyyVal ldzzVal map eom }
to:memoryRemap::@return
memoryRemap::@return: scope:[memoryRemap] from memoryRemap
[53] return
[55] return
to:@return
void memcpy_dma4(byte memcpy_dma4::dest_bank , void* memcpy_dma4::dest , byte memcpy_dma4::src_bank , void* memcpy_dma4::src , word memcpy_dma4::num)
memcpy_dma4: scope:[memcpy_dma4] from main::@4
[54] memcpy_dma4::dmaMode#0 = *((byte*)DMA+OFFSET_STRUCT_F018_DMAGIC_EN018B)
[55] *((word*)&memcpy_dma_command4+OFFSET_STRUCT_DMA_LIST_F018B_COUNT) = memcpy_dma4::num#0
[56] *((byte*)&memcpy_dma_command4+OFFSET_STRUCT_DMA_LIST_F018B_SRC_BANK) = memcpy_dma4::src_bank#0
[57] *((byte**)&memcpy_dma_command4+OFFSET_STRUCT_DMA_LIST_F018B_SRC) = (byte*)memcpy_dma4::src#0
[58] *((byte*)&memcpy_dma_command4+OFFSET_STRUCT_DMA_LIST_F018B_DEST_BANK) = memcpy_dma4::dest_bank#0
[59] *((byte**)&memcpy_dma_command4+OFFSET_STRUCT_DMA_LIST_F018B_DEST) = (byte*)memcpy_dma4::dest#0
[60] *((byte*)DMA+OFFSET_STRUCT_F018_DMAGIC_EN018B) = 1
[61] *((byte*)DMA+OFFSET_STRUCT_F018_DMAGIC_ADDRMB) = 0
[62] *((byte*)DMA+OFFSET_STRUCT_F018_DMAGIC_ADDRBANK) = 0
[63] *((byte*)DMA+OFFSET_STRUCT_F018_DMAGIC_ADDRMSB) = byte1 &memcpy_dma_command4
[64] *((byte*)DMA) = byte0 &memcpy_dma_command4
[65] *((byte*)DMA+OFFSET_STRUCT_F018_DMAGIC_EN018B) = memcpy_dma4::dmaMode#0
memcpy_dma4: scope:[memcpy_dma4] from main::@5
[56] memcpy_dma4::dmaMode#0 = *((byte*)DMA+OFFSET_STRUCT_F018_DMAGIC_EN018B)
[57] *((word*)&memcpy_dma_command4+OFFSET_STRUCT_DMA_LIST_F018B_COUNT) = memcpy_dma4::num#0
[58] *((byte*)&memcpy_dma_command4+OFFSET_STRUCT_DMA_LIST_F018B_SRC_BANK) = memcpy_dma4::src_bank#0
[59] *((byte**)&memcpy_dma_command4+OFFSET_STRUCT_DMA_LIST_F018B_SRC) = (byte*)memcpy_dma4::src#0
[60] *((byte*)&memcpy_dma_command4+OFFSET_STRUCT_DMA_LIST_F018B_DEST_BANK) = memcpy_dma4::dest_bank#0
[61] *((byte**)&memcpy_dma_command4+OFFSET_STRUCT_DMA_LIST_F018B_DEST) = (byte*)memcpy_dma4::dest#0
[62] *((byte*)DMA+OFFSET_STRUCT_F018_DMAGIC_EN018B) = 1
[63] *((byte*)DMA+OFFSET_STRUCT_F018_DMAGIC_ADDRMB) = 0
[64] *((byte*)DMA+OFFSET_STRUCT_F018_DMAGIC_ADDRBANK) = 0
[65] *((byte*)DMA+OFFSET_STRUCT_F018_DMAGIC_ADDRMSB) = byte1 &memcpy_dma_command4
[66] *((byte*)DMA) = byte0 &memcpy_dma_command4
[67] *((byte*)DMA+OFFSET_STRUCT_F018_DMAGIC_EN018B) = memcpy_dma4::dmaMode#0
to:memcpy_dma4::@return
memcpy_dma4::@return: scope:[memcpy_dma4] from memcpy_dma4
[66] return
[68] return
to:@return

File diff suppressed because it is too large Load Diff

View File

@ -148,12 +148,12 @@ irq: {
// Generate Raster Bars and more
ldx.z sin_idx
ldz #0
__b1:
__b2:
// for(char line=0;line!=RASTER_LINES;line++)
cpz #RASTER_LINES
beq !__b2+
jmp __b2
!__b2:
beq !__b3+
jmp __b3
!__b3:
// (*songPlay)()
// play music
jsr songPlay
@ -161,37 +161,37 @@ irq: {
// Set up colors behind logo, scroll and greets
ldy.z sin_idx
ldx #0
__b16:
__b17:
// for(char i=0;i<40;i++)
cpx #$28
bcs !__b17+
jmp __b17
!__b17:
bcs !__b18+
jmp __b18
!__b18:
ldx #0
// Set all raster bars to black
__b18:
__b19:
// for(char l=0;l!=RASTER_LINES;l++)
cpx #RASTER_LINES
beq !__b19+
jmp __b19
!__b19:
beq !__b20+
jmp __b20
!__b20:
// char sin_bar = sin_idx
// Big block of bars (16)
lda.z sin_idx
sta.z sin_bar
lda #0
sta.z barcnt
__b21:
__b22:
// for(char barcnt=0; barcnt<16; barcnt++)
lda.z barcnt
cmp #$10
bcc __b22
bcc __b23
ldx #0
// Produce dark area behind text
__b28:
__b29:
// for(char i=0;i<19;i++)
cpx #$13
bcc __b29
bcc __b30
// char greet_offset = greet_idx*16
// Set up greetings
lda.z greet_idx
@ -201,10 +201,10 @@ irq: {
asl
tay
ldx #0
__b31:
__b32:
// for(char i=0;i<16;i++)
cpx #$10
bcc __b32
bcc __b33
// if(--scroll_soft == 0xff)
dec.z scroll_soft
lda #$ff
@ -215,10 +215,10 @@ irq: {
sta.z scroll_soft
ldx #0
// Move scroll on screen
__b35:
__b36:
// for(char i=0;i<39;i++)
cpx #$27
bcc __b36
bcc __b37
// char nxt = *(scroll_ptr++)
// Show next char
ldy #0
@ -226,7 +226,7 @@ irq: {
inw.z scroll_ptr
// if(nxt == 0)
cmp #0
bne __b39
bne __b40
// scroll_ptr = SCROLL_TEXT
lda #<SCROLL_TEXT
sta.z scroll_ptr
@ -234,7 +234,7 @@ irq: {
sta.z scroll_ptr+1
// nxt = *scroll_ptr
lda (scroll_ptr),y
__b39:
__b40:
// nxt & 0xbf
and #$bf
// *(SCREEN + SCROLL_ROW*40 + 39) = nxt & 0xbf
@ -246,14 +246,14 @@ irq: {
plx
pla
rti
__b36:
__b37:
// (SCREEN + SCROLL_ROW*40)[i] = (SCREEN + SCROLL_ROW*40 + 1)[i]
lda DEFAULT_SCREEN+SCROLL_ROW*$28+1,x
sta DEFAULT_SCREEN+SCROLL_ROW*$28,x
// for(char i=0;i<39;i++)
inx
jmp __b35
__b32:
jmp __b36
__b33:
// GREETING[greet_offset++] & 0xbf
lda #$bf
and GREETING,y
@ -263,8 +263,8 @@ irq: {
iny
// for(char i=0;i<16;i++)
inx
jmp __b31
__b29:
jmp __b32
__b30:
// rasters[SCROLL_Y+i] /2
lda rasters+SCROLL_Y,x
lsr
@ -274,8 +274,8 @@ irq: {
sta rasters+SCROLL_Y,x
// for(char i=0;i<19;i++)
inx
jmp __b28
__b22:
jmp __b29
__b23:
// char idx = SINE[sin_bar]
ldy.z sin_bar
ldx SINE,y
@ -287,15 +287,15 @@ irq: {
asl
taz
ldy #0
__b23:
__b24:
// for(char i=0;i<16;i++)
cpy #$10
bcc __b24
bcc __b25
ldy #0
__b25:
__b26:
// for(char i=0;i<15;i++)
cpy #$f
bcc __b26
bcc __b27
// sin_bar += 10
lda #$a
clc
@ -303,8 +303,8 @@ irq: {
sta.z sin_bar
// for(char barcnt=0; barcnt<16; barcnt++)
inc.z barcnt
jmp __b21
__b26:
jmp __b22
__b27:
// rasters[idx++] = --barcol;
dez
// rasters[idx++] = --barcol
@ -314,8 +314,8 @@ irq: {
inx
// for(char i=0;i<15;i++)
iny
jmp __b25
__b24:
jmp __b26
__b25:
// rasters[idx++] = barcol++
tza
sta rasters,x
@ -324,15 +324,15 @@ irq: {
inz
// for(char i=0;i<16;i++)
iny
jmp __b23
__b19:
jmp __b24
__b20:
// rasters[l] = 0
lda #0
sta rasters,x
// for(char l=0;l!=RASTER_LINES;l++)
inx
jmp __b18
__b17:
jmp __b19
__b18:
// char col = SINE[sin_col]/4
// Greeting colors
lda SINE,y
@ -363,8 +363,8 @@ irq: {
iny
// for(char i=0;i<40;i++)
inx
jmp __b16
__b2:
jmp __b17
__b3:
// char col = rasters[line]
tza
tay
@ -375,16 +375,16 @@ irq: {
sta VICIII+OFFSET_STRUCT_MOS4569_VICIII_BG_COLOR
// if(line < SCROLL_Y)
cpz #SCROLL_Y
bcc __b4
bcc __b5
// if(line == SCROLL_Y)
cpz #SCROLL_Y
beq __b5
beq __b6
// if(line == SCROLL_Y+SCROLL_BLACKBARS)
cpz #SCROLL_Y+SCROLL_BLACKBARS
beq __b6
beq __b7
// if(line == SCROLL_Y+SCROLL_BLACKBARS+1)
cpz #SCROLL_Y+SCROLL_BLACKBARS+1
bne __b7
bne __b8
// char zoomval = SINE[greet_zoomx++]
// if raster position > SCROLL_Y pos do zoom
ldy.z greet_zoomx
@ -398,34 +398,34 @@ irq: {
sta VICIV+OFFSET_STRUCT_MEGA65_VICIV_TEXTXPOS_LO
// if(greet_zoomx==0)
lda.z greet_zoomx
bne __b7
bne __b8
// if(++greet_idx == GREET_COUNT)
inc.z greet_idx
lda #GREET_COUNT
cmp.z greet_idx
bne __b7
bne __b8
// greet_idx = 0
lda #0
sta.z greet_idx
__b7:
__b8:
// char raster = VICII->RASTER
// Wait for the next raster line
lda VICII+OFFSET_STRUCT_MOS6569_VICII_RASTER
__b8:
__b9:
// while(raster == VICII->RASTER)
cmp VICII+OFFSET_STRUCT_MOS6569_VICII_RASTER
beq __b8
beq __b9
// for(char line=0;line!=RASTER_LINES;line++)
inz
jmp __b1
__b6:
jmp __b2
__b7:
// VICIV->TEXTXPOS_LO = 0x50
// if raster position > SCROLL_Y pos do nozoom
// default value
lda #$50
sta VICIV+OFFSET_STRUCT_MEGA65_VICIV_TEXTXPOS_LO
jmp __b7
__b5:
jmp __b8
__b6:
// if raster position = SCROLL_Y pos do scroll
// no wobbling from this point
lda #$50
@ -434,8 +434,8 @@ irq: {
// set softscroll
lda.z scroll_soft
sta VICII+OFFSET_STRUCT_MOS6569_VICII_CONTROL2
jmp __b7
__b4:
jmp __b8
__b5:
// VICIV->TEXTXPOS_LO = SINE[wobble_idx++]
// if raster position < SCROLL_Y pos do wobble Logo!
lda SINE,x
@ -446,7 +446,7 @@ irq: {
// No zooming
lda #$66
sta VICIV+OFFSET_STRUCT_MEGA65_VICIV_CHRXSCL
jmp __b7
jmp __b8
}
main: {
// VICIII->KEY = 0x47
@ -475,18 +475,18 @@ main: {
jsr memset
ldx #0
// Put MEGA logo on screen
__b1:
__b2:
// for( char i=0; i<sizeof(MEGA_LOGO); i++)
cpx #$bc*SIZEOF_BYTE
bcc __b2
bcc __b3
ldx #0
// Put '*' as default greeting
__b3:
__b4:
// for( char i=0;i<40;i++)
cpx #$28
bcc __b4
bcc __b5
ldx #0
__b5:
__b6:
// PALETTE_RED[i] = PAL_RED[i]
lda PAL_RED,x
sta PALETTE_RED,x
@ -499,7 +499,7 @@ main: {
// while(++i!=0)
inx
cpx #0
bne __b5
bne __b6
// asm
// Set up raster interrupts C64 style
sei
@ -539,22 +539,22 @@ main: {
// asm
// Enable IRQ
cli
__b7:
jmp __b7
__b4:
__b8:
jmp __b8
__b5:
// (SCREEN + GREET_ROW*40)[i] = '*'
lda #'*'
sta DEFAULT_SCREEN+GREET_ROW*$28,x
// for( char i=0;i<40;i++)
inx
jmp __b3
__b2:
jmp __b4
__b3:
// (SCREEN + LOGO_ROW*40)[i] = MEGA_LOGO[i]
lda MEGA_LOGO,x
sta DEFAULT_SCREEN+LOGO_ROW*$28,x
// for( char i=0; i<sizeof(MEGA_LOGO); i++)
inx
jmp __b1
jmp __b2
}
// Copies the character c (an unsigned char) to the first num characters of the object pointed to by the argument str.
memset: {

View File

@ -25,127 +25,129 @@ irq: scope:[irq] from
[11] *((byte*)VICII+OFFSET_STRUCT_MOS6569_VICII_CONTROL2) = 0
[12] sin_idx = ++ sin_idx
[13] irq::wobble_idx#0 = sin_idx
to:irq::@1
irq::@1: scope:[irq] from irq irq::@9
[14] irq::wobble_idx#10 = phi( irq/irq::wobble_idx#0, irq::@9/irq::wobble_idx#7 )
[14] irq::line#10 = phi( irq/0, irq::@9/irq::line#1 )
[15] if(irq::line#10!=RASTER_LINES) goto irq::@2
to:irq::@3
irq::@3: scope:[irq] from irq::@1
to:irq::@2
irq::@2: scope:[irq] from irq irq::@10
[14] irq::wobble_idx#10 = phi( irq/irq::wobble_idx#0, irq::@10/irq::wobble_idx#7 )
[14] irq::line#10 = phi( irq/0, irq::@10/irq::line#1 )
[15] if(irq::line#10!=RASTER_LINES) goto irq::@3
to:irq::@4
irq::@4: scope:[irq] from irq::@2
[16] phi()
[17] callexecute *songPlay
to:irq::@1
irq::@1: scope:[irq] from irq::@4
[18] irq::sin_col#0 = sin_idx
to:irq::@16
irq::@16: scope:[irq] from irq::@17 irq::@3
[19] irq::sin_col#2 = phi( irq::@17/irq::sin_col#1, irq::@3/irq::sin_col#0 )
[19] irq::i#2 = phi( irq::@17/irq::i#1, irq::@3/0 )
[20] if(irq::i#2<$28) goto irq::@17
to:irq::@18
irq::@18: scope:[irq] from irq::@16 irq::@19
[21] irq::l#2 = phi( irq::@16/0, irq::@19/irq::l#1 )
[22] if(irq::l#2!=RASTER_LINES) goto irq::@19
to:irq::@20
irq::@20: scope:[irq] from irq::@18
[23] irq::sin_bar#0 = sin_idx
to:irq::@17
irq::@17: scope:[irq] from irq::@1 irq::@18
[19] irq::sin_col#2 = phi( irq::@1/irq::sin_col#0, irq::@18/irq::sin_col#1 )
[19] irq::i#2 = phi( irq::@1/0, irq::@18/irq::i#1 )
[20] if(irq::i#2<$28) goto irq::@18
to:irq::@19
irq::@19: scope:[irq] from irq::@17 irq::@20
[21] irq::l#2 = phi( irq::@17/0, irq::@20/irq::l#1 )
[22] if(irq::l#2!=RASTER_LINES) goto irq::@20
to:irq::@21
irq::@21: scope:[irq] from irq::@20 irq::@27
[24] irq::sin_bar#2 = phi( irq::@20/irq::sin_bar#0, irq::@27/irq::sin_bar#1 )
[24] irq::barcnt#2 = phi( irq::@20/0, irq::@27/irq::barcnt#1 )
[25] if(irq::barcnt#2<$10) goto irq::@22
to:irq::@28
irq::@28: scope:[irq] from irq::@21 irq::@29
[26] irq::i3#2 = phi( irq::@21/0, irq::@29/irq::i3#1 )
[27] if(irq::i3#2<$13) goto irq::@29
to:irq::@30
irq::@30: scope:[irq] from irq::@28
[28] irq::greet_offset#0 = greet_idx << 4
irq::@21: scope:[irq] from irq::@19
[23] irq::sin_bar#0 = sin_idx
to:irq::@22
irq::@22: scope:[irq] from irq::@21 irq::@28
[24] irq::sin_bar#2 = phi( irq::@21/irq::sin_bar#0, irq::@28/irq::sin_bar#1 )
[24] irq::barcnt#2 = phi( irq::@21/0, irq::@28/irq::barcnt#1 )
[25] if(irq::barcnt#2<$10) goto irq::@23
to:irq::@29
irq::@29: scope:[irq] from irq::@22 irq::@30
[26] irq::i3#2 = phi( irq::@22/0, irq::@30/irq::i3#1 )
[27] if(irq::i3#2<$13) goto irq::@30
to:irq::@31
irq::@31: scope:[irq] from irq::@30 irq::@32
[29] irq::greet_offset#2 = phi( irq::@30/irq::greet_offset#0, irq::@32/irq::greet_offset#1 )
[29] irq::i4#2 = phi( irq::@30/0, irq::@32/irq::i4#1 )
[30] if(irq::i4#2<$10) goto irq::@32
to:irq::@33
irq::@33: scope:[irq] from irq::@31
irq::@31: scope:[irq] from irq::@29
[28] irq::greet_offset#0 = greet_idx << 4
to:irq::@32
irq::@32: scope:[irq] from irq::@31 irq::@33
[29] irq::greet_offset#2 = phi( irq::@31/irq::greet_offset#0, irq::@33/irq::greet_offset#1 )
[29] irq::i4#2 = phi( irq::@31/0, irq::@33/irq::i4#1 )
[30] if(irq::i4#2<$10) goto irq::@33
to:irq::@34
irq::@34: scope:[irq] from irq::@32
[31] scroll_soft = -- scroll_soft
[32] if(scroll_soft!=$ff) goto irq::@return
to:irq::@34
irq::@34: scope:[irq] from irq::@33
[33] scroll_soft = 7
to:irq::@35
irq::@35: scope:[irq] from irq::@34 irq::@36
[34] irq::i5#2 = phi( irq::@34/0, irq::@36/irq::i5#1 )
[35] if(irq::i5#2<$27) goto irq::@36
to:irq::@37
irq::@37: scope:[irq] from irq::@35
irq::@35: scope:[irq] from irq::@34
[33] scroll_soft = 7
to:irq::@36
irq::@36: scope:[irq] from irq::@35 irq::@37
[34] irq::i5#2 = phi( irq::@35/0, irq::@37/irq::i5#1 )
[35] if(irq::i5#2<$27) goto irq::@37
to:irq::@38
irq::@38: scope:[irq] from irq::@36
[36] irq::nxt#0 = *scroll_ptr
[37] scroll_ptr = ++ scroll_ptr
[38] if(irq::nxt#0!=0) goto irq::@39
to:irq::@38
irq::@38: scope:[irq] from irq::@37
[38] if(irq::nxt#0!=0) goto irq::@40
to:irq::@39
irq::@39: scope:[irq] from irq::@38
[39] scroll_ptr = SCROLL_TEXT
[40] irq::nxt#1 = *scroll_ptr
to:irq::@39
irq::@39: scope:[irq] from irq::@37 irq::@38
[41] irq::nxt#2 = phi( irq::@37/irq::nxt#0, irq::@38/irq::nxt#1 )
to:irq::@40
irq::@40: scope:[irq] from irq::@38 irq::@39
[41] irq::nxt#2 = phi( irq::@38/irq::nxt#0, irq::@39/irq::nxt#1 )
[42] irq::$33 = irq::nxt#2 & $bf
[43] *(DEFAULT_SCREEN+SCROLL_ROW*$28+$27) = irq::$33
to:irq::@return
irq::@return: scope:[irq] from irq::@33 irq::@39
irq::@return: scope:[irq] from irq::@34 irq::@40
[44] return
to:@return
irq::@36: scope:[irq] from irq::@35
irq::@37: scope:[irq] from irq::@36
[45] (DEFAULT_SCREEN+SCROLL_ROW*$28)[irq::i5#2] = (DEFAULT_SCREEN+SCROLL_ROW*$28+1)[irq::i5#2]
[46] irq::i5#1 = ++ irq::i5#2
to:irq::@35
irq::@32: scope:[irq] from irq::@31
to:irq::@36
irq::@33: scope:[irq] from irq::@32
[47] irq::$29 = GREETING[irq::greet_offset#2] & $bf
[48] (DEFAULT_SCREEN+GREET_ROW*$28+$d)[irq::i4#2] = irq::$29
[49] irq::greet_offset#1 = ++ irq::greet_offset#2
[50] irq::i4#1 = ++ irq::i4#2
to:irq::@31
irq::@29: scope:[irq] from irq::@28
to:irq::@32
irq::@30: scope:[irq] from irq::@29
[51] irq::$26 = (rasters+SCROLL_Y)[irq::i3#2] >> 1
[52] irq::$27 = irq::$26 & 7
[53] (rasters+SCROLL_Y)[irq::i3#2] = irq::$27
[54] irq::i3#1 = ++ irq::i3#2
to:irq::@28
irq::@22: scope:[irq] from irq::@21
to:irq::@29
irq::@23: scope:[irq] from irq::@22
[55] irq::idx#0 = SINE[irq::sin_bar#2]
[56] irq::barcol#0 = irq::barcnt#2 << 4
to:irq::@23
irq::@23: scope:[irq] from irq::@22 irq::@24
[57] irq::idx#3 = phi( irq::@22/irq::idx#0, irq::@24/irq::idx#1 )
[57] irq::barcol#3 = phi( irq::@22/irq::barcol#0, irq::@24/irq::barcol#1 )
[57] irq::i1#2 = phi( irq::@22/0, irq::@24/irq::i1#1 )
[58] if(irq::i1#2<$10) goto irq::@24
to:irq::@25
irq::@25: scope:[irq] from irq::@23 irq::@26
[59] irq::idx#4 = phi( irq::@23/irq::idx#3, irq::@26/irq::idx#2 )
[59] irq::barcol#4 = phi( irq::@23/irq::barcol#3, irq::@26/irq::barcol#2 )
[59] irq::i2#2 = phi( irq::@23/0, irq::@26/irq::i2#1 )
[60] if(irq::i2#2<$f) goto irq::@26
to:irq::@27
irq::@27: scope:[irq] from irq::@25
to:irq::@24
irq::@24: scope:[irq] from irq::@23 irq::@25
[57] irq::idx#3 = phi( irq::@23/irq::idx#0, irq::@25/irq::idx#1 )
[57] irq::barcol#3 = phi( irq::@23/irq::barcol#0, irq::@25/irq::barcol#1 )
[57] irq::i1#2 = phi( irq::@23/0, irq::@25/irq::i1#1 )
[58] if(irq::i1#2<$10) goto irq::@25
to:irq::@26
irq::@26: scope:[irq] from irq::@24 irq::@27
[59] irq::idx#4 = phi( irq::@24/irq::idx#3, irq::@27/irq::idx#2 )
[59] irq::barcol#4 = phi( irq::@24/irq::barcol#3, irq::@27/irq::barcol#2 )
[59] irq::i2#2 = phi( irq::@24/0, irq::@27/irq::i2#1 )
[60] if(irq::i2#2<$f) goto irq::@27
to:irq::@28
irq::@28: scope:[irq] from irq::@26
[61] irq::sin_bar#1 = irq::sin_bar#2 + $a
[62] irq::barcnt#1 = ++ irq::barcnt#2
to:irq::@21
irq::@26: scope:[irq] from irq::@25
to:irq::@22
irq::@27: scope:[irq] from irq::@26
[63] irq::barcol#2 = -- irq::barcol#4
[64] rasters[irq::idx#4] = irq::barcol#2
[65] irq::idx#2 = ++ irq::idx#4
[66] irq::i2#1 = ++ irq::i2#2
to:irq::@25
irq::@24: scope:[irq] from irq::@23
to:irq::@26
irq::@25: scope:[irq] from irq::@24
[67] rasters[irq::idx#3] = irq::barcol#3
[68] irq::idx#1 = ++ irq::idx#3
[69] irq::barcol#1 = ++ irq::barcol#3
[70] irq::i1#1 = ++ irq::i1#2
to:irq::@23
irq::@19: scope:[irq] from irq::@18
to:irq::@24
irq::@20: scope:[irq] from irq::@19
[71] rasters[irq::l#2] = 0
[72] irq::l#1 = ++ irq::l#2
to:irq::@18
irq::@17: scope:[irq] from irq::@16
to:irq::@19
irq::@18: scope:[irq] from irq::@17
[73] irq::col1#0 = SINE[irq::sin_col#2] >> 2
[74] (COLORRAM+GREET_ROW*$28)[irq::i#2] = irq::col1#0
[75] irq::col1#1 = irq::col1#0 >> 1
@ -158,59 +160,59 @@ irq::@17: scope:[irq] from irq::@16
[82] (COLORRAM+SCROLL_ROW*$28)[irq::i#2] = PAL_GREEN[irq::sin_col#2]
[83] irq::sin_col#1 = ++ irq::sin_col#2
[84] irq::i#1 = ++ irq::i#2
to:irq::@16
irq::@2: scope:[irq] from irq::@1
to:irq::@17
irq::@3: scope:[irq] from irq::@2
[85] irq::col#0 = rasters[irq::line#10]
[86] *((byte*)VICIII+OFFSET_STRUCT_MOS4569_VICIII_BORDER_COLOR) = irq::col#0
[87] *((byte*)VICIII+OFFSET_STRUCT_MOS4569_VICIII_BG_COLOR) = irq::col#0
[88] if(irq::line#10<SCROLL_Y) goto irq::@4
to:irq::@10
irq::@10: scope:[irq] from irq::@2
[89] if(irq::line#10==SCROLL_Y) goto irq::@5
[88] if(irq::line#10<SCROLL_Y) goto irq::@5
to:irq::@11
irq::@11: scope:[irq] from irq::@10
[90] if(irq::line#10==SCROLL_Y+SCROLL_BLACKBARS) goto irq::@6
irq::@11: scope:[irq] from irq::@3
[89] if(irq::line#10==SCROLL_Y) goto irq::@6
to:irq::@12
irq::@12: scope:[irq] from irq::@11
[91] if(irq::line#10!=SCROLL_Y+SCROLL_BLACKBARS+1) goto irq::@7
[90] if(irq::line#10==SCROLL_Y+SCROLL_BLACKBARS) goto irq::@7
to:irq::@13
irq::@13: scope:[irq] from irq::@12
[91] if(irq::line#10!=SCROLL_Y+SCROLL_BLACKBARS+1) goto irq::@8
to:irq::@14
irq::@14: scope:[irq] from irq::@13
[92] irq::zoomval#0 = SINE[greet_zoomx]
[93] greet_zoomx = ++ greet_zoomx
[94] *((byte*)VICIV+OFFSET_STRUCT_MEGA65_VICIV_CHRXSCL) = irq::zoomval#0
[95] irq::$10 = irq::zoomval#0 + 1
[96] *((byte*)VICIV+OFFSET_STRUCT_MEGA65_VICIV_TEXTXPOS_LO) = irq::$10
[97] if(greet_zoomx!=0) goto irq::@7
to:irq::@14
irq::@14: scope:[irq] from irq::@13
[98] greet_idx = ++ greet_idx
[99] if(greet_idx!=GREET_COUNT) goto irq::@7
[97] if(greet_zoomx!=0) goto irq::@8
to:irq::@15
irq::@15: scope:[irq] from irq::@14
[98] greet_idx = ++ greet_idx
[99] if(greet_idx!=GREET_COUNT) goto irq::@8
to:irq::@16
irq::@16: scope:[irq] from irq::@15
[100] greet_idx = 0
to:irq::@7
irq::@7: scope:[irq] from irq::@12 irq::@13 irq::@14 irq::@15 irq::@4 irq::@5 irq::@6
[101] irq::wobble_idx#7 = phi( irq::@12/irq::wobble_idx#10, irq::@13/irq::wobble_idx#10, irq::@14/irq::wobble_idx#10, irq::@15/irq::wobble_idx#10, irq::@4/irq::wobble_idx#1, irq::@5/irq::wobble_idx#10, irq::@6/irq::wobble_idx#10 )
[102] irq::raster#0 = *((byte*)VICII+OFFSET_STRUCT_MOS6569_VICII_RASTER)
to:irq::@8
irq::@8: scope:[irq] from irq::@7 irq::@8
[103] if(irq::raster#0==*((byte*)VICII+OFFSET_STRUCT_MOS6569_VICII_RASTER)) goto irq::@8
irq::@8: scope:[irq] from irq::@13 irq::@14 irq::@15 irq::@16 irq::@5 irq::@6 irq::@7
[101] irq::wobble_idx#7 = phi( irq::@13/irq::wobble_idx#10, irq::@14/irq::wobble_idx#10, irq::@15/irq::wobble_idx#10, irq::@16/irq::wobble_idx#10, irq::@5/irq::wobble_idx#1, irq::@6/irq::wobble_idx#10, irq::@7/irq::wobble_idx#10 )
[102] irq::raster#0 = *((byte*)VICII+OFFSET_STRUCT_MOS6569_VICII_RASTER)
to:irq::@9
irq::@9: scope:[irq] from irq::@8
irq::@9: scope:[irq] from irq::@8 irq::@9
[103] if(irq::raster#0==*((byte*)VICII+OFFSET_STRUCT_MOS6569_VICII_RASTER)) goto irq::@9
to:irq::@10
irq::@10: scope:[irq] from irq::@9
[104] irq::line#1 = ++ irq::line#10
to:irq::@1
irq::@6: scope:[irq] from irq::@11
to:irq::@2
irq::@7: scope:[irq] from irq::@12
[105] *((byte*)VICIV+OFFSET_STRUCT_MEGA65_VICIV_TEXTXPOS_LO) = $50
to:irq::@7
irq::@5: scope:[irq] from irq::@10
to:irq::@8
irq::@6: scope:[irq] from irq::@11
[106] *((byte*)VICIV+OFFSET_STRUCT_MEGA65_VICIV_TEXTXPOS_LO) = $50
[107] *((byte*)VICII+OFFSET_STRUCT_MOS6569_VICII_CONTROL2) = scroll_soft
to:irq::@7
irq::@4: scope:[irq] from irq::@2
to:irq::@8
irq::@5: scope:[irq] from irq::@3
[108] *((byte*)VICIV+OFFSET_STRUCT_MEGA65_VICIV_TEXTXPOS_LO) = SINE[irq::wobble_idx#10]
[109] irq::wobble_idx#1 = ++ irq::wobble_idx#10
[110] *((byte*)VICIV+OFFSET_STRUCT_MEGA65_VICIV_CHRXSCL) = $66
to:irq::@7
to:irq::@8
void main()
main: scope:[main] from __start::@1
@ -220,60 +222,63 @@ main: scope:[main] from __start::@1
[114] *((byte*)VICIV+OFFSET_STRUCT_MEGA65_VICIV_CONTROLC) = *((byte*)VICIV+OFFSET_STRUCT_MEGA65_VICIV_CONTROLC) | $40
asm { lda#0 }
[116] callexecute *songInit
[117] call memset
to:main::@1
main::@1: scope:[main] from main main::@2
[118] main::i1#2 = phi( main/0, main::@2/main::i1#1 )
[119] if(main::i1#2<$bc*SIZEOF_BYTE) goto main::@2
to:main::@3
main::@3: scope:[main] from main::@1 main::@4
[120] main::i2#2 = phi( main::@1/0, main::@4/main::i2#1 )
[121] if(main::i2#2<$28) goto main::@4
to:main::@5
main::@5: scope:[main] from main::@3 main::@5
[122] main::i#2 = phi( main::@3/0, main::@5/main::i#1 )
[123] PALETTE_RED[main::i#2] = PAL_RED[main::i#2]
[124] PALETTE_GREEN[main::i#2] = PAL_GREEN[main::i#2]
[125] PALETTE_BLUE[main::i#2] = PAL_BLUE[main::i#2]
[126] main::i#1 = ++ main::i#2
[127] if(main::i#1!=0) goto main::@5
main::@1: scope:[main] from main
[117] phi()
[118] call memset
to:main::@2
main::@2: scope:[main] from main::@1 main::@3
[119] main::i1#2 = phi( main::@1/0, main::@3/main::i1#1 )
[120] if(main::i1#2<$bc*SIZEOF_BYTE) goto main::@3
to:main::@4
main::@4: scope:[main] from main::@2 main::@5
[121] main::i2#2 = phi( main::@2/0, main::@5/main::i2#1 )
[122] if(main::i2#2<$28) goto main::@5
to:main::@6
main::@6: scope:[main] from main::@5
main::@6: scope:[main] from main::@4 main::@6
[123] main::i#2 = phi( main::@4/0, main::@6/main::i#1 )
[124] PALETTE_RED[main::i#2] = PAL_RED[main::i#2]
[125] PALETTE_GREEN[main::i#2] = PAL_GREEN[main::i#2]
[126] PALETTE_BLUE[main::i#2] = PAL_BLUE[main::i#2]
[127] main::i#1 = ++ main::i#2
[128] if(main::i#1!=0) goto main::@6
to:main::@7
main::@7: scope:[main] from main::@6
asm { sei }
[129] *((byte*)CIA1+OFFSET_STRUCT_MOS6526_CIA_INTERRUPT) = CIA_INTERRUPT_CLEAR
[130] *((byte*)VICII+OFFSET_STRUCT_MOS6569_VICII_RASTER) = IRQ_Y
[131] *((byte*)VICII+OFFSET_STRUCT_MOS6569_VICII_CONTROL1) = *((byte*)VICII+OFFSET_STRUCT_MOS6569_VICII_CONTROL1) & $7f
[132] *((byte*)VICII+OFFSET_STRUCT_MOS6569_VICII_IRQ_ENABLE) = IRQ_RASTER
[133] *HARDWARE_IRQ = &irq
[134] *PROCPORT_DDR = PROCPORT_DDR_MEMORY_MASK
[135] *PROCPORT = PROCPORT_RAM_IO
[136] *((byte*)VICIV+OFFSET_STRUCT_MEGA65_VICIV_SIDBDRWD_LO) = 1
[130] *((byte*)CIA1+OFFSET_STRUCT_MOS6526_CIA_INTERRUPT) = CIA_INTERRUPT_CLEAR
[131] *((byte*)VICII+OFFSET_STRUCT_MOS6569_VICII_RASTER) = IRQ_Y
[132] *((byte*)VICII+OFFSET_STRUCT_MOS6569_VICII_CONTROL1) = *((byte*)VICII+OFFSET_STRUCT_MOS6569_VICII_CONTROL1) & $7f
[133] *((byte*)VICII+OFFSET_STRUCT_MOS6569_VICII_IRQ_ENABLE) = IRQ_RASTER
[134] *HARDWARE_IRQ = &irq
[135] *PROCPORT_DDR = PROCPORT_DDR_MEMORY_MASK
[136] *PROCPORT = PROCPORT_RAM_IO
[137] *((byte*)VICIV+OFFSET_STRUCT_MEGA65_VICIV_SIDBDRWD_LO) = 1
asm { cli }
to:main::@7
main::@7: scope:[main] from main::@6 main::@7
[138] phi()
to:main::@7
main::@4: scope:[main] from main::@3
[139] (DEFAULT_SCREEN+GREET_ROW*$28)[main::i2#2] = '*'
[140] main::i2#1 = ++ main::i2#2
to:main::@3
main::@2: scope:[main] from main::@1
[141] (DEFAULT_SCREEN+LOGO_ROW*$28)[main::i1#2] = MEGA_LOGO[main::i1#2]
[142] main::i1#1 = ++ main::i1#2
to:main::@1
to:main::@8
main::@8: scope:[main] from main::@7 main::@8
[139] phi()
to:main::@8
main::@5: scope:[main] from main::@4
[140] (DEFAULT_SCREEN+GREET_ROW*$28)[main::i2#2] = '*'
[141] main::i2#1 = ++ main::i2#2
to:main::@4
main::@3: scope:[main] from main::@2
[142] (DEFAULT_SCREEN+LOGO_ROW*$28)[main::i1#2] = MEGA_LOGO[main::i1#2]
[143] main::i1#1 = ++ main::i1#2
to:main::@2
void* memset(void* memset::str , byte memset::c , word memset::num)
memset: scope:[memset] from main
[143] phi()
memset: scope:[memset] from main::@1
[144] phi()
to:memset::@1
memset::@1: scope:[memset] from memset memset::@2
[144] memset::dst#2 = phi( memset/(byte*)memset::str#0, memset::@2/memset::dst#1 )
[145] if(memset::dst#2!=memset::end#0) goto memset::@2
[145] memset::dst#2 = phi( memset/(byte*)memset::str#0, memset::@2/memset::dst#1 )
[146] if(memset::dst#2!=memset::end#0) goto memset::@2
to:memset::@return
memset::@return: scope:[memset] from memset::@1
[146] return
[147] return
to:@return
memset::@2: scope:[memset] from memset::@1
[147] *memset::dst#2 = memset::c#0
[148] memset::dst#1 = ++ memset::dst#2
[148] *memset::dst#2 = memset::c#0
[149] memset::dst#1 = ++ memset::dst#2
to:memset::@1

File diff suppressed because it is too large Load Diff

View File

@ -159,7 +159,7 @@ constant void()* songPlay = (void()*)SONG+3
reg byte z [ irq::line#10 irq::line#1 ]
reg byte x [ irq::wobble_idx#10 irq::wobble_idx#0 irq::wobble_idx#7 irq::wobble_idx#1 ]
reg byte x [ irq::i#2 irq::i#1 ]
reg byte y [ irq::sin_col#2 irq::sin_col#1 irq::sin_col#0 ]
reg byte y [ irq::sin_col#2 irq::sin_col#0 irq::sin_col#1 ]
reg byte x [ irq::l#2 irq::l#1 ]
zp[1]:2 [ irq::barcnt#2 irq::barcnt#1 ]
zp[1]:3 [ irq::sin_bar#2 irq::sin_bar#0 irq::sin_bar#1 ]

View File

@ -0,0 +1,268 @@
// Tests calling advanced functions pointers (with multiple parameters and a return value)
// Commodore 64 PRG executable file
.file [name="function-pointer-advanced-1.prg", type="prg", segments="Program"]
.segmentdef Program [segments="Basic, Code, Data"]
.segmentdef Basic [start=$0801]
.segmentdef Code [start=$80d]
.segmentdef Data [startAfter="Code"]
.segment Basic
:BasicUpstart(__start)
.const STACK_BASE = $103
.const SIZEOF_BYTE = 1
.label line = 8
.label idx = 7
.segment Code
__start: {
// __ma char* line = (char*)0x400
lda #<$400
sta.z line
lda #>$400
sta.z line+1
jsr main
rts
}
// xor(byte zp($a) a, byte register(A) b)
xor: {
.const OFFSET_STACK_A = 1
.const OFFSET_STACK_B = 0
.const OFFSET_STACK_RETURN_1 = 1
.label a = $a
tsx
lda STACK_BASE+OFFSET_STACK_A,x
sta.z a
tsx
lda STACK_BASE+OFFSET_STACK_B,x
// a^b
eor.z a
// }
tsx
sta STACK_BASE+OFFSET_STACK_RETURN_1,x
rts
}
// min(byte register(Y) a, byte register(A) b)
min: {
.const OFFSET_STACK_A = 1
.const OFFSET_STACK_B = 0
.const OFFSET_STACK_RETURN_1 = 1
// return a;
tsx
lda STACK_BASE+OFFSET_STACK_A,x
tay
// return b;
tsx
lda STACK_BASE+OFFSET_STACK_B,x
// if(a<b)
sta.z $ff
cpy.z $ff
bcc __b1
jmp __breturn
__b1:
tya
__breturn:
// }
tsx
sta STACK_BASE+OFFSET_STACK_RETURN_1,x
rts
}
// max(byte zp($b) a, byte register(A) b)
max: {
.const OFFSET_STACK_A = 1
.const OFFSET_STACK_B = 0
.const OFFSET_STACK_RETURN_1 = 1
.label a = $b
// return a;
tsx
lda STACK_BASE+OFFSET_STACK_A,x
sta.z a
// return b;
tsx
lda STACK_BASE+OFFSET_STACK_B,x
// if(a>b)
cmp.z a
bcc __b1
jmp __breturn
__b1:
lda.z a
__breturn:
// }
tsx
sta STACK_BASE+OFFSET_STACK_RETURN_1,x
rts
}
// sum(byte zp($c) a, byte register(A) b)
sum: {
.const OFFSET_STACK_A = 1
.const OFFSET_STACK_B = 0
.const OFFSET_STACK_RETURN_1 = 1
.label a = $c
tsx
lda STACK_BASE+OFFSET_STACK_A,x
sta.z a
tsx
lda STACK_BASE+OFFSET_STACK_B,x
// a+b
clc
adc.z a
// }
tsx
sta STACK_BASE+OFFSET_STACK_RETURN_1,x
rts
}
main: {
.label i = 2
lda #0
sta.z idx
sta.z i
__b1:
// for(char i=0;i<sizeof(INPUT);i++)
lda.z i
cmp #6*SIZEOF_BYTE
bcc __b2
// ln()
jsr ln
// exec(&sum)
lda #<sum
sta.z exec.collect
lda #>sum
sta.z exec.collect+1
jsr exec
// ln()
jsr ln
// exec(&min)
lda #<min
sta.z exec.collect
lda #>min
sta.z exec.collect+1
jsr exec
// ln()
jsr ln
// exec(&max)
lda #<max
sta.z exec.collect
lda #>max
sta.z exec.collect+1
jsr exec
// ln()
jsr ln
// exec(&xor)
lda #<xor
sta.z exec.collect
lda #>xor
sta.z exec.collect+1
jsr exec
// }
rts
__b2:
// print(INPUT[i])
ldy.z i
lda INPUT,y
sta.z print.i
jsr print
// cout(' ')
ldx #' '
jsr cout
// for(char i=0;i<sizeof(INPUT);i++)
inc.z i
jmp __b1
}
ln: {
// line += 40
lda #$28
clc
adc.z line
sta.z line
bcc !+
inc.z line+1
!:
// }
rts
}
// exec(byte(byte,byte)* zp(3) collect)
exec: {
.label out = 6
.label i = 5
.label collect = 3
// cout(' ')
lda #0
sta.z idx
ldx #' '
jsr cout
// cout(' ')
ldx #' '
jsr cout
// cout(' ')
ldx #' '
jsr cout
// char out = INPUT[0]
lda INPUT
sta.z out
lda #1
sta.z i
__b1:
// for(char i=1;i<sizeof(INPUT);i++)
lda.z i
cmp #6*SIZEOF_BYTE
bcc __b2
// }
rts
__b2:
// (*collect)(out,INPUT[i])
lda.z out
pha
ldy.z i
lda INPUT,y
pha
jsr bi_collect
pla
// out = (*collect)(out,INPUT[i])
pla
sta.z out
// print(out)
jsr print
// cout(' ')
ldx #' '
jsr cout
// for(char i=1;i<sizeof(INPUT);i++)
inc.z i
jmp __b1
bi_collect:
jmp (collect)
}
// print(byte zp(6) i)
print: {
.label i = 6
// i>>4
lda.z i
lsr
lsr
lsr
lsr
// cout(HEX[i>>4])
tay
ldx HEX,y
jsr cout
// i&0x0f
lda #$f
and.z i
// cout(HEX[i&0x0f])
tay
ldx HEX,y
jsr cout
// }
rts
}
// cout(byte register(X) c)
cout: {
// line[idx++] = c
ldy.z idx
txa
sta (line),y
// line[idx++] = c;
inc.z idx
// }
rts
}
.segment Data
INPUT: .byte 2, 1, 3, 4, 6, 5
HEX: .text "0123456789abcdef"
.byte 0

View File

@ -0,0 +1,202 @@
void __start()
__start: scope:[__start] from
[0] phi()
to:__start::__init1
__start::__init1: scope:[__start] from __start
[1] line = (byte*) 1024
to:__start::@1
__start::@1: scope:[__start] from __start::__init1
[2] phi()
[3] call main
to:__start::@return
__start::@return: scope:[__start] from __start::@1
[4] return
to:@return
__stackcall byte xor(byte xor::a , byte xor::b)
xor: scope:[xor] from
[5] xor::a#0 = stackidx(byte,xor::OFFSET_STACK_A)
[6] xor::b#0 = stackidx(byte,xor::OFFSET_STACK_B)
[7] xor::return#0 = xor::a#0 ^ xor::b#0
to:xor::@return
xor::@return: scope:[xor] from xor
[8] stackidx(byte,xor::OFFSET_STACK_RETURN_1) = xor::return#0
[9] return
to:@return
__stackcall byte min(byte min::a , byte min::b)
min: scope:[min] from
[10] min::a#0 = stackidx(byte,min::OFFSET_STACK_A)
[11] min::b#0 = stackidx(byte,min::OFFSET_STACK_B)
[12] if(min::a#0<min::b#0) goto min::@1
to:min::@return
min::@1: scope:[min] from min
[13] min::return#4 = min::a#0
to:min::@return
min::@return: scope:[min] from min min::@1
[14] min::return#2 = phi( min::@1/min::return#4, min/min::b#0 )
[15] stackidx(byte,min::OFFSET_STACK_RETURN_1) = min::return#2
[16] return
to:@return
__stackcall byte max(byte max::a , byte max::b)
max: scope:[max] from
[17] max::a#0 = stackidx(byte,max::OFFSET_STACK_A)
[18] max::b#0 = stackidx(byte,max::OFFSET_STACK_B)
[19] if(max::a#0>max::b#0) goto max::@1
to:max::@return
max::@1: scope:[max] from max
[20] max::return#4 = max::a#0
to:max::@return
max::@return: scope:[max] from max max::@1
[21] max::return#2 = phi( max::@1/max::return#4, max/max::b#0 )
[22] stackidx(byte,max::OFFSET_STACK_RETURN_1) = max::return#2
[23] return
to:@return
__stackcall byte sum(byte sum::a , byte sum::b)
sum: scope:[sum] from
[24] sum::a#0 = stackidx(byte,sum::OFFSET_STACK_A)
[25] sum::b#0 = stackidx(byte,sum::OFFSET_STACK_B)
[26] sum::return#0 = sum::a#0 + sum::b#0
to:sum::@return
sum::@return: scope:[sum] from sum
[27] stackidx(byte,sum::OFFSET_STACK_RETURN_1) = sum::return#0
[28] return
to:@return
void main()
main: scope:[main] from __start::@1
[29] phi()
to:main::@1
main::@1: scope:[main] from main main::@5
[30] idx#54 = phi( main/0, main::@5/idx#0 )
[30] main::i#2 = phi( main/0, main::@5/main::i#1 )
[31] if(main::i#2<6*SIZEOF_BYTE) goto main::@2
to:main::@3
main::@3: scope:[main] from main::@1
[32] phi()
[33] call ln
to:main::@6
main::@6: scope:[main] from main::@3
[34] phi()
[35] call exec
to:main::@7
main::@7: scope:[main] from main::@6
[36] phi()
[37] call ln
to:main::@8
main::@8: scope:[main] from main::@7
[38] phi()
[39] call exec
to:main::@9
main::@9: scope:[main] from main::@8
[40] phi()
[41] call ln
to:main::@10
main::@10: scope:[main] from main::@9
[42] phi()
[43] call exec
to:main::@11
main::@11: scope:[main] from main::@10
[44] phi()
[45] call ln
to:main::@12
main::@12: scope:[main] from main::@11
[46] phi()
[47] call exec
to:main::@return
main::@return: scope:[main] from main::@12
[48] return
to:@return
main::@2: scope:[main] from main::@1
[49] print::i#0 = INPUT[main::i#2]
[50] call print
to:main::@4
main::@4: scope:[main] from main::@2
[51] phi()
[52] call cout
to:main::@5
main::@5: scope:[main] from main::@4
[53] main::i#1 = ++ main::i#2
to:main::@1
void ln()
ln: scope:[ln] from main::@11 main::@3 main::@7 main::@9
[54] line = line + $28
to:ln::@return
ln::@return: scope:[ln] from ln
[55] return
to:@return
void exec(byte(byte,byte)* exec::collect)
exec: scope:[exec] from main::@10 main::@12 main::@6 main::@8
[56] exec::collect#10 = phi( main::@10/&max, main::@12/&xor, main::@6/&sum, main::@8/&min )
[57] call cout
to:exec::@4
exec::@4: scope:[exec] from exec
[58] phi()
[59] call cout
to:exec::@5
exec::@5: scope:[exec] from exec::@4
[60] phi()
[61] call cout
to:exec::@6
exec::@6: scope:[exec] from exec::@5
[62] exec::out#0 = *INPUT
to:exec::@1
exec::@1: scope:[exec] from exec::@6 exec::@8
[63] exec::out#2 = phi( exec::@6/exec::out#0, exec::@8/exec::out#1 )
[63] exec::i#2 = phi( exec::@6/1, exec::@8/exec::i#1 )
[64] if(exec::i#2<6*SIZEOF_BYTE) goto exec::@2
to:exec::@return
exec::@return: scope:[exec] from exec::@1
[65] return
to:@return
exec::@2: scope:[exec] from exec::@1
[66] stackpush(byte) = exec::out#2
[67] stackpush(byte) = INPUT[exec::i#2]
[68] callexecute *exec::collect#10
sideeffect stackpullbytes(1)
[70] exec::out#1 = stackpull(byte)
to:exec::@3
exec::@3: scope:[exec] from exec::@2
[71] print::i#1 = exec::out#1
[72] call print
to:exec::@7
exec::@7: scope:[exec] from exec::@3
[73] phi()
[74] call cout
to:exec::@8
exec::@8: scope:[exec] from exec::@7
[75] exec::i#1 = ++ exec::i#2
to:exec::@1
void print(byte print::i)
print: scope:[print] from exec::@3 main::@2
[76] idx#53 = phi( exec::@3/idx#0, main::@2/idx#54 )
[76] print::i#2 = phi( exec::@3/print::i#1, main::@2/print::i#0 )
[77] print::$0 = print::i#2 >> 4
[78] cout::c#0 = HEX[print::$0]
[79] call cout
to:print::@1
print::@1: scope:[print] from print
[80] print::$2 = print::i#2 & $f
[81] cout::c#1 = HEX[print::$2]
[82] call cout
to:print::@return
print::@return: scope:[print] from print::@1
[83] return
to:@return
void cout(byte cout::c)
cout: scope:[cout] from exec exec::@4 exec::@5 exec::@7 main::@4 print print::@1
[84] idx#27 = phi( exec/0, exec::@4/idx#0, exec::@5/idx#0, exec::@7/idx#0, main::@4/idx#0, print/idx#53, print::@1/idx#0 )
[84] cout::c#7 = phi( exec/' ', exec::@4/' ', exec::@5/' ', exec::@7/' ', main::@4/' ', print/cout::c#0, print::@1/cout::c#1 )
[85] line[idx#27] = cout::c#7
[86] idx#0 = ++ idx#27
to:cout::@return
cout::@return: scope:[cout] from cout
[87] return
to:@return

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,100 @@
constant byte* HEX[] = "0123456789abcdef"
constant byte* INPUT[] = { 2, 1, 3, 4, 6, 5 }
constant byte SIZEOF_BYTE = 1
constant word STACK_BASE = $103
void __start()
void cout(byte cout::c)
byte cout::c
byte cout::c#0 reg byte x 20002.0
byte cout::c#1 reg byte x 20002.0
byte cout::c#7 reg byte x 120003.0
void exec(byte(byte,byte)* exec::collect)
byte(byte,byte)* exec::collect
byte(byte,byte)* exec::collect#10 collect zp[2]:3
byte exec::i
byte exec::i#1 i zp[1]:5 2002.0
byte exec::i#2 i zp[1]:5 400.4
byte exec::out
byte exec::out#0 out zp[1]:6 202.0
byte exec::out#1 out zp[1]:6 500.5
byte exec::out#2 out zp[1]:6 1051.5
byte idx
byte idx#0 idx zp[1]:7 5352.761904761905
byte idx#27 idx zp[1]:7 110654.0
byte idx#53 idx zp[1]:7 3701.0
byte idx#54 idx zp[1]:7 67.33333333333333
byte* line loadstore zp[2]:8 1757.982456140351
void ln()
void main()
byte main::i
byte main::i#1 i zp[1]:2 202.0
byte main::i#2 i zp[1]:2 67.33333333333333
__stackcall byte max(byte max::a , byte max::b)
constant byte max::OFFSET_STACK_A = 1
constant byte max::OFFSET_STACK_B = 0
constant byte max::OFFSET_STACK_RETURN_1 = 1
byte max::a
byte max::a#0 a zp[1]:11 2.0
byte max::b
byte max::b#0 reg byte a 3.0
byte max::return
byte max::return#2 reg byte a 6.0
byte max::return#4 reg byte a 4.0
__stackcall byte min(byte min::a , byte min::b)
constant byte min::OFFSET_STACK_A = 1
constant byte min::OFFSET_STACK_B = 0
constant byte min::OFFSET_STACK_RETURN_1 = 1
byte min::a
byte min::a#0 reg byte y 2.0
byte min::b
byte min::b#0 reg byte a 3.0
byte min::return
byte min::return#2 reg byte a 6.0
byte min::return#4 reg byte a 4.0
void print(byte print::i)
byte~ print::$0 reg byte a 20002.0
byte~ print::$2 reg byte a 20002.0
byte print::i
byte print::i#0 i zp[1]:6 202.0
byte print::i#1 i zp[1]:6 2002.0
byte print::i#2 i zp[1]:6 5276.0
__stackcall byte sum(byte sum::a , byte sum::b)
constant byte sum::OFFSET_STACK_A = 1
constant byte sum::OFFSET_STACK_B = 0
constant byte sum::OFFSET_STACK_RETURN_1 = 1
byte sum::a
byte sum::a#0 a zp[1]:12 2.0
byte sum::b
byte sum::b#0 reg byte a 4.0
byte sum::return
byte sum::return#0 reg byte a 4.0
__stackcall byte xor(byte xor::a , byte xor::b)
constant byte xor::OFFSET_STACK_A = 1
constant byte xor::OFFSET_STACK_B = 0
constant byte xor::OFFSET_STACK_RETURN_1 = 1
byte xor::a
byte xor::a#0 a zp[1]:10 2.0
byte xor::b
byte xor::b#0 reg byte a 4.0
byte xor::return
byte xor::return#0 reg byte a 4.0
reg byte a [ min::return#2 min::return#4 min::b#0 ]
reg byte a [ max::return#2 max::return#4 max::b#0 ]
zp[1]:2 [ main::i#2 main::i#1 ]
zp[2]:3 [ exec::collect#10 ]
zp[1]:5 [ exec::i#2 exec::i#1 ]
zp[1]:6 [ exec::out#2 exec::out#0 exec::out#1 print::i#2 print::i#1 print::i#0 ]
reg byte x [ cout::c#7 cout::c#0 cout::c#1 ]
zp[1]:7 [ idx#27 idx#53 idx#54 idx#0 ]
zp[2]:8 [ line ]
zp[1]:10 [ xor::a#0 ]
reg byte a [ xor::b#0 ]
reg byte a [ xor::return#0 ]
reg byte y [ min::a#0 ]
zp[1]:11 [ max::a#0 ]
zp[1]:12 [ sum::a#0 ]
reg byte a [ sum::b#0 ]
reg byte a [ sum::return#0 ]
reg byte a [ print::$0 ]
reg byte a [ print::$2 ]

View File

@ -64,12 +64,14 @@ void do10(void()* do10::fn)
do10: scope:[do10] from main main::@1
[23] do10::fn#3 = phi( main/&hello, main::@1/&world )
to:do10::@1
do10::@1: scope:[do10] from do10 do10::@1
[24] do10::i#2 = phi( do10/0, do10::@1/do10::i#1 )
do10::@1: scope:[do10] from do10 do10::@2
[24] do10::i#2 = phi( do10/0, do10::@2/do10::i#1 )
[25] callexecute *do10::fn#3
to:do10::@2
do10::@2: scope:[do10] from do10::@1
[26] do10::i#1 = ++ do10::i#2
[27] if(do10::i#1!=$a) goto do10::@1
to:do10::@return
do10::@return: scope:[do10] from do10::@1
do10::@return: scope:[do10] from do10::@2
[28] return
to:@return

View File

@ -8,15 +8,19 @@ do10: scope:[do10] from main main::@1
do10::fn#3 = phi( main/do10::fn#0, main::@1/do10::fn#1 )
do10::i#0 = 0
to:do10::@1
do10::@1: scope:[do10] from do10 do10::@1
do10::i#2 = phi( do10/do10::i#0, do10::@1/do10::i#1 )
do10::fn#2 = phi( do10/do10::fn#3, do10::@1/do10::fn#2 )
do10::@1: scope:[do10] from do10 do10::@2
do10::i#3 = phi( do10/do10::i#0, do10::@2/do10::i#1 )
do10::fn#2 = phi( do10/do10::fn#3, do10::@2/do10::fn#4 )
callexecute *do10::fn#2
to:do10::@2
do10::@2: scope:[do10] from do10::@1
do10::fn#4 = phi( do10::@1/do10::fn#2 )
do10::i#2 = phi( do10::@1/do10::i#3 )
do10::i#1 = do10::i#2 + rangenext(0,9)
do10::$1 = do10::i#1 != rangelast(0,9)
if(do10::$1) goto do10::@1
to:do10::@return
do10::@return: scope:[do10] from do10::@1
do10::@return: scope:[do10] from do10::@2
return
to:@return
@ -100,10 +104,12 @@ void()* do10::fn#0
void()* do10::fn#1
void()* do10::fn#2
void()* do10::fn#3
void()* do10::fn#4
byte do10::i
byte do10::i#0
byte do10::i#1
byte do10::i#2
byte do10::i#3
void hello()
constant byte* hello::msg[7] = "hello "
volatile byte idx loadstore
@ -129,6 +135,9 @@ Simplifying constant integer cast 0
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (byte) 0
Successful SSA optimization PassNFinalizeNumberTypeConversions
Alias do10::i#2 = do10::i#3
Alias do10::fn#2 = do10::fn#4
Successful SSA optimization Pass2AliasElimination
Identical Phi Values do10::fn#2 do10::fn#3
Identical Phi Values print::msg#2 print::msg#3
Successful SSA optimization Pass2IdenticalPhiElimination
@ -163,7 +172,7 @@ Constant inlined do10::fn#0 = &hello
Constant inlined print::msg#1 = world::msg
Constant inlined print::msg#0 = hello::msg
Successful SSA optimization Pass2ConstantInlining
Added new block during phi lifting do10::@2(between do10::@1 and do10::@1)
Added new block during phi lifting do10::@3(between do10::@2 and do10::@1)
Added new block during phi lifting print::@2(between print::@1 and print::@1)
Adding NOP phi() at start of __start
Adding NOP phi() at start of __start::@1
@ -184,14 +193,14 @@ Calls in [do10] to null:30
Created 4 initial phi equivalence classes
Coalesced [27] print::i#3 = print::i#1
Coalesced [34] do10::i#3 = do10::i#1
Coalesced [34] do10::i#4 = do10::i#1
Coalesced down to 4 phi equivalence classes
Culled Empty Block label __start::@2
Culled Empty Block label world::@1
Culled Empty Block label hello::@1
Culled Empty Block label main::@2
Culled Empty Block label print::@2
Culled Empty Block label do10::@2
Culled Empty Block label do10::@3
Adding NOP phi() at start of __start
Adding NOP phi() at start of __start::@1
Adding NOP phi() at start of world
@ -266,13 +275,15 @@ void do10(void()* do10::fn)
do10: scope:[do10] from main main::@1
[23] do10::fn#3 = phi( main/&hello, main::@1/&world )
to:do10::@1
do10::@1: scope:[do10] from do10 do10::@1
[24] do10::i#2 = phi( do10/0, do10::@1/do10::i#1 )
do10::@1: scope:[do10] from do10 do10::@2
[24] do10::i#2 = phi( do10/0, do10::@2/do10::i#1 )
[25] callexecute *do10::fn#3
to:do10::@2
do10::@2: scope:[do10] from do10::@1
[26] do10::i#1 = ++ do10::i#2
[27] if(do10::i#1!=$a) goto do10::@1
to:do10::@return
do10::@return: scope:[do10] from do10::@1
do10::@return: scope:[do10] from do10::@2
[28] return
to:@return
@ -344,17 +355,17 @@ Uplift Scope [world]
Uplift Scope [main]
Uplift Scope [__start]
Uplifting [do10] best 1024 combination zp[1]:7 [ do10::i#2 do10::i#1 ] zp[2]:5 [ do10::fn#3 ]
Uplifting [print] best 904 combination reg byte y [ print::i#2 print::i#1 ] zp[2]:2 [ print::msg#3 ]
Uplifting [] best 904 combination zp[1]:8 [ idx ]
Uplifting [hello] best 904 combination
Uplifting [world] best 904 combination
Uplifting [main] best 904 combination
Uplifting [__start] best 904 combination
Uplifting [do10] best 1054 combination zp[1]:7 [ do10::i#2 do10::i#1 ] zp[2]:5 [ do10::fn#3 ]
Uplifting [print] best 934 combination reg byte y [ print::i#2 print::i#1 ] zp[2]:2 [ print::msg#3 ]
Uplifting [] best 934 combination zp[1]:8 [ idx ]
Uplifting [hello] best 934 combination
Uplifting [world] best 934 combination
Uplifting [main] best 934 combination
Uplifting [__start] best 934 combination
Attempting to uplift remaining variables inzp[1]:7 [ do10::i#2 do10::i#1 ]
Uplifting [do10] best 904 combination zp[1]:7 [ do10::i#2 do10::i#1 ]
Uplifting [do10] best 934 combination zp[1]:7 [ do10::i#2 do10::i#1 ]
Attempting to uplift remaining variables inzp[1]:8 [ idx ]
Uplifting [] best 904 combination zp[1]:8 [ idx ]
Uplifting [] best 934 combination zp[1]:8 [ idx ]
Allocated (was zp[2]:5) zp[2]:4 [ do10::fn#3 ]
Allocated (was zp[1]:7) zp[1]:6 [ do10::i#2 do10::i#1 ]
Allocated (was zp[1]:8) zp[1]:7 [ idx ]
@ -515,20 +526,23 @@ do10: {
lda #0
sta.z i
jmp __b1
// [24] phi from do10::@1 to do10::@1 [phi:do10::@1->do10::@1]
__b1_from___b1:
// [24] phi do10::i#2 = do10::i#1 [phi:do10::@1->do10::@1#0] -- register_copy
// [24] phi from do10::@2 to do10::@1 [phi:do10::@2->do10::@1]
__b1_from___b2:
// [24] phi do10::i#2 = do10::i#1 [phi:do10::@2->do10::@1#0] -- register_copy
jmp __b1
// do10::@1
__b1:
// [25] callexecute *do10::fn#3
jsr bi_fn
jmp __b2
// do10::@2
__b2:
// [26] do10::i#1 = ++ do10::i#2 -- vbuz1=_inc_vbuz1
inc.z i
// [27] if(do10::i#1!=$a) goto do10::@1 -- vbuz1_neq_vbuc1_then_la1
lda #$a
cmp.z i
bne __b1_from___b1
bne __b1_from___b2
jmp __breturn
// do10::@return
__breturn:
@ -550,16 +564,17 @@ Removing instruction jmp __breturn
Removing instruction jmp __b1
Removing instruction jmp __breturn
Removing instruction jmp __b1
Removing instruction jmp __b2
Removing instruction jmp __breturn
Succesful ASM optimization Pass5NextJumpElimination
Replacing label __b1_from___b1 with __b1
Replacing label __b1_from___b1 with __b1
Replacing label __b1_from___b2 with __b1
Removing instruction __b1_from___init1:
Removing instruction main_from___b1:
Removing instruction __b1_from_main:
Removing instruction do10_from___b1:
Removing instruction __b1_from___b1:
Removing instruction __b1_from___b1:
Removing instruction __b1_from___b2:
Succesful ASM optimization Pass5RedundantLabelElimination
Removing instruction __init1:
Removing instruction __b1:
@ -574,6 +589,7 @@ Removing instruction __breturn:
Removing instruction __b1_from_print:
Removing instruction __breturn:
Removing instruction __b1_from_do10:
Removing instruction __b2:
Removing instruction __breturn:
Succesful ASM optimization Pass5UnusedLabelElimination
Removing instruction jmp __b1
@ -750,13 +766,14 @@ do10: {
// [24] phi do10::i#2 = 0 [phi:do10->do10::@1#0] -- vbuz1=vbuc1
lda #0
sta.z i
// [24] phi from do10::@1 to do10::@1 [phi:do10::@1->do10::@1]
// [24] phi do10::i#2 = do10::i#1 [phi:do10::@1->do10::@1#0] -- register_copy
// [24] phi from do10::@2 to do10::@1 [phi:do10::@2->do10::@1]
// [24] phi do10::i#2 = do10::i#1 [phi:do10::@2->do10::@1#0] -- register_copy
// do10::@1
__b1:
// (*fn)()
// [25] callexecute *do10::fn#3
jsr bi_fn
// do10::@2
// for( byte i: 0..9)
// [26] do10::i#1 = ++ do10::i#2 -- vbuz1=_inc_vbuz1
inc.z i

View File

@ -11,6 +11,7 @@
main: {
// (*funcPointer)()
jsr myFunc
// (*funcPointer)()
jsr myFunc2
// }
rts

View File

@ -3,24 +3,27 @@ void main()
main: scope:[main] from
[0] phi()
[1] callexecute myFunc
[2] callexecute myFunc2
to:main::@1
main::@1: scope:[main] from main
[2] phi()
[3] callexecute myFunc2
to:main::@return
main::@return: scope:[main] from main
[3] return
main::@return: scope:[main] from main::@1
[4] return
to:@return
__stackcall void myFunc2()
myFunc2: scope:[myFunc2] from main
[4] *myFunc2::BG_COLOR = ++ *myFunc2::BG_COLOR
myFunc2: scope:[myFunc2] from main::@1
[5] *myFunc2::BG_COLOR = ++ *myFunc2::BG_COLOR
to:myFunc2::@return
myFunc2::@return: scope:[myFunc2] from myFunc2
[5] return
[6] return
to:@return
__stackcall void myFunc()
myFunc: scope:[myFunc] from
[6] *myFunc::BORDER_COLOR = ++ *myFunc::BORDER_COLOR
myFunc: scope:[myFunc] from main
[7] *myFunc::BORDER_COLOR = ++ *myFunc::BORDER_COLOR
to:myFunc::@return
myFunc::@return: scope:[myFunc] from myFunc
[7] return
[8] return
to:@return

View File

@ -24,11 +24,13 @@ void main()
main: scope:[main] from __start::@1
funcPointer#0 = &myFunc
callexecute *funcPointer#0
to:main::@1
main::@1: scope:[main] from main
funcPointer#1 = &myFunc2
callexecute *funcPointer#1
to:main::@return
main::@return: scope:[main] from main
funcPointer#6 = phi( main/funcPointer#1 )
main::@return: scope:[main] from main::@1
funcPointer#6 = phi( main::@1/funcPointer#1 )
funcPointer#2 = funcPointer#6
return
to:@return
@ -100,12 +102,14 @@ Removing unused procedure block __start::@2
Removing unused procedure block __start::@return
Successful SSA optimization PassNEliminateEmptyStart
Adding NOP phi() at start of main
Adding NOP phi() at start of main::@1
CALL GRAPH
Calls in [main] to myFunc:1 myFunc2:2
Calls in [main] to myFunc:1 myFunc2:3
Created 0 initial phi equivalence classes
Coalesced down to 0 phi equivalence classes
Adding NOP phi() at start of main
Adding NOP phi() at start of main::@1
FINAL CONTROL FLOW GRAPH
@ -113,26 +117,29 @@ void main()
main: scope:[main] from
[0] phi()
[1] callexecute myFunc
[2] callexecute myFunc2
to:main::@1
main::@1: scope:[main] from main
[2] phi()
[3] callexecute myFunc2
to:main::@return
main::@return: scope:[main] from main
[3] return
main::@return: scope:[main] from main::@1
[4] return
to:@return
__stackcall void myFunc2()
myFunc2: scope:[myFunc2] from main
[4] *myFunc2::BG_COLOR = ++ *myFunc2::BG_COLOR
myFunc2: scope:[myFunc2] from main::@1
[5] *myFunc2::BG_COLOR = ++ *myFunc2::BG_COLOR
to:myFunc2::@return
myFunc2::@return: scope:[myFunc2] from myFunc2
[5] return
[6] return
to:@return
__stackcall void myFunc()
myFunc: scope:[myFunc] from
[6] *myFunc::BORDER_COLOR = ++ *myFunc::BORDER_COLOR
myFunc: scope:[myFunc] from main
[7] *myFunc::BORDER_COLOR = ++ *myFunc::BORDER_COLOR
to:myFunc::@return
myFunc::@return: scope:[myFunc] from myFunc
[7] return
[8] return
to:@return
@ -152,10 +159,10 @@ Uplift Scope [myFunc2]
Uplift Scope [main]
Uplift Scope []
Uplifting [myFunc] best 51 combination
Uplifting [myFunc2] best 51 combination
Uplifting [main] best 51 combination
Uplifting [] best 51 combination
Uplifting [myFunc] best 54 combination
Uplifting [myFunc2] best 54 combination
Uplifting [main] best 54 combination
Uplifting [] best 54 combination
ASSEMBLER BEFORE OPTIMIZATION
// File Comments
@ -175,43 +182,52 @@ ASSEMBLER BEFORE OPTIMIZATION
main: {
// [1] callexecute myFunc -- jsr
jsr myFunc
// [2] callexecute myFunc2 -- jsr
// [2] phi from main to main::@1 [phi:main->main::@1]
__b1_from_main:
jmp __b1
// main::@1
__b1:
// [3] callexecute myFunc2 -- jsr
jsr myFunc2
jmp __breturn
// main::@return
__breturn:
// [3] return
// [4] return
rts
}
// myFunc2
myFunc2: {
.label BG_COLOR = $d021
// [4] *myFunc2::BG_COLOR = ++ *myFunc2::BG_COLOR -- _deref_pbuc1=_inc__deref_pbuc1
// [5] *myFunc2::BG_COLOR = ++ *myFunc2::BG_COLOR -- _deref_pbuc1=_inc__deref_pbuc1
inc BG_COLOR
jmp __breturn
// myFunc2::@return
__breturn:
// [5] return
// [6] return
rts
}
// myFunc
myFunc: {
.label BORDER_COLOR = $d020
// [6] *myFunc::BORDER_COLOR = ++ *myFunc::BORDER_COLOR -- _deref_pbuc1=_inc__deref_pbuc1
// [7] *myFunc::BORDER_COLOR = ++ *myFunc::BORDER_COLOR -- _deref_pbuc1=_inc__deref_pbuc1
inc BORDER_COLOR
jmp __breturn
// myFunc::@return
__breturn:
// [7] return
// [8] return
rts
}
// File Data
ASSEMBLER OPTIMIZATIONS
Removing instruction jmp __b1
Removing instruction jmp __breturn
Removing instruction jmp __breturn
Removing instruction jmp __breturn
Succesful ASM optimization Pass5NextJumpElimination
Removing instruction __b1_from_main:
Succesful ASM optimization Pass5RedundantLabelElimination
Removing instruction __b1:
Removing instruction __breturn:
Removing instruction __breturn:
Removing instruction __breturn:
@ -248,33 +264,36 @@ main: {
// (*funcPointer)()
// [1] callexecute myFunc -- jsr
jsr myFunc
// [2] callexecute myFunc2 -- jsr
// [2] phi from main to main::@1 [phi:main->main::@1]
// main::@1
// (*funcPointer)()
// [3] callexecute myFunc2 -- jsr
jsr myFunc2
// main::@return
// }
// [3] return
// [4] return
rts
}
// myFunc2
myFunc2: {
.label BG_COLOR = $d021
// (*BG_COLOR)++;
// [4] *myFunc2::BG_COLOR = ++ *myFunc2::BG_COLOR -- _deref_pbuc1=_inc__deref_pbuc1
// [5] *myFunc2::BG_COLOR = ++ *myFunc2::BG_COLOR -- _deref_pbuc1=_inc__deref_pbuc1
inc BG_COLOR
// myFunc2::@return
// }
// [5] return
// [6] return
rts
}
// myFunc
myFunc: {
.label BORDER_COLOR = $d020
// (*BORDER_COLOR)++;
// [6] *myFunc::BORDER_COLOR = ++ *myFunc::BORDER_COLOR -- _deref_pbuc1=_inc__deref_pbuc1
// [7] *myFunc::BORDER_COLOR = ++ *myFunc::BORDER_COLOR -- _deref_pbuc1=_inc__deref_pbuc1
inc BORDER_COLOR
// myFunc::@return
// }
// [7] return
// [8] return
rts
}
// File Data

View File

@ -5,10 +5,12 @@ main: scope:[main] from
[1] *(addrtable+1*SIZEOF_POINTER) = &myFunc2
[2] main::fn#0 = *addrtable
[3] callexecute *main::fn#0
to:main::@1
main::@1: scope:[main] from main
[4] main::fn#1 = *(addrtable+1*SIZEOF_POINTER)
[5] callexecute *main::fn#1
to:main::@return
main::@return: scope:[main] from main
main::@return: scope:[main] from main::@1
[6] return
to:@return

View File

@ -28,11 +28,13 @@ main: scope:[main] from __start
main::$4 = 0 * SIZEOF_POINTER
main::fn#0 = addrtable[main::$4]
callexecute *main::fn#0
to:main::@1
main::@1: scope:[main] from main
main::$5 = 1 * SIZEOF_POINTER
main::fn#1 = addrtable[main::$5]
callexecute *main::fn#1
to:main::@return
main::@return: scope:[main] from main
main::@return: scope:[main] from main::@1
return
to:@return
@ -135,10 +137,12 @@ main: scope:[main] from
[1] *(addrtable+1*SIZEOF_POINTER) = &myFunc2
[2] main::fn#0 = *addrtable
[3] callexecute *main::fn#0
to:main::@1
main::@1: scope:[main] from main
[4] main::fn#1 = *(addrtable+1*SIZEOF_POINTER)
[5] callexecute *main::fn#1
to:main::@return
main::@return: scope:[main] from main
main::@return: scope:[main] from main::@1
[6] return
to:@return
@ -191,10 +195,10 @@ Uplift Scope [myFunc]
Uplift Scope [myFunc2]
Uplift Scope []
Uplifting [main] best 113 combination zp[2]:2 [ main::fn#0 ] zp[2]:4 [ main::fn#1 ]
Uplifting [myFunc] best 113 combination
Uplifting [myFunc2] best 113 combination
Uplifting [] best 113 combination
Uplifting [main] best 116 combination zp[2]:2 [ main::fn#0 ] zp[2]:4 [ main::fn#1 ]
Uplifting [myFunc] best 116 combination
Uplifting [myFunc2] best 116 combination
Uplifting [] best 116 combination
ASSEMBLER BEFORE OPTIMIZATION
// File Comments
@ -232,6 +236,9 @@ main: {
sta.z fn+1
// [3] callexecute *main::fn#0
jsr bi_fn
jmp __b1
// main::@1
__b1:
// [4] main::fn#1 = *(addrtable+1*SIZEOF_POINTER) -- pprz1=_deref_qprc1
lda addrtable+1*SIZEOF_POINTER
sta.z fn_1
@ -276,10 +283,12 @@ myFunc: {
addrtable: .fill 2*$100, 0
ASSEMBLER OPTIMIZATIONS
Removing instruction jmp __b1
Removing instruction jmp __breturn
Removing instruction jmp __breturn
Removing instruction jmp __breturn
Succesful ASM optimization Pass5NextJumpElimination
Removing instruction __b1:
Removing instruction __breturn:
Removing instruction __breturn:
Removing instruction __breturn:
@ -343,6 +352,7 @@ main: {
// (*fn)()
// [3] callexecute *main::fn#0
jsr bi_fn
// main::@1
// fn = addrtable[1]
// [4] main::fn#1 = *(addrtable+1*SIZEOF_POINTER) -- pprz1=_deref_qprc1
lda addrtable+1*SIZEOF_POINTER

View File

@ -3,8 +3,8 @@ void main()
main: scope:[main] from
[0] phi()
to:main::@1
main::@1: scope:[main] from main main::@2
[1] main::cols#2 = phi( main/(byte*) 55296, main::@2/main::cols#1 )
main::@1: scope:[main] from main main::@3
[1] main::cols#2 = phi( main/(byte*) 55296, main::@3/main::cols#1 )
[2] if(main::cols#2<$d800+$3e8) goto main::@2
to:main::@return
main::@return: scope:[main] from main::@1
@ -13,6 +13,8 @@ main::@return: scope:[main] from main::@1
main::@2: scope:[main] from main::@1
[4] phi()
[5] callexecute fn1
to:main::@3
main::@3: scope:[main] from main::@2
[6] *main::cols#2 = ++ *main::cols#2
[7] main::cols#1 = ++ main::cols#2
to:main::@1

View File

@ -24,14 +24,17 @@ void main()
main: scope:[main] from __start
main::cols#0 = (byte*)$d800
to:main::@1
main::@1: scope:[main] from main main::@2
main::cols#2 = phi( main/main::cols#0, main::@2/main::cols#1 )
main::@1: scope:[main] from main main::@3
main::cols#2 = phi( main/main::cols#0, main::@3/main::cols#1 )
main::$0 = main::cols#2 < $d800+$3e8
if(main::$0) goto main::@2
to:main::@return
main::@2: scope:[main] from main::@1
main::cols#3 = phi( main::@1/main::cols#2 )
main::cols#4 = phi( main::@1/main::cols#2 )
callexecute *main::cls
to:main::@3
main::@3: scope:[main] from main::@2
main::cols#3 = phi( main::@2/main::cols#4 )
*main::cols#3 = ++ *main::cols#3
main::cols#1 = ++ main::cols#3
to:main::@1
@ -66,6 +69,7 @@ byte* main::cols#0
byte* main::cols#1
byte* main::cols#2
byte* main::cols#3
byte* main::cols#4
Adding number conversion cast (unumber) $400+$3e8 in fn1::$0 = fn1::screen#2 < $400+$3e8
Adding number conversion cast (unumber) $d800+$3e8 in main::$0 = main::cols#2 < $d800+$3e8
@ -74,7 +78,7 @@ Simplifying constant pointer cast (byte*) 1024
Simplifying constant pointer cast (byte*) 55296
Successful SSA optimization PassNCastSimplification
Alias fn1::screen#2 = fn1::screen#3
Alias main::cols#2 = main::cols#3
Alias main::cols#2 = main::cols#4 main::cols#3
Successful SSA optimization Pass2AliasElimination
Simple Condition fn1::$0 [3] if(fn1::screen#2<(word)$400+$3e8) goto fn1::@2
Simple Condition main::$0 [10] if(main::cols#2<(word)$d800+$3e8) goto main::@2
@ -111,7 +115,7 @@ CALL GRAPH
Calls in [main] to fn1:5
Created 2 initial phi equivalence classes
Coalesced [8] main::cols#4 = main::cols#1
Coalesced [8] main::cols#5 = main::cols#1
Coalesced [15] fn1::screen#4 = fn1::screen#1
Coalesced down to 2 phi equivalence classes
Adding NOP phi() at start of main
@ -124,8 +128,8 @@ void main()
main: scope:[main] from
[0] phi()
to:main::@1
main::@1: scope:[main] from main main::@2
[1] main::cols#2 = phi( main/(byte*) 55296, main::@2/main::cols#1 )
main::@1: scope:[main] from main main::@3
[1] main::cols#2 = phi( main/(byte*) 55296, main::@3/main::cols#1 )
[2] if(main::cols#2<$d800+$3e8) goto main::@2
to:main::@return
main::@return: scope:[main] from main::@1
@ -134,6 +138,8 @@ main::@return: scope:[main] from main::@1
main::@2: scope:[main] from main::@1
[4] phi()
[5] callexecute fn1
to:main::@3
main::@3: scope:[main] from main::@2
[6] *main::cols#2 = ++ *main::cols#2
[7] main::cols#1 = ++ main::cols#2
to:main::@1
@ -186,9 +192,9 @@ Uplift Scope [fn1] 36,670.33: zp[2]:4 [ fn1::screen#2 fn1::screen#1 ]
Uplift Scope [main] 33: zp[2]:2 [ main::cols#2 main::cols#1 ]
Uplift Scope []
Uplifting [fn1] best 7637 combination zp[2]:4 [ fn1::screen#2 fn1::screen#1 ]
Uplifting [main] best 7637 combination zp[2]:2 [ main::cols#2 main::cols#1 ]
Uplifting [] best 7637 combination
Uplifting [fn1] best 7667 combination zp[2]:4 [ fn1::screen#2 fn1::screen#1 ]
Uplifting [main] best 7667 combination zp[2]:2 [ main::cols#2 main::cols#1 ]
Uplifting [] best 7667 combination
ASSEMBLER BEFORE OPTIMIZATION
// File Comments
@ -238,6 +244,9 @@ main: {
__b2:
// [5] callexecute fn1 -- jsr
jsr fn1
jmp __b3
// main::@3
__b3:
// [6] *main::cols#2 = ++ *main::cols#2 -- _deref_pbuz1=_inc__deref_pbuz1
ldy #0
lda (cols),y
@ -250,9 +259,9 @@ main: {
bne !+
inc.z cols+1
!:
// [1] phi from main::@2 to main::@1 [phi:main::@2->main::@1]
__b1_from___b2:
// [1] phi main::cols#2 = main::cols#1 [phi:main::@2->main::@1#0] -- register_copy
// [1] phi from main::@3 to main::@1 [phi:main::@3->main::@1]
__b1_from___b3:
// [1] phi main::cols#2 = main::cols#1 [phi:main::@3->main::@1#0] -- register_copy
jmp __b1
}
// fn1
@ -307,6 +316,7 @@ ASSEMBLER OPTIMIZATIONS
Removing instruction jmp __b1
Removing instruction jmp __breturn
Removing instruction jmp __b2
Removing instruction jmp __b3
Removing instruction jmp __b1
Removing instruction jmp __breturn
Succesful ASM optimization Pass5NextJumpElimination
@ -319,7 +329,8 @@ Removing instruction __b2_from___b1:
Succesful ASM optimization Pass5RedundantLabelElimination
Removing instruction __b1_from_main:
Removing instruction __breturn:
Removing instruction __b1_from___b2:
Removing instruction __b3:
Removing instruction __b1_from___b3:
Removing instruction __b1_from_fn1:
Removing instruction __breturn:
Removing instruction __b1_from___b2:
@ -386,6 +397,7 @@ main: {
// (*cls)()
// [5] callexecute fn1 -- jsr
jsr fn1
// main::@3
// (*cols)++;
// [6] *main::cols#2 = ++ *main::cols#2 -- _deref_pbuz1=_inc__deref_pbuz1
ldy #0
@ -399,8 +411,8 @@ main: {
bne !+
inc.z cols+1
!:
// [1] phi from main::@2 to main::@1 [phi:main::@2->main::@1]
// [1] phi main::cols#2 = main::cols#1 [phi:main::@2->main::@1#0] -- register_copy
// [1] phi from main::@3 to main::@1 [phi:main::@3->main::@1]
// [1] phi main::cols#2 = main::cols#1 [phi:main::@3->main::@1#0] -- register_copy
jmp __b1
}
// fn1

View File

@ -42,12 +42,14 @@ void do10(void()* do10::fn)
do10: scope:[do10] from main
[15] phi()
to:do10::@1
do10::@1: scope:[do10] from do10 do10::@1
[16] do10::i#2 = phi( do10/0, do10::@1/do10::i#1 )
do10::@1: scope:[do10] from do10 do10::@2
[16] do10::i#2 = phi( do10/0, do10::@2/do10::i#1 )
[17] callexecute hello
to:do10::@2
do10::@2: scope:[do10] from do10::@1
[18] do10::i#1 = ++ do10::i#2
[19] if(do10::i#1!=$a) goto do10::@1
to:do10::@return
do10::@return: scope:[do10] from do10::@1
do10::@return: scope:[do10] from do10::@2
[20] return
to:@return

View File

@ -8,15 +8,19 @@ do10: scope:[do10] from main
do10::fn#2 = phi( main/do10::fn#0 )
do10::i#0 = 0
to:do10::@1
do10::@1: scope:[do10] from do10 do10::@1
do10::i#2 = phi( do10/do10::i#0, do10::@1/do10::i#1 )
do10::fn#1 = phi( do10/do10::fn#2, do10::@1/do10::fn#1 )
do10::@1: scope:[do10] from do10 do10::@2
do10::i#3 = phi( do10/do10::i#0, do10::@2/do10::i#1 )
do10::fn#1 = phi( do10/do10::fn#2, do10::@2/do10::fn#3 )
callexecute *do10::fn#1
to:do10::@2
do10::@2: scope:[do10] from do10::@1
do10::fn#3 = phi( do10::@1/do10::fn#1 )
do10::i#2 = phi( do10::@1/do10::i#3 )
do10::i#1 = do10::i#2 + rangenext(0,9)
do10::$1 = do10::i#1 != rangelast(0,9)
if(do10::$1) goto do10::@1
to:do10::@return
do10::@return: scope:[do10] from do10::@1
do10::@return: scope:[do10] from do10::@2
return
to:@return
@ -71,10 +75,12 @@ void()* do10::fn
void()* do10::fn#0
void()* do10::fn#1
void()* do10::fn#2
void()* do10::fn#3
byte do10::i
byte do10::i#0
byte do10::i#1
byte do10::i#2
byte do10::i#3
void hello()
bool~ hello::$0
byte hello::i
@ -93,6 +99,9 @@ Simplifying constant integer cast 0
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (byte) 0
Successful SSA optimization PassNFinalizeNumberTypeConversions
Alias do10::i#2 = do10::i#3
Alias do10::fn#1 = do10::fn#3
Successful SSA optimization Pass2AliasElimination
Identical Phi Values do10::fn#2 do10::fn#0
Identical Phi Values do10::fn#1 do10::fn#2
Successful SSA optimization Pass2IdenticalPhiElimination
@ -122,7 +131,7 @@ Inlining constant with var siblings hello::i#0
Constant inlined hello::i#0 = 0
Constant inlined do10::i#0 = 0
Successful SSA optimization Pass2ConstantInlining
Added new block during phi lifting do10::@2(between do10::@1 and do10::@1)
Added new block during phi lifting do10::@3(between do10::@2 and do10::@1)
Added new block during phi lifting hello::@2(between hello::@1 and hello::@1)
Adding NOP phi() at start of __start
Adding NOP phi() at start of __start::@1
@ -138,12 +147,12 @@ Calls in [do10] to hello:20
Created 2 initial phi equivalence classes
Coalesced [13] hello::i#3 = hello::i#1
Coalesced [24] do10::i#3 = do10::i#1
Coalesced [24] do10::i#4 = do10::i#1
Coalesced down to 2 phi equivalence classes
Culled Empty Block label __start::@2
Culled Empty Block label hello::@2
Culled Empty Block label main::@1
Culled Empty Block label do10::@2
Culled Empty Block label do10::@3
Adding NOP phi() at start of __start
Adding NOP phi() at start of __start::@1
Adding NOP phi() at start of hello
@ -195,17 +204,19 @@ void do10(void()* do10::fn)
do10: scope:[do10] from main
[15] phi()
to:do10::@1
do10::@1: scope:[do10] from do10 do10::@1
[16] do10::i#2 = phi( do10/0, do10::@1/do10::i#1 )
do10::@1: scope:[do10] from do10 do10::@2
[16] do10::i#2 = phi( do10/0, do10::@2/do10::i#1 )
[17] callexecute hello
to:do10::@2
do10::@2: scope:[do10] from do10::@1
[18] do10::i#1 = ++ do10::i#2
[19] if(do10::i#1!=$a) goto do10::@1
to:do10::@return
do10::@return: scope:[do10] from do10::@1
do10::@return: scope:[do10] from do10::@2
[20] return
to:@return
null depth in calling loop Loop head: do10::@1 tails: do10::@1 blocks: do10::@1 in scope hello
null depth in calling loop Loop head: do10::@1 tails: do10::@2 blocks: do10::@2 do10::@1 in scope hello
VARIABLE REGISTER WEIGHTS
void __start()
@ -254,15 +265,15 @@ Uplift Scope [do10] 2,502.5: zp[1]:3 [ do10::i#2 do10::i#1 ]
Uplift Scope [main]
Uplift Scope [__start]
Uplifting [hello] best 800 combination reg byte x [ hello::i#2 hello::i#1 ]
Uplifting [] best 800 combination zp[1]:4 [ idx ]
Uplifting [do10] best 800 combination zp[1]:3 [ do10::i#2 do10::i#1 ]
Uplifting [main] best 800 combination
Uplifting [__start] best 800 combination
Uplifting [hello] best 830 combination reg byte x [ hello::i#2 hello::i#1 ]
Uplifting [] best 830 combination zp[1]:4 [ idx ]
Uplifting [do10] best 830 combination zp[1]:3 [ do10::i#2 do10::i#1 ]
Uplifting [main] best 830 combination
Uplifting [__start] best 830 combination
Attempting to uplift remaining variables inzp[1]:4 [ idx ]
Uplifting [] best 800 combination zp[1]:4 [ idx ]
Uplifting [] best 830 combination zp[1]:4 [ idx ]
Attempting to uplift remaining variables inzp[1]:3 [ do10::i#2 do10::i#1 ]
Uplifting [do10] best 800 combination zp[1]:3 [ do10::i#2 do10::i#1 ]
Uplifting [do10] best 830 combination zp[1]:3 [ do10::i#2 do10::i#1 ]
Allocated (was zp[1]:3) zp[1]:2 [ do10::i#2 do10::i#1 ]
Allocated (was zp[1]:4) zp[1]:3 [ idx ]
@ -357,20 +368,23 @@ do10: {
lda #0
sta.z i
jmp __b1
// [16] phi from do10::@1 to do10::@1 [phi:do10::@1->do10::@1]
__b1_from___b1:
// [16] phi do10::i#2 = do10::i#1 [phi:do10::@1->do10::@1#0] -- register_copy
// [16] phi from do10::@2 to do10::@1 [phi:do10::@2->do10::@1]
__b1_from___b2:
// [16] phi do10::i#2 = do10::i#1 [phi:do10::@2->do10::@1#0] -- register_copy
jmp __b1
// do10::@1
__b1:
// [17] callexecute hello -- jsr
jsr hello
jmp __b2
// do10::@2
__b2:
// [18] do10::i#1 = ++ do10::i#2 -- vbuz1=_inc_vbuz1
inc.z i
// [19] if(do10::i#1!=$a) goto do10::@1 -- vbuz1_neq_vbuc1_then_la1
lda #$a
cmp.z i
bne __b1_from___b1
bne __b1_from___b2
jmp __breturn
// do10::@return
__breturn:
@ -390,14 +404,15 @@ Removing instruction jmp __b1
Removing instruction jmp __breturn
Removing instruction jmp __breturn
Removing instruction jmp __b1
Removing instruction jmp __b2
Removing instruction jmp __breturn
Succesful ASM optimization Pass5NextJumpElimination
Replacing label __b1_from___b1 with __b1
Replacing label __b1_from___b1 with __b1
Replacing label __b1_from___b2 with __b1
Removing instruction __b1_from___init1:
Removing instruction main_from___b1:
Removing instruction __b1_from___b1:
Removing instruction __b1_from___b1:
Removing instruction __b1_from___b2:
Succesful ASM optimization Pass5RedundantLabelElimination
Removing instruction __init1:
Removing instruction __b1:
@ -407,6 +422,7 @@ Removing instruction __breturn:
Removing instruction do10_from_main:
Removing instruction __breturn:
Removing instruction __b1_from_do10:
Removing instruction __b2:
Removing instruction __breturn:
Succesful ASM optimization Pass5UnusedLabelElimination
Removing instruction jmp __b1
@ -515,13 +531,14 @@ do10: {
// [16] phi do10::i#2 = 0 [phi:do10->do10::@1#0] -- vbuz1=vbuc1
lda #0
sta.z i
// [16] phi from do10::@1 to do10::@1 [phi:do10::@1->do10::@1]
// [16] phi do10::i#2 = do10::i#1 [phi:do10::@1->do10::@1#0] -- register_copy
// [16] phi from do10::@2 to do10::@1 [phi:do10::@2->do10::@1]
// [16] phi do10::i#2 = do10::i#1 [phi:do10::@2->do10::@1#0] -- register_copy
// do10::@1
__b1:
// (*fn)()
// [17] callexecute hello -- jsr
jsr hello
// do10::@2
// for( byte i: 0..9)
// [18] do10::i#1 = ++ do10::i#2 -- vbuz1=_inc_vbuz1
inc.z i

View File

@ -47,12 +47,14 @@ void do10(void()* do10::fn)
do10: scope:[do10] from main main::@1
[18] phi()
to:do10::@1
do10::@1: scope:[do10] from do10 do10::@1
[19] do10::i#2 = phi( do10/0, do10::@1/do10::i#1 )
do10::@1: scope:[do10] from do10 do10::@2
[19] do10::i#2 = phi( do10/0, do10::@2/do10::i#1 )
[20] callexecute hello
to:do10::@2
do10::@2: scope:[do10] from do10::@1
[21] do10::i#1 = ++ do10::i#2
[22] if(do10::i#1!=$a) goto do10::@1
to:do10::@return
do10::@return: scope:[do10] from do10::@1
do10::@return: scope:[do10] from do10::@2
[23] return
to:@return

View File

@ -8,15 +8,19 @@ do10: scope:[do10] from main main::@1
do10::fn#3 = phi( main/do10::fn#0, main::@1/do10::fn#1 )
do10::i#0 = 0
to:do10::@1
do10::@1: scope:[do10] from do10 do10::@1
do10::i#2 = phi( do10/do10::i#0, do10::@1/do10::i#1 )
do10::fn#2 = phi( do10/do10::fn#3, do10::@1/do10::fn#2 )
do10::@1: scope:[do10] from do10 do10::@2
do10::i#3 = phi( do10/do10::i#0, do10::@2/do10::i#1 )
do10::fn#2 = phi( do10/do10::fn#3, do10::@2/do10::fn#4 )
callexecute *do10::fn#2
to:do10::@2
do10::@2: scope:[do10] from do10::@1
do10::fn#4 = phi( do10::@1/do10::fn#2 )
do10::i#2 = phi( do10::@1/do10::i#3 )
do10::i#1 = do10::i#2 + rangenext(0,9)
do10::$1 = do10::i#1 != rangelast(0,9)
if(do10::$1) goto do10::@1
to:do10::@return
do10::@return: scope:[do10] from do10::@1
do10::@return: scope:[do10] from do10::@2
return
to:@return
@ -79,10 +83,12 @@ void()* do10::fn#0
void()* do10::fn#1
void()* do10::fn#2
void()* do10::fn#3
void()* do10::fn#4
byte do10::i
byte do10::i#0
byte do10::i#1
byte do10::i#2
byte do10::i#3
void hello()
bool~ hello::$0
byte hello::i
@ -103,6 +109,9 @@ Simplifying constant integer cast 0
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (byte) 0
Successful SSA optimization PassNFinalizeNumberTypeConversions
Alias do10::i#2 = do10::i#3
Alias do10::fn#2 = do10::fn#4
Successful SSA optimization Pass2AliasElimination
Identical Phi Values do10::fn#2 do10::fn#3
Successful SSA optimization Pass2IdenticalPhiElimination
Simple Condition do10::$1 [6] if(do10::i#1!=rangelast(0,9)) goto do10::@1
@ -136,7 +145,7 @@ Replacing constant pointer function [2] callexecute hello
Successful SSA optimization Pass2ConstantCallPointerIdentification
Eliminating unused constant main::f
Successful SSA optimization PassNEliminateUnusedVars
Added new block during phi lifting do10::@2(between do10::@1 and do10::@1)
Added new block during phi lifting do10::@3(between do10::@2 and do10::@1)
Added new block during phi lifting hello::@2(between hello::@1 and hello::@1)
Adding NOP phi() at start of __start
Adding NOP phi() at start of __start::@1
@ -151,12 +160,12 @@ Calls in [do10] to hello:23
Created 2 initial phi equivalence classes
Coalesced [14] hello::i#3 = hello::i#1
Coalesced [27] do10::i#3 = do10::i#1
Coalesced [27] do10::i#4 = do10::i#1
Coalesced down to 2 phi equivalence classes
Culled Empty Block label __start::@2
Culled Empty Block label hello::@2
Culled Empty Block label main::@2
Culled Empty Block label do10::@2
Culled Empty Block label do10::@3
Adding NOP phi() at start of __start
Adding NOP phi() at start of __start::@1
Adding NOP phi() at start of hello
@ -212,17 +221,19 @@ void do10(void()* do10::fn)
do10: scope:[do10] from main main::@1
[18] phi()
to:do10::@1
do10::@1: scope:[do10] from do10 do10::@1
[19] do10::i#2 = phi( do10/0, do10::@1/do10::i#1 )
do10::@1: scope:[do10] from do10 do10::@2
[19] do10::i#2 = phi( do10/0, do10::@2/do10::i#1 )
[20] callexecute hello
to:do10::@2
do10::@2: scope:[do10] from do10::@1
[21] do10::i#1 = ++ do10::i#2
[22] if(do10::i#1!=$a) goto do10::@1
to:do10::@return
do10::@return: scope:[do10] from do10::@1
do10::@return: scope:[do10] from do10::@2
[23] return
to:@return
null depth in calling loop Loop head: do10::@1 tails: do10::@1 blocks: do10::@1 in scope hello
null depth in calling loop Loop head: do10::@1 tails: do10::@2 blocks: do10::@2 do10::@1 in scope hello
VARIABLE REGISTER WEIGHTS
void __start()
@ -282,15 +293,15 @@ Uplift Scope [do10] 2,502.5: zp[1]:3 [ do10::i#2 do10::i#1 ]
Uplift Scope [main]
Uplift Scope [__start]
Uplifting [hello] best 859 combination reg byte y [ hello::i#2 hello::i#1 ]
Uplifting [] best 859 combination zp[1]:6 [ idx ] zp[2]:4 [ msg ]
Uplifting [do10] best 859 combination zp[1]:3 [ do10::i#2 do10::i#1 ]
Uplifting [main] best 859 combination
Uplifting [__start] best 859 combination
Uplifting [hello] best 889 combination reg byte y [ hello::i#2 hello::i#1 ]
Uplifting [] best 889 combination zp[1]:6 [ idx ] zp[2]:4 [ msg ]
Uplifting [do10] best 889 combination zp[1]:3 [ do10::i#2 do10::i#1 ]
Uplifting [main] best 889 combination
Uplifting [__start] best 889 combination
Attempting to uplift remaining variables inzp[1]:6 [ idx ]
Uplifting [] best 859 combination zp[1]:6 [ idx ]
Uplifting [] best 889 combination zp[1]:6 [ idx ]
Attempting to uplift remaining variables inzp[1]:3 [ do10::i#2 do10::i#1 ]
Uplifting [do10] best 859 combination zp[1]:3 [ do10::i#2 do10::i#1 ]
Uplifting [do10] best 889 combination zp[1]:3 [ do10::i#2 do10::i#1 ]
Allocated (was zp[1]:3) zp[1]:2 [ do10::i#2 do10::i#1 ]
Allocated (was zp[2]:4) zp[2]:3 [ msg ]
Allocated (was zp[1]:6) zp[1]:5 [ idx ]
@ -407,20 +418,23 @@ do10: {
lda #0
sta.z i
jmp __b1
// [19] phi from do10::@1 to do10::@1 [phi:do10::@1->do10::@1]
__b1_from___b1:
// [19] phi do10::i#2 = do10::i#1 [phi:do10::@1->do10::@1#0] -- register_copy
// [19] phi from do10::@2 to do10::@1 [phi:do10::@2->do10::@1]
__b1_from___b2:
// [19] phi do10::i#2 = do10::i#1 [phi:do10::@2->do10::@1#0] -- register_copy
jmp __b1
// do10::@1
__b1:
// [20] callexecute hello -- jsr
jsr hello
jmp __b2
// do10::@2
__b2:
// [21] do10::i#1 = ++ do10::i#2 -- vbuz1=_inc_vbuz1
inc.z i
// [22] if(do10::i#1!=$a) goto do10::@1 -- vbuz1_neq_vbuc1_then_la1
lda #$a
cmp.z i
bne __b1_from___b1
bne __b1_from___b2
jmp __breturn
// do10::@return
__breturn:
@ -443,16 +457,17 @@ Removing instruction jmp __breturn
Removing instruction jmp __b1
Removing instruction jmp __breturn
Removing instruction jmp __b1
Removing instruction jmp __b2
Removing instruction jmp __breturn
Succesful ASM optimization Pass5NextJumpElimination
Removing instruction lda #>0
Removing instruction lda #0
Succesful ASM optimization Pass5UnnecesaryLoadElimination
Replacing label __b1_from___b1 with __b1
Replacing label __b1_from___b1 with __b1
Replacing label __b1_from___b2 with __b1
Removing instruction __b1_from___init1:
Removing instruction __b1_from___b1:
Removing instruction __b1_from___b1:
Removing instruction __b1_from___b2:
Succesful ASM optimization Pass5RedundantLabelElimination
Removing instruction __init1:
Removing instruction __b1:
@ -464,6 +479,7 @@ Removing instruction __b1:
Removing instruction do10_from___b1:
Removing instruction __breturn:
Removing instruction __b1_from_do10:
Removing instruction __b2:
Removing instruction __breturn:
Succesful ASM optimization Pass5UnusedLabelElimination
Removing instruction jmp __b1
@ -596,13 +612,14 @@ do10: {
// [19] phi do10::i#2 = 0 [phi:do10->do10::@1#0] -- vbuz1=vbuc1
lda #0
sta.z i
// [19] phi from do10::@1 to do10::@1 [phi:do10::@1->do10::@1]
// [19] phi do10::i#2 = do10::i#1 [phi:do10::@1->do10::@1#0] -- register_copy
// [19] phi from do10::@2 to do10::@1 [phi:do10::@2->do10::@1]
// [19] phi do10::i#2 = do10::i#1 [phi:do10::@2->do10::@1#0] -- register_copy
// do10::@1
__b1:
// (*fn)()
// [20] callexecute hello -- jsr
jsr hello
// do10::@2
// for( byte i: 0..9)
// [21] do10::i#1 = ++ do10::i#2 -- vbuz1=_inc_vbuz1
inc.z i

View File

@ -15,7 +15,7 @@ __start::@return: scope:[__start] from __start::@1
to:@return
__stackcall void fn1()
fn1: scope:[fn1] from main
fn1: scope:[fn1] from main main::@1
[5] idx = ++ idx
to:fn1::@return
fn1::@return: scope:[fn1] from fn1
@ -26,10 +26,14 @@ void main()
main: scope:[main] from __start::@1
[7] phi()
[8] callexecute fn1
to:main::@1
main::@1: scope:[main] from main
[9] SCREEN[idx] = 'a'
[10] callexecute fn1
to:main::@2
main::@2: scope:[main] from main::@1
[11] SCREEN[idx] = 'a'
to:main::@return
main::@return: scope:[main] from main
main::@return: scope:[main] from main::@2
[12] return
to:@return

View File

@ -15,11 +15,15 @@ fn1::@return: scope:[fn1] from fn1
void main()
main: scope:[main] from __start::@1
callexecute *main::f
to:main::@1
main::@1: scope:[main] from main
SCREEN[idx] = 'a'
callexecute *main::f
to:main::@2
main::@2: scope:[main] from main::@1
SCREEN[idx] = 'a'
to:main::@return
main::@return: scope:[main] from main
main::@return: scope:[main] from main::@2
return
to:@return
@ -86,7 +90,7 @@ __start::@return: scope:[__start] from __start::@1
to:@return
__stackcall void fn1()
fn1: scope:[fn1] from main
fn1: scope:[fn1] from main main::@1
[5] idx = ++ idx
to:fn1::@return
fn1::@return: scope:[fn1] from fn1
@ -97,11 +101,15 @@ void main()
main: scope:[main] from __start::@1
[7] phi()
[8] callexecute fn1
to:main::@1
main::@1: scope:[main] from main
[9] SCREEN[idx] = 'a'
[10] callexecute fn1
to:main::@2
main::@2: scope:[main] from main::@1
[11] SCREEN[idx] = 'a'
to:main::@return
main::@return: scope:[main] from main
main::@return: scope:[main] from main::@2
[12] return
to:@return
@ -129,12 +137,12 @@ Uplift Scope [fn1]
Uplift Scope [main]
Uplift Scope [__start]
Uplifting [] best 108 combination zp[1]:2 [ idx ]
Uplifting [fn1] best 108 combination
Uplifting [main] best 108 combination
Uplifting [__start] best 108 combination
Uplifting [] best 114 combination zp[1]:2 [ idx ]
Uplifting [fn1] best 114 combination
Uplifting [main] best 114 combination
Uplifting [__start] best 114 combination
Attempting to uplift remaining variables inzp[1]:2 [ idx ]
Uplifting [] best 108 combination zp[1]:2 [ idx ]
Uplifting [] best 114 combination zp[1]:2 [ idx ]
ASSEMBLER BEFORE OPTIMIZATION
// File Comments
@ -189,12 +197,18 @@ fn1: {
main: {
// [8] callexecute fn1 -- jsr
jsr fn1
jmp __b1
// main::@1
__b1:
// [9] SCREEN[idx] = 'a' -- pbuc1_derefidx_vbuz1=vbuc2
lda #'a'
ldy.z idx
sta SCREEN,y
// [10] callexecute fn1 -- jsr
jsr fn1
jmp __b2
// main::@2
__b2:
// [11] SCREEN[idx] = 'a' -- pbuc1_derefidx_vbuz1=vbuc2
lda #'a'
ldy.z idx
@ -212,6 +226,8 @@ Removing instruction jmp __init1
Removing instruction jmp __b1
Removing instruction jmp __breturn
Removing instruction jmp __breturn
Removing instruction jmp __b1
Removing instruction jmp __b2
Removing instruction jmp __breturn
Succesful ASM optimization Pass5NextJumpElimination
Removing instruction __b1_from___init1:
@ -221,6 +237,8 @@ Removing instruction __init1:
Removing instruction __b1:
Removing instruction __breturn:
Removing instruction __breturn:
Removing instruction __b1:
Removing instruction __b2:
Removing instruction __breturn:
Succesful ASM optimization Pass5UnusedLabelElimination
@ -283,6 +301,7 @@ main: {
// (*f)()
// [8] callexecute fn1 -- jsr
jsr fn1
// main::@1
// SCREEN[idx] = 'a'
// [9] SCREEN[idx] = 'a' -- pbuc1_derefidx_vbuz1=vbuc2
lda #'a'
@ -291,6 +310,7 @@ main: {
// (*f)()
// [10] callexecute fn1 -- jsr
jsr fn1
// main::@2
// SCREEN[idx] = 'a'
// [11] SCREEN[idx] = 'a' -- pbuc1_derefidx_vbuz1=vbuc2
lda #'a'

View File

@ -109,8 +109,8 @@ fn1: {
main: {
.label param_char = $c
.label f = $d
.label j = 3
.label i = 2
.label j = 3
lda #'a'
sta.z i
__b1:

View File

@ -64,8 +64,8 @@ main::@1: scope:[main] from main main::@4
main::@return: scope:[main] from main::@1
[35] return
to:@return
main::@2: scope:[main] from main::@1 main::@3
[36] main::j#2 = phi( main::@1/0, main::@3/main::j#1 )
main::@2: scope:[main] from main::@1 main::@5
[36] main::j#2 = phi( main::@1/0, main::@5/main::j#1 )
[37] if(main::j#2<2) goto main::@3
to:main::@4
main::@4: scope:[main] from main::@2
@ -80,5 +80,7 @@ main::@3: scope:[main] from main::@2
[44] main::$3 = main::j#2 << 1
[45] main::f#0 = main::fns[main::$3]
[46] callexecute *main::f#0
to:main::@5
main::@5: scope:[main] from main::@3
[47] main::j#1 = ++ main::j#2
to:main::@2

View File

@ -57,9 +57,9 @@ main::@2: scope:[main] from main::@1
main::i#6 = phi( main::@1/main::i#2 )
main::j#0 = 0
to:main::@3
main::@3: scope:[main] from main::@2 main::@4
main::i#5 = phi( main::@2/main::i#6, main::@4/main::i#3 )
main::j#2 = phi( main::@2/main::j#0, main::@4/main::j#1 )
main::@3: scope:[main] from main::@2 main::@6
main::i#5 = phi( main::@2/main::i#6, main::@6/main::i#7 )
main::j#2 = phi( main::@2/main::j#0, main::@6/main::j#1 )
main::$1 = main::j#2 < 2
if(main::$1) goto main::@4
to:main::@5
@ -74,12 +74,16 @@ main::@4: scope:[main] from main::@3
main::$3 = main::j#3 * SIZEOF_POINTER
main::f#0 = main::fns[main::$3]
callexecute *main::f#0
main::j#1 = ++ main::j#3
to:main::@3
to:main::@6
main::@5: scope:[main] from main::@3
main::i#4 = phi( main::@3/main::i#5 )
main::i#1 = ++ main::i#4
to:main::@1
main::@6: scope:[main] from main::@4
main::i#7 = phi( main::@4/main::i#3 )
main::j#4 = phi( main::@4/main::j#3 )
main::j#1 = ++ main::j#4
to:main::@3
main::@return: scope:[main] from main::@1
return
to:@return
@ -136,11 +140,13 @@ byte main::i#3
byte main::i#4
byte main::i#5
byte main::i#6
byte main::i#7
byte main::j
byte main::j#0
byte main::j#1
byte main::j#2
byte main::j#3
byte main::j#4
volatile byte main::param_char loadstore
Adding number conversion cast (unumber) 2 in main::$1 = main::j#2 < 2
@ -153,15 +159,17 @@ Finalized unsigned number type (byte) 2
Successful SSA optimization PassNFinalizeNumberTypeConversions
Alias candidate removed (volatile)fn1::b#0 = fn1::param_char fn1::c#0
Alias candidate removed (volatile)fn2::b#0 = fn2::param_char fn2::c#0
Alias candidate removed (volatile)main::i#3 = main::i#5 main::param_char main::j#3 main::j#2 main::i#4
Alias candidate removed (volatile)main::i#3 = main::i#5 main::param_char main::j#3 main::j#2 main::i#4 main::j#4 main::i#7
Alias main::i#2 = main::i#6
Successful SSA optimization Pass2AliasElimination
Alias candidate removed (volatile)fn1::b#0 = fn1::param_char fn1::c#0
Alias candidate removed (volatile)fn2::b#0 = fn2::param_char fn2::c#0
Alias candidate removed (volatile)main::i#3 = main::i#5 main::param_char main::j#3 main::j#2 main::i#4
Alias candidate removed (volatile)main::i#3 = main::i#5 main::param_char main::j#3 main::j#2 main::i#4 main::j#4 main::i#7
Identical Phi Values main::i#3 main::i#5
Identical Phi Values main::j#3 main::j#2
Identical Phi Values main::i#4 main::i#5
Identical Phi Values main::j#4 main::j#3
Identical Phi Values main::i#7 main::i#3
Successful SSA optimization Pass2IdenticalPhiElimination
Identical Phi Values main::i#5 main::i#2
Successful SSA optimization Pass2IdenticalPhiElimination
@ -207,14 +215,15 @@ Calls in [__start] to main:4
Calls in [main] to null:49
Created 2 initial phi equivalence classes
Coalesced [41] main::i#7 = main::i#1
Coalesced [51] main::j#4 = main::j#1
Coalesced [41] main::i#8 = main::i#1
Coalesced [51] main::j#5 = main::j#1
Coalesced down to 2 phi equivalence classes
Culled Empty Block label __start::@2
Culled Empty Block label main::@2
Renumbering block main::@3 to main::@2
Renumbering block main::@4 to main::@3
Renumbering block main::@5 to main::@4
Renumbering block main::@6 to main::@5
Adding NOP phi() at start of __start
Adding NOP phi() at start of __start::@1
Adding NOP phi() at start of main
@ -286,8 +295,8 @@ main::@1: scope:[main] from main main::@4
main::@return: scope:[main] from main::@1
[35] return
to:@return
main::@2: scope:[main] from main::@1 main::@3
[36] main::j#2 = phi( main::@1/0, main::@3/main::j#1 )
main::@2: scope:[main] from main::@1 main::@5
[36] main::j#2 = phi( main::@1/0, main::@5/main::j#1 )
[37] if(main::j#2<2) goto main::@3
to:main::@4
main::@4: scope:[main] from main::@2
@ -302,6 +311,8 @@ main::@3: scope:[main] from main::@2
[44] main::$3 = main::j#2 << 1
[45] main::f#0 = main::fns[main::$3]
[46] callexecute *main::f#0
to:main::@5
main::@5: scope:[main] from main::@3
[47] main::j#1 = ++ main::j#2
to:main::@2
@ -471,25 +482,25 @@ Uplift Scope [fn2] 1.2: zp[1]:8 [ fn2::param_char ] 1: zp[1]:9 [ fn2::b#0 ] 1: z
Uplift Scope [] 1.27: zp[1]:4 [ idx1 ] 1.27: zp[1]:5 [ idx2 ]
Uplift Scope [__start]
Uplifting [main] best 9607 combination zp[2]:18 [ main::f#0 ] zp[1]:3 [ main::j#2 main::j#1 ] reg byte a [ main::$3 ] zp[1]:16 [ main::param_char ] zp[1]:2 [ main::i#2 main::i#1 ]
Uplifting [fn1] best 9599 combination zp[1]:13 [ fn1::param_char ] reg byte y [ fn1::b#0 ] reg byte x [ fn1::c#0 ] zp[2]:11 [ fn1::ret_addr ]
Uplifting [fn2] best 9591 combination zp[1]:8 [ fn2::param_char ] reg byte y [ fn2::b#0 ] reg byte x [ fn2::c#0 ] zp[2]:6 [ fn2::ret_addr ]
Uplifting [] best 9591 combination zp[1]:4 [ idx1 ] zp[1]:5 [ idx2 ]
Uplifting [__start] best 9591 combination
Uplifting [main] best 9907 combination zp[2]:18 [ main::f#0 ] zp[1]:3 [ main::j#2 main::j#1 ] reg byte a [ main::$3 ] zp[1]:16 [ main::param_char ] zp[1]:2 [ main::i#2 main::i#1 ]
Uplifting [fn1] best 9899 combination zp[1]:13 [ fn1::param_char ] reg byte y [ fn1::b#0 ] reg byte x [ fn1::c#0 ] zp[2]:11 [ fn1::ret_addr ]
Uplifting [fn2] best 9891 combination zp[1]:8 [ fn2::param_char ] reg byte y [ fn2::b#0 ] reg byte x [ fn2::c#0 ] zp[2]:6 [ fn2::ret_addr ]
Uplifting [] best 9891 combination zp[1]:4 [ idx1 ] zp[1]:5 [ idx2 ]
Uplifting [__start] best 9891 combination
Attempting to uplift remaining variables inzp[1]:3 [ main::j#2 main::j#1 ]
Uplifting [main] best 9591 combination zp[1]:3 [ main::j#2 main::j#1 ]
Uplifting [main] best 9891 combination zp[1]:3 [ main::j#2 main::j#1 ]
Attempting to uplift remaining variables inzp[1]:16 [ main::param_char ]
Uplifting [main] best 9591 combination zp[1]:16 [ main::param_char ]
Uplifting [main] best 9891 combination zp[1]:16 [ main::param_char ]
Attempting to uplift remaining variables inzp[1]:2 [ main::i#2 main::i#1 ]
Uplifting [main] best 9591 combination zp[1]:2 [ main::i#2 main::i#1 ]
Uplifting [main] best 9891 combination zp[1]:2 [ main::i#2 main::i#1 ]
Attempting to uplift remaining variables inzp[1]:4 [ idx1 ]
Uplifting [] best 9591 combination zp[1]:4 [ idx1 ]
Uplifting [] best 9891 combination zp[1]:4 [ idx1 ]
Attempting to uplift remaining variables inzp[1]:5 [ idx2 ]
Uplifting [] best 9591 combination zp[1]:5 [ idx2 ]
Uplifting [] best 9891 combination zp[1]:5 [ idx2 ]
Attempting to uplift remaining variables inzp[1]:8 [ fn2::param_char ]
Uplifting [fn2] best 9591 combination zp[1]:8 [ fn2::param_char ]
Uplifting [fn2] best 9891 combination zp[1]:8 [ fn2::param_char ]
Attempting to uplift remaining variables inzp[1]:13 [ fn1::param_char ]
Uplifting [fn1] best 9591 combination zp[1]:13 [ fn1::param_char ]
Uplifting [fn1] best 9891 combination zp[1]:13 [ fn1::param_char ]
Allocated (was zp[2]:11) zp[2]:9 [ fn1::ret_addr ]
Allocated (was zp[1]:13) zp[1]:11 [ fn1::param_char ]
Allocated (was zp[1]:16) zp[1]:12 [ main::param_char ]
@ -650,8 +661,8 @@ fn1: {
main: {
.label param_char = $c
.label f = $d
.label j = 3
.label i = 2
.label j = 3
// [33] phi from main to main::@1 [phi:main->main::@1]
__b1_from_main:
// [33] phi main::i#2 = 'a' [phi:main->main::@1#0] -- vbuz1=vbuc1
@ -718,11 +729,14 @@ main: {
sta.z f+1
// [46] callexecute *main::f#0
jsr bi_f
jmp __b5
// main::@5
__b5:
// [47] main::j#1 = ++ main::j#2 -- vbuz1=_inc_vbuz1
inc.z j
// [36] phi from main::@3 to main::@2 [phi:main::@3->main::@2]
__b2_from___b3:
// [36] phi main::j#2 = main::j#1 [phi:main::@3->main::@2#0] -- register_copy
// [36] phi from main::@5 to main::@2 [phi:main::@5->main::@2]
__b2_from___b5:
// [36] phi main::j#2 = main::j#1 [phi:main::@5->main::@2#0] -- register_copy
jmp __b2
bi_f:
jmp (f)
@ -741,6 +755,7 @@ Removing instruction jmp __b1
Removing instruction jmp __breturn
Removing instruction jmp __b2
Removing instruction jmp __b4
Removing instruction jmp __b5
Succesful ASM optimization Pass5NextJumpElimination
Removing instruction lda #0
Removing instruction lda #>0
@ -766,7 +781,8 @@ Removing instruction __b1_from_main:
Removing instruction __breturn:
Removing instruction __b4:
Removing instruction __b1_from___b4:
Removing instruction __b2_from___b3:
Removing instruction __b5:
Removing instruction __b2_from___b5:
Succesful ASM optimization Pass5UnusedLabelElimination
Relabelling long label __b2_from___b1 to __b4
Succesful ASM optimization Pass5RelabelLongLabels
@ -979,8 +995,8 @@ fn1: {
main: {
.label param_char = $c
.label f = $d
.label j = 3
.label i = 2
.label j = 3
// [33] phi from main to main::@1 [phi:main->main::@1]
// [33] phi main::i#2 = 'a' [phi:main->main::@1#0] -- vbuz1=vbuc1
lda #'a'
@ -1045,11 +1061,12 @@ main: {
// (*f)()
// [46] callexecute *main::f#0
jsr bi_f
// main::@5
// for(char j=0;j<2;j++)
// [47] main::j#1 = ++ main::j#2 -- vbuz1=_inc_vbuz1
inc.z j
// [36] phi from main::@3 to main::@2 [phi:main::@3->main::@2]
// [36] phi main::j#2 = main::j#1 [phi:main::@3->main::@2#0] -- register_copy
// [36] phi from main::@5 to main::@2 [phi:main::@5->main::@2]
// [36] phi main::j#2 = main::j#1 [phi:main::@5->main::@2#0] -- register_copy
jmp __b2
bi_f:
jmp (f)

View File

@ -59,9 +59,10 @@ main: {
lda #>fn1
sta.z f+1
__b3:
// char v = (*f)()
// (*f)()
pha
jsr bi_f
// char v = (*f)()
pla
// SCREEN[0] = v
sta SCREEN

View File

@ -23,8 +23,8 @@ void main()
main: scope:[main] from
[8] phi()
to:main::@1
main::@1: scope:[main] from main main::@3
[9] main::i#2 = phi( main/0, main::@3/main::i#1 )
main::@1: scope:[main] from main main::@4
[9] main::i#2 = phi( main/0, main::@4/main::i#1 )
[10] main::i#1 = ++ main::i#2
[11] main::$0 = main::i#1 & 1
[12] if(main::$0==0) goto main::@2
@ -37,5 +37,7 @@ main::@3: scope:[main] from main::@1 main::@2
sideeffect stackpushbytes(1)
[16] callexecute *main::f#3
[17] main::v#0 = stackpull(byte)
to:main::@4
main::@4: scope:[main] from main::@3
[18] *main::SCREEN = main::v#0
to:main::@1

View File

@ -2,11 +2,10 @@ Resolved forward reference fn1 to byte fn1()
Resolved forward reference fn2 to byte fn2()
Setting inferred __stackcall on procedure affected by address-of __stackcall byte fn1() caused by statement main::f = &fn1
Setting inferred __stackcall on procedure affected by address-of __stackcall byte fn2() caused by statement main::f = &fn2
Eliminating unused variable with no statement main::$2
Calling convention STACK_CALL adding prepare/execute/finalize for main::v = call *main::f
Calling convention STACK_CALL adding prepare/execute/finalize for main::$2 = call *main::f
Calling convention STACK_CALL adding stack return stackidx(byte,fn1::OFFSET_STACK_RETURN_0) = fn1::return
Calling convention STACK_CALL adding stack return stackidx(byte,fn2::OFFSET_STACK_RETURN_0) = fn2::return
Calling convention STACK_CALL adding stack pull main::v = stackpull(byte)
Calling convention STACK_CALL adding stack pull main::$2 = stackpull(byte)
CONTROL FLOW GRAPH SSA
@ -15,27 +14,31 @@ main: scope:[main] from __start
main::f#0 = (byte()*) 0
main::i#0 = 0
to:main::@1
main::@1: scope:[main] from main main::@3
main::i#2 = phi( main/main::i#0, main::@3/main::i#3 )
main::@1: scope:[main] from main main::@4
main::i#2 = phi( main/main::i#0, main::@4/main::i#3 )
main::i#1 = ++ main::i#2
main::$0 = main::i#1 & 1
main::$1 = main::$0 == 0
if(main::$1) goto main::@2
to:main::@4
to:main::@5
main::@2: scope:[main] from main::@1
main::i#4 = phi( main::@1/main::i#1 )
main::i#5 = phi( main::@1/main::i#1 )
main::f#1 = &fn1
to:main::@3
main::@4: scope:[main] from main::@1
main::i#5 = phi( main::@1/main::i#1 )
main::@5: scope:[main] from main::@1
main::i#6 = phi( main::@1/main::i#1 )
main::f#2 = &fn2
to:main::@3
main::@3: scope:[main] from main::@2 main::@4
main::i#3 = phi( main::@2/main::i#4, main::@4/main::i#5 )
main::f#3 = phi( main::@2/main::f#1, main::@4/main::f#2 )
main::@3: scope:[main] from main::@2 main::@5
main::i#4 = phi( main::@2/main::i#5, main::@5/main::i#6 )
main::f#3 = phi( main::@2/main::f#1, main::@5/main::f#2 )
sideeffect stackpushbytes(1)
callexecute *main::f#3
main::v#0 = stackpull(byte)
main::$2 = stackpull(byte)
to:main::@4
main::@4: scope:[main] from main::@3
main::i#3 = phi( main::@3/main::i#4 )
main::v#0 = main::$2
main::SCREEN[0] = main::v#0
to:main::@1
main::@return: scope:[main] from
@ -96,6 +99,7 @@ byte fn2::return#2
void main()
number~ main::$0
bool~ main::$1
byte~ main::$2
constant byte* const main::SCREEN = (byte*)$400
byte()* main::f
byte()* main::f#0
@ -109,6 +113,7 @@ byte main::i#2
byte main::i#3
byte main::i#4
byte main::i#5
byte main::i#6
byte main::v
byte main::v#0
@ -129,7 +134,9 @@ Finalized unsigned number type (byte) 0
Finalized unsigned number type (byte) 0
Successful SSA optimization PassNFinalizeNumberTypeConversions
Inferred type updated to byte in main::$0 = main::i#1 & 1
Alias main::i#1 = main::i#4 main::i#5
Alias main::i#1 = main::i#5 main::i#6
Alias main::i#3 = main::i#4
Alias main::v#0 = main::$2
Alias fn1::return#0 = fn1::return#2 fn1::return#1
Alias fn2::return#0 = fn2::return#2 fn2::return#1
Successful SSA optimization Pass2AliasElimination
@ -163,15 +170,15 @@ Successful SSA optimization Pass2ConstantInlining
Finalized unsigned number type (byte) 1
Successful SSA optimization PassNFinalizeNumberTypeConversions
Adding NOP phi() at start of main
Adding NOP phi() at start of main::@4
Adding NOP phi() at start of main::@5
Adding NOP phi() at start of main::@2
CALL GRAPH
Calls in [main] to null:16
Created 2 initial phi equivalence classes
Coalesced [19] main::i#6 = main::i#1
Coalesced [19] main::i#7 = main::i#1
Coalesced down to 2 phi equivalence classes
Culled Empty Block label main::@4
Culled Empty Block label main::@5
Adding NOP phi() at start of main
Adding NOP phi() at start of main::@2
@ -201,8 +208,8 @@ void main()
main: scope:[main] from
[8] phi()
to:main::@1
main::@1: scope:[main] from main main::@3
[9] main::i#2 = phi( main/0, main::@3/main::i#1 )
main::@1: scope:[main] from main main::@4
[9] main::i#2 = phi( main/0, main::@4/main::i#1 )
[10] main::i#1 = ++ main::i#2
[11] main::$0 = main::i#1 & 1
[12] if(main::$0==0) goto main::@2
@ -215,6 +222,8 @@ main::@3: scope:[main] from main::@1 main::@2
sideeffect stackpushbytes(1)
[16] callexecute *main::f#3
[17] main::v#0 = stackpull(byte)
to:main::@4
main::@4: scope:[main] from main::@3
[18] *main::SCREEN = main::v#0
to:main::@1
@ -282,12 +291,12 @@ Uplift Scope [fn1] 4: zp[1]:6 [ fn1::return#0 ]
Uplift Scope [fn2] 4: zp[1]:5 [ fn2::return#0 ]
Uplift Scope []
Uplifting [main] best 829 combination zp[1]:2 [ main::i#2 main::i#1 ] reg byte a [ main::$0 ] reg byte a [ main::v#0 ] zp[2]:3 [ main::f#3 ]
Uplifting [fn1] best 823 combination reg byte a [ fn1::return#0 ]
Uplifting [fn2] best 817 combination reg byte a [ fn2::return#0 ]
Uplifting [] best 817 combination
Uplifting [main] best 859 combination zp[1]:2 [ main::i#2 main::i#1 ] reg byte a [ main::$0 ] reg byte a [ main::v#0 ] zp[2]:3 [ main::f#3 ]
Uplifting [fn1] best 853 combination reg byte a [ fn1::return#0 ]
Uplifting [fn2] best 847 combination reg byte a [ fn2::return#0 ]
Uplifting [] best 847 combination
Attempting to uplift remaining variables inzp[1]:2 [ main::i#2 main::i#1 ]
Uplifting [main] best 817 combination zp[1]:2 [ main::i#2 main::i#1 ]
Uplifting [main] best 847 combination zp[1]:2 [ main::i#2 main::i#1 ]
ASSEMBLER BEFORE OPTIMIZATION
// File Comments
@ -388,11 +397,14 @@ main: {
jsr bi_f
// [17] main::v#0 = stackpull(byte) -- vbuaa=_stackpullbyte_
pla
jmp __b4
// main::@4
__b4:
// [18] *main::SCREEN = main::v#0 -- _deref_pbuc1=vbuaa
sta SCREEN
// [9] phi from main::@3 to main::@1 [phi:main::@3->main::@1]
__b1_from___b3:
// [9] phi main::i#2 = main::i#1 [phi:main::@3->main::@1#0] -- register_copy
// [9] phi from main::@4 to main::@1 [phi:main::@4->main::@1]
__b1_from___b4:
// [9] phi main::i#2 = main::i#1 [phi:main::@4->main::@1#0] -- register_copy
jmp __b1
bi_f:
jmp (f)
@ -405,6 +417,7 @@ Removing instruction jmp __breturn
Removing instruction jmp __b1
Removing instruction jmp __b2
Removing instruction jmp __b3
Removing instruction jmp __b4
Succesful ASM optimization Pass5NextJumpElimination
Replacing label __b2_from___b1 with __b2
Removing instruction __b2_from___b1:
@ -414,7 +427,8 @@ Removing instruction __breturn:
Removing instruction __breturn:
Removing instruction __b1_from_main:
Removing instruction __b3_from___b1:
Removing instruction __b1_from___b3:
Removing instruction __b4:
Removing instruction __b1_from___b4:
Succesful ASM optimization Pass5UnusedLabelElimination
FINAL SYMBOL TABLE
@ -541,18 +555,20 @@ main: {
sta.z f+1
// main::@3
__b3:
// char v = (*f)()
// (*f)()
// sideeffect stackpushbytes(1) -- _stackpushbyte_1
pha
// [16] callexecute *main::f#3
jsr bi_f
// char v = (*f)()
// [17] main::v#0 = stackpull(byte) -- vbuaa=_stackpullbyte_
pla
// main::@4
// SCREEN[0] = v
// [18] *main::SCREEN = main::v#0 -- _deref_pbuc1=vbuaa
sta SCREEN
// [9] phi from main::@3 to main::@1 [phi:main::@3->main::@1]
// [9] phi main::i#2 = main::i#1 [phi:main::@3->main::@1#0] -- register_copy
// [9] phi from main::@4 to main::@1 [phi:main::@4->main::@1]
// [9] phi main::i#2 = main::i#1 [phi:main::@4->main::@1#0] -- register_copy
jmp __b1
bi_f:
jmp (f)

View File

@ -12,6 +12,7 @@
main: {
// (*proc_ptr)()
jsr proc1
// (*proc_ptr)()
jsr proc2
// }
rts

View File

@ -3,24 +3,27 @@ void main()
main: scope:[main] from
[0] phi()
[1] callexecute proc1
[2] callexecute proc2
to:main::@1
main::@1: scope:[main] from main
[2] phi()
[3] callexecute proc2
to:main::@return
main::@return: scope:[main] from main
[3] return
main::@return: scope:[main] from main::@1
[4] return
to:@return
__stackcall void proc2()
proc2: scope:[proc2] from main
[4] *(SCREEN+1) = 'b'
proc2: scope:[proc2] from main::@1
[5] *(SCREEN+1) = 'b'
to:proc2::@return
proc2::@return: scope:[proc2] from proc2
[5] return
[6] return
to:@return
__stackcall void proc1()
proc1: scope:[proc1] from
[6] *SCREEN = 'a'
proc1: scope:[proc1] from main
[7] *SCREEN = 'a'
to:proc1::@return
proc1::@return: scope:[proc1] from proc1
[7] return
[8] return
to:@return

View File

@ -24,11 +24,13 @@ void main()
main: scope:[main] from __start::@1
proc_ptr#0 = &proc1
callexecute *proc_ptr#0
to:main::@1
main::@1: scope:[main] from main
proc_ptr#1 = &proc2
callexecute *proc_ptr#1
to:main::@return
main::@return: scope:[main] from main
proc_ptr#6 = phi( main/proc_ptr#1 )
main::@return: scope:[main] from main::@1
proc_ptr#6 = phi( main::@1/proc_ptr#1 )
proc_ptr#2 = proc_ptr#6
return
to:@return
@ -110,12 +112,14 @@ Successful SSA optimization PassNEliminateEmptyStart
Consolidated array index constant in *(SCREEN+1)
Successful SSA optimization Pass2ConstantAdditionElimination
Adding NOP phi() at start of main
Adding NOP phi() at start of main::@1
CALL GRAPH
Calls in [main] to proc1:1 proc2:2
Calls in [main] to proc1:1 proc2:3
Created 0 initial phi equivalence classes
Coalesced down to 0 phi equivalence classes
Adding NOP phi() at start of main
Adding NOP phi() at start of main::@1
FINAL CONTROL FLOW GRAPH
@ -123,26 +127,29 @@ void main()
main: scope:[main] from
[0] phi()
[1] callexecute proc1
[2] callexecute proc2
to:main::@1
main::@1: scope:[main] from main
[2] phi()
[3] callexecute proc2
to:main::@return
main::@return: scope:[main] from main
[3] return
main::@return: scope:[main] from main::@1
[4] return
to:@return
__stackcall void proc2()
proc2: scope:[proc2] from main
[4] *(SCREEN+1) = 'b'
proc2: scope:[proc2] from main::@1
[5] *(SCREEN+1) = 'b'
to:proc2::@return
proc2::@return: scope:[proc2] from proc2
[5] return
[6] return
to:@return
__stackcall void proc1()
proc1: scope:[proc1] from
[6] *SCREEN = 'a'
proc1: scope:[proc1] from main
[7] *SCREEN = 'a'
to:proc1::@return
proc1::@return: scope:[proc1] from proc1
[7] return
[8] return
to:@return
@ -155,8 +162,8 @@ void()* proc_ptr
Initial phi equivalence classes
Complete equivalence classes
REGISTER UPLIFT POTENTIAL REGISTERS
Statement [4] *(SCREEN+1) = 'b' [ ] ( proc2:2 [ ] { } ) always clobbers reg byte a
Statement [6] *SCREEN = 'a' [ ] ( proc1:1 [ ] { } ) always clobbers reg byte a
Statement [5] *(SCREEN+1) = 'b' [ ] ( proc2:3 [ ] { } ) always clobbers reg byte a
Statement [7] *SCREEN = 'a' [ ] ( proc1:1 [ ] { } ) always clobbers reg byte a
REGISTER UPLIFT SCOPES
Uplift Scope [proc1]
@ -164,10 +171,10 @@ Uplift Scope [proc2]
Uplift Scope [main]
Uplift Scope []
Uplifting [proc1] best 51 combination
Uplifting [proc2] best 51 combination
Uplifting [main] best 51 combination
Uplifting [] best 51 combination
Uplifting [proc1] best 54 combination
Uplifting [proc2] best 54 combination
Uplifting [main] best 54 combination
Uplifting [] best 54 combination
ASSEMBLER BEFORE OPTIMIZATION
// File Comments
@ -188,43 +195,52 @@ ASSEMBLER BEFORE OPTIMIZATION
main: {
// [1] callexecute proc1 -- jsr
jsr proc1
// [2] callexecute proc2 -- jsr
// [2] phi from main to main::@1 [phi:main->main::@1]
__b1_from_main:
jmp __b1
// main::@1
__b1:
// [3] callexecute proc2 -- jsr
jsr proc2
jmp __breturn
// main::@return
__breturn:
// [3] return
// [4] return
rts
}
// proc2
proc2: {
// [4] *(SCREEN+1) = 'b' -- _deref_pbuc1=vbuc2
// [5] *(SCREEN+1) = 'b' -- _deref_pbuc1=vbuc2
lda #'b'
sta SCREEN+1
jmp __breturn
// proc2::@return
__breturn:
// [5] return
// [6] return
rts
}
// proc1
proc1: {
// [6] *SCREEN = 'a' -- _deref_pbuc1=vbuc2
// [7] *SCREEN = 'a' -- _deref_pbuc1=vbuc2
lda #'a'
sta SCREEN
jmp __breturn
// proc1::@return
__breturn:
// [7] return
// [8] return
rts
}
// File Data
ASSEMBLER OPTIMIZATIONS
Removing instruction jmp __b1
Removing instruction jmp __breturn
Removing instruction jmp __breturn
Removing instruction jmp __breturn
Succesful ASM optimization Pass5NextJumpElimination
Removing instruction __b1_from_main:
Succesful ASM optimization Pass5RedundantLabelElimination
Removing instruction __b1:
Removing instruction __breturn:
Removing instruction __breturn:
Removing instruction __breturn:
@ -261,33 +277,36 @@ main: {
// (*proc_ptr)()
// [1] callexecute proc1 -- jsr
jsr proc1
// [2] callexecute proc2 -- jsr
// [2] phi from main to main::@1 [phi:main->main::@1]
// main::@1
// (*proc_ptr)()
// [3] callexecute proc2 -- jsr
jsr proc2
// main::@return
// }
// [3] return
// [4] return
rts
}
// proc2
proc2: {
// SCREEN[1] = 'b'
// [4] *(SCREEN+1) = 'b' -- _deref_pbuc1=vbuc2
// [5] *(SCREEN+1) = 'b' -- _deref_pbuc1=vbuc2
lda #'b'
sta SCREEN+1
// proc2::@return
// }
// [5] return
// [6] return
rts
}
// proc1
proc1: {
// SCREEN[0] = 'a'
// [6] *SCREEN = 'a' -- _deref_pbuc1=vbuc2
// [7] *SCREEN = 'a' -- _deref_pbuc1=vbuc2
lda #'a'
sta SCREEN
// proc1::@return
// }
// [7] return
// [8] return
rts
}
// File Data