mirror of
https://gitlab.com/camelot/kickc.git
synced 2025-04-09 21:37:31 +00:00
Added example of a 8bit-per-pixel logo for the XMega65.
This commit is contained in:
parent
09c504e693
commit
bd83f1f5bf
@ -405,6 +405,11 @@ public class TestPrograms {
|
||||
compileAndCompare("complex/ataritempest/ataritempest");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testXMega65Logo() throws IOException, URISyntaxException {
|
||||
compileAndCompare("complex/xmega65/xmega65logo");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testXMega65() throws IOException, URISyntaxException {
|
||||
compileAndCompare("complex/xmega65/xmega65");
|
||||
|
BIN
src/test/kc/complex/xmega65/mega65-256.png
Normal file
BIN
src/test/kc/complex/xmega65/mega65-256.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 6.8 KiB |
84
src/test/kc/complex/xmega65/xmega65graphics.asm
Normal file
84
src/test/kc/complex/xmega65/xmega65graphics.asm
Normal file
@ -0,0 +1,84 @@
|
||||
#importonce
|
||||
|
||||
// Creates a palette for a picture.
|
||||
// The palette is a hashtable mapping color RGB in hexadeciaml RRGGBB format to the index of the color.
|
||||
// The size of the palette is the number of different RGB-colors present in the picture
|
||||
// Parameters
|
||||
// - picture: a picture loaded using LoadPicture()
|
||||
.function getPalette(picture) {
|
||||
.var palette = Hashtable()
|
||||
.var colIdx = 0;
|
||||
.for (var x=0; x<picture.width; x++) {
|
||||
.for (var y=0; y<picture.height; y++) {
|
||||
.var col = toHexString(picture.getPixel(x,y),6)
|
||||
.if(palette.get(col)==null) .eval palette.put(col,colIdx++)
|
||||
}
|
||||
}
|
||||
.return palette
|
||||
}
|
||||
|
||||
// Get the RGB value of a palette color
|
||||
// Parameters
|
||||
// - palette: A palette typically created using getPalette(picture)
|
||||
// - idx: The index of the color in the palette to get the red value
|
||||
// Returns the RGB value of the color with the given index. 0 if the index is not defined.
|
||||
.function getPaletteRgb(palette, idx) {
|
||||
.if(idx>=palette.keys().size())
|
||||
.return 0
|
||||
.var colHex = palette.keys().get(idx)
|
||||
.return colHex.asNumber(16)
|
||||
}
|
||||
|
||||
// Get the red value of a palette color
|
||||
// Parameters
|
||||
// - palette: A palette typically created using getPalette(picture)
|
||||
// - idx: The index of the color in the palette to get the red value
|
||||
.function getPaletteRed(palette, idx) {
|
||||
.return getPaletteRgb(palette, idx)>>16 & $ff
|
||||
}
|
||||
|
||||
// Get the green value of a palette color
|
||||
// Parameters
|
||||
// - palette: A palette typically created using getPalette(picture)
|
||||
// - idx: The index of the color in the palette to get the green value
|
||||
.function getPaletteGreen(palette, idx) {
|
||||
.return getPaletteRgb(palette, idx)>>8 & $ff
|
||||
}
|
||||
|
||||
// Get the blue value of a palette color
|
||||
// Parameters
|
||||
// - palette: A palette typically created using getPalette(picture)
|
||||
// - idx: The index of the color in the palette to get the blue value
|
||||
.function getPaletteBlue(palette, idx) {
|
||||
.return getPaletteRgb(palette, idx) & $ff
|
||||
}
|
||||
|
||||
// Get the index in a color palette for a single pixel in a picture
|
||||
// Parameters
|
||||
// - picture: a picture loaded using LoadPicture()
|
||||
// - x: the x-coordinate of the pixel
|
||||
// - y: the y-coordinate of the pixel
|
||||
// - palette: a palette for the picture typically created using getPalette(picture)
|
||||
.function getPaletteColour(picture, palette, x, y) {
|
||||
.return palette.get(toHexString(picture.getPixel(x,y),6))
|
||||
}
|
||||
|
||||
|
||||
// Converts 1 pixels to a single color byte using the palette
|
||||
// - picture: a picture loaded using LoadPicture()
|
||||
// - x: the x-coordinate of the pixel
|
||||
// - y: the y-coordinate of the pixel
|
||||
// - palette: a palette for the picture typically created using getPalette(picture)
|
||||
.function getFullcolourByte(picture, palette, x, y) {
|
||||
.return getPaletteColour(picture, palette, x, y) & $ff
|
||||
}
|
||||
|
||||
// Converts 2 pixels to a multi color byte (2 4-bit color nybbles) using the palette
|
||||
// - picture: a picture loaded using LoadPicture()
|
||||
// - x: the x-coordinate of the first pixel.
|
||||
// - y: the y-coordinate of the pixel
|
||||
// - palette: a palette for the picture. Only the first 16 colors of the palette is used.
|
||||
// Returns: A byte containing two pixels. The high nybble is the color at (x,y) the low nybble is the color at (x+1,y)
|
||||
.function getSixteencolourByte(picture, palette, x, y) {
|
||||
.return ((getPaletteColour(picture, palette, x, y) & $f) << 4) | (getPaletteColour(picture, palette, x+1, y) &$f)
|
||||
}
|
34
src/test/kc/complex/xmega65/xmega65logo.kc
Normal file
34
src/test/kc/complex/xmega65/xmega65logo.kc
Normal file
@ -0,0 +1,34 @@
|
||||
// Import an XMega65 8bit-per-color logo
|
||||
// Fill the palette values into
|
||||
|
||||
void main() {
|
||||
const char* SCREEN = 0x0400;
|
||||
for(byte i:0..0xff) {
|
||||
(SCREEN+40*0)[i] = LOGO256_RED[i];
|
||||
(SCREEN+40*8)[i] = LOGO256_GREEN[i];
|
||||
(SCREEN+40*16)[i] = LOGO256_BLUE[i];
|
||||
}
|
||||
}
|
||||
|
||||
// Import a 128x128 8bit-per-color logo using inline KickAsm
|
||||
char[] LOGO256 = kickasm(resource "mega65-256.png", resource "xmega65graphics.asm") {{
|
||||
#import "xmega65graphics.asm"
|
||||
.var logo256 = LoadPicture("mega65-256.png")
|
||||
.var palette256 = getPalette(logo256)
|
||||
.print "width: "+logo256.width + " height: "+logo256.height + " colors: "+palette256.keys().size()
|
||||
// Output the graphics
|
||||
.for (var x=0; x<logo256.width; x++)
|
||||
.for (var y=0; y<logo256.height; y++)
|
||||
.byte getFullcolourByte(logo256, palette256, x, y)
|
||||
// Output the RGB-values of the palette
|
||||
.fill 256, getPaletteRed(palette256,i)
|
||||
.fill 256, getPaletteGreen(palette256,i)
|
||||
.fill 256, getPaletteBlue(palette256,i)
|
||||
}};
|
||||
// Create pointers to the palette RGBs in the logo (assumes dimensions are 128x128)
|
||||
char* LOGO256_RED = LOGO256+128*128;
|
||||
char* LOGO256_GREEN = LOGO256_RED+256;
|
||||
char* LOGO256_BLUE = LOGO256_GREEN+256;
|
||||
|
||||
|
||||
|
38
src/test/ref/complex/xmega65/xmega65logo.asm
Normal file
38
src/test/ref/complex/xmega65/xmega65logo.asm
Normal file
@ -0,0 +1,38 @@
|
||||
// Import an XMega65 8bit-per-color logo
|
||||
// Fill the palette values into
|
||||
.pc = $801 "Basic"
|
||||
:BasicUpstart(main)
|
||||
.pc = $80d "Program"
|
||||
.label LOGO256_RED = LOGO256+$80*$80
|
||||
.label LOGO256_GREEN = LOGO256_RED+$100
|
||||
.label LOGO256_BLUE = LOGO256_GREEN+$100
|
||||
main: {
|
||||
.label SCREEN = $400
|
||||
ldx #0
|
||||
__b1:
|
||||
lda LOGO256_RED,x
|
||||
sta SCREEN,x
|
||||
lda LOGO256_GREEN,x
|
||||
sta SCREEN+$28*8,x
|
||||
lda LOGO256_BLUE,x
|
||||
sta SCREEN+$28*$10,x
|
||||
inx
|
||||
cpx #0
|
||||
bne __b1
|
||||
rts
|
||||
}
|
||||
// Import a 128x128 8bit-per-color logo using inline KickAsm
|
||||
LOGO256:
|
||||
#import "xmega65graphics.asm"
|
||||
.var logo256 = LoadPicture("mega65-256.png")
|
||||
.var palette256 = getPalette(logo256)
|
||||
.print "width: "+logo256.width + " height: "+logo256.height + " colors: "+palette256.keys().size()
|
||||
// Output the graphics
|
||||
.for (var x=0; x<logo256.width; x++)
|
||||
.for (var y=0; y<logo256.height; y++)
|
||||
.byte getFullcolourByte(logo256, palette256, x, y)
|
||||
// Output the RGB-values of the palette
|
||||
.fill 256, getPaletteRed(palette256,i)
|
||||
.fill 256, getPaletteGreen(palette256,i)
|
||||
.fill 256, getPaletteBlue(palette256,i)
|
||||
|
25
src/test/ref/complex/xmega65/xmega65logo.cfg
Normal file
25
src/test/ref/complex/xmega65/xmega65logo.cfg
Normal file
@ -0,0 +1,25 @@
|
||||
@begin: scope:[] from
|
||||
[0] phi()
|
||||
to:@1
|
||||
@1: scope:[] from @begin
|
||||
[1] phi()
|
||||
[2] call main
|
||||
to:@end
|
||||
@end: scope:[] from @1
|
||||
[3] phi()
|
||||
|
||||
(void()) main()
|
||||
main: scope:[main] from @1
|
||||
[4] phi()
|
||||
to:main::@1
|
||||
main::@1: scope:[main] from main main::@1
|
||||
[5] (byte) main::i#2 ← phi( main/(byte) 0 main::@1/(byte) main::i#1 )
|
||||
[6] *((const byte*) main::SCREEN + (byte) main::i#2) ← *((const byte*) LOGO256_RED#0 + (byte) main::i#2)
|
||||
[7] *((const byte*) main::SCREEN+(word)(number) $28*(number) 8 + (byte) main::i#2) ← *((const byte*) LOGO256_GREEN#0 + (byte) main::i#2)
|
||||
[8] *((const byte*) main::SCREEN+(word)(number) $28*(number) $10 + (byte) main::i#2) ← *((const byte*) LOGO256_BLUE#0 + (byte) main::i#2)
|
||||
[9] (byte) main::i#1 ← ++ (byte) main::i#2
|
||||
[10] if((byte) main::i#1!=(byte) 0) goto main::@1
|
||||
to:main::@return
|
||||
main::@return: scope:[main] from main::@1
|
||||
[11] return
|
||||
to:@return
|
532
src/test/ref/complex/xmega65/xmega65logo.log
Normal file
532
src/test/ref/complex/xmega65/xmega65logo.log
Normal file
@ -0,0 +1,532 @@
|
||||
Resolved forward reference LOGO256_RED to (byte*) LOGO256_RED
|
||||
Resolved forward reference LOGO256_GREEN to (byte*) LOGO256_GREEN
|
||||
Resolved forward reference LOGO256_BLUE to (byte*) LOGO256_BLUE
|
||||
Culled Empty Block (label) main::@2
|
||||
|
||||
CONTROL FLOW GRAPH SSA
|
||||
@begin: scope:[] from
|
||||
to:@1
|
||||
|
||||
(void()) main()
|
||||
main: scope:[main] from @1
|
||||
(byte*) LOGO256_BLUE#2 ← phi( @1/(byte*) LOGO256_BLUE#0 )
|
||||
(byte*) LOGO256_GREEN#2 ← phi( @1/(byte*) LOGO256_GREEN#0 )
|
||||
(byte*) LOGO256_RED#2 ← phi( @1/(byte*) LOGO256_RED#0 )
|
||||
(byte) main::i#0 ← (byte) 0
|
||||
to:main::@1
|
||||
main::@1: scope:[main] from main main::@1
|
||||
(byte*) LOGO256_BLUE#1 ← phi( main/(byte*) LOGO256_BLUE#2 main::@1/(byte*) LOGO256_BLUE#1 )
|
||||
(byte*) LOGO256_GREEN#1 ← phi( main/(byte*) LOGO256_GREEN#2 main::@1/(byte*) LOGO256_GREEN#1 )
|
||||
(byte) main::i#2 ← phi( main/(byte) main::i#0 main::@1/(byte) main::i#1 )
|
||||
(byte*) LOGO256_RED#1 ← phi( main/(byte*) LOGO256_RED#2 main::@1/(byte*) LOGO256_RED#1 )
|
||||
*((const byte*) main::SCREEN+(number) $28*(number) 0 + (byte) main::i#2) ← *((byte*) LOGO256_RED#1 + (byte) main::i#2)
|
||||
*((const byte*) main::SCREEN+(number) $28*(number) 8 + (byte) main::i#2) ← *((byte*) LOGO256_GREEN#1 + (byte) main::i#2)
|
||||
*((const byte*) main::SCREEN+(number) $28*(number) $10 + (byte) main::i#2) ← *((byte*) LOGO256_BLUE#1 + (byte) main::i#2)
|
||||
(byte) main::i#1 ← (byte) main::i#2 + rangenext(0,$ff)
|
||||
(bool~) main::$0 ← (byte) main::i#1 != rangelast(0,$ff)
|
||||
if((bool~) main::$0) goto main::@1
|
||||
to:main::@return
|
||||
main::@return: scope:[main] from main::@1
|
||||
return
|
||||
to:@return
|
||||
@1: scope:[] from @begin
|
||||
(byte[]) LOGO256 ← kickasm {{ #import "xmega65graphics.asm"
|
||||
.var logo256 = LoadPicture("mega65-256.png")
|
||||
.var palette256 = getPalette(logo256)
|
||||
.print "width: "+logo256.width + " height: "+logo256.height + " colors: "+palette256.keys().size()
|
||||
// Output the graphics
|
||||
.for (var x=0; x<logo256.width; x++)
|
||||
.for (var y=0; y<logo256.height; y++)
|
||||
.byte getFullcolourByte(logo256, palette256, x, y)
|
||||
// Output the RGB-values of the palette
|
||||
.fill 256, getPaletteRed(palette256,i)
|
||||
.fill 256, getPaletteGreen(palette256,i)
|
||||
.fill 256, getPaletteBlue(palette256,i)
|
||||
}}
|
||||
(byte*~) $0 ← (byte[]) LOGO256 + (number) $80*(number) $80
|
||||
(byte*) LOGO256_RED#0 ← (byte*~) $0
|
||||
(byte*~) $1 ← (byte*) LOGO256_RED#0 + (number) $100
|
||||
(byte*) LOGO256_GREEN#0 ← (byte*~) $1
|
||||
(byte*~) $2 ← (byte*) LOGO256_GREEN#0 + (number) $100
|
||||
(byte*) LOGO256_BLUE#0 ← (byte*~) $2
|
||||
call main
|
||||
to:@2
|
||||
@2: scope:[] from @1
|
||||
to:@end
|
||||
@end: scope:[] from @2
|
||||
|
||||
SYMBOL TABLE SSA
|
||||
(byte*~) $0
|
||||
(byte*~) $1
|
||||
(byte*~) $2
|
||||
(label) @1
|
||||
(label) @2
|
||||
(label) @begin
|
||||
(label) @end
|
||||
(byte[]) LOGO256
|
||||
(byte*) LOGO256_BLUE
|
||||
(byte*) LOGO256_BLUE#0
|
||||
(byte*) LOGO256_BLUE#1
|
||||
(byte*) LOGO256_BLUE#2
|
||||
(byte*) LOGO256_GREEN
|
||||
(byte*) LOGO256_GREEN#0
|
||||
(byte*) LOGO256_GREEN#1
|
||||
(byte*) LOGO256_GREEN#2
|
||||
(byte*) LOGO256_RED
|
||||
(byte*) LOGO256_RED#0
|
||||
(byte*) LOGO256_RED#1
|
||||
(byte*) LOGO256_RED#2
|
||||
(void()) main()
|
||||
(bool~) main::$0
|
||||
(label) main::@1
|
||||
(label) main::@return
|
||||
(const byte*) main::SCREEN = (byte*)(number) $400
|
||||
(byte) main::i
|
||||
(byte) main::i#0
|
||||
(byte) main::i#1
|
||||
(byte) main::i#2
|
||||
|
||||
Adding number conversion cast (unumber) $28*0 in *((const byte*) main::SCREEN+(number) $28*(number) 0 + (byte) main::i#2) ← *((byte*) LOGO256_RED#1 + (byte) main::i#2)
|
||||
Adding number conversion cast (unumber) $28*8 in *((const byte*) main::SCREEN+(number) $28*(number) 8 + (byte) main::i#2) ← *((byte*) LOGO256_GREEN#1 + (byte) main::i#2)
|
||||
Adding number conversion cast (unumber) $28*$10 in *((const byte*) main::SCREEN+(number) $28*(number) $10 + (byte) main::i#2) ← *((byte*) LOGO256_BLUE#1 + (byte) main::i#2)
|
||||
Adding number conversion cast (unumber) $80*$80 in (byte*~) $0 ← (byte[]) LOGO256 + (number) $80*(number) $80
|
||||
Adding number conversion cast (unumber) $100 in (byte*~) $1 ← (byte*) LOGO256_RED#0 + (number) $100
|
||||
Adding number conversion cast (unumber) $100 in (byte*~) $2 ← (byte*) LOGO256_GREEN#0 + (number) $100
|
||||
Successful SSA optimization PassNAddNumberTypeConversions
|
||||
Simplifying constant pointer cast (byte*) 1024
|
||||
Simplifying constant integer cast $100
|
||||
Simplifying constant integer cast $100
|
||||
Successful SSA optimization PassNCastSimplification
|
||||
Finalized unsigned number type (word) $100
|
||||
Finalized unsigned number type (word) $100
|
||||
Successful SSA optimization PassNFinalizeNumberTypeConversions
|
||||
Alias (byte*) LOGO256_RED#0 = (byte*~) $0
|
||||
Alias (byte*) LOGO256_GREEN#0 = (byte*~) $1
|
||||
Alias (byte*) LOGO256_BLUE#0 = (byte*~) $2
|
||||
Successful SSA optimization Pass2AliasElimination
|
||||
Identical Phi Values (byte*) LOGO256_RED#2 (byte*) LOGO256_RED#0
|
||||
Identical Phi Values (byte*) LOGO256_GREEN#2 (byte*) LOGO256_GREEN#0
|
||||
Identical Phi Values (byte*) LOGO256_BLUE#2 (byte*) LOGO256_BLUE#0
|
||||
Identical Phi Values (byte*) LOGO256_RED#1 (byte*) LOGO256_RED#2
|
||||
Identical Phi Values (byte*) LOGO256_GREEN#1 (byte*) LOGO256_GREEN#2
|
||||
Identical Phi Values (byte*) LOGO256_BLUE#1 (byte*) LOGO256_BLUE#2
|
||||
Successful SSA optimization Pass2IdenticalPhiElimination
|
||||
Simple Condition (bool~) main::$0 [8] if((byte) main::i#1!=rangelast(0,$ff)) goto main::@1
|
||||
Successful SSA optimization Pass2ConditionalJumpSimplification
|
||||
Constant (const byte) main::i#0 = 0
|
||||
Constant (const byte[]) LOGO256 = kickasm {{ #import "xmega65graphics.asm"
|
||||
.var logo256 = LoadPicture("mega65-256.png")
|
||||
.var palette256 = getPalette(logo256)
|
||||
.print "width: "+logo256.width + " height: "+logo256.height + " colors: "+palette256.keys().size()
|
||||
// Output the graphics
|
||||
.for (var x=0; x<logo256.width; x++)
|
||||
.for (var y=0; y<logo256.height; y++)
|
||||
.byte getFullcolourByte(logo256, palette256, x, y)
|
||||
// Output the RGB-values of the palette
|
||||
.fill 256, getPaletteRed(palette256,i)
|
||||
.fill 256, getPaletteGreen(palette256,i)
|
||||
.fill 256, getPaletteBlue(palette256,i)
|
||||
}}
|
||||
Successful SSA optimization Pass2ConstantIdentification
|
||||
Resolved ranged next value [6] main::i#1 ← ++ main::i#2 to ++
|
||||
Resolved ranged comparison value [8] if(main::i#1!=rangelast(0,$ff)) goto main::@1 to (number) 0
|
||||
Simplifying constant evaluating to zero (byte)(number) $28*(number) 0 in [3] *((const byte*) main::SCREEN+(byte)(number) $28*(number) 0 + (byte) main::i#2) ← *((byte*) LOGO256_RED#0 + (byte) main::i#2)
|
||||
Successful SSA optimization PassNSimplifyConstantZero
|
||||
Simplifying expression containing zero main::SCREEN in [3] *((const byte*) main::SCREEN+(byte) 0 + (byte) main::i#2) ← *((byte*) LOGO256_RED#0 + (byte) main::i#2)
|
||||
Successful SSA optimization PassNSimplifyExpressionWithZero
|
||||
Adding number conversion cast (unumber) 0 in if((byte) main::i#1!=(number) 0) goto main::@1
|
||||
Successful SSA optimization PassNAddNumberTypeConversions
|
||||
Simplifying constant integer cast 0
|
||||
Successful SSA optimization PassNCastSimplification
|
||||
Finalized unsigned number type (byte) 0
|
||||
Successful SSA optimization PassNFinalizeNumberTypeConversions
|
||||
Constant right-side identified [7] (byte*) LOGO256_RED#0 ← (const byte[]) LOGO256 + (word)(number) $80*(number) $80
|
||||
Successful SSA optimization Pass2ConstantRValueConsolidation
|
||||
Constant (const byte*) LOGO256_RED#0 = LOGO256+(word)$80*$80
|
||||
Successful SSA optimization Pass2ConstantIdentification
|
||||
Constant right-side identified [7] (byte*) LOGO256_GREEN#0 ← (const byte*) LOGO256_RED#0 + (word) $100
|
||||
Successful SSA optimization Pass2ConstantRValueConsolidation
|
||||
Constant (const byte*) LOGO256_GREEN#0 = LOGO256_RED#0+$100
|
||||
Successful SSA optimization Pass2ConstantIdentification
|
||||
Constant right-side identified [7] (byte*) LOGO256_BLUE#0 ← (const byte*) LOGO256_GREEN#0 + (word) $100
|
||||
Successful SSA optimization Pass2ConstantRValueConsolidation
|
||||
Constant (const byte*) LOGO256_BLUE#0 = LOGO256_GREEN#0+$100
|
||||
Successful SSA optimization Pass2ConstantIdentification
|
||||
Inlining constant with var siblings (const byte) main::i#0
|
||||
Constant inlined main::i#0 = (byte) 0
|
||||
Successful SSA optimization Pass2ConstantInlining
|
||||
Added new block during phi lifting main::@3(between main::@1 and main::@1)
|
||||
Adding NOP phi() at start of @begin
|
||||
Adding NOP phi() at start of @1
|
||||
Adding NOP phi() at start of @2
|
||||
Adding NOP phi() at start of @end
|
||||
Adding NOP phi() at start of main
|
||||
CALL GRAPH
|
||||
Calls in [] to main:2
|
||||
|
||||
Created 1 initial phi equivalence classes
|
||||
Coalesced [13] main::i#3 ← main::i#1
|
||||
Coalesced down to 1 phi equivalence classes
|
||||
Culled Empty Block (label) @2
|
||||
Culled Empty Block (label) main::@3
|
||||
Adding NOP phi() at start of @begin
|
||||
Adding NOP phi() at start of @1
|
||||
Adding NOP phi() at start of @end
|
||||
Adding NOP phi() at start of main
|
||||
|
||||
FINAL CONTROL FLOW GRAPH
|
||||
@begin: scope:[] from
|
||||
[0] phi()
|
||||
to:@1
|
||||
@1: scope:[] from @begin
|
||||
[1] phi()
|
||||
[2] call main
|
||||
to:@end
|
||||
@end: scope:[] from @1
|
||||
[3] phi()
|
||||
|
||||
(void()) main()
|
||||
main: scope:[main] from @1
|
||||
[4] phi()
|
||||
to:main::@1
|
||||
main::@1: scope:[main] from main main::@1
|
||||
[5] (byte) main::i#2 ← phi( main/(byte) 0 main::@1/(byte) main::i#1 )
|
||||
[6] *((const byte*) main::SCREEN + (byte) main::i#2) ← *((const byte*) LOGO256_RED#0 + (byte) main::i#2)
|
||||
[7] *((const byte*) main::SCREEN+(word)(number) $28*(number) 8 + (byte) main::i#2) ← *((const byte*) LOGO256_GREEN#0 + (byte) main::i#2)
|
||||
[8] *((const byte*) main::SCREEN+(word)(number) $28*(number) $10 + (byte) main::i#2) ← *((const byte*) LOGO256_BLUE#0 + (byte) main::i#2)
|
||||
[9] (byte) main::i#1 ← ++ (byte) main::i#2
|
||||
[10] if((byte) main::i#1!=(byte) 0) goto main::@1
|
||||
to:main::@return
|
||||
main::@return: scope:[main] from main::@1
|
||||
[11] return
|
||||
to:@return
|
||||
|
||||
|
||||
VARIABLE REGISTER WEIGHTS
|
||||
(byte*) LOGO256_BLUE
|
||||
(byte*) LOGO256_GREEN
|
||||
(byte*) LOGO256_RED
|
||||
(void()) main()
|
||||
(byte) main::i
|
||||
(byte) main::i#1 16.5
|
||||
(byte) main::i#2 22.0
|
||||
|
||||
Initial phi equivalence classes
|
||||
[ main::i#2 main::i#1 ]
|
||||
Complete equivalence classes
|
||||
[ main::i#2 main::i#1 ]
|
||||
Allocated zp[1]:2 [ main::i#2 main::i#1 ]
|
||||
|
||||
INITIAL ASM
|
||||
Target platform is c64basic / MOS6502X
|
||||
// File Comments
|
||||
// Import an XMega65 8bit-per-color logo
|
||||
// Fill the palette values into
|
||||
// Upstart
|
||||
.pc = $801 "Basic"
|
||||
:BasicUpstart(__bbegin)
|
||||
.pc = $80d "Program"
|
||||
// Global Constants & labels
|
||||
.label LOGO256_RED = LOGO256+$80*$80
|
||||
.label LOGO256_GREEN = LOGO256_RED+$100
|
||||
.label LOGO256_BLUE = LOGO256_GREEN+$100
|
||||
// @begin
|
||||
__bbegin:
|
||||
// [1] phi from @begin to @1 [phi:@begin->@1]
|
||||
__b1_from___bbegin:
|
||||
jmp __b1
|
||||
// @1
|
||||
__b1:
|
||||
// [2] call main
|
||||
// [4] phi from @1 to main [phi:@1->main]
|
||||
main_from___b1:
|
||||
jsr main
|
||||
// [3] phi from @1 to @end [phi:@1->@end]
|
||||
__bend_from___b1:
|
||||
jmp __bend
|
||||
// @end
|
||||
__bend:
|
||||
// main
|
||||
main: {
|
||||
.label SCREEN = $400
|
||||
.label i = 2
|
||||
// [5] phi from main to main::@1 [phi:main->main::@1]
|
||||
__b1_from_main:
|
||||
// [5] phi (byte) main::i#2 = (byte) 0 [phi:main->main::@1#0] -- vbuz1=vbuc1
|
||||
lda #0
|
||||
sta.z i
|
||||
jmp __b1
|
||||
// [5] phi from main::@1 to main::@1 [phi:main::@1->main::@1]
|
||||
__b1_from___b1:
|
||||
// [5] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@1->main::@1#0] -- register_copy
|
||||
jmp __b1
|
||||
// main::@1
|
||||
__b1:
|
||||
// [6] *((const byte*) main::SCREEN + (byte) main::i#2) ← *((const byte*) LOGO256_RED#0 + (byte) main::i#2) -- pbuc1_derefidx_vbuz1=pbuc2_derefidx_vbuz1
|
||||
ldy.z i
|
||||
lda LOGO256_RED,y
|
||||
sta SCREEN,y
|
||||
// [7] *((const byte*) main::SCREEN+(word)(number) $28*(number) 8 + (byte) main::i#2) ← *((const byte*) LOGO256_GREEN#0 + (byte) main::i#2) -- pbuc1_derefidx_vbuz1=pbuc2_derefidx_vbuz1
|
||||
ldy.z i
|
||||
lda LOGO256_GREEN,y
|
||||
sta SCREEN+$28*8,y
|
||||
// [8] *((const byte*) main::SCREEN+(word)(number) $28*(number) $10 + (byte) main::i#2) ← *((const byte*) LOGO256_BLUE#0 + (byte) main::i#2) -- pbuc1_derefidx_vbuz1=pbuc2_derefidx_vbuz1
|
||||
ldy.z i
|
||||
lda LOGO256_BLUE,y
|
||||
sta SCREEN+$28*$10,y
|
||||
// [9] (byte) main::i#1 ← ++ (byte) main::i#2 -- vbuz1=_inc_vbuz1
|
||||
inc.z i
|
||||
// [10] if((byte) main::i#1!=(byte) 0) goto main::@1 -- vbuz1_neq_0_then_la1
|
||||
lda.z i
|
||||
cmp #0
|
||||
bne __b1_from___b1
|
||||
jmp __breturn
|
||||
// main::@return
|
||||
__breturn:
|
||||
// [11] return
|
||||
rts
|
||||
}
|
||||
// File Data
|
||||
// Import a 128x128 8bit-per-color logo using inline KickAsm
|
||||
LOGO256:
|
||||
#import "xmega65graphics.asm"
|
||||
.var logo256 = LoadPicture("mega65-256.png")
|
||||
.var palette256 = getPalette(logo256)
|
||||
.print "width: "+logo256.width + " height: "+logo256.height + " colors: "+palette256.keys().size()
|
||||
// Output the graphics
|
||||
.for (var x=0; x<logo256.width; x++)
|
||||
.for (var y=0; y<logo256.height; y++)
|
||||
.byte getFullcolourByte(logo256, palette256, x, y)
|
||||
// Output the RGB-values of the palette
|
||||
.fill 256, getPaletteRed(palette256,i)
|
||||
.fill 256, getPaletteGreen(palette256,i)
|
||||
.fill 256, getPaletteBlue(palette256,i)
|
||||
|
||||
|
||||
REGISTER UPLIFT POTENTIAL REGISTERS
|
||||
Statement [6] *((const byte*) main::SCREEN + (byte) main::i#2) ← *((const byte*) LOGO256_RED#0 + (byte) main::i#2) [ main::i#2 ] ( main:2 [ main::i#2 ] ) always clobbers reg byte a
|
||||
Removing always clobbered register reg byte a as potential for zp[1]:2 [ main::i#2 main::i#1 ]
|
||||
Statement [7] *((const byte*) main::SCREEN+(word)(number) $28*(number) 8 + (byte) main::i#2) ← *((const byte*) LOGO256_GREEN#0 + (byte) main::i#2) [ main::i#2 ] ( main:2 [ main::i#2 ] ) always clobbers reg byte a
|
||||
Statement [8] *((const byte*) main::SCREEN+(word)(number) $28*(number) $10 + (byte) main::i#2) ← *((const byte*) LOGO256_BLUE#0 + (byte) main::i#2) [ main::i#2 ] ( main:2 [ main::i#2 ] ) always clobbers reg byte a
|
||||
Statement [6] *((const byte*) main::SCREEN + (byte) main::i#2) ← *((const byte*) LOGO256_RED#0 + (byte) main::i#2) [ main::i#2 ] ( main:2 [ main::i#2 ] ) always clobbers reg byte a
|
||||
Statement [7] *((const byte*) main::SCREEN+(word)(number) $28*(number) 8 + (byte) main::i#2) ← *((const byte*) LOGO256_GREEN#0 + (byte) main::i#2) [ main::i#2 ] ( main:2 [ main::i#2 ] ) always clobbers reg byte a
|
||||
Statement [8] *((const byte*) main::SCREEN+(word)(number) $28*(number) $10 + (byte) main::i#2) ← *((const byte*) LOGO256_BLUE#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 ,
|
||||
|
||||
REGISTER UPLIFT SCOPES
|
||||
Uplift Scope [main] 38.5: zp[1]:2 [ main::i#2 main::i#1 ]
|
||||
Uplift Scope []
|
||||
|
||||
Uplifting [main] best 478 combination reg byte x [ main::i#2 main::i#1 ]
|
||||
Uplifting [] best 478 combination
|
||||
|
||||
ASSEMBLER BEFORE OPTIMIZATION
|
||||
// File Comments
|
||||
// Import an XMega65 8bit-per-color logo
|
||||
// Fill the palette values into
|
||||
// Upstart
|
||||
.pc = $801 "Basic"
|
||||
:BasicUpstart(__bbegin)
|
||||
.pc = $80d "Program"
|
||||
// Global Constants & labels
|
||||
.label LOGO256_RED = LOGO256+$80*$80
|
||||
.label LOGO256_GREEN = LOGO256_RED+$100
|
||||
.label LOGO256_BLUE = LOGO256_GREEN+$100
|
||||
// @begin
|
||||
__bbegin:
|
||||
// [1] phi from @begin to @1 [phi:@begin->@1]
|
||||
__b1_from___bbegin:
|
||||
jmp __b1
|
||||
// @1
|
||||
__b1:
|
||||
// [2] call main
|
||||
// [4] phi from @1 to main [phi:@1->main]
|
||||
main_from___b1:
|
||||
jsr main
|
||||
// [3] phi from @1 to @end [phi:@1->@end]
|
||||
__bend_from___b1:
|
||||
jmp __bend
|
||||
// @end
|
||||
__bend:
|
||||
// main
|
||||
main: {
|
||||
.label SCREEN = $400
|
||||
// [5] phi from main to main::@1 [phi:main->main::@1]
|
||||
__b1_from_main:
|
||||
// [5] phi (byte) main::i#2 = (byte) 0 [phi:main->main::@1#0] -- vbuxx=vbuc1
|
||||
ldx #0
|
||||
jmp __b1
|
||||
// [5] phi from main::@1 to main::@1 [phi:main::@1->main::@1]
|
||||
__b1_from___b1:
|
||||
// [5] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@1->main::@1#0] -- register_copy
|
||||
jmp __b1
|
||||
// main::@1
|
||||
__b1:
|
||||
// [6] *((const byte*) main::SCREEN + (byte) main::i#2) ← *((const byte*) LOGO256_RED#0 + (byte) main::i#2) -- pbuc1_derefidx_vbuxx=pbuc2_derefidx_vbuxx
|
||||
lda LOGO256_RED,x
|
||||
sta SCREEN,x
|
||||
// [7] *((const byte*) main::SCREEN+(word)(number) $28*(number) 8 + (byte) main::i#2) ← *((const byte*) LOGO256_GREEN#0 + (byte) main::i#2) -- pbuc1_derefidx_vbuxx=pbuc2_derefidx_vbuxx
|
||||
lda LOGO256_GREEN,x
|
||||
sta SCREEN+$28*8,x
|
||||
// [8] *((const byte*) main::SCREEN+(word)(number) $28*(number) $10 + (byte) main::i#2) ← *((const byte*) LOGO256_BLUE#0 + (byte) main::i#2) -- pbuc1_derefidx_vbuxx=pbuc2_derefidx_vbuxx
|
||||
lda LOGO256_BLUE,x
|
||||
sta SCREEN+$28*$10,x
|
||||
// [9] (byte) main::i#1 ← ++ (byte) main::i#2 -- vbuxx=_inc_vbuxx
|
||||
inx
|
||||
// [10] if((byte) main::i#1!=(byte) 0) goto main::@1 -- vbuxx_neq_0_then_la1
|
||||
cpx #0
|
||||
bne __b1_from___b1
|
||||
jmp __breturn
|
||||
// main::@return
|
||||
__breturn:
|
||||
// [11] return
|
||||
rts
|
||||
}
|
||||
// File Data
|
||||
// Import a 128x128 8bit-per-color logo using inline KickAsm
|
||||
LOGO256:
|
||||
#import "xmega65graphics.asm"
|
||||
.var logo256 = LoadPicture("mega65-256.png")
|
||||
.var palette256 = getPalette(logo256)
|
||||
.print "width: "+logo256.width + " height: "+logo256.height + " colors: "+palette256.keys().size()
|
||||
// Output the graphics
|
||||
.for (var x=0; x<logo256.width; x++)
|
||||
.for (var y=0; y<logo256.height; y++)
|
||||
.byte getFullcolourByte(logo256, palette256, x, y)
|
||||
// Output the RGB-values of the palette
|
||||
.fill 256, getPaletteRed(palette256,i)
|
||||
.fill 256, getPaletteGreen(palette256,i)
|
||||
.fill 256, getPaletteBlue(palette256,i)
|
||||
|
||||
|
||||
ASSEMBLER OPTIMIZATIONS
|
||||
Removing instruction jmp __b1
|
||||
Removing instruction jmp __bend
|
||||
Removing instruction jmp __b1
|
||||
Removing instruction jmp __breturn
|
||||
Succesful ASM optimization Pass5NextJumpElimination
|
||||
Replacing label __bbegin with __b1
|
||||
Replacing label __b1_from___b1 with __b1
|
||||
Removing instruction __bbegin:
|
||||
Removing instruction __b1_from___bbegin:
|
||||
Removing instruction main_from___b1:
|
||||
Removing instruction __bend_from___b1:
|
||||
Removing instruction __b1_from___b1:
|
||||
Succesful ASM optimization Pass5RedundantLabelElimination
|
||||
Removing instruction __bend:
|
||||
Removing instruction __b1_from_main:
|
||||
Removing instruction __breturn:
|
||||
Succesful ASM optimization Pass5UnusedLabelElimination
|
||||
Updating BasicUpstart to call main directly
|
||||
Removing instruction jsr main
|
||||
Succesful ASM optimization Pass5SkipBegin
|
||||
Removing instruction jmp __b1
|
||||
Succesful ASM optimization Pass5NextJumpElimination
|
||||
Removing instruction __b1:
|
||||
Succesful ASM optimization Pass5UnusedLabelElimination
|
||||
|
||||
FINAL SYMBOL TABLE
|
||||
(label) @1
|
||||
(label) @begin
|
||||
(label) @end
|
||||
(const byte[]) LOGO256 = kickasm {{ #import "xmega65graphics.asm"
|
||||
.var logo256 = LoadPicture("mega65-256.png")
|
||||
.var palette256 = getPalette(logo256)
|
||||
.print "width: "+logo256.width + " height: "+logo256.height + " colors: "+palette256.keys().size()
|
||||
// Output the graphics
|
||||
.for (var x=0; x<logo256.width; x++)
|
||||
.for (var y=0; y<logo256.height; y++)
|
||||
.byte getFullcolourByte(logo256, palette256, x, y)
|
||||
// Output the RGB-values of the palette
|
||||
.fill 256, getPaletteRed(palette256,i)
|
||||
.fill 256, getPaletteGreen(palette256,i)
|
||||
.fill 256, getPaletteBlue(palette256,i)
|
||||
}}
|
||||
(byte*) LOGO256_BLUE
|
||||
(const byte*) LOGO256_BLUE#0 LOGO256_BLUE = (const byte*) LOGO256_GREEN#0+(word) $100
|
||||
(byte*) LOGO256_GREEN
|
||||
(const byte*) LOGO256_GREEN#0 LOGO256_GREEN = (const byte*) LOGO256_RED#0+(word) $100
|
||||
(byte*) LOGO256_RED
|
||||
(const byte*) LOGO256_RED#0 LOGO256_RED = (const byte[]) LOGO256+(word)(number) $80*(number) $80
|
||||
(void()) main()
|
||||
(label) main::@1
|
||||
(label) main::@return
|
||||
(const byte*) main::SCREEN = (byte*) 1024
|
||||
(byte) main::i
|
||||
(byte) main::i#1 reg byte x 16.5
|
||||
(byte) main::i#2 reg byte x 22.0
|
||||
|
||||
reg byte x [ main::i#2 main::i#1 ]
|
||||
|
||||
|
||||
FINAL ASSEMBLER
|
||||
Score: 376
|
||||
|
||||
// File Comments
|
||||
// Import an XMega65 8bit-per-color logo
|
||||
// Fill the palette values into
|
||||
// Upstart
|
||||
.pc = $801 "Basic"
|
||||
:BasicUpstart(main)
|
||||
.pc = $80d "Program"
|
||||
// Global Constants & labels
|
||||
.label LOGO256_RED = LOGO256+$80*$80
|
||||
.label LOGO256_GREEN = LOGO256_RED+$100
|
||||
.label LOGO256_BLUE = LOGO256_GREEN+$100
|
||||
// @begin
|
||||
// [1] phi from @begin to @1 [phi:@begin->@1]
|
||||
// @1
|
||||
// [2] call main
|
||||
// [4] phi from @1 to main [phi:@1->main]
|
||||
// [3] phi from @1 to @end [phi:@1->@end]
|
||||
// @end
|
||||
// main
|
||||
main: {
|
||||
.label SCREEN = $400
|
||||
// [5] phi from main to main::@1 [phi:main->main::@1]
|
||||
// [5] phi (byte) main::i#2 = (byte) 0 [phi:main->main::@1#0] -- vbuxx=vbuc1
|
||||
ldx #0
|
||||
// [5] phi from main::@1 to main::@1 [phi:main::@1->main::@1]
|
||||
// [5] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@1->main::@1#0] -- register_copy
|
||||
// main::@1
|
||||
__b1:
|
||||
// (SCREEN+40*0)[i] = LOGO256_RED[i]
|
||||
// [6] *((const byte*) main::SCREEN + (byte) main::i#2) ← *((const byte*) LOGO256_RED#0 + (byte) main::i#2) -- pbuc1_derefidx_vbuxx=pbuc2_derefidx_vbuxx
|
||||
lda LOGO256_RED,x
|
||||
sta SCREEN,x
|
||||
// (SCREEN+40*8)[i] = LOGO256_GREEN[i]
|
||||
// [7] *((const byte*) main::SCREEN+(word)(number) $28*(number) 8 + (byte) main::i#2) ← *((const byte*) LOGO256_GREEN#0 + (byte) main::i#2) -- pbuc1_derefidx_vbuxx=pbuc2_derefidx_vbuxx
|
||||
lda LOGO256_GREEN,x
|
||||
sta SCREEN+$28*8,x
|
||||
// (SCREEN+40*16)[i] = LOGO256_BLUE[i]
|
||||
// [8] *((const byte*) main::SCREEN+(word)(number) $28*(number) $10 + (byte) main::i#2) ← *((const byte*) LOGO256_BLUE#0 + (byte) main::i#2) -- pbuc1_derefidx_vbuxx=pbuc2_derefidx_vbuxx
|
||||
lda LOGO256_BLUE,x
|
||||
sta SCREEN+$28*$10,x
|
||||
// for(byte i:0..0xff)
|
||||
// [9] (byte) main::i#1 ← ++ (byte) main::i#2 -- vbuxx=_inc_vbuxx
|
||||
inx
|
||||
// [10] if((byte) main::i#1!=(byte) 0) goto main::@1 -- vbuxx_neq_0_then_la1
|
||||
cpx #0
|
||||
bne __b1
|
||||
// main::@return
|
||||
// }
|
||||
// [11] return
|
||||
rts
|
||||
}
|
||||
// File Data
|
||||
// Import a 128x128 8bit-per-color logo using inline KickAsm
|
||||
LOGO256:
|
||||
#import "xmega65graphics.asm"
|
||||
.var logo256 = LoadPicture("mega65-256.png")
|
||||
.var palette256 = getPalette(logo256)
|
||||
.print "width: "+logo256.width + " height: "+logo256.height + " colors: "+palette256.keys().size()
|
||||
// Output the graphics
|
||||
.for (var x=0; x<logo256.width; x++)
|
||||
.for (var y=0; y<logo256.height; y++)
|
||||
.byte getFullcolourByte(logo256, palette256, x, y)
|
||||
// Output the RGB-values of the palette
|
||||
.fill 256, getPaletteRed(palette256,i)
|
||||
.fill 256, getPaletteGreen(palette256,i)
|
||||
.fill 256, getPaletteBlue(palette256,i)
|
||||
|
||||
|
31
src/test/ref/complex/xmega65/xmega65logo.sym
Normal file
31
src/test/ref/complex/xmega65/xmega65logo.sym
Normal file
@ -0,0 +1,31 @@
|
||||
(label) @1
|
||||
(label) @begin
|
||||
(label) @end
|
||||
(const byte[]) LOGO256 = kickasm {{ #import "xmega65graphics.asm"
|
||||
.var logo256 = LoadPicture("mega65-256.png")
|
||||
.var palette256 = getPalette(logo256)
|
||||
.print "width: "+logo256.width + " height: "+logo256.height + " colors: "+palette256.keys().size()
|
||||
// Output the graphics
|
||||
.for (var x=0; x<logo256.width; x++)
|
||||
.for (var y=0; y<logo256.height; y++)
|
||||
.byte getFullcolourByte(logo256, palette256, x, y)
|
||||
// Output the RGB-values of the palette
|
||||
.fill 256, getPaletteRed(palette256,i)
|
||||
.fill 256, getPaletteGreen(palette256,i)
|
||||
.fill 256, getPaletteBlue(palette256,i)
|
||||
}}
|
||||
(byte*) LOGO256_BLUE
|
||||
(const byte*) LOGO256_BLUE#0 LOGO256_BLUE = (const byte*) LOGO256_GREEN#0+(word) $100
|
||||
(byte*) LOGO256_GREEN
|
||||
(const byte*) LOGO256_GREEN#0 LOGO256_GREEN = (const byte*) LOGO256_RED#0+(word) $100
|
||||
(byte*) LOGO256_RED
|
||||
(const byte*) LOGO256_RED#0 LOGO256_RED = (const byte[]) LOGO256+(word)(number) $80*(number) $80
|
||||
(void()) main()
|
||||
(label) main::@1
|
||||
(label) main::@return
|
||||
(const byte*) main::SCREEN = (byte*) 1024
|
||||
(byte) main::i
|
||||
(byte) main::i#1 reg byte x 16.5
|
||||
(byte) main::i#2 reg byte x 22.0
|
||||
|
||||
reg byte x [ main::i#2 main::i#1 ]
|
Loading…
x
Reference in New Issue
Block a user