1
0
mirror of https://gitlab.com/camelot/kickc.git synced 2024-09-08 17:54:40 +00:00

Added missing stack fragments.

This commit is contained in:
Jesper Gravgaard 2020-02-27 19:35:43 +01:00
parent c44cb02b96
commit 378798d6ba
11 changed files with 86 additions and 59 deletions

View File

@ -0,0 +1,5 @@
tsx
lda {m1}
sta STACK_BASE+{c1},x
lda {m1}+1
sta STACK_BASE+{c1}+1,x

View File

@ -0,0 +1,4 @@
lda #0
pha
lda #<{c1}
pha

View File

@ -0,0 +1,4 @@
lda #>{c1}
pha
lda #<{c1}
pha

View File

@ -0,0 +1,4 @@
lda {m1}+1
pha
lda {m1}
pha

View File

@ -0,0 +1,5 @@
tsx
lda STACK_BASE+{c1},x
sta {m1}
lda STACK_BASE+{c1}+1,x
sta {m1}+1

View File

@ -0,0 +1,5 @@
tsx
lda STACK_BASE+{c1},x
sta {m1}
lda STACK_BASE+{c1}+1,x
sta {m1}+1

View File

@ -6,10 +6,10 @@ void main() {
}
void fillscreen(byte c) {
for(byte j : 0..255) {
byte* SCREEN2 = SCREEN+$100;
byte* SCREEN3 = SCREEN+$200;
byte* SCREEN4 = SCREEN+$3e8;
for(byte j : 0..249) {
byte* SCREEN2 = SCREEN+250;
byte* SCREEN3 = SCREEN+500;
byte* SCREEN4 = SCREEN+750;
SCREEN[j] = c;
SCREEN2[j] = c;
SCREEN3[j] = c;

View File

@ -12,9 +12,9 @@ main: {
}
// fillscreen(byte register(A) c)
fillscreen: {
.label SCREEN2 = SCREEN+$100
.label SCREEN3 = SCREEN+$200
.label SCREEN4 = SCREEN+$3e8
.label SCREEN2 = SCREEN+$fa
.label SCREEN3 = SCREEN+$1f4
.label SCREEN4 = SCREEN+$2ee
ldx #0
__b1:
// SCREEN[j] = c
@ -25,9 +25,9 @@ fillscreen: {
sta SCREEN3,x
// SCREEN4[j] = c
sta SCREEN4,x
// for(byte j : 0..255)
// for(byte j : 0..249)
inx
cpx #0
cpx #$fa
bne __b1
// }
rts

View File

@ -29,7 +29,7 @@ fillscreen::@1: scope:[fillscreen] from fillscreen fillscreen::@1
[12] *((const byte*) fillscreen::SCREEN3#0 + (byte) fillscreen::j#2) ← (byte) fillscreen::c#0
[13] *((const byte*) fillscreen::SCREEN4#0 + (byte) fillscreen::j#2) ← (byte) fillscreen::c#0
[14] (byte) fillscreen::j#1 ← ++ (byte) fillscreen::j#2
[15] if((byte) fillscreen::j#1!=(byte) 0) goto fillscreen::@1
[15] if((byte) fillscreen::j#1!=(byte) $fa) goto fillscreen::@1
to:fillscreen::@return
fillscreen::@return: scope:[fillscreen] from fillscreen::@1
[16] return

View File

@ -26,18 +26,18 @@ fillscreen: scope:[fillscreen] from main
fillscreen::@1: scope:[fillscreen] from fillscreen fillscreen::@1
(byte) fillscreen::j#2 ← phi( fillscreen/(byte) fillscreen::j#0 fillscreen::@1/(byte) fillscreen::j#1 )
(byte) fillscreen::c#1 ← phi( fillscreen/(byte) fillscreen::c#2 fillscreen::@1/(byte) fillscreen::c#1 )
(byte*~) fillscreen::$0 ← (const byte*) SCREEN + (number) $100
(byte*~) fillscreen::$0 ← (const byte*) SCREEN + (number) $fa
(byte*) fillscreen::SCREEN2#0 ← (byte*~) fillscreen::$0
(byte*~) fillscreen::$1 ← (const byte*) SCREEN + (number) $200
(byte*~) fillscreen::$1 ← (const byte*) SCREEN + (number) $1f4
(byte*) fillscreen::SCREEN3#0 ← (byte*~) fillscreen::$1
(byte*~) fillscreen::$2 ← (const byte*) SCREEN + (number) $3e8
(byte*~) fillscreen::$2 ← (const byte*) SCREEN + (number) $2ee
(byte*) fillscreen::SCREEN4#0 ← (byte*~) fillscreen::$2
*((const byte*) SCREEN + (byte) fillscreen::j#2) ← (byte) fillscreen::c#1
*((byte*) fillscreen::SCREEN2#0 + (byte) fillscreen::j#2) ← (byte) fillscreen::c#1
*((byte*) fillscreen::SCREEN3#0 + (byte) fillscreen::j#2) ← (byte) fillscreen::c#1
*((byte*) fillscreen::SCREEN4#0 + (byte) fillscreen::j#2) ← (byte) fillscreen::c#1
(byte) fillscreen::j#1 ← (byte) fillscreen::j#2 + rangenext(0,$ff)
(bool~) fillscreen::$3 ← (byte) fillscreen::j#1 != rangelast(0,$ff)
(byte) fillscreen::j#1 ← (byte) fillscreen::j#2 + rangenext(0,$f9)
(bool~) fillscreen::$3 ← (byte) fillscreen::j#1 != rangelast(0,$f9)
if((bool~) fillscreen::$3) goto fillscreen::@1
to:fillscreen::@return
fillscreen::@return: scope:[fillscreen] from fillscreen::@1
@ -83,18 +83,18 @@ SYMBOL TABLE SSA
(byte) main::c
(byte) main::c#0
Adding number conversion cast (unumber) $100 in (byte*~) fillscreen::$0 ← (const byte*) SCREEN + (number) $100
Adding number conversion cast (unumber) $200 in (byte*~) fillscreen::$1 ← (const byte*) SCREEN + (number) $200
Adding number conversion cast (unumber) $3e8 in (byte*~) fillscreen::$2 ← (const byte*) SCREEN + (number) $3e8
Adding number conversion cast (unumber) $fa in (byte*~) fillscreen::$0 ← (const byte*) SCREEN + (number) $fa
Adding number conversion cast (unumber) $1f4 in (byte*~) fillscreen::$1 ← (const byte*) SCREEN + (number) $1f4
Adding number conversion cast (unumber) $2ee in (byte*~) fillscreen::$2 ← (const byte*) SCREEN + (number) $2ee
Successful SSA optimization PassNAddNumberTypeConversions
Simplifying constant pointer cast (byte*) 1024
Simplifying constant integer cast $100
Simplifying constant integer cast $200
Simplifying constant integer cast $3e8
Simplifying constant integer cast $fa
Simplifying constant integer cast $1f4
Simplifying constant integer cast $2ee
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (word) $100
Finalized unsigned number type (word) $200
Finalized unsigned number type (word) $3e8
Finalized unsigned number type (byte) $fa
Finalized unsigned number type (word) $1f4
Finalized unsigned number type (word) $2ee
Successful SSA optimization PassNFinalizeNumberTypeConversions
Alias (byte*) fillscreen::SCREEN2#0 = (byte*~) fillscreen::$0
Alias (byte*) fillscreen::SCREEN3#0 = (byte*~) fillscreen::$1
@ -103,24 +103,24 @@ Successful SSA optimization Pass2AliasElimination
Identical Phi Values (byte) fillscreen::c#2 (byte) fillscreen::c#0
Identical Phi Values (byte) fillscreen::c#1 (byte) fillscreen::c#2
Successful SSA optimization Pass2IdenticalPhiElimination
Simple Condition (bool~) fillscreen::$3 [16] if((byte) fillscreen::j#1!=rangelast(0,$ff)) goto fillscreen::@1
Simple Condition (bool~) fillscreen::$3 [16] if((byte) fillscreen::j#1!=rangelast(0,$f9)) goto fillscreen::@1
Successful SSA optimization Pass2ConditionalJumpSimplification
Constant right-side identified [7] (byte*) fillscreen::SCREEN2#0 ← (const byte*) SCREEN + (word) $100
Constant right-side identified [8] (byte*) fillscreen::SCREEN3#0 ← (const byte*) SCREEN + (word) $200
Constant right-side identified [9] (byte*) fillscreen::SCREEN4#0 ← (const byte*) SCREEN + (word) $3e8
Constant right-side identified [7] (byte*) fillscreen::SCREEN2#0 ← (const byte*) SCREEN + (byte) $fa
Constant right-side identified [8] (byte*) fillscreen::SCREEN3#0 ← (const byte*) SCREEN + (word) $1f4
Constant right-side identified [9] (byte*) fillscreen::SCREEN4#0 ← (const byte*) SCREEN + (word) $2ee
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant (const byte) fillscreen::j#0 = 0
Constant (const byte*) fillscreen::SCREEN2#0 = SCREEN+$100
Constant (const byte*) fillscreen::SCREEN3#0 = SCREEN+$200
Constant (const byte*) fillscreen::SCREEN4#0 = SCREEN+$3e8
Constant (const byte*) fillscreen::SCREEN2#0 = SCREEN+$fa
Constant (const byte*) fillscreen::SCREEN3#0 = SCREEN+$1f4
Constant (const byte*) fillscreen::SCREEN4#0 = SCREEN+$2ee
Successful SSA optimization Pass2ConstantIdentification
Resolved ranged next value [14] fillscreen::j#1 ← ++ fillscreen::j#2 to ++
Resolved ranged comparison value [16] if(fillscreen::j#1!=rangelast(0,$ff)) goto fillscreen::@1 to (number) 0
Adding number conversion cast (unumber) 0 in if((byte) fillscreen::j#1!=(number) 0) goto fillscreen::@1
Resolved ranged comparison value [16] if(fillscreen::j#1!=rangelast(0,$f9)) goto fillscreen::@1 to (number) $fa
Adding number conversion cast (unumber) $fa in if((byte) fillscreen::j#1!=(number) $fa) goto fillscreen::@1
Successful SSA optimization PassNAddNumberTypeConversions
Simplifying constant integer cast 0
Simplifying constant integer cast $fa
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (byte) 0
Finalized unsigned number type (byte) $fa
Successful SSA optimization PassNFinalizeNumberTypeConversions
Inlining constant with var siblings (const byte) fillscreen::j#0
Constant inlined fillscreen::j#0 = (byte) 0
@ -180,7 +180,7 @@ fillscreen::@1: scope:[fillscreen] from fillscreen fillscreen::@1
[12] *((const byte*) fillscreen::SCREEN3#0 + (byte) fillscreen::j#2) ← (byte) fillscreen::c#0
[13] *((const byte*) fillscreen::SCREEN4#0 + (byte) fillscreen::j#2) ← (byte) fillscreen::c#0
[14] (byte) fillscreen::j#1 ← ++ (byte) fillscreen::j#2
[15] if((byte) fillscreen::j#1!=(byte) 0) goto fillscreen::@1
[15] if((byte) fillscreen::j#1!=(byte) $fa) goto fillscreen::@1
to:fillscreen::@return
fillscreen::@return: scope:[fillscreen] from fillscreen::@1
[16] return
@ -258,9 +258,9 @@ main: {
// fillscreen
// fillscreen(byte zp(4) c)
fillscreen: {
.label SCREEN2 = SCREEN+$100
.label SCREEN3 = SCREEN+$200
.label SCREEN4 = SCREEN+$3e8
.label SCREEN2 = SCREEN+$fa
.label SCREEN3 = SCREEN+$1f4
.label SCREEN4 = SCREEN+$2ee
.label c = 4
.label j = 2
// [9] phi from fillscreen to fillscreen::@1 [phi:fillscreen->fillscreen::@1]
@ -293,9 +293,9 @@ fillscreen: {
sta SCREEN4,y
// [14] (byte) fillscreen::j#1 ← ++ (byte) fillscreen::j#2 -- vbuz1=_inc_vbuz1
inc.z j
// [15] if((byte) fillscreen::j#1!=(byte) 0) goto fillscreen::@1 -- vbuz1_neq_0_then_la1
lda.z j
cmp #0
// [15] if((byte) fillscreen::j#1!=(byte) $fa) goto fillscreen::@1 -- vbuz1_neq_vbuc1_then_la1
lda #$fa
cmp.z j
bne __b1_from___b1
jmp __breturn
// fillscreen::@return
@ -359,9 +359,9 @@ main: {
// fillscreen
// fillscreen(byte register(A) c)
fillscreen: {
.label SCREEN2 = SCREEN+$100
.label SCREEN3 = SCREEN+$200
.label SCREEN4 = SCREEN+$3e8
.label SCREEN2 = SCREEN+$fa
.label SCREEN3 = SCREEN+$1f4
.label SCREEN4 = SCREEN+$2ee
// [9] phi from fillscreen to fillscreen::@1 [phi:fillscreen->fillscreen::@1]
__b1_from_fillscreen:
// [9] phi (byte) fillscreen::j#2 = (byte) 0 [phi:fillscreen->fillscreen::@1#0] -- vbuxx=vbuc1
@ -383,8 +383,8 @@ fillscreen: {
sta SCREEN4,x
// [14] (byte) fillscreen::j#1 ← ++ (byte) fillscreen::j#2 -- vbuxx=_inc_vbuxx
inx
// [15] if((byte) fillscreen::j#1!=(byte) 0) goto fillscreen::@1 -- vbuxx_neq_0_then_la1
cpx #0
// [15] if((byte) fillscreen::j#1!=(byte) $fa) goto fillscreen::@1 -- vbuxx_neq_vbuc1_then_la1
cpx #$fa
bne __b1_from___b1
jmp __breturn
// fillscreen::@return
@ -431,11 +431,11 @@ FINAL SYMBOL TABLE
(label) fillscreen::@1
(label) fillscreen::@return
(byte*) fillscreen::SCREEN2
(const byte*) fillscreen::SCREEN2#0 SCREEN2 = (const byte*) SCREEN+(word) $100
(const byte*) fillscreen::SCREEN2#0 SCREEN2 = (const byte*) SCREEN+(byte) $fa
(byte*) fillscreen::SCREEN3
(const byte*) fillscreen::SCREEN3#0 SCREEN3 = (const byte*) SCREEN+(word) $200
(const byte*) fillscreen::SCREEN3#0 SCREEN3 = (const byte*) SCREEN+(word) $1f4
(byte*) fillscreen::SCREEN4
(const byte*) fillscreen::SCREEN4#0 SCREEN4 = (const byte*) SCREEN+(word) $3e8
(const byte*) fillscreen::SCREEN4#0 SCREEN4 = (const byte*) SCREEN+(word) $2ee
(byte) fillscreen::c
(byte) fillscreen::c#0 reg byte a 5.111111111111112
(byte) fillscreen::j
@ -485,9 +485,9 @@ main: {
// fillscreen
// fillscreen(byte register(A) c)
fillscreen: {
.label SCREEN2 = SCREEN+$100
.label SCREEN3 = SCREEN+$200
.label SCREEN4 = SCREEN+$3e8
.label SCREEN2 = SCREEN+$fa
.label SCREEN3 = SCREEN+$1f4
.label SCREEN4 = SCREEN+$2ee
// [9] phi from fillscreen to fillscreen::@1 [phi:fillscreen->fillscreen::@1]
// [9] phi (byte) fillscreen::j#2 = (byte) 0 [phi:fillscreen->fillscreen::@1#0] -- vbuxx=vbuc1
ldx #0
@ -507,11 +507,11 @@ fillscreen: {
// SCREEN4[j] = c
// [13] *((const byte*) fillscreen::SCREEN4#0 + (byte) fillscreen::j#2) ← (byte) fillscreen::c#0 -- pbuc1_derefidx_vbuxx=vbuaa
sta SCREEN4,x
// for(byte j : 0..255)
// for(byte j : 0..249)
// [14] (byte) fillscreen::j#1 ← ++ (byte) fillscreen::j#2 -- vbuxx=_inc_vbuxx
inx
// [15] if((byte) fillscreen::j#1!=(byte) 0) goto fillscreen::@1 -- vbuxx_neq_0_then_la1
cpx #0
// [15] if((byte) fillscreen::j#1!=(byte) $fa) goto fillscreen::@1 -- vbuxx_neq_vbuc1_then_la1
cpx #$fa
bne __b1
// fillscreen::@return
// }

View File

@ -6,11 +6,11 @@
(label) fillscreen::@1
(label) fillscreen::@return
(byte*) fillscreen::SCREEN2
(const byte*) fillscreen::SCREEN2#0 SCREEN2 = (const byte*) SCREEN+(word) $100
(const byte*) fillscreen::SCREEN2#0 SCREEN2 = (const byte*) SCREEN+(byte) $fa
(byte*) fillscreen::SCREEN3
(const byte*) fillscreen::SCREEN3#0 SCREEN3 = (const byte*) SCREEN+(word) $200
(const byte*) fillscreen::SCREEN3#0 SCREEN3 = (const byte*) SCREEN+(word) $1f4
(byte*) fillscreen::SCREEN4
(const byte*) fillscreen::SCREEN4#0 SCREEN4 = (const byte*) SCREEN+(word) $3e8
(const byte*) fillscreen::SCREEN4#0 SCREEN4 = (const byte*) SCREEN+(word) $2ee
(byte) fillscreen::c
(byte) fillscreen::c#0 reg byte a 5.111111111111112
(byte) fillscreen::j