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

Improved fragments. Improved printing main memory registers.

This commit is contained in:
jespergravgaard 2019-10-12 11:51:55 +02:00
parent 70aa2836da
commit f2660a8680
16 changed files with 83 additions and 96 deletions

View File

@ -0,0 +1,13 @@
sec
lda {c1}
sbc {m2}
sta {m1}
lda {c1}+1
sbc {m2}+1
sta {m1}+1
lda {c1}+2
sbc {m2}+2
sta {m1}+2
lda {c1}+3
sbc {m2}+3
sta {m1}+3

View File

@ -1,13 +0,0 @@
sec
lda {c1}
sbc {z2}
sta {z1}
lda {c1}+1
sbc {z2}+1
sta {z1}+1
lda {c1}+2
sbc {z2}+2
sta {z1}+2
lda {c1}+3
sbc {z2}+3
sta {z1}+3

View File

@ -1,13 +0,0 @@
clc
lda {c1}
adc #2
sta {z1}
lda {c1}+1
adc #0
sta {z1}+1
lda {c1}+2
adc #0
sta {z1}+2
lda {c1}+3
adc #0
sta {z1}+3

View File

@ -70,7 +70,7 @@ public class Registers {
private int bytes;
public RegisterMainMem(VariableRef variableRef, int bytes ) {
public RegisterMainMem(VariableRef variableRef, int bytes) {
this.variableRef = variableRef;
this.bytes = bytes;
}
@ -101,7 +101,7 @@ public class Registers {
@Override
public String toString() {
return "mem "+variableRef.toString();
return "mem[" + getBytes() + "]:" + variableRef.toString();
}
@Override
@ -130,10 +130,10 @@ public class Registers {
private int zp;
/** The number of bytes that the register takes up*/
/** The number of bytes that the register takes up */
private int bytes;
/** True if the address of the register is delcared in the code (non-relocatable)*/
/** True if the address of the register is delcared in the code (non-relocatable) */
private boolean isNonRelocatable;

View File

@ -122,7 +122,7 @@ Complete equivalence classes
[ main::i#2 main::i#1 ]
[ idx ]
Allocated zp[1]:2 [ main::i#2 main::i#1 ]
Allocated mem idx [ idx ]
Allocated mem[1]:idx [ idx ]
INITIAL ASM
Target platform is c64basic / MOS6502X
@ -201,14 +201,14 @@ Statement [0] (byte) idx ← (byte) 0 [ idx ] ( [ idx ] ) always clobbers reg b
Statement [6] *((const byte*) SCREEN + (byte) main::i#2) ← (byte) idx [ main::i#2 ] ( main:2 [ main::i#2 ] ) always clobbers reg byte a
Statement [7] (byte) idx ← (byte) idx + (byte) main::i#2 [ idx main::i#2 ] ( main:2 [ idx main::i#2 ] ) always clobbers reg byte a
Potential registers zp[1]:2 [ main::i#2 main::i#1 ] : zp[1]:2 , reg byte x , reg byte y ,
Potential registers mem idx [ idx ] : mem idx ,
Potential registers mem[1]:idx [ idx ] : mem[1]:idx ,
REGISTER UPLIFT SCOPES
Uplift Scope [main] 31.17: zp[1]:2 [ main::i#2 main::i#1 ]
Uplift Scope [] 5: mem idx [ idx ]
Uplift Scope [] 5: mem[1]:idx [ idx ]
Uplifting [main] best 409 combination reg byte x [ main::i#2 main::i#1 ]
Uplifting [] best 409 combination mem idx [ idx ]
Uplifting [] best 409 combination mem[1]:idx [ idx ]
ASSEMBLER BEFORE OPTIMIZATION
// File Comments
@ -300,7 +300,7 @@ FINAL SYMBOL TABLE
(label) @begin
(label) @end
(const byte*) SCREEN SCREEN = (byte*) 1024
(byte) idx memory mem idx 5.0
(byte) idx memory mem[1]:idx 5.0
(void()) main()
(label) main::@1
(label) main::@return
@ -309,7 +309,7 @@ FINAL SYMBOL TABLE
(byte) main::i#2 reg byte x 14.666666666666666
reg byte x [ main::i#2 main::i#1 ]
mem idx [ idx ]
mem[1]:idx [ idx ]
FINAL ASSEMBLER

View File

@ -2,7 +2,7 @@
(label) @begin
(label) @end
(const byte*) SCREEN SCREEN = (byte*) 1024
(byte) idx memory mem idx 5.0
(byte) idx memory mem[1]:idx 5.0
(void()) main()
(label) main::@1
(label) main::@return
@ -11,4 +11,4 @@
(byte) main::i#2 reg byte x 14.666666666666666
reg byte x [ main::i#2 main::i#1 ]
mem idx [ idx ]
mem[1]:idx [ idx ]

View File

@ -143,7 +143,7 @@ Complete equivalence classes
[ main::i#2 main::i#1 ]
[ idx ]
Allocated zp[1]:2 [ main::i#2 main::i#1 ]
Allocated mem idx [ idx ]
Allocated mem[1]:idx [ idx ]
INITIAL ASM
Target platform is c64basic / MOS6502X
@ -224,14 +224,14 @@ Statement [0] (byte) idx ← (byte) 0 [ ] ( [ ] ) always clobbers reg byte a
Statement [6] *((const byte*) SCREEN + (byte) main::i#2) ← *((const byte*) idx_p#0) [ main::i#2 ] ( main:2 [ main::i#2 ] ) always clobbers reg byte a
Statement [7] *((const byte*) idx_p#0) ← *((const byte*) idx_p#0) + (byte) main::i#2 [ main::i#2 ] ( main:2 [ main::i#2 ] ) always clobbers reg byte a
Potential registers zp[1]:2 [ main::i#2 main::i#1 ] : zp[1]:2 , reg byte x , reg byte y ,
Potential registers mem idx [ idx ] : mem idx ,
Potential registers mem[1]:idx [ idx ] : mem[1]:idx ,
REGISTER UPLIFT SCOPES
Uplift Scope [main] 31.17: zp[1]:2 [ main::i#2 main::i#1 ]
Uplift Scope [] 20: mem idx [ idx ]
Uplift Scope [] 20: mem[1]:idx [ idx ]
Uplifting [main] best 409 combination reg byte x [ main::i#2 main::i#1 ]
Uplifting [] best 409 combination mem idx [ idx ]
Uplifting [] best 409 combination mem[1]:idx [ idx ]
ASSEMBLER BEFORE OPTIMIZATION
// File Comments
@ -325,7 +325,7 @@ FINAL SYMBOL TABLE
(label) @begin
(label) @end
(const byte*) SCREEN SCREEN = (byte*) 1024
(byte) idx memory mem idx 20.0
(byte) idx memory mem[1]:idx 20.0
(byte*) idx_p
(const byte*) idx_p#0 idx_p = &(byte) idx
(void()) main()
@ -336,7 +336,7 @@ FINAL SYMBOL TABLE
(byte) main::i#2 reg byte x 14.666666666666666
reg byte x [ main::i#2 main::i#1 ]
mem idx [ idx ]
mem[1]:idx [ idx ]
FINAL ASSEMBLER

View File

@ -2,7 +2,7 @@
(label) @begin
(label) @end
(const byte*) SCREEN SCREEN = (byte*) 1024
(byte) idx memory mem idx 20.0
(byte) idx memory mem[1]:idx 20.0
(byte*) idx_p
(const byte*) idx_p#0 idx_p = &(byte) idx
(void()) main()
@ -13,4 +13,4 @@
(byte) main::i#2 reg byte x 14.666666666666666
reg byte x [ main::i#2 main::i#1 ]
mem idx [ idx ]
mem[1]:idx [ idx ]

View File

@ -128,7 +128,7 @@ Complete equivalence classes
[ main::i#2 main::i#1 ]
[ cursor ]
Allocated zp[1]:2 [ main::i#2 main::i#1 ]
Allocated mem cursor [ cursor ]
Allocated mem[2]:cursor [ cursor ]
INITIAL ASM
Target platform is c64basic / MOS6502X
@ -218,14 +218,14 @@ Statement [0] (byte*) cursor ← (const byte*) SCREEN [ cursor ] ( [ cursor ] )
Statement [6] *((byte*) cursor) ← (byte) '*' [ main::i#2 ] ( main:2 [ main::i#2 ] ) always clobbers reg byte a reg byte y
Statement [7] (byte*) cursor ← (byte*) cursor + (byte) $29 [ cursor main::i#2 ] ( main:2 [ cursor main::i#2 ] ) always clobbers reg byte a
Potential registers zp[1]:2 [ main::i#2 main::i#1 ] : zp[1]:2 , reg byte x ,
Potential registers mem cursor [ cursor ] : mem cursor ,
Potential registers mem[2]:cursor [ cursor ] : mem[2]:cursor ,
REGISTER UPLIFT SCOPES
Uplift Scope [main] 23.83: zp[1]:2 [ main::i#2 main::i#1 ]
Uplift Scope [] 5: mem cursor [ cursor ]
Uplift Scope [] 5: mem[2]:cursor [ cursor ]
Uplifting [main] best 650 combination reg byte x [ main::i#2 main::i#1 ]
Uplifting [] best 650 combination mem cursor [ cursor ]
Uplifting [] best 650 combination mem[2]:cursor [ cursor ]
ASSEMBLER BEFORE OPTIMIZATION
// File Comments
@ -328,7 +328,7 @@ FINAL SYMBOL TABLE
(label) @begin
(label) @end
(const byte*) SCREEN SCREEN = (byte*) 1024
(byte*) cursor memory mem cursor 5.0
(byte*) cursor memory mem[2]:cursor 5.0
(void()) main()
(label) main::@1
(label) main::@return
@ -337,7 +337,7 @@ FINAL SYMBOL TABLE
(byte) main::i#2 reg byte x 7.333333333333333
reg byte x [ main::i#2 main::i#1 ]
mem cursor [ cursor ]
mem[2]:cursor [ cursor ]
FINAL ASSEMBLER

View File

@ -2,7 +2,7 @@
(label) @begin
(label) @end
(const byte*) SCREEN SCREEN = (byte*) 1024
(byte*) cursor memory mem cursor 5.0
(byte*) cursor memory mem[2]:cursor 5.0
(void()) main()
(label) main::@1
(label) main::@return
@ -11,4 +11,4 @@
(byte) main::i#2 reg byte x 7.333333333333333
reg byte x [ main::i#2 main::i#1 ]
mem cursor [ cursor ]
mem[2]:cursor [ cursor ]

View File

@ -159,8 +159,8 @@ Added variable bar_thing2 to zero page equivalence class [ bar_thing2 ]
Complete equivalence classes
[ bar_thing1 ]
[ bar_thing2 ]
Allocated mem bar_thing1 [ bar_thing1 ]
Allocated mem bar_thing2 [ bar_thing2 ]
Allocated mem[1]:bar_thing1 [ bar_thing1 ]
Allocated mem[1]:bar_thing2 [ bar_thing2 ]
INITIAL ASM
Target platform is c64basic / MOS6502X
@ -218,15 +218,15 @@ Statement [0] (byte) bar_thing1 ← (byte) 'a' [ ] ( [ ] ) always clobbers reg
Statement [1] (byte) bar_thing2 ← (byte) 'b' [ ] ( [ ] ) always clobbers reg byte a
Statement [5] *((const byte*) main::SCREEN) ← *((byte*)(const struct foo*) main::barp#0) [ ] ( main:3 [ ] ) always clobbers reg byte a
Statement [6] *((const byte*) main::SCREEN+(byte) 1) ← *((byte*)(const struct foo*) main::barp#0+(const byte) OFFSET_STRUCT_FOO_THING2) [ ] ( main:3 [ ] ) always clobbers reg byte a
Potential registers mem bar_thing1 [ bar_thing1 ] : mem bar_thing1 ,
Potential registers mem bar_thing2 [ bar_thing2 ] : mem bar_thing2 ,
Potential registers mem[1]:bar_thing1 [ bar_thing1 ] : mem[1]:bar_thing1 ,
Potential registers mem[1]:bar_thing2 [ bar_thing2 ] : mem[1]:bar_thing2 ,
REGISTER UPLIFT SCOPES
Uplift Scope [] 20: mem bar_thing1 [ bar_thing1 ] 20: mem bar_thing2 [ bar_thing2 ]
Uplift Scope [] 20: mem[1]:bar_thing1 [ bar_thing1 ] 20: mem[1]:bar_thing2 [ bar_thing2 ]
Uplift Scope [foo]
Uplift Scope [main]
Uplifting [] best 49 combination mem bar_thing1 [ bar_thing1 ] mem bar_thing2 [ bar_thing2 ]
Uplifting [] best 49 combination mem[1]:bar_thing1 [ bar_thing1 ] mem[1]:bar_thing2 [ bar_thing2 ]
Uplifting [foo] best 49 combination
Uplifting [main] best 49 combination
@ -300,8 +300,8 @@ FINAL SYMBOL TABLE
(label) @begin
(label) @end
(const byte) OFFSET_STRUCT_FOO_THING2 OFFSET_STRUCT_FOO_THING2 = (byte) 1
(byte) bar_thing1 memory mem bar_thing1 20.0
(byte) bar_thing2 memory mem bar_thing2 20.0
(byte) bar_thing1 memory mem[1]:bar_thing1 20.0
(byte) bar_thing2 memory mem[1]:bar_thing2 20.0
(byte) foo::thing1
(byte) foo::thing2
(void()) main()
@ -311,8 +311,8 @@ FINAL SYMBOL TABLE
(const struct foo*) main::barp#0 barp = (struct foo*)&(byte) bar_thing1
(byte) main::i
mem bar_thing1 [ bar_thing1 ]
mem bar_thing2 [ bar_thing2 ]
mem[1]:bar_thing1 [ bar_thing1 ]
mem[1]:bar_thing2 [ bar_thing2 ]
FINAL ASSEMBLER

View File

@ -2,8 +2,8 @@
(label) @begin
(label) @end
(const byte) OFFSET_STRUCT_FOO_THING2 OFFSET_STRUCT_FOO_THING2 = (byte) 1
(byte) bar_thing1 memory mem bar_thing1 20.0
(byte) bar_thing2 memory mem bar_thing2 20.0
(byte) bar_thing1 memory mem[1]:bar_thing1 20.0
(byte) bar_thing2 memory mem[1]:bar_thing2 20.0
(byte) foo::thing1
(byte) foo::thing2
(void()) main()
@ -13,5 +13,5 @@
(const struct foo*) main::barp#0 barp = (struct foo*)&(byte) bar_thing1
(byte) main::i
mem bar_thing1 [ bar_thing1 ]
mem bar_thing2 [ bar_thing2 ]
mem[1]:bar_thing1 [ bar_thing1 ]
mem[1]:bar_thing2 [ bar_thing2 ]

View File

@ -249,8 +249,8 @@ Complete equivalence classes
Allocated zp[1]:2 [ main::j#2 main::j#1 ]
Allocated zp[1]:3 [ main::i#4 main::i#3 ]
Allocated zp[2]:4 [ bar_thing3#0 ]
Allocated mem bar_thing1 [ bar_thing1 ]
Allocated mem bar_thing2 [ bar_thing2 ]
Allocated mem[1]:bar_thing1 [ bar_thing1 ]
Allocated mem[1]:bar_thing2 [ bar_thing2 ]
INITIAL ASM
Target platform is c64basic / MOS6502X
@ -361,15 +361,15 @@ Statement [9] *((const byte*) main::SCREEN + (byte) main::i#4) ← *((byte[$c])(
Potential registers zp[1]:2 [ main::j#2 main::j#1 ] : zp[1]:2 , reg byte x , reg byte y ,
Potential registers zp[1]:3 [ main::i#4 main::i#3 ] : zp[1]:3 , reg byte x , reg byte y ,
Potential registers zp[2]:4 [ bar_thing3#0 ] : zp[2]:4 ,
Potential registers mem bar_thing1 [ bar_thing1 ] : mem bar_thing1 ,
Potential registers mem bar_thing2 [ bar_thing2 ] : mem bar_thing2 ,
Potential registers mem[1]:bar_thing1 [ bar_thing1 ] : mem[1]:bar_thing1 ,
Potential registers mem[1]:bar_thing2 [ bar_thing2 ] : mem[1]:bar_thing2 ,
REGISTER UPLIFT SCOPES
Uplift Scope [] 20: zp[2]:4 [ bar_thing3#0 ] 20: mem bar_thing1 [ bar_thing1 ] 20: mem bar_thing2 [ bar_thing2 ]
Uplift Scope [] 20: zp[2]:4 [ bar_thing3#0 ] 20: mem[1]:bar_thing1 [ bar_thing1 ] 20: mem[1]:bar_thing2 [ bar_thing2 ]
Uplift Scope [main] 27.5: zp[1]:2 [ main::j#2 main::j#1 ] 23.83: zp[1]:3 [ main::i#4 main::i#3 ]
Uplift Scope [foo]
Uplifting [] best 576 combination zp[2]:4 [ bar_thing3#0 ] mem bar_thing1 [ bar_thing1 ] mem bar_thing2 [ bar_thing2 ]
Uplifting [] best 576 combination zp[2]:4 [ bar_thing3#0 ] mem[1]:bar_thing1 [ bar_thing1 ] mem[1]:bar_thing2 [ bar_thing2 ]
Uplifting [main] best 366 combination reg byte y [ main::j#2 main::j#1 ] reg byte x [ main::i#4 main::i#3 ]
Uplifting [foo] best 366 combination
Allocated (was zp[2]:4) zp[2]:2 [ bar_thing3#0 ]
@ -485,8 +485,8 @@ FINAL SYMBOL TABLE
(label) @end
(const byte) OFFSET_STRUCT_FOO_THING2 OFFSET_STRUCT_FOO_THING2 = (byte) 1
(const byte) OFFSET_STRUCT_FOO_THING3 OFFSET_STRUCT_FOO_THING3 = (byte) 2
(byte) bar_thing1 memory mem bar_thing1 20.0
(byte) bar_thing2 memory mem bar_thing2 20.0
(byte) bar_thing1 memory mem[1]:bar_thing1 20.0
(byte) bar_thing2 memory mem[1]:bar_thing2 20.0
(byte[$c]) bar_thing3
(byte[$c]) bar_thing3#0 bar_thing3 zp[2]:2 20.0
(byte) foo::thing1
@ -508,8 +508,8 @@ FINAL SYMBOL TABLE
reg byte y [ main::j#2 main::j#1 ]
reg byte x [ main::i#4 main::i#3 ]
zp[2]:2 [ bar_thing3#0 ]
mem bar_thing1 [ bar_thing1 ]
mem bar_thing2 [ bar_thing2 ]
mem[1]:bar_thing1 [ bar_thing1 ]
mem[1]:bar_thing2 [ bar_thing2 ]
FINAL ASSEMBLER

View File

@ -4,8 +4,8 @@
(label) @end
(const byte) OFFSET_STRUCT_FOO_THING2 OFFSET_STRUCT_FOO_THING2 = (byte) 1
(const byte) OFFSET_STRUCT_FOO_THING3 OFFSET_STRUCT_FOO_THING3 = (byte) 2
(byte) bar_thing1 memory mem bar_thing1 20.0
(byte) bar_thing2 memory mem bar_thing2 20.0
(byte) bar_thing1 memory mem[1]:bar_thing1 20.0
(byte) bar_thing2 memory mem[1]:bar_thing2 20.0
(byte[$c]) bar_thing3
(byte[$c]) bar_thing3#0 bar_thing3 zp[2]:2 20.0
(byte) foo::thing1
@ -27,5 +27,5 @@
reg byte y [ main::j#2 main::j#1 ]
reg byte x [ main::i#4 main::i#3 ]
zp[2]:2 [ bar_thing3#0 ]
mem bar_thing1 [ bar_thing1 ]
mem bar_thing2 [ bar_thing2 ]
mem[1]:bar_thing1 [ bar_thing1 ]
mem[1]:bar_thing2 [ bar_thing2 ]

View File

@ -126,8 +126,8 @@ Added variable bar_thing2 to zero page equivalence class [ bar_thing2 ]
Complete equivalence classes
[ bar_thing1 ]
[ bar_thing2 ]
Allocated mem bar_thing1 [ bar_thing1 ]
Allocated mem bar_thing2 [ bar_thing2 ]
Allocated mem[1]:bar_thing1 [ bar_thing1 ]
Allocated mem[1]:bar_thing2 [ bar_thing2 ]
INITIAL ASM
Target platform is c64basic / MOS6502X
@ -183,15 +183,15 @@ Statement [0] (byte) bar_thing1 ← (byte) 'a' [ bar_thing1 ] ( [ bar_thing1 ]
Statement [1] (byte) bar_thing2 ← (byte) 'b' [ bar_thing1 bar_thing2 ] ( [ bar_thing1 bar_thing2 ] ) always clobbers reg byte a
Statement [5] *((const byte*) main::SCREEN) ← (byte) bar_thing1 [ bar_thing2 ] ( main:3 [ bar_thing2 ] ) always clobbers reg byte a
Statement [6] *((const byte*) main::SCREEN+(byte) 1) ← (byte) bar_thing2 [ ] ( main:3 [ ] ) always clobbers reg byte a
Potential registers mem bar_thing1 [ bar_thing1 ] : mem bar_thing1 ,
Potential registers mem bar_thing2 [ bar_thing2 ] : mem bar_thing2 ,
Potential registers mem[1]:bar_thing1 [ bar_thing1 ] : mem[1]:bar_thing1 ,
Potential registers mem[1]:bar_thing2 [ bar_thing2 ] : mem[1]:bar_thing2 ,
REGISTER UPLIFT SCOPES
Uplift Scope [] 1.33: mem bar_thing1 [ bar_thing1 ] 1.33: mem bar_thing2 [ bar_thing2 ]
Uplift Scope [] 1.33: mem[1]:bar_thing1 [ bar_thing1 ] 1.33: mem[1]:bar_thing2 [ bar_thing2 ]
Uplift Scope [foo]
Uplift Scope [main]
Uplifting [] best 49 combination mem bar_thing1 [ bar_thing1 ] mem bar_thing2 [ bar_thing2 ]
Uplifting [] best 49 combination mem[1]:bar_thing1 [ bar_thing1 ] mem[1]:bar_thing2 [ bar_thing2 ]
Uplifting [foo] best 49 combination
Uplifting [main] best 49 combination
@ -262,8 +262,8 @@ FINAL SYMBOL TABLE
(label) @1
(label) @begin
(label) @end
(byte) bar_thing1 memory mem bar_thing1 1.3333333333333333
(byte) bar_thing2 memory mem bar_thing2 1.3333333333333333
(byte) bar_thing1 memory mem[1]:bar_thing1 1.3333333333333333
(byte) bar_thing2 memory mem[1]:bar_thing2 1.3333333333333333
(byte) foo::thing1
(byte) foo::thing2
(void()) main()
@ -271,8 +271,8 @@ FINAL SYMBOL TABLE
(const byte*) main::SCREEN SCREEN = (byte*) 1024
(byte) main::i
mem bar_thing1 [ bar_thing1 ]
mem bar_thing2 [ bar_thing2 ]
mem[1]:bar_thing1 [ bar_thing1 ]
mem[1]:bar_thing2 [ bar_thing2 ]
FINAL ASSEMBLER

View File

@ -1,8 +1,8 @@
(label) @1
(label) @begin
(label) @end
(byte) bar_thing1 memory mem bar_thing1 1.3333333333333333
(byte) bar_thing2 memory mem bar_thing2 1.3333333333333333
(byte) bar_thing1 memory mem[1]:bar_thing1 1.3333333333333333
(byte) bar_thing2 memory mem[1]:bar_thing2 1.3333333333333333
(byte) foo::thing1
(byte) foo::thing2
(void()) main()
@ -10,5 +10,5 @@
(const byte*) main::SCREEN SCREEN = (byte*) 1024
(byte) main::i
mem bar_thing1 [ bar_thing1 ]
mem bar_thing2 [ bar_thing2 ]
mem[1]:bar_thing1 [ bar_thing1 ]
mem[1]:bar_thing2 [ bar_thing2 ]