1
0
mirror of https://gitlab.com/camelot/kickc.git synced 2024-11-23 08:32:39 +00:00

Added support for string concatenation C style (using simple space separation).

Fixed tests.
This commit is contained in:
Jesper Gravgaard 2019-05-24 20:57:43 +02:00
parent 3376a462fc
commit e46fd03ec5
24 changed files with 848 additions and 1240 deletions

View File

@ -146,7 +146,7 @@ expr
| '{' expr (',' expr )* '}' #initList
| NAME #exprId
| NUMBER #exprNumber
| STRING #exprString
| STRING+ #exprString
| CHAR #exprChar
| BOOLEAN #exprBool
;

View File

@ -1,4 +1,4 @@
// Generated from /Users/jespergravgaard/c64/kickc/src/main/java/dk/camelot64/kickc/parser/KickC.g4 by ANTLR 4.7
// Generated from C:/c64/kickc/src/main/java/dk/camelot64/kickc/parser\KickC.g4 by ANTLR 4.7
package dk.camelot64.kickc.parser;
import org.antlr.v4.runtime.ParserRuleContext;

View File

@ -1,4 +1,4 @@
// Generated from /Users/jespergravgaard/c64/kickc/src/main/java/dk/camelot64/kickc/parser/KickC.g4 by ANTLR 4.7
// Generated from C:/c64/kickc/src/main/java/dk/camelot64/kickc/parser\KickC.g4 by ANTLR 4.7
package dk.camelot64.kickc.parser;
import org.antlr.v4.runtime.tree.AbstractParseTreeVisitor;

View File

@ -1,4 +1,4 @@
// Generated from /Users/jespergravgaard/c64/kickc/src/main/java/dk/camelot64/kickc/parser/KickC.g4 by ANTLR 4.7
// Generated from C:/c64/kickc/src/main/java/dk/camelot64/kickc/parser\KickC.g4 by ANTLR 4.7
package dk.camelot64.kickc.parser;
import org.antlr.v4.runtime.Lexer;
import org.antlr.v4.runtime.CharStream;

View File

@ -1,4 +1,4 @@
// Generated from /Users/jespergravgaard/c64/kickc/src/main/java/dk/camelot64/kickc/parser/KickC.g4 by ANTLR 4.7
// Generated from C:/c64/kickc/src/main/java/dk/camelot64/kickc/parser\KickC.g4 by ANTLR 4.7
package dk.camelot64.kickc.parser;
import org.antlr.v4.runtime.tree.ParseTreeListener;

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
// Generated from /Users/jespergravgaard/c64/kickc/src/main/java/dk/camelot64/kickc/parser/KickC.g4 by ANTLR 4.7
// Generated from C:/c64/kickc/src/main/java/dk/camelot64/kickc/parser\KickC.g4 by ANTLR 4.7
package dk.camelot64.kickc.parser;
import org.antlr.v4.runtime.tree.ParseTreeVisitor;

View File

@ -1307,12 +1307,18 @@ public class Pass0GenerateStatementSequence extends KickCBaseVisitor<Object> {
@Override
public RValue visitExprString(KickCParser.ExprStringContext ctx) {
String text = ctx.getText();
String stringValue;
if(text.endsWith("z")) {
stringValue = text.substring(1, text.length() - 2);
} else {
stringValue = text.substring(1, text.length() - 1)+"@";
String stringValue ="";
String subText = "";
for(TerminalNode stringNode : ctx.STRING()) {
subText = stringNode.getText();
if(subText.endsWith("z")) {
stringValue += subText.substring(1, subText.length() - 2);
} else {
stringValue += subText.substring(1, subText.length() - 1);
}
}
if(!subText.endsWith("z")) {
stringValue += "@";
}
return new ConstantString(stringValue);
}

View File

@ -32,23 +32,9 @@ public class TestPrograms {
public TestPrograms() {
}
/*
* Avaiting String concatenation
@Test
public void testLiterals() throws IOException, URISyntaxException {
compileAndCompare("literals");
}
@Test
public void testConstantStringConcat() throws IOException, URISyntaxException {
compileAndCompare("constant-string-concat");
}
@Test
public void testConcatChar() throws IOException, URISyntaxException {
compileAndCompare("concat-char");
public void testC64DtvGfxExplorer() throws IOException, URISyntaxException {
compileAndCompare("c64dtv-gfxexplorer", 10);
}
@Test
@ -57,11 +43,20 @@ public class TestPrograms {
}
@Test
public void testC64DtvGfxExplorer() throws IOException, URISyntaxException {
compileAndCompare("c64dtv-gfxexplorer", 10);
public void testConstantStringConcat0() throws IOException, URISyntaxException {
compileAndCompare("constant-string-concat-0", log().verboseParse().verboseStatementSequence().verboseCreateSsa());
}
*/
@Test
public void testLiterals() throws IOException, URISyntaxException {
compileAndCompare("literals");
}
@Test
public void testConstantStringConcat() throws IOException, URISyntaxException {
compileAndCompare("constant-string-concat");
}
@Test
public void testStatementSequence1() throws IOException, URISyntaxException {

View File

@ -115,40 +115,40 @@ const byte* FORM_SCREEN = $0400;
const byte* FORM_CHARSET = $1800; // Charset ROM
byte[] FORM_TEXT =
" C64 DTV Graphics Mode Explorer @"z +
" @"z +
" PRESET 0 Standard Charset @"z +
" @"z +
" CONTROL PLANE A VIC II @"z +
" bmm 0 pattern p0 screen s0 @"z +
" mcm 0 start 00 gfx g0 @"z +
" ecm 0 step 00 colors c0 @"z +
" hicolor 0 modulo 00 @"z +
" linear 0 COLORS @"z +
" color off 0 PLANE B palet 0 @"z +
" chunky 0 pattern p0 bgcol0 00 @"z +
" border off 0 start 00 bgcol1 00 @"z +
" overscan 0 step 00 bgcol2 00 @"z +
" modulo 00 bgcol3 00 @"z +
"@"z ;
" C64 DTV Graphics Mode Explorer @"
" @"
" PRESET 0 Standard Charset @"
" @"
" CONTROL PLANE A VIC II @"
" bmm 0 pattern p0 screen s0 @"
" mcm 0 start 00 gfx g0 @"
" ecm 0 step 00 colors c0 @"
" hicolor 0 modulo 00 @"
" linear 0 COLORS @"
" color off 0 PLANE B palet 0 @"
" chunky 0 pattern p0 bgcol0 00 @"
" border off 0 start 00 bgcol1 00 @"
" overscan 0 step 00 bgcol2 00 @"
" modulo 00 bgcol3 00 @"
;
byte[] FORM_COLS =
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa@"z +
" @"z +
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa@"z +
" @"z +
" nnnnnnnnnnnn mmmmmmmmmm ooooooooo @"z +
" nnnnnnnnnnnn mmmmmmmmmm ooooooooo @"z +
" nnnnnnnnnnnn mmmmmmmmmm ooooooooo @"z +
" nnnnnnnnnnnn mmmmmmmmmm ooooooooo @"z +
" nnnnnnnnnnnn mmmmmmmmmm @"z +
" nnnnnnnnnnnn jjjjjjjjj @"z +
" nnnnnnnnnnnn mmmmmmmmmm jjjjjjjjj @"z +
" nnnnnnnnnnnn mmmmmmmmmm jjjjjjjjj @"z +
" nnnnnnnnnnnn mmmmmmmmmm jjjjjjjjj @"z +
" nnnnnnnnnnnn mmmmmmmmmm jjjjjjjjj @"z +
" nnnnnnnnnnnn mmmmmmmmmm jjjjjjjjj @"z +
" nnnnnnnnnnnn mmmmmmmmmm jjjjjjjjj @"z +
"@"z ;
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa@"
" @"
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa@"
" @"
" nnnnnnnnnnnn mmmmmmmmmm ooooooooo @"
" nnnnnnnnnnnn mmmmmmmmmm ooooooooo @"
" nnnnnnnnnnnn mmmmmmmmmm ooooooooo @"
" nnnnnnnnnnnn mmmmmmmmmm ooooooooo @"
" nnnnnnnnnnnn mmmmmmmmmm @"
" nnnnnnnnnnnn jjjjjjjjj @"
" nnnnnnnnnnnn mmmmmmmmmm jjjjjjjjj @"
" nnnnnnnnnnnn mmmmmmmmmm jjjjjjjjj @"
" nnnnnnnnnnnn mmmmmmmmmm jjjjjjjjj @"
" nnnnnnnnnnnn mmmmmmmmmm jjjjjjjjj @"
" nnnnnnnnnnnn mmmmmmmmmm jjjjjjjjj @"
" nnnnnnnnnnnn mmmmmmmmmm jjjjjjjjj @"
;
// Number of form fields
byte form_fields_cnt = 36;

View File

@ -18,27 +18,28 @@ void main() {
}
byte[] MENU_TEXT =
"C64DTV Graphics Modes CCLHBME@"z +
" OHIIMCC@"z +
" LUNCMMM@"z +
"----------------------------------------@"z +
"1. Standard Char (V) 0000000@"z +
"2. Extended Color Char (V) 0000001@"z +
"3. Multicolor Char (V) 0000010@"z +
"4. Standard Bitmap (V) 0000100@"z +
"5. Multicolor Bitmap (V) 0000110@"z +
"6. High Color Standard Char (H) 0001000@"z +
"7. High Extended Color Char (H) 0001001@"z +
"8. High Multicolor Char (H) 0001010@"z +
"9. High Multicolor Bitmap (H) 0001110@"z +
"a. Sixs Fred 2 (D) 0010111@"z +
"b. Two Plane Bitmap (D) 0011101@"z +
"c. Sixs Fred (2 Plane MC BM) (D) 0011111@"z +
"d. 8bpp Pixel Cell (D) 0111011@"z +
"e. Chunky 8bpp Bitmap (D) 1111011@"z +
"----------------------------------------@"z +
" (V) vicII (H) vicII+hicol (D) c64dtv@"z +
"@"z ;
"C64DTV Graphics Modes CCLHBME@"
" OHIIMCC@"
" LUNCMMM@"
"----------------------------------------@"
"1. Standard Char (V) 0000000@"
"2. Extended Color Char (V) 0000001@"
"3. Multicolor Char (V) 0000010@"
"4. Standard Bitmap (V) 0000100@"
"5. Multicolor Bitmap (V) 0000110@"
"6. High Color Standard Char (H) 0001000@"
"7. High Extended Color Char (H) 0001001@"
"8. High Multicolor Char (H) 0001010@"
"9. High Multicolor Bitmap (H) 0001110@"
"a. Sixs Fred 2 (D) 0010111@"
"b. Two Plane Bitmap (D) 0011101@"
"c. Sixs Fred (2 Plane MC BM) (D) 0011111@"
"d. 8bpp Pixel Cell (D) 0111011@"
"e. Chunky 8bpp Bitmap (D) 1111011@"
"----------------------------------------@"
" (V) vicII (H) vicII+hicol (D) c64dtv@"
;
void menu() {
const byte* SCREEN = $8000;

View File

@ -1,10 +0,0 @@
// Concatenate a char to a string
void main() {
byte* screen = $400;
byte l = 'l';
byte[] msg = "cm"z+l;
for( byte i: 0..2 ) {
screen[i] = msg[i];
}
}

View File

@ -0,0 +1,8 @@
// Concatenates string constants in different ways
void main() {
byte[] msg = "camel" "ot";
byte* SCREEN = 0x0400;
for( byte i=0;msg[i]!=0;i++) {
SCREEN[i] = msg[i];
}
}

View File

@ -1,13 +1,10 @@
// Concatenates string constants in different ways
void main() {
byte[] s = "e"z+"l"z;
byte[] s2 = s+'o';
byte[] s3 = "cam"z+s2;
byte e = '!';
byte[] s4 = ""z+'t'+ e;
byte[] s5 = s3+s4;
byte[] s = "c"
"ame"
"lot";
byte* SCREEN = $400;
for( byte i: 0..7) {
SCREEN[i] = s5[i];
SCREEN[i] = s[i];
}
}

View File

@ -2,7 +2,7 @@ byte* SCREEN = $0400;
byte ch = 'a';
byte num = 1;
byte[] str = "bc"z+"d"z+'e';
byte[] str = "bc" "d" "e";
byte[] nums = { 2, 3, 4, 5};
void main() {

File diff suppressed because it is too large Load Diff

View File

@ -120,10 +120,10 @@ menu: {
.label c = 2
// Charset ROM
// DTV Graphics Bank
lda #($ffffffff&CHARSET)/$10000
lda #0
sta DTV_GRAPHICS_VIC_BANK
// DTV Color Bank
lda #DTV_COLOR_BANK_DEFAULT/$400
lda #<DTV_COLOR_BANK_DEFAULT/$400
sta DTV_COLOR_BANK_LO
lda #0
sta DTV_COLOR_BANK_HI
@ -142,7 +142,7 @@ menu: {
lda #VIC_CSEL
sta VIC_CONTROL2
// VIC Memory Pointers
lda #(SCREEN&$3fff)/$40|(CHARSET&$3fff)/$400
lda #(CHARSET&$3fff)/$400
sta VIC_MEMORY
ldx #0
// DTV Palette - default
@ -286,11 +286,10 @@ mode_8bppchunkybmm: {
lda #VIC_MCM|VIC_CSEL
sta VIC_CONTROL2
// Linear Graphics Plane B Counter
lda #PLANEB&$ffff
sta DTV_PLANEB_START_LO
lda #0
sta DTV_PLANEB_START_LO
sta DTV_PLANEB_START_MI
lda #PLANEB>>$10
lda #<PLANEB>>$10
sta DTV_PLANEB_START_HI
lda #8
sta DTV_PLANEB_STEP
@ -525,7 +524,7 @@ mode_8bpppixelcell: {
lda #VIC_MCM|VIC_CSEL
sta VIC_CONTROL2
// Linear Graphics Plane A Counter
lda #<PLANEA
lda #0
sta DTV_PLANEA_START_LO
lda #>PLANEA
sta DTV_PLANEA_START_MI
@ -537,7 +536,6 @@ mode_8bpppixelcell: {
sta DTV_PLANEA_MODULO_LO
sta DTV_PLANEA_MODULO_HI
// Linear Graphics Plane B Counter
lda #<PLANEB
sta DTV_PLANEB_START_LO
lda #>PLANEB
sta DTV_PLANEB_START_MI
@ -674,7 +672,7 @@ mode_sixsfred: {
lda #VIC_MCM|VIC_CSEL
sta VIC_CONTROL2
// Linear Graphics Plane A Counter
lda #<PLANEA
lda #0
sta DTV_PLANEA_START_LO
lda #>PLANEA
sta DTV_PLANEA_START_MI
@ -686,7 +684,6 @@ mode_sixsfred: {
sta DTV_PLANEA_MODULO_LO
sta DTV_PLANEA_MODULO_HI
// Linear Graphics Plane B Counter
lda #<PLANEB
sta DTV_PLANEB_START_LO
lda #>PLANEB
sta DTV_PLANEB_START_MI
@ -700,9 +697,9 @@ mode_sixsfred: {
// DTV Color Bank
lda #<COLORS/$400
sta DTV_COLOR_BANK_LO
lda #>COLORS/$400
lda #0
sta DTV_COLOR_BANK_HI
ldx #0
tax
// DTV Palette - Grey Tones
b1:
txa
@ -823,7 +820,7 @@ mode_twoplanebitmap: {
lda #VIC_CSEL
sta VIC_CONTROL2
// Linear Graphics Plane A Counter
lda #<PLANEA
lda #0
sta DTV_PLANEA_START_LO
lda #>PLANEA
sta DTV_PLANEA_START_MI
@ -835,7 +832,6 @@ mode_twoplanebitmap: {
sta DTV_PLANEA_MODULO_LO
sta DTV_PLANEA_MODULO_HI
// Linear Graphics Plane B Counter
lda #<PLANEB
sta DTV_PLANEB_START_LO
lda #>PLANEB
sta DTV_PLANEB_START_MI
@ -849,9 +845,9 @@ mode_twoplanebitmap: {
// DTV Color Bank
lda #<COLORS/$400
sta DTV_COLOR_BANK_LO
lda #>COLORS/$400
lda #0
sta DTV_COLOR_BANK_HI
ldx #0
tax
// DTV Palette - Grey Tones
b1:
txa
@ -989,7 +985,7 @@ mode_sixsfred2: {
lda #VIC_MCM|VIC_CSEL
sta VIC_CONTROL2
// Linear Graphics Plane A Counter
lda #<PLANEA
lda #0
sta DTV_PLANEA_START_LO
lda #>PLANEA
sta DTV_PLANEA_START_MI
@ -1001,7 +997,6 @@ mode_sixsfred2: {
sta DTV_PLANEA_MODULO_LO
sta DTV_PLANEA_MODULO_HI
// Linear Graphics Plane B Counter
lda #<PLANEB
sta DTV_PLANEB_START_LO
lda #>PLANEB
sta DTV_PLANEB_START_MI
@ -1015,9 +1010,9 @@ mode_sixsfred2: {
// DTV Color Bank
lda #<COLORS/$400
sta DTV_COLOR_BANK_LO
lda #>COLORS/$400
lda #0
sta DTV_COLOR_BANK_HI
ldx #0
tax
// DTV Palette - Grey Tones
b1:
txa
@ -1138,10 +1133,10 @@ mode_hicolmcchar: {
.label ch = 5
.label cy = 4
// DTV Graphics Bank
lda #($ffffffff&CHARSET)/$10000
lda #0
sta DTV_GRAPHICS_VIC_BANK
// DTV Color Bank
lda #COLORS/$400
lda #<COLORS/$400
sta DTV_COLOR_BANK_LO
lda #0
sta DTV_COLOR_BANK_HI
@ -1160,7 +1155,7 @@ mode_hicolmcchar: {
lda #VIC_CSEL|VIC_MCM
sta VIC_CONTROL2
// VIC Memory Pointers
lda #(SCREEN&$3fff)/$40|(CHARSET&$3fff)/$400
lda #(CHARSET&$3fff)/$400
sta VIC_MEMORY
ldx #0
// DTV Palette - Grey Tones
@ -1247,10 +1242,10 @@ mode_hicolecmchar: {
.label ch = 5
.label cy = 4
// DTV Graphics Bank
lda #($ffffffff&CHARSET)/$10000
lda #0
sta DTV_GRAPHICS_VIC_BANK
// DTV Color Bank
lda #COLORS/$400
lda #<COLORS/$400
sta DTV_COLOR_BANK_LO
lda #0
sta DTV_COLOR_BANK_HI
@ -1269,7 +1264,7 @@ mode_hicolecmchar: {
lda #VIC_CSEL
sta VIC_CONTROL2
// VIC Memory Pointers
lda #(SCREEN&$3fff)/$40|(CHARSET&$3fff)/$400
lda #(CHARSET&$3fff)/$400
sta VIC_MEMORY
ldx #0
// DTV Palette - Grey Tones
@ -1354,10 +1349,10 @@ mode_hicolstdchar: {
.label ch = 5
.label cy = 4
// DTV Graphics Bank
lda #($ffffffff&CHARSET)/$10000
lda #0
sta DTV_GRAPHICS_VIC_BANK
// DTV Color Bank
lda #COLORS/$400
lda #<COLORS/$400
sta DTV_COLOR_BANK_LO
lda #0
sta DTV_COLOR_BANK_HI
@ -1376,7 +1371,7 @@ mode_hicolstdchar: {
lda #VIC_CSEL
sta VIC_CONTROL2
// VIC Memory Pointers
lda #(SCREEN&$3fff)/$40|(CHARSET&$3fff)/$400
lda #(CHARSET&$3fff)/$400
sta VIC_MEMORY
ldx #0
// DTV Palette - Grey Tones
@ -1453,9 +1448,8 @@ mode_stdbitmap: {
.label cy = 4
.label l = 4
// DTV Graphics Bank
lda #($ffffffff&BITMAP)/$10000
sta DTV_GRAPHICS_VIC_BANK
lda #0
sta DTV_GRAPHICS_VIC_BANK
sta DTV_CONTROL
// VIC Graphics Bank
lda #3
@ -1470,7 +1464,7 @@ mode_stdbitmap: {
lda #VIC_CSEL
sta VIC_CONTROL2
// VIC Memory Pointers
lda #(SCREEN&$3fff)/$40|(BITMAP&$3fff)/$400
lda #(BITMAP&$3fff)/$400
sta VIC_MEMORY
ldx #0
// DTV Palette - default
@ -1694,6 +1688,7 @@ bitmap_plot: {
.label _0 = 2
.label plotter_x = 2
.label plotter_y = 5
.label plotter = 2
lda bitmap_plot_xhi,x
sta plotter_x+1
lda bitmap_plot_xlo,x
@ -1711,8 +1706,8 @@ bitmap_plot: {
sta _0+1
lda bitmap_plot_bit,x
ldy #0
ora (_0),y
sta (_0),y
ora (plotter),y
sta (plotter),y
rts
}
// bitmap_line_ydxi(byte zeropage($a) y, byte register(X) x, byte zeropage($c) y1, byte zeropage(7) yd, byte zeropage(8) xd)
@ -1850,7 +1845,7 @@ bitmap_clear: {
}
// Initialize the bitmap plotter tables for a specific bitmap
bitmap_init: {
.label _6 = 4
.label _10 = 4
.label yoffs = 2
ldy #$80
ldx #0
@ -1878,15 +1873,14 @@ bitmap_init: {
tax
b3:
lda #7
sax _6
sax _10
lda yoffs
ora _6
ora _10
sta bitmap_plot_ylo,x
lda yoffs+1
sta bitmap_plot_yhi,x
txa
and #7
cmp #7
lda #7
cmp _10
bne b4
clc
lda yoffs
@ -1923,10 +1917,10 @@ mode_mcchar: {
.label ch = 5
.label cy = 4
// DTV Graphics Bank
lda #($ffffffff&CHARSET)/$10000
lda #0
sta DTV_GRAPHICS_VIC_BANK
// DTV Color Bank
lda #DTV_COLOR_BANK_DEFAULT/$400
lda #<DTV_COLOR_BANK_DEFAULT/$400
sta DTV_COLOR_BANK_LO
lda #0
sta DTV_COLOR_BANK_HI
@ -1944,7 +1938,7 @@ mode_mcchar: {
lda #VIC_CSEL|VIC_MCM
sta VIC_CONTROL2
// VIC Memory Pointers
lda #(SCREEN&$3fff)/$40|(CHARSET&$3fff)/$400
lda #(CHARSET&$3fff)/$400
sta VIC_MEMORY
ldx #0
// DTV Palette - default
@ -2035,10 +2029,10 @@ mode_ecmchar: {
.label ch = 5
.label cy = 4
// DTV Graphics Bank
lda #($ffffffff&CHARSET)/$10000
lda #0
sta DTV_GRAPHICS_VIC_BANK
// DTV Color Bank
lda #DTV_COLOR_BANK_DEFAULT/$400
lda #<DTV_COLOR_BANK_DEFAULT/$400
sta DTV_COLOR_BANK_LO
lda #0
sta DTV_COLOR_BANK_HI
@ -2056,7 +2050,7 @@ mode_ecmchar: {
lda #VIC_CSEL
sta VIC_CONTROL2
// VIC Memory Pointers
lda #(SCREEN&$3fff)/$40|(CHARSET&$3fff)/$400
lda #(CHARSET&$3fff)/$400
sta VIC_MEMORY
ldx #0
// DTV Palette - default
@ -2144,10 +2138,10 @@ mode_stdchar: {
.label ch = 5
.label cy = 4
// DTV Graphics Bank
lda #($ffffffff&CHARSET)/$10000
lda #0
sta DTV_GRAPHICS_VIC_BANK
// DTV Color Bank
lda #DTV_COLOR_BANK_DEFAULT/$400
lda #<DTV_COLOR_BANK_DEFAULT/$400
sta DTV_COLOR_BANK_LO
lda #0
sta DTV_COLOR_BANK_HI
@ -2165,7 +2159,7 @@ mode_stdchar: {
lda #VIC_CSEL
sta VIC_CONTROL2
// VIC Memory Pointers
lda #(SCREEN&$3fff)/$40|(CHARSET&$3fff)/$400
lda #(CHARSET&$3fff)/$400
sta VIC_MEMORY
ldx #0
// DTV Palette - default
@ -2337,4 +2331,4 @@ print_set_screen: {
bitmap_plot_ylo: .fill $100, 0
bitmap_plot_yhi: .fill $100, 0
bitmap_plot_bit: .fill $100, 0
MENU_TEXT: .text "C64DTV Graphics Modes CCLHBME@"+" OHIIMCC@"+" LUNCMMM@"+"----------------------------------------@"+"1. Standard Char (V) 0000000@"+"2. Extended Color Char (V) 0000001@"+"3. Multicolor Char (V) 0000010@"+"4. Standard Bitmap (V) 0000100@"+"5. Multicolor Bitmap (V) 0000110@"+"6. High Color Standard Char (H) 0001000@"+"7. High Extended Color Char (H) 0001001@"+"8. High Multicolor Char (H) 0001010@"+"9. High Multicolor Bitmap (H) 0001110@"+"a. Sixs Fred 2 (D) 0010111@"+"b. Two Plane Bitmap (D) 0011101@"+"c. Sixs Fred (2 Plane MC BM) (D) 0011111@"+"d. 8bpp Pixel Cell (D) 0111011@"+"e. Chunky 8bpp Bitmap (D) 1111011@"+"----------------------------------------@"+" (V) vicII (H) vicII+hicol (D) c64dtv@"+"@"
MENU_TEXT: .text "C64DTV Graphics Modes CCLHBME@ OHIIMCC@ LUNCMMM@----------------------------------------@1. Standard Char (V) 0000000@2. Extended Color Char (V) 0000001@3. Multicolor Char (V) 0000010@4. Standard Bitmap (V) 0000100@5. Multicolor Bitmap (V) 0000110@6. High Color Standard Char (H) 0001000@7. High Extended Color Char (H) 0001001@8. High Multicolor Char (H) 0001010@9. High Multicolor Bitmap (H) 0001110@a. Sixs Fred 2 (D) 0010111@b. Two Plane Bitmap (D) 0011101@c. Sixs Fred (2 Plane MC BM) (D) 0011111@d. 8bpp Pixel Cell (D) 0111011@e. Chunky 8bpp Bitmap (D) 1111011@----------------------------------------@ (V) vicII (H) vicII+hicol (D) c64dtv@@"

View File

@ -1,16 +0,0 @@
// Concatenate a char to a string
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
main: {
.label screen = $400
ldx #0
b1:
lda msg,x
sta screen,x
inx
cpx #3
bne b1
rts
msg: .text "cm"+'l'
}

View File

@ -1,21 +0,0 @@
@begin: scope:[] from
[0] phi()
to:@1
@1: scope:[] from @begin
[1] phi()
[2] call main
to:@end
@end: scope:[] from @1
[3] phi()
main: scope:[main] from @1
[4] phi()
to:main::@1
main::@1: scope:[main] from main main::@1
[5] (byte) main::i#2 ← phi( main/(byte/signed byte/word/signed word/dword/signed dword) 0 main::@1/(byte) main::i#1 )
[6] *((const byte*) main::screen#0 + (byte) main::i#2) ← *((const byte[]) main::msg#0 + (byte) main::i#2)
[7] (byte) main::i#1 ← ++ (byte) main::i#2
[8] if((byte) main::i#1!=(byte/signed byte/word/signed word/dword/signed dword) 3) goto main::@1
to:main::@return
main::@return: scope:[main] from main::@1
[9] return
to:@return

View File

@ -1,338 +0,0 @@
Identified constant variable (byte*) main::screen
Identified constant variable (byte) main::l
CONTROL FLOW GRAPH SSA
@begin: scope:[] from
to:@1
main: scope:[main] from @1
(byte*) main::screen#0 ← ((byte*)) (word/signed word/dword/signed dword) $400
(byte) main::l#0 ← (byte) 'l'
(string~) main::$0 ← (const string) main::$2 + (byte) main::l#0
(byte[]) main::msg#0 ← (string~) main::$0
(byte) main::i#0 ← (byte/signed byte/word/signed word/dword/signed dword) 0
to:main::@1
main::@1: scope:[main] from main main::@1
(byte) main::i#2 ← phi( main/(byte) main::i#0 main::@1/(byte) main::i#1 )
*((byte*) main::screen#0 + (byte) main::i#2) ← *((byte[]) main::msg#0 + (byte) main::i#2)
(byte) main::i#1 ← (byte) main::i#2 + rangenext(0,2)
(bool~) main::$1 ← (byte) main::i#1 != rangelast(0,2)
if((bool~) main::$1) goto main::@1
to:main::@return
main::@return: scope:[main] from main::@1
return
to:@return
@1: scope:[] from @begin
call main
to:@2
@2: scope:[] from @1
to:@end
@end: scope:[] from @2
SYMBOL TABLE SSA
(label) @1
(label) @2
(label) @begin
(label) @end
(void()) main()
(string~) main::$0
(bool~) main::$1
(const string) main::$2 = (string) "cm"
(label) main::@1
(label) main::@return
(byte) main::i
(byte) main::i#0
(byte) main::i#1
(byte) main::i#2
(byte) main::l
(byte) main::l#0
(byte[]) main::msg
(byte[]) main::msg#0
(byte*) main::screen
(byte*) main::screen#0
Culled Empty Block (label) @2
Successful SSA optimization Pass2CullEmptyBlocks
Alias (byte[]) main::msg#0 = (string~) main::$0
Successful SSA optimization Pass2AliasElimination
Simple Condition (bool~) main::$1 [9] if((byte) main::i#1!=rangelast(0,2)) goto main::@1
Successful SSA optimization Pass2ConditionalJumpSimplification
Constant (const byte*) main::screen#0 = ((byte*))$400
Constant (const byte) main::l#0 = 'l'
Constant (const byte) main::i#0 = 0
Successful SSA optimization Pass2ConstantIdentification
Constant (const byte[]) main::msg#0 = "cm"+'l'
Successful SSA optimization Pass2ConstantIdentification
Eliminating unused constant (const string) main::$2
Eliminating unused constant (const byte) main::l#0
Successful SSA optimization PassNEliminateUnusedVars
Resolved ranged next value main::i#1 ← ++ main::i#2 to ++
Resolved ranged comparison value if(main::i#1!=rangelast(0,2)) goto main::@1 to (byte/signed byte/word/signed word/dword/signed dword) 3
Inlining constant with var siblings (const byte) main::i#0
Constant inlined main::i#0 = (byte/signed byte/word/signed word/dword/signed dword) 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 @end
Adding NOP phi() at start of main
CALL GRAPH
Calls in [] to main:2
Created 1 initial phi equivalence classes
Coalesced [10] main::i#3 ← main::i#1
Coalesced down to 1 phi equivalence classes
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()
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/signed byte/word/signed word/dword/signed dword) 0 main::@1/(byte) main::i#1 )
[6] *((const byte*) main::screen#0 + (byte) main::i#2) ← *((const byte[]) main::msg#0 + (byte) main::i#2)
[7] (byte) main::i#1 ← ++ (byte) main::i#2
[8] if((byte) main::i#1!=(byte/signed byte/word/signed word/dword/signed dword) 3) goto main::@1
to:main::@return
main::@return: scope:[main] from main::@1
[9] return
to:@return
VARIABLE REGISTER WEIGHTS
(void()) main()
(byte) main::i
(byte) main::i#1 16.5
(byte) main::i#2 22.0
(byte) main::l
(byte[]) main::msg
(byte*) main::screen
Initial phi equivalence classes
[ main::i#2 main::i#1 ]
Complete equivalence classes
[ main::i#2 main::i#1 ]
Allocated zp ZP_BYTE:2 [ main::i#2 main::i#1 ]
INITIAL ASM
//SEG0 File Comments
// Concatenate a char to a string
//SEG1 Basic Upstart
.pc = $801 "Basic"
:BasicUpstart(bbegin)
.pc = $80d "Program"
//SEG2 Global Constants & labels
//SEG3 @begin
bbegin:
//SEG4 [1] phi from @begin to @1 [phi:@begin->@1]
b1_from_bbegin:
jmp b1
//SEG5 @1
b1:
//SEG6 [2] call main
//SEG7 [4] phi from @1 to main [phi:@1->main]
main_from_b1:
jsr main
//SEG8 [3] phi from @1 to @end [phi:@1->@end]
bend_from_b1:
jmp bend
//SEG9 @end
bend:
//SEG10 main
main: {
.label screen = $400
.label i = 2
//SEG11 [5] phi from main to main::@1 [phi:main->main::@1]
b1_from_main:
//SEG12 [5] phi (byte) main::i#2 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:main->main::@1#0] -- vbuz1=vbuc1
lda #0
sta i
jmp b1
//SEG13 [5] phi from main::@1 to main::@1 [phi:main::@1->main::@1]
b1_from_b1:
//SEG14 [5] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@1->main::@1#0] -- register_copy
jmp b1
//SEG15 main::@1
b1:
//SEG16 [6] *((const byte*) main::screen#0 + (byte) main::i#2) ← *((const byte[]) main::msg#0 + (byte) main::i#2) -- pbuc1_derefidx_vbuz1=pbuc2_derefidx_vbuz1
ldy i
lda msg,y
sta screen,y
//SEG17 [7] (byte) main::i#1 ← ++ (byte) main::i#2 -- vbuz1=_inc_vbuz1
inc i
//SEG18 [8] if((byte) main::i#1!=(byte/signed byte/word/signed word/dword/signed dword) 3) goto main::@1 -- vbuz1_neq_vbuc1_then_la1
lda #3
cmp i
bne b1_from_b1
jmp breturn
//SEG19 main::@return
breturn:
//SEG20 [9] return
rts
msg: .text "cm"+'l'
}
REGISTER UPLIFT POTENTIAL REGISTERS
Statement [6] *((const byte*) main::screen#0 + (byte) main::i#2) ← *((const byte[]) main::msg#0 + (byte) main::i#2) [ main::i#2 ] ( main:2 [ main::i#2 ] ) always clobbers reg byte a
Removing always clobbered register reg byte a as potential for zp ZP_BYTE:2 [ main::i#2 main::i#1 ]
Statement [6] *((const byte*) main::screen#0 + (byte) main::i#2) ← *((const byte[]) main::msg#0 + (byte) main::i#2) [ main::i#2 ] ( main:2 [ main::i#2 ] ) always clobbers reg byte a
Potential registers zp ZP_BYTE:2 [ main::i#2 main::i#1 ] : zp ZP_BYTE:2 , reg byte x , reg byte y ,
REGISTER UPLIFT SCOPES
Uplift Scope [main] 38.5: zp ZP_BYTE:2 [ main::i#2 main::i#1 ]
Uplift Scope []
Uplifting [main] best 288 combination reg byte x [ main::i#2 main::i#1 ]
Uplifting [] best 288 combination
ASSEMBLER BEFORE OPTIMIZATION
//SEG0 File Comments
// Concatenate a char to a string
//SEG1 Basic Upstart
.pc = $801 "Basic"
:BasicUpstart(bbegin)
.pc = $80d "Program"
//SEG2 Global Constants & labels
//SEG3 @begin
bbegin:
//SEG4 [1] phi from @begin to @1 [phi:@begin->@1]
b1_from_bbegin:
jmp b1
//SEG5 @1
b1:
//SEG6 [2] call main
//SEG7 [4] phi from @1 to main [phi:@1->main]
main_from_b1:
jsr main
//SEG8 [3] phi from @1 to @end [phi:@1->@end]
bend_from_b1:
jmp bend
//SEG9 @end
bend:
//SEG10 main
main: {
.label screen = $400
//SEG11 [5] phi from main to main::@1 [phi:main->main::@1]
b1_from_main:
//SEG12 [5] phi (byte) main::i#2 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:main->main::@1#0] -- vbuxx=vbuc1
ldx #0
jmp b1
//SEG13 [5] phi from main::@1 to main::@1 [phi:main::@1->main::@1]
b1_from_b1:
//SEG14 [5] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@1->main::@1#0] -- register_copy
jmp b1
//SEG15 main::@1
b1:
//SEG16 [6] *((const byte*) main::screen#0 + (byte) main::i#2) ← *((const byte[]) main::msg#0 + (byte) main::i#2) -- pbuc1_derefidx_vbuxx=pbuc2_derefidx_vbuxx
lda msg,x
sta screen,x
//SEG17 [7] (byte) main::i#1 ← ++ (byte) main::i#2 -- vbuxx=_inc_vbuxx
inx
//SEG18 [8] if((byte) main::i#1!=(byte/signed byte/word/signed word/dword/signed dword) 3) goto main::@1 -- vbuxx_neq_vbuc1_then_la1
cpx #3
bne b1_from_b1
jmp breturn
//SEG19 main::@return
breturn:
//SEG20 [9] return
rts
msg: .text "cm"+'l'
}
ASSEMBLER OPTIMIZATIONS
Removing instruction jmp b1
Removing instruction jmp bend
Removing instruction jmp b1
Removing instruction jmp breturn
Succesful ASM optimization Pass5NextJumpElimination
Replacing label b1_from_b1 with b1
Removing instruction b1_from_bbegin:
Removing instruction b1:
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 bbegin:
Succesful ASM optimization Pass5UnusedLabelElimination
FINAL SYMBOL TABLE
(label) @1
(label) @begin
(label) @end
(void()) main()
(label) main::@1
(label) main::@return
(byte) main::i
(byte) main::i#1 reg byte x 16.5
(byte) main::i#2 reg byte x 22.0
(byte) main::l
(byte[]) main::msg
(const byte[]) main::msg#0 msg = (string) "cm"+(byte) 'l'
(byte*) main::screen
(const byte*) main::screen#0 screen = ((byte*))(word/signed word/dword/signed dword) $400
reg byte x [ main::i#2 main::i#1 ]
FINAL ASSEMBLER
Score: 186
//SEG0 File Comments
// Concatenate a char to a string
//SEG1 Basic Upstart
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
//SEG2 Global Constants & labels
//SEG3 @begin
//SEG4 [1] phi from @begin to @1 [phi:@begin->@1]
//SEG5 @1
//SEG6 [2] call main
//SEG7 [4] phi from @1 to main [phi:@1->main]
//SEG8 [3] phi from @1 to @end [phi:@1->@end]
//SEG9 @end
//SEG10 main
main: {
.label screen = $400
//SEG11 [5] phi from main to main::@1 [phi:main->main::@1]
//SEG12 [5] phi (byte) main::i#2 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:main->main::@1#0] -- vbuxx=vbuc1
ldx #0
//SEG13 [5] phi from main::@1 to main::@1 [phi:main::@1->main::@1]
//SEG14 [5] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@1->main::@1#0] -- register_copy
//SEG15 main::@1
b1:
//SEG16 [6] *((const byte*) main::screen#0 + (byte) main::i#2) ← *((const byte[]) main::msg#0 + (byte) main::i#2) -- pbuc1_derefidx_vbuxx=pbuc2_derefidx_vbuxx
lda msg,x
sta screen,x
//SEG17 [7] (byte) main::i#1 ← ++ (byte) main::i#2 -- vbuxx=_inc_vbuxx
inx
//SEG18 [8] if((byte) main::i#1!=(byte/signed byte/word/signed word/dword/signed dword) 3) goto main::@1 -- vbuxx_neq_vbuc1_then_la1
cpx #3
bne b1
//SEG19 main::@return
//SEG20 [9] return
rts
msg: .text "cm"+'l'
}

View File

@ -1,16 +0,0 @@
(label) @1
(label) @begin
(label) @end
(void()) main()
(label) main::@1
(label) main::@return
(byte) main::i
(byte) main::i#1 reg byte x 16.5
(byte) main::i#2 reg byte x 22.0
(byte) main::l
(byte[]) main::msg
(const byte[]) main::msg#0 msg = (string) "cm"+(byte) 'l'
(byte*) main::screen
(const byte*) main::screen#0 screen = ((byte*))(word/signed word/dword/signed dword) $400
reg byte x [ main::i#2 main::i#1 ]

View File

@ -0,0 +1,17 @@
// Concatenates string constants in different ways
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
main: {
.label SCREEN = $400
ldx #0
b1:
lda msg,x
sta SCREEN,x
inx
lda msg,x
cmp #0
bne b1
rts
msg: .text "camelot@"
}

View File

@ -6,14 +6,11 @@ main: {
.label SCREEN = $400
ldx #0
b1:
lda s5,x
lda s,x
sta SCREEN,x
inx
cpx #8
bne b1
rts
s: .text "e"+"l"
s4: .text ""+'t'+'!'
s3: .text "cam"+s+'o'
s5: .text s3+s4
s: .text "camelot@"
}

View File

@ -20,5 +20,5 @@ main: {
bne b1
rts
}
str: .text "bcde@"
nums: .byte 2, 3, 4, 5
str: .text "bc"+"d"+'e'