1
0
mirror of https://gitlab.com/camelot/kickc.git synced 2024-12-22 21:29:50 +00:00

Upgraded to KickAsm 5.14. Fixed PETSCII encoding problem. Closes #401

This commit is contained in:
jespergravgaard 2020-04-13 10:33:44 +02:00
parent cf4d25b5f6
commit ab10f2184d
28 changed files with 381 additions and 196 deletions

View File

@ -1,13 +1,13 @@
<component name="libraryTable"> <component name="libraryTable">
<library name="Maven: cml.kickass:kickassembler:5.13"> <library name="Maven: cml.kickass:kickassembler:5.14">
<CLASSES> <CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/cml/kickass/kickassembler/5.13/kickassembler-5.13.jar!/" /> <root url="jar://$MAVEN_REPOSITORY$/cml/kickass/kickassembler/5.14/kickassembler-5.14.jar!/" />
</CLASSES> </CLASSES>
<JAVADOC> <JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/cml/kickass/kickassembler/5.13/kickassembler-5.13-javadoc.jar!/" /> <root url="jar://$MAVEN_REPOSITORY$/cml/kickass/kickassembler/5.14/kickassembler-5.14-javadoc.jar!/" />
</JAVADOC> </JAVADOC>
<SOURCES> <SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/cml/kickass/kickassembler/5.13/kickassembler-5.13-sources.jar!/" /> <root url="jar://$MAVEN_REPOSITORY$/cml/kickass/kickassembler/5.14/kickassembler-5.14-sources.jar!/" />
</SOURCES> </SOURCES>
</library> </library>
</component> </component>

View File

@ -22,7 +22,7 @@
<orderEntry type="library" name="Maven: org.antlr:antlr4-runtime:4.7.1" level="project" /> <orderEntry type="library" name="Maven: org.antlr:antlr4-runtime:4.7.1" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: junit:junit:4.12" level="project" /> <orderEntry type="library" scope="TEST" name="Maven: junit:junit:4.12" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.hamcrest:hamcrest-core:1.3" level="project" /> <orderEntry type="library" scope="TEST" name="Maven: org.hamcrest:hamcrest-core:1.3" level="project" />
<orderEntry type="library" name="Maven: cml.kickass:kickassembler:5.13" level="project" /> <orderEntry type="library" name="Maven: cml.kickass:kickassembler:5.14" level="project" />
<orderEntry type="library" name="Maven: info.picocli:picocli:3.6.0" level="project" /> <orderEntry type="library" name="Maven: info.picocli:picocli:3.6.0" level="project" />
</component> </component>
</module> </module>

View File

@ -44,7 +44,7 @@
<dependency> <dependency>
<groupId>cml.kickass</groupId> <groupId>cml.kickass</groupId>
<artifactId>kickassembler</artifactId> <artifactId>kickassembler</artifactId>
<version>5.13</version> <version>5.14</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>info.picocli</groupId> <groupId>info.picocli</groupId>

View File

@ -0,0 +1,4 @@
#NOTE: This is a Maven Resolver internal implementation file, its format can be changed without prior notice.
#Mon Apr 13 09:14:19 CEST 2020
kickassembler-5.14.jar>=
kickassembler-5.14.pom>=

View File

@ -0,0 +1 @@
028e2a8db4a5dc8234a977356ad36bbb

View File

@ -0,0 +1 @@
ced8f6f0a44cc03345cf3094887635b6fd0baeb8

View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>cml.kickass</groupId>
<artifactId>kickassembler</artifactId>
<version>5.14</version>
<description>POM was created from install:install-file</description>
</project>

View File

@ -0,0 +1 @@
96c8375a48889a6e4dcd784baf5ed419

View File

@ -0,0 +1 @@
afd7d9dad7f1730f5c5b76fe2a5def866af06ab7

View File

@ -3,10 +3,10 @@
<groupId>cml.kickass</groupId> <groupId>cml.kickass</groupId>
<artifactId>kickassembler</artifactId> <artifactId>kickassembler</artifactId>
<versioning> <versioning>
<release>5.13</release> <release>5.14</release>
<versions> <versions>
<version>5.13</version> <version>5.14</version>
</versions> </versions>
<lastUpdated>20200412054708</lastUpdated> <lastUpdated>20200413071419</lastUpdated>
</versioning> </versioning>
</metadata> </metadata>

View File

@ -1 +1 @@
5e4e6add8965d6e2023c3831d6abc8f0 445929e8493b0af34c41e228496dcf1f

View File

@ -1 +1 @@
07cecbcfd2a194279e0d9bacabdf255ffdc91213 7a1f4ed0f91c25dba71cd27f0d23e1e3a71fd05e

View File

@ -34,12 +34,8 @@ public class AsmFormat {
return getAsmBool(((ConstantBool) value).getBool()); return getAsmBool(((ConstantBool) value).getBool());
} else if(value instanceof ConstantChar) { } else if(value instanceof ConstantChar) {
ConstantChar constantChar = (ConstantChar) value; ConstantChar constantChar = (ConstantChar) value;
if(!constantChar.getEncoding().hasEncoding(constantChar.getChar()))
return getAsmNumber(constantChar.getInteger());
else {
String escapedChar = constantChar.getCharEscaped(); String escapedChar = constantChar.getCharEscaped();
return "'" + escapedChar + "'"; return "'" + escapedChar + "'";
}
} else if(value instanceof ConstantString) { } else if(value instanceof ConstantString) {
String stringValue = ((ConstantString) value).getValue(); String stringValue = ((ConstantString) value).getValue();
String escapedString = ((ConstantString) value).getStringEscaped(); String escapedString = ((ConstantString) value).getStringEscaped();

View File

@ -36,11 +36,12 @@ public class ConstantChar implements ConstantEnumerable<Character> {
/** /**
* Get the integer value of the character * Get the integer value of the character
*
* @return The integer value (taking encoding into account) * @return The integer value (taking encoding into account)
*/ */
@Override @Override
public Long getInteger() { public Long getInteger() {
return encoding.encodedFromChar(value); return (long) encoding.encodedFromChar(value);
} }
public StringEncoding getEncoding() { public StringEncoding getEncoding() {
@ -49,10 +50,11 @@ public class ConstantChar implements ConstantEnumerable<Character> {
/** /**
* Get the char where any special character has been properly escaped (eg '\n' for a newline). * Get the char where any special character has been properly escaped (eg '\n' for a newline).
*
* @return The character with escapes if needed. * @return The character with escapes if needed.
*/ */
public String getCharEscaped() { public String getCharEscaped() {
return encoding.asciiToEscape(value, true); return encoding.asciiToEscapedEncoded(value, true);
} }
@Override @Override

View File

@ -50,7 +50,7 @@ public class ConstantString implements ConstantLiteral<String> {
* @return The escaped string. * @return The escaped string.
*/ */
public String getStringEscaped() { public String getStringEscaped() {
return encoding.asciiToEscape(value); return encoding.asciiToEscapedEncoded(value);
} }
public boolean isZeroTerminated() { public boolean isZeroTerminated() {

View File

@ -9,8 +9,8 @@ import java.util.PrimitiveIterator;
/** String encoding. */ /** String encoding. */
public enum StringEncoding { public enum StringEncoding {
PETSCII_MIXED("petscii_mixed", "pm", CharToPetsciiConverter.charToScreenCode_mixed), PETSCII_MIXED("petscii_mixed", "pm", CharToPetsciiConverter.charToPetscii_mixed),
PETSCII_UPPER("petscii_upper", "pu", CharToPetsciiConverter.charToScreenCode_upper), PETSCII_UPPER("petscii_upper", "pu", CharToPetsciiConverter.charToPetscii_mixed),
SCREENCODE_MIXED("screencode_mixed", "sm", CharToPetsciiConverter.charToScreenCode_mixed), SCREENCODE_MIXED("screencode_mixed", "sm", CharToPetsciiConverter.charToScreenCode_mixed),
SCREENCODE_UPPER("screencode_upper", "su", CharToPetsciiConverter.charToScreenCode_upper); SCREENCODE_UPPER("screencode_upper", "su", CharToPetsciiConverter.charToScreenCode_upper);
@ -78,17 +78,18 @@ public enum StringEncoding {
* @param aChar The character in UNICODE/ASCII * @param aChar The character in UNICODE/ASCII
* @return The integer value of the character within the encoding * @return The integer value of the character within the encoding
*/ */
public Long encodedFromChar(Character aChar) { public Byte encodedFromChar(Character aChar) {
Byte encodedValue = mapping.get(aChar); Byte encodedValue = mapping.get(aChar);
if(encodedValue != null) if(encodedValue != null)
return encodedValue.longValue(); return encodedValue;
else else
// Char is not in encoding - it must be made up! // Char is not in encoding - it must be made up!
return (long) aChar - CHAR_SPECIAL_VAL; return (byte) (aChar - CHAR_SPECIAL_VAL);
} }
/** /**
* Determine if a character has en encoding within the specific encoding * Determine if a character has en encoding within the specific encoding
*
* @param aChar The char to examine * @param aChar The char to examine
* @return true if the char has a proper encoding. False if it does not. * @return true if the char has a proper encoding. False if it does not.
*/ */
@ -161,10 +162,8 @@ public enum StringEncoding {
String hexNum = ""; String hexNum = "";
hexNum += (char) escapedCharsIterator.nextInt(); hexNum += (char) escapedCharsIterator.nextInt();
hexNum += (char) escapedCharsIterator.nextInt(); hexNum += (char) escapedCharsIterator.nextInt();
final int hexChar = Integer.parseInt(hexNum, 16); final byte hexEncoding = (byte) Integer.parseInt(hexNum, 16);
final Character aChar = charFromEncoded((byte) hexChar); final Character aChar = charFromEncoded(hexEncoding);
if(aChar == null)
throw new CompileError("No character 0x" + hexNum + " in encoding " + name);
return aChar; return aChar;
default: default:
throw new CompileError("Illegal string escape sequence \\" + escapeChar); throw new CompileError("Illegal string escape sequence \\" + escapeChar);
@ -172,13 +171,13 @@ public enum StringEncoding {
} }
/** /**
* Converts a char to an escape sequence if needed. If not needed the char itself is returned. * Converts a char to an encoded escape sequence if needed. If not needed the char itself is returned.
* *
* @param aChar The char * @param aChar The char
* @param escapeSingleQuotes Should single quotes ' be escaped. (true when encoding chars, false when encoding chars) * @param escapeSingleQuotes Should single quotes ' be escaped. (true when encoding chars, false when encoding chars)
* @return The char itself - or the appropriate escape sequence * @return The char itself - or the appropriate escape sequence if needed.
*/ */
public String asciiToEscape(char aChar, boolean escapeSingleQuotes) { public String asciiToEscapedEncoded(char aChar, boolean escapeSingleQuotes) {
switch(aChar) { switch(aChar) {
case '\n': case '\n':
return "\\n"; return "\\n";
@ -196,9 +195,10 @@ public enum StringEncoding {
case '\\': case '\\':
return "\\\\"; return "\\\\";
} }
if(aChar >= CHAR_SPECIAL_MIN && aChar <= CHAR_SPECIAL_MAX) { if(aChar > 127) {
final byte charValue = (byte) (aChar - CHAR_SPECIAL_VAL); // Encode all large chars - including SPECIAL's
return String.format("\\$%x", charValue); final byte encoded = encodedFromChar(aChar);
return String.format("\\$%x", encoded);
} else } else
return Character.toString(aChar); return Character.toString(aChar);
} }
@ -209,9 +209,9 @@ public enum StringEncoding {
* @param string The string * @param string The string
* @return The escaped string. * @return The escaped string.
*/ */
public String asciiToEscape(String string) { public String asciiToEscapedEncoded(String string) {
StringBuilder escaped = new StringBuilder(); StringBuilder escaped = new StringBuilder();
string.chars().forEach(value -> escaped.append(asciiToEscape((char) value, false))); string.chars().forEach(value -> escaped.append(asciiToEscapedEncoded((char) value, false)));
return escaped.toString(); return escaped.toString();
} }

View File

@ -1,2 +1,2 @@
#!/usr/bin/env bash #!/usr/bin/env bash
mvn install:install-file -Dmaven.repo.local=./repo/ -Dfile=/Applications/KickAssembler/KickAss.jar -DgroupId=cml.kickass -DartifactId=kickassembler -Dpackaging=jar -DgeneratePom=true -DcreateChecksum=true -Dversion=5.13 mvn install:install-file -Dmaven.repo.local=./repo/ -Dfile=/Applications/KickAssembler/KickAss.jar -DgroupId=cml.kickass -DartifactId=kickassembler -Dpackaging=jar -DgeneratePom=true -DcreateChecksum=true -Dversion=5.14

View File

@ -2,16 +2,15 @@
// Uses \xnn to add chars by hex-code // Uses \xnn to add chars by hex-code
#pragma encoding(petscii_mixed) #pragma encoding(petscii_mixed)
char MSG1[] = "c\x41m\x45lot"; char MSG1[] = "c\xc1mElot";
#pragma encoding(screencode_upper) #pragma encoding(screencode_upper)
char MSG2[] = "C\x01M\x05LOT"; char MSG2[] = "C\x01M\x05LOT";
char CH = '\x10'; char CH = '\xde';
char* SCREEN1 = 0x0400; char* SCREEN1 = 0x0400;
char* SCREEN2 = 0x0428; char* SCREEN2 = 0x0428;
char* SCREEN3 = 0x0428;
void main() { void main() {
// Show mixed chars on screen // Show mixed chars on screen
@ -19,11 +18,20 @@ void main() {
char i=0; char i=0;
while(MSG1[i]) { while(MSG1[i]) {
SCREEN1[i] = MSG1[i]; chrout(MSG1[i]);
SCREEN2[i] = MSG2[i]; SCREEN1[i] = MSG2[i];
i++; i++;
} }
SCREEN3[0] = CH; SCREEN2[0] = CH;
} }
void chrout(char petscii) {
char* mem = 0xff;
*mem = petscii;
asm {
lda mem
jsr $ffd2
}
}

View File

@ -1,8 +1,8 @@
// Test using some simple supported string escape // Test using some simple supported string escape
// Uses \xnn to add chars by hex-code that do not exist with the encoding. // Uses \xnn to add chars by hex-code that do not exist with the encoding.
#pragma encoding(petscii_mixed) #pragma encoding(screencode_mixed)
char MESSAGE[] = "qwe\xffasd\xferty"; char MESSAGE[] = "q\xffw\x60e\xddr";
char CH = '\xff'; char CH = '\xff';

View File

@ -4,37 +4,51 @@
:BasicUpstart(main) :BasicUpstart(main)
.pc = $80d "Program" .pc = $80d "Program"
.encoding "screencode_upper" .encoding "screencode_upper"
.const CH = 'P' .const CH = '\$de'
.label SCREEN1 = $400 .label SCREEN1 = $400
.label SCREEN2 = $428 .label SCREEN2 = $428
.label SCREEN3 = $428
main: { main: {
.label i = 2
// *((char*)0xd018) = 0x17 // *((char*)0xd018) = 0x17
// Show mixed chars on screen // Show mixed chars on screen
lda #$17 lda #$17
sta $d018 sta $d018
ldx #0 lda #0
sta.z i
__b1: __b1:
// while(MSG1[i]) // while(MSG1[i])
lda MSG1,x lda #0
cmp #0 ldy.z i
cmp MSG1,y
bne __b2 bne __b2
// SCREEN3[0] = CH // SCREEN2[0] = CH
lda #CH lda #CH
sta SCREEN3 sta SCREEN2
// } // }
rts rts
__b2: __b2:
// SCREEN1[i] = MSG1[i] // chrout(MSG1[i])
lda MSG1,x ldy.z i
sta SCREEN1,x lda MSG1,y
// SCREEN2[i] = MSG2[i] jsr chrout
lda MSG2,x // SCREEN1[i] = MSG2[i]
sta SCREEN2,x ldy.z i
lda MSG2,y
sta SCREEN1,y
// i++; // i++;
inx inc.z i
jmp __b1 jmp __b1
} }
// chrout(byte register(A) petscii)
chrout: {
.label mem = $ff
// *mem = petscii
sta mem
// asm
jsr $ffd2
// }
rts
}
.encoding "petscii_mixed" .encoding "petscii_mixed"
MSG1: .text "cAmElot" MSG1: .text "cAmElot"
.byte 0 .byte 0

View File

@ -12,18 +12,30 @@
main: scope:[main] from @1 main: scope:[main] from @1
[4] *((byte*) 53272) ← (byte) $17 [4] *((byte*) 53272) ← (byte) $17
to:main::@1 to:main::@1
main::@1: scope:[main] from main main::@2 main::@1: scope:[main] from main main::@4
[5] (byte) main::i#2 ← phi( main/(byte) 0 main::@2/(byte) main::i#1 ) [5] (byte) main::i#2 ← phi( main/(byte) 0 main::@4/(byte) main::i#1 )
[6] if((byte) 0!=*((const byte*) MSG1 + (byte) main::i#2)) goto main::@2 [6] if((byte) 0!=*((const byte*) MSG1 + (byte) main::i#2)) goto main::@2
to:main::@3 to:main::@3
main::@3: scope:[main] from main::@1 main::@3: scope:[main] from main::@1
[7] *((const byte*) SCREEN3) ← (const byte) CH [7] *((const byte*) SCREEN2) ← (const byte) CH
to:main::@return to:main::@return
main::@return: scope:[main] from main::@3 main::@return: scope:[main] from main::@3
[8] return [8] return
to:@return to:@return
main::@2: scope:[main] from main::@1 main::@2: scope:[main] from main::@1
[9] *((const byte*) SCREEN1 + (byte) main::i#2) ← *((const byte*) MSG1 + (byte) main::i#2) [9] (byte) chrout::petscii#0 ← *((const byte*) MSG1 + (byte) main::i#2)
[10] *((const byte*) SCREEN2 + (byte) main::i#2) ← *((const byte*) MSG2 + (byte) main::i#2) [10] call chrout
[11] (byte) main::i#1 ← ++ (byte) main::i#2 to:main::@4
main::@4: scope:[main] from main::@2
[11] *((const byte*) SCREEN1 + (byte) main::i#2) ← *((const byte*) MSG2 + (byte) main::i#2)
[12] (byte) main::i#1 ← ++ (byte) main::i#2
to:main::@1 to:main::@1
(void()) chrout((byte) chrout::petscii)
chrout: scope:[chrout] from main::@2
[13] *((const byte*) chrout::mem) ← (byte) chrout::petscii#0
asm { ldamem jsr$ffd2 }
to:chrout::@return
chrout::@return: scope:[chrout] from chrout
[15] return
to:@return

View File

@ -2,76 +2,98 @@ Warning! Adding boolean cast to non-boolean condition *((const byte*) MSG1 + (by
Identified constant variable (byte) CH Identified constant variable (byte) CH
Identified constant variable (byte*) SCREEN1 Identified constant variable (byte*) SCREEN1
Identified constant variable (byte*) SCREEN2 Identified constant variable (byte*) SCREEN2
Identified constant variable (byte*) SCREEN3 Identified constant variable (byte*) chrout::mem
Culled Empty Block (label) main::@4 Culled Empty Block (label) main::@4
Culled Empty Block (label) main::@5 Culled Empty Block (label) main::@5
Culled Empty Block (label) main::@6 Culled Empty Block (label) main::@6
Culled Empty Block (label) @1
CONTROL FLOW GRAPH SSA CONTROL FLOW GRAPH SSA
@begin: scope:[] from @begin: scope:[] from
to:@1 to:@2
(void()) main() (void()) main()
main: scope:[main] from @1 main: scope:[main] from @2
*((byte*)(number) $d018) ← (number) $17 *((byte*)(number) $d018) ← (number) $17
(byte) main::i#0 ← (byte) 0 (byte) main::i#0 ← (byte) 0
to:main::@1 to:main::@1
main::@1: scope:[main] from main main::@2 main::@1: scope:[main] from main main::@7
(byte) main::i#2 ← phi( main/(byte) main::i#0 main::@2/(byte) main::i#1 ) (byte) main::i#2 ← phi( main/(byte) main::i#0 main::@7/(byte) main::i#1 )
(bool~) main::$0 ← (number) 0 != *((const byte*) MSG1 + (byte) main::i#2) (bool~) main::$1 ← (number) 0 != *((const byte*) MSG1 + (byte) main::i#2)
if((bool~) main::$0) goto main::@2 if((bool~) main::$1) goto main::@2
to:main::@3 to:main::@3
main::@2: scope:[main] from main::@1 main::@2: scope:[main] from main::@1
(byte) main::i#3 ← phi( main::@1/(byte) main::i#2 ) (byte) main::i#3 ← phi( main::@1/(byte) main::i#2 )
*((const byte*) SCREEN1 + (byte) main::i#3) ← *((const byte*) MSG1 + (byte) main::i#3) (byte) chrout::petscii#0 ← *((const byte*) MSG1 + (byte) main::i#3)
*((const byte*) SCREEN2 + (byte) main::i#3) ← *((const byte*) MSG2 + (byte) main::i#3) call chrout
(byte) main::i#1 ← ++ (byte) main::i#3 to:main::@7
main::@7: scope:[main] from main::@2
(byte) main::i#4 ← phi( main::@2/(byte) main::i#3 )
*((const byte*) SCREEN1 + (byte) main::i#4) ← *((const byte*) MSG2 + (byte) main::i#4)
(byte) main::i#1 ← ++ (byte) main::i#4
to:main::@1 to:main::@1
main::@3: scope:[main] from main::@1 main::@3: scope:[main] from main::@1
*((const byte*) SCREEN3 + (number) 0) ← (const byte) CH *((const byte*) SCREEN2 + (number) 0) ← (const byte) CH
to:main::@return to:main::@return
main::@return: scope:[main] from main::@3 main::@return: scope:[main] from main::@3
return return
to:@return to:@return
@1: scope:[] from @begin
(void()) chrout((byte) chrout::petscii)
chrout: scope:[chrout] from main::@2
(byte) chrout::petscii#1 ← phi( main::@2/(byte) chrout::petscii#0 )
*((const byte*) chrout::mem) ← (byte) chrout::petscii#1
asm { ldamem jsr$ffd2 }
to:chrout::@return
chrout::@return: scope:[chrout] from chrout
return
to:@return
@2: scope:[] from @begin
call main call main
to:@2 to:@3
@2: scope:[] from @1 @3: scope:[] from @2
to:@end to:@end
@end: scope:[] from @2 @end: scope:[] from @3
SYMBOL TABLE SSA SYMBOL TABLE SSA
(label) @1
(label) @2 (label) @2
(label) @3
(label) @begin (label) @begin
(label) @end (label) @end
(const byte) CH = (byte) 'P'su (const byte) CH = (byte) ''su
(const byte*) MSG1[] = (byte*) "cAmElot"pm (const byte*) MSG1[] = (byte*) "cAmElot"pm
(const byte*) MSG2[] = (byte*) "CAMELOT"su (const byte*) MSG2[] = (byte*) "CAMELOT"su
(const byte*) SCREEN1 = (byte*)(number) $400 (const byte*) SCREEN1 = (byte*)(number) $400
(const byte*) SCREEN2 = (byte*)(number) $428 (const byte*) SCREEN2 = (byte*)(number) $428
(const byte*) SCREEN3 = (byte*)(number) $428 (void()) chrout((byte) chrout::petscii)
(label) chrout::@return
(const byte*) chrout::mem = (byte*)(number) $ff
(byte) chrout::petscii
(byte) chrout::petscii#0
(byte) chrout::petscii#1
(void()) main() (void()) main()
(bool~) main::$0 (bool~) main::$1
(label) main::@1 (label) main::@1
(label) main::@2 (label) main::@2
(label) main::@3 (label) main::@3
(label) main::@7
(label) main::@return (label) main::@return
(byte) main::i (byte) main::i
(byte) main::i#0 (byte) main::i#0
(byte) main::i#1 (byte) main::i#1
(byte) main::i#2 (byte) main::i#2
(byte) main::i#3 (byte) main::i#3
(byte) main::i#4
Adding number conversion cast (unumber) $17 in *((byte*)(number) $d018) ← (number) $17 Adding number conversion cast (unumber) $17 in *((byte*)(number) $d018) ← (number) $17
Adding number conversion cast (unumber) 0 in (bool~) main::$0 ← (number) 0 != *((const byte*) MSG1 + (byte) main::i#2) Adding number conversion cast (unumber) 0 in (bool~) main::$1 ← (number) 0 != *((const byte*) MSG1 + (byte) main::i#2)
Adding number conversion cast (unumber) 0 in *((const byte*) SCREEN3 + (number) 0) ← (const byte) CH Adding number conversion cast (unumber) 0 in *((const byte*) SCREEN2 + (number) 0) ← (const byte) CH
Successful SSA optimization PassNAddNumberTypeConversions Successful SSA optimization PassNAddNumberTypeConversions
Inlining cast *((byte*)(number) $d018) ← (unumber)(number) $17 Inlining cast *((byte*)(number) $d018) ← (unumber)(number) $17
Successful SSA optimization Pass2InlineCast Successful SSA optimization Pass2InlineCast
Simplifying constant pointer cast (byte*) 255
Simplifying constant pointer cast (byte*) 1024 Simplifying constant pointer cast (byte*) 1024
Simplifying constant pointer cast (byte*) 1064 Simplifying constant pointer cast (byte*) 1064
Simplifying constant pointer cast (byte*) 1064
Simplifying constant integer cast $17 Simplifying constant integer cast $17
Simplifying constant pointer cast (byte*) 53272 Simplifying constant pointer cast (byte*) 53272
Simplifying constant integer cast 0 Simplifying constant integer cast 0
@ -81,28 +103,33 @@ Finalized unsigned number type (byte) $17
Finalized unsigned number type (byte) 0 Finalized unsigned number type (byte) 0
Finalized unsigned number type (byte) 0 Finalized unsigned number type (byte) 0
Successful SSA optimization PassNFinalizeNumberTypeConversions Successful SSA optimization PassNFinalizeNumberTypeConversions
Alias main::i#2 = main::i#3 Alias main::i#2 = main::i#3 main::i#4
Successful SSA optimization Pass2AliasElimination Successful SSA optimization Pass2AliasElimination
Simple Condition (bool~) main::$0 [4] if((byte) 0!=*((const byte*) MSG1 + (byte) main::i#2)) goto main::@2 Identical Phi Values (byte) chrout::petscii#1 (byte) chrout::petscii#0
Successful SSA optimization Pass2IdenticalPhiElimination
Simple Condition (bool~) main::$1 [4] if((byte) 0!=*((const byte*) MSG1 + (byte) main::i#2)) goto main::@2
Successful SSA optimization Pass2ConditionalJumpSimplification Successful SSA optimization Pass2ConditionalJumpSimplification
Constant (const byte) main::i#0 = 0 Constant (const byte) main::i#0 = 0
Successful SSA optimization Pass2ConstantIdentification Successful SSA optimization Pass2ConstantIdentification
Simplifying expression containing zero SCREEN3 in [8] *((const byte*) SCREEN3 + (byte) 0) ← (const byte) CH Simplifying expression containing zero SCREEN2 in [9] *((const byte*) SCREEN2 + (byte) 0) ← (const byte) CH
Successful SSA optimization PassNSimplifyExpressionWithZero Successful SSA optimization PassNSimplifyExpressionWithZero
Inlining constant with var siblings (const byte) main::i#0 Inlining constant with var siblings (const byte) main::i#0
Constant inlined main::i#0 = (byte) 0 Constant inlined main::i#0 = (byte) 0
Successful SSA optimization Pass2ConstantInlining Successful SSA optimization Pass2ConstantInlining
Adding NOP phi() at start of @begin 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 @2
Adding NOP phi() at start of @3
Adding NOP phi() at start of @end Adding NOP phi() at start of @end
CALL GRAPH CALL GRAPH
Calls in [] to main:2 Calls in [] to main:2
Calls in [main] to chrout:11
Created 1 initial phi equivalence classes Created 1 initial phi equivalence classes
Coalesced [13] main::i#4 ← main::i#1 Coalesced [14] main::i#5 ← main::i#1
Coalesced down to 1 phi equivalence classes Coalesced down to 1 phi equivalence classes
Culled Empty Block (label) @2 Culled Empty Block (label) @3
Renumbering block @2 to @1
Renumbering block main::@7 to main::@4
Adding NOP phi() at start of @begin Adding NOP phi() at start of @begin
Adding NOP phi() at start of @1 Adding NOP phi() at start of @1
Adding NOP phi() at start of @end Adding NOP phi() at start of @end
@ -122,34 +149,52 @@ FINAL CONTROL FLOW GRAPH
main: scope:[main] from @1 main: scope:[main] from @1
[4] *((byte*) 53272) ← (byte) $17 [4] *((byte*) 53272) ← (byte) $17
to:main::@1 to:main::@1
main::@1: scope:[main] from main main::@2 main::@1: scope:[main] from main main::@4
[5] (byte) main::i#2 ← phi( main/(byte) 0 main::@2/(byte) main::i#1 ) [5] (byte) main::i#2 ← phi( main/(byte) 0 main::@4/(byte) main::i#1 )
[6] if((byte) 0!=*((const byte*) MSG1 + (byte) main::i#2)) goto main::@2 [6] if((byte) 0!=*((const byte*) MSG1 + (byte) main::i#2)) goto main::@2
to:main::@3 to:main::@3
main::@3: scope:[main] from main::@1 main::@3: scope:[main] from main::@1
[7] *((const byte*) SCREEN3) ← (const byte) CH [7] *((const byte*) SCREEN2) ← (const byte) CH
to:main::@return to:main::@return
main::@return: scope:[main] from main::@3 main::@return: scope:[main] from main::@3
[8] return [8] return
to:@return to:@return
main::@2: scope:[main] from main::@1 main::@2: scope:[main] from main::@1
[9] *((const byte*) SCREEN1 + (byte) main::i#2) ← *((const byte*) MSG1 + (byte) main::i#2) [9] (byte) chrout::petscii#0 ← *((const byte*) MSG1 + (byte) main::i#2)
[10] *((const byte*) SCREEN2 + (byte) main::i#2) ← *((const byte*) MSG2 + (byte) main::i#2) [10] call chrout
[11] (byte) main::i#1 ← ++ (byte) main::i#2 to:main::@4
main::@4: scope:[main] from main::@2
[11] *((const byte*) SCREEN1 + (byte) main::i#2) ← *((const byte*) MSG2 + (byte) main::i#2)
[12] (byte) main::i#1 ← ++ (byte) main::i#2
to:main::@1 to:main::@1
(void()) chrout((byte) chrout::petscii)
chrout: scope:[chrout] from main::@2
[13] *((const byte*) chrout::mem) ← (byte) chrout::petscii#0
asm { ldamem jsr$ffd2 }
to:chrout::@return
chrout::@return: scope:[chrout] from chrout
[15] return
to:@return
VARIABLE REGISTER WEIGHTS VARIABLE REGISTER WEIGHTS
(void()) chrout((byte) chrout::petscii)
(byte) chrout::petscii
(byte) chrout::petscii#0 1102.0
(void()) main() (void()) main()
(byte) main::i (byte) main::i
(byte) main::i#1 202.0 (byte) main::i#1 202.0
(byte) main::i#2 176.75 (byte) main::i#2 121.2
Initial phi equivalence classes Initial phi equivalence classes
[ main::i#2 main::i#1 ] [ main::i#2 main::i#1 ]
Added variable chrout::petscii#0 to live range equivalence class [ chrout::petscii#0 ]
Complete equivalence classes Complete equivalence classes
[ main::i#2 main::i#1 ] [ main::i#2 main::i#1 ]
[ chrout::petscii#0 ]
Allocated zp[1]:2 [ main::i#2 main::i#1 ] Allocated zp[1]:2 [ main::i#2 main::i#1 ]
Allocated zp[1]:3 [ chrout::petscii#0 ]
INITIAL ASM INITIAL ASM
Target platform is c64basic / MOS6502X Target platform is c64basic / MOS6502X
@ -162,10 +207,9 @@ Target platform is c64basic / MOS6502X
.pc = $80d "Program" .pc = $80d "Program"
// Global Constants & labels // Global Constants & labels
.encoding "screencode_upper" .encoding "screencode_upper"
.const CH = 'P' .const CH = '\$de'
.label SCREEN1 = $400 .label SCREEN1 = $400
.label SCREEN2 = $428 .label SCREEN2 = $428
.label SCREEN3 = $428
// @begin // @begin
__bbegin: __bbegin:
// [1] phi from @begin to @1 [phi:@begin->@1] // [1] phi from @begin to @1 [phi:@begin->@1]
@ -203,9 +247,9 @@ main: {
jmp __b3 jmp __b3
// main::@3 // main::@3
__b3: __b3:
// [7] *((const byte*) SCREEN3) ← (const byte) CH -- _deref_pbuc1=vbuc2 // [7] *((const byte*) SCREEN2) ← (const byte) CH -- _deref_pbuc1=vbuc2
lda #CH lda #CH
sta SCREEN3 sta SCREEN2
jmp __breturn jmp __breturn
// main::@return // main::@return
__breturn: __breturn:
@ -213,20 +257,42 @@ main: {
rts rts
// main::@2 // main::@2
__b2: __b2:
// [9] *((const byte*) SCREEN1 + (byte) main::i#2) ← *((const byte*) MSG1 + (byte) main::i#2) -- pbuc1_derefidx_vbuz1=pbuc2_derefidx_vbuz1 // [9] (byte) chrout::petscii#0 ← *((const byte*) MSG1 + (byte) main::i#2) -- vbuz1=pbuc1_derefidx_vbuz2
ldy.z i ldy.z i
lda MSG1,y lda MSG1,y
sta SCREEN1,y sta.z chrout.petscii
// [10] *((const byte*) SCREEN2 + (byte) main::i#2) ← *((const byte*) MSG2 + (byte) main::i#2) -- pbuc1_derefidx_vbuz1=pbuc2_derefidx_vbuz1 // [10] call chrout
jsr chrout
jmp __b4
// main::@4
__b4:
// [11] *((const byte*) SCREEN1 + (byte) main::i#2) ← *((const byte*) MSG2 + (byte) main::i#2) -- pbuc1_derefidx_vbuz1=pbuc2_derefidx_vbuz1
ldy.z i ldy.z i
lda MSG2,y lda MSG2,y
sta SCREEN2,y sta SCREEN1,y
// [11] (byte) main::i#1 ← ++ (byte) main::i#2 -- vbuz1=_inc_vbuz1 // [12] (byte) main::i#1 ← ++ (byte) main::i#2 -- vbuz1=_inc_vbuz1
inc.z i inc.z i
// [5] phi from main::@2 to main::@1 [phi:main::@2->main::@1] // [5] phi from main::@4 to main::@1 [phi:main::@4->main::@1]
__b1_from___b2: __b1_from___b4:
// [5] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@2->main::@1#0] -- register_copy // [5] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@4->main::@1#0] -- register_copy
jmp __b1 jmp __b1
}
// chrout
// chrout(byte zp(3) petscii)
chrout: {
.label mem = $ff
.label petscii = 3
// [13] *((const byte*) chrout::mem) ← (byte) chrout::petscii#0 -- _deref_pbuc1=vbuz1
lda.z petscii
sta mem
// asm { ldamem jsr$ffd2 }
lda mem
jsr $ffd2
jmp __breturn
// chrout::@return
__breturn:
// [15] return
rts
} }
// File Data // File Data
.encoding "petscii_mixed" .encoding "petscii_mixed"
@ -240,22 +306,30 @@ REGISTER UPLIFT POTENTIAL REGISTERS
Statement [4] *((byte*) 53272) ← (byte) $17 [ ] ( main:2 [ ] { } ) always clobbers reg byte a Statement [4] *((byte*) 53272) ← (byte) $17 [ ] ( main:2 [ ] { } ) always clobbers reg byte a
Statement [6] if((byte) 0!=*((const byte*) MSG1 + (byte) main::i#2)) goto main::@2 [ main::i#2 ] ( main:2 [ main::i#2 ] { } ) always clobbers reg byte a Statement [6] if((byte) 0!=*((const byte*) MSG1 + (byte) main::i#2)) goto main::@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 ] Removing always clobbered register reg byte a as potential for zp[1]:2 [ main::i#2 main::i#1 ]
Statement [7] *((const byte*) SCREEN3) ← (const byte) CH [ ] ( main:2 [ ] { } ) always clobbers reg byte a Statement [7] *((const byte*) SCREEN2) ← (const byte) CH [ ] ( main:2 [ ] { } ) always clobbers reg byte a
Statement [9] *((const byte*) SCREEN1 + (byte) main::i#2) ← *((const byte*) MSG1 + (byte) main::i#2) [ main::i#2 ] ( main:2 [ main::i#2 ] { } ) always clobbers reg byte a Statement [11] *((const byte*) SCREEN1 + (byte) main::i#2) ← *((const byte*) MSG2 + (byte) main::i#2) [ main::i#2 ] ( main:2 [ main::i#2 ] { } ) always clobbers reg byte a
Statement [10] *((const byte*) SCREEN2 + (byte) main::i#2) ← *((const byte*) MSG2 + (byte) main::i#2) [ main::i#2 ] ( main:2 [ main::i#2 ] { } ) always clobbers reg byte a Statement asm { ldamem jsr$ffd2 } always clobbers reg byte a reg byte x reg byte y
Removing always clobbered register reg byte x as potential for zp[1]:2 [ main::i#2 main::i#1 ]
Removing always clobbered register reg byte y as potential for zp[1]:2 [ main::i#2 main::i#1 ]
Statement [4] *((byte*) 53272) ← (byte) $17 [ ] ( main:2 [ ] { } ) always clobbers reg byte a Statement [4] *((byte*) 53272) ← (byte) $17 [ ] ( main:2 [ ] { } ) always clobbers reg byte a
Statement [6] if((byte) 0!=*((const byte*) MSG1 + (byte) main::i#2)) goto main::@2 [ main::i#2 ] ( main:2 [ main::i#2 ] { } ) always clobbers reg byte a Statement [6] if((byte) 0!=*((const byte*) MSG1 + (byte) main::i#2)) goto main::@2 [ main::i#2 ] ( main:2 [ main::i#2 ] { } ) always clobbers reg byte a reg byte y
Statement [7] *((const byte*) SCREEN3) ← (const byte) CH [ ] ( main:2 [ ] { } ) always clobbers reg byte a Statement [7] *((const byte*) SCREEN2) ← (const byte) CH [ ] ( main:2 [ ] { } ) always clobbers reg byte a
Statement [9] *((const byte*) SCREEN1 + (byte) main::i#2) ← *((const byte*) MSG1 + (byte) main::i#2) [ main::i#2 ] ( main:2 [ main::i#2 ] { } ) always clobbers reg byte a Statement [9] (byte) chrout::petscii#0 ← *((const byte*) MSG1 + (byte) main::i#2) [ main::i#2 chrout::petscii#0 ] ( main:2 [ main::i#2 chrout::petscii#0 ] { } ) always clobbers reg byte y
Statement [10] *((const byte*) SCREEN2 + (byte) main::i#2) ← *((const byte*) MSG2 + (byte) main::i#2) [ main::i#2 ] ( main:2 [ main::i#2 ] { } ) always clobbers reg byte a Statement [11] *((const byte*) SCREEN1 + (byte) main::i#2) ← *((const byte*) MSG2 + (byte) main::i#2) [ main::i#2 ] ( main:2 [ main::i#2 ] { } ) always clobbers reg byte a reg byte y
Potential registers zp[1]:2 [ main::i#2 main::i#1 ] : zp[1]:2 , reg byte x , reg byte y , Statement asm { ldamem jsr$ffd2 } always clobbers reg byte a reg byte x reg byte y
Potential registers zp[1]:2 [ main::i#2 main::i#1 ] : zp[1]:2 ,
Potential registers zp[1]:3 [ chrout::petscii#0 ] : zp[1]:3 , reg byte a , reg byte x , reg byte y ,
REGISTER UPLIFT SCOPES REGISTER UPLIFT SCOPES
Uplift Scope [main] 378.75: zp[1]:2 [ main::i#2 main::i#1 ] Uplift Scope [chrout] 1,102: zp[1]:3 [ chrout::petscii#0 ]
Uplift Scope [main] 323.2: zp[1]:2 [ main::i#2 main::i#1 ]
Uplift Scope [] Uplift Scope []
Uplifting [main] best 443 combination reg byte x [ main::i#2 main::i#1 ] Uplifting [chrout] best 656 combination reg byte a [ chrout::petscii#0 ]
Uplifting [] best 443 combination Uplifting [main] best 656 combination zp[1]:2 [ main::i#2 main::i#1 ]
Uplifting [] best 656 combination
Attempting to uplift remaining variables inzp[1]:2 [ main::i#2 main::i#1 ]
Uplifting [main] best 656 combination zp[1]:2 [ main::i#2 main::i#1 ]
ASSEMBLER BEFORE OPTIMIZATION ASSEMBLER BEFORE OPTIMIZATION
// File Comments // File Comments
@ -267,10 +341,9 @@ ASSEMBLER BEFORE OPTIMIZATION
.pc = $80d "Program" .pc = $80d "Program"
// Global Constants & labels // Global Constants & labels
.encoding "screencode_upper" .encoding "screencode_upper"
.const CH = 'P' .const CH = '\$de'
.label SCREEN1 = $400 .label SCREEN1 = $400
.label SCREEN2 = $428 .label SCREEN2 = $428
.label SCREEN3 = $428
// @begin // @begin
__bbegin: __bbegin:
// [1] phi from @begin to @1 [phi:@begin->@1] // [1] phi from @begin to @1 [phi:@begin->@1]
@ -287,27 +360,30 @@ __bend_from___b1:
__bend: __bend:
// main // main
main: { main: {
.label i = 2
// [4] *((byte*) 53272) ← (byte) $17 -- _deref_pbuc1=vbuc2 // [4] *((byte*) 53272) ← (byte) $17 -- _deref_pbuc1=vbuc2
// Show mixed chars on screen // Show mixed chars on screen
lda #$17 lda #$17
sta $d018 sta $d018
// [5] phi from main to main::@1 [phi:main->main::@1] // [5] phi from main to main::@1 [phi:main->main::@1]
__b1_from_main: __b1_from_main:
// [5] phi (byte) main::i#2 = (byte) 0 [phi:main->main::@1#0] -- vbuxx=vbuc1 // [5] phi (byte) main::i#2 = (byte) 0 [phi:main->main::@1#0] -- vbuz1=vbuc1
ldx #0 lda #0
sta.z i
jmp __b1 jmp __b1
// main::@1 // main::@1
__b1: __b1:
// [6] if((byte) 0!=*((const byte*) MSG1 + (byte) main::i#2)) goto main::@2 -- vbuc1_neq_pbuc2_derefidx_vbuxx_then_la1 // [6] if((byte) 0!=*((const byte*) MSG1 + (byte) main::i#2)) goto main::@2 -- vbuc1_neq_pbuc2_derefidx_vbuz1_then_la1
lda MSG1,x lda #0
cmp #0 ldy.z i
cmp MSG1,y
bne __b2 bne __b2
jmp __b3 jmp __b3
// main::@3 // main::@3
__b3: __b3:
// [7] *((const byte*) SCREEN3) ← (const byte) CH -- _deref_pbuc1=vbuc2 // [7] *((const byte*) SCREEN2) ← (const byte) CH -- _deref_pbuc1=vbuc2
lda #CH lda #CH
sta SCREEN3 sta SCREEN2
jmp __breturn jmp __breturn
// main::@return // main::@return
__breturn: __breturn:
@ -315,18 +391,39 @@ main: {
rts rts
// main::@2 // main::@2
__b2: __b2:
// [9] *((const byte*) SCREEN1 + (byte) main::i#2) ← *((const byte*) MSG1 + (byte) main::i#2) -- pbuc1_derefidx_vbuxx=pbuc2_derefidx_vbuxx // [9] (byte) chrout::petscii#0 ← *((const byte*) MSG1 + (byte) main::i#2) -- vbuaa=pbuc1_derefidx_vbuz1
lda MSG1,x ldy.z i
sta SCREEN1,x lda MSG1,y
// [10] *((const byte*) SCREEN2 + (byte) main::i#2) ← *((const byte*) MSG2 + (byte) main::i#2) -- pbuc1_derefidx_vbuxx=pbuc2_derefidx_vbuxx // [10] call chrout
lda MSG2,x jsr chrout
sta SCREEN2,x jmp __b4
// [11] (byte) main::i#1 ← ++ (byte) main::i#2 -- vbuxx=_inc_vbuxx // main::@4
inx __b4:
// [5] phi from main::@2 to main::@1 [phi:main::@2->main::@1] // [11] *((const byte*) SCREEN1 + (byte) main::i#2) ← *((const byte*) MSG2 + (byte) main::i#2) -- pbuc1_derefidx_vbuz1=pbuc2_derefidx_vbuz1
__b1_from___b2: ldy.z i
// [5] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@2->main::@1#0] -- register_copy lda MSG2,y
sta SCREEN1,y
// [12] (byte) main::i#1 ← ++ (byte) main::i#2 -- vbuz1=_inc_vbuz1
inc.z i
// [5] phi from main::@4 to main::@1 [phi:main::@4->main::@1]
__b1_from___b4:
// [5] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@4->main::@1#0] -- register_copy
jmp __b1 jmp __b1
}
// chrout
// chrout(byte register(A) petscii)
chrout: {
.label mem = $ff
// [13] *((const byte*) chrout::mem) ← (byte) chrout::petscii#0 -- _deref_pbuc1=vbuaa
sta mem
// asm { ldamem jsr$ffd2 }
lda mem
jsr $ffd2
jmp __breturn
// chrout::@return
__breturn:
// [15] return
rts
} }
// File Data // File Data
.encoding "petscii_mixed" .encoding "petscii_mixed"
@ -342,7 +439,11 @@ Removing instruction jmp __bend
Removing instruction jmp __b1 Removing instruction jmp __b1
Removing instruction jmp __b3 Removing instruction jmp __b3
Removing instruction jmp __breturn Removing instruction jmp __breturn
Removing instruction jmp __b4
Removing instruction jmp __breturn
Succesful ASM optimization Pass5NextJumpElimination Succesful ASM optimization Pass5NextJumpElimination
Removing instruction lda mem
Succesful ASM optimization Pass5UnnecesaryLoadElimination
Removing instruction __b1_from___bbegin: Removing instruction __b1_from___bbegin:
Removing instruction __b1: Removing instruction __b1:
Removing instruction __bend_from___b1: Removing instruction __bend_from___b1:
@ -351,7 +452,9 @@ Removing instruction __bend:
Removing instruction __b1_from_main: Removing instruction __b1_from_main:
Removing instruction __b3: Removing instruction __b3:
Removing instruction __breturn: Removing instruction __breturn:
Removing instruction __b1_from___b2: Removing instruction __b4:
Removing instruction __b1_from___b4:
Removing instruction __breturn:
Succesful ASM optimization Pass5UnusedLabelElimination Succesful ASM optimization Pass5UnusedLabelElimination
Updating BasicUpstart to call main directly Updating BasicUpstart to call main directly
Removing instruction jsr main Removing instruction jsr main
@ -363,26 +466,32 @@ FINAL SYMBOL TABLE
(label) @1 (label) @1
(label) @begin (label) @begin
(label) @end (label) @end
(const byte) CH = (byte) 'P'su (const byte) CH = (byte) ''su
(const byte*) MSG1[] = (byte*) "cAmElot"pm (const byte*) MSG1[] = (byte*) "cAmElot"pm
(const byte*) MSG2[] = (byte*) "CAMELOT"su (const byte*) MSG2[] = (byte*) "CAMELOT"su
(const byte*) SCREEN1 = (byte*) 1024 (const byte*) SCREEN1 = (byte*) 1024
(const byte*) SCREEN2 = (byte*) 1064 (const byte*) SCREEN2 = (byte*) 1064
(const byte*) SCREEN3 = (byte*) 1064 (void()) chrout((byte) chrout::petscii)
(label) chrout::@return
(const byte*) chrout::mem = (byte*) 255
(byte) chrout::petscii
(byte) chrout::petscii#0 reg byte a 1102.0
(void()) main() (void()) main()
(label) main::@1 (label) main::@1
(label) main::@2 (label) main::@2
(label) main::@3 (label) main::@3
(label) main::@4
(label) main::@return (label) main::@return
(byte) main::i (byte) main::i
(byte) main::i#1 reg byte x 202.0 (byte) main::i#1 i zp[1]:2 202.0
(byte) main::i#2 reg byte x 176.75 (byte) main::i#2 i zp[1]:2 121.2
reg byte x [ main::i#2 main::i#1 ] zp[1]:2 [ main::i#2 main::i#1 ]
reg byte a [ chrout::petscii#0 ]
FINAL ASSEMBLER FINAL ASSEMBLER
Score: 368 Score: 544
// File Comments // File Comments
// Test using some simple supported string escape // Test using some simple supported string escape
@ -393,10 +502,9 @@ Score: 368
.pc = $80d "Program" .pc = $80d "Program"
// Global Constants & labels // Global Constants & labels
.encoding "screencode_upper" .encoding "screencode_upper"
.const CH = 'P' .const CH = '\$de'
.label SCREEN1 = $400 .label SCREEN1 = $400
.label SCREEN2 = $428 .label SCREEN2 = $428
.label SCREEN3 = $428
// @begin // @begin
// [1] phi from @begin to @1 [phi:@begin->@1] // [1] phi from @begin to @1 [phi:@begin->@1]
// @1 // @1
@ -405,46 +513,68 @@ Score: 368
// @end // @end
// main // main
main: { main: {
.label i = 2
// *((char*)0xd018) = 0x17 // *((char*)0xd018) = 0x17
// [4] *((byte*) 53272) ← (byte) $17 -- _deref_pbuc1=vbuc2 // [4] *((byte*) 53272) ← (byte) $17 -- _deref_pbuc1=vbuc2
// Show mixed chars on screen // Show mixed chars on screen
lda #$17 lda #$17
sta $d018 sta $d018
// [5] phi from main to main::@1 [phi:main->main::@1] // [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 // [5] phi (byte) main::i#2 = (byte) 0 [phi:main->main::@1#0] -- vbuz1=vbuc1
ldx #0 lda #0
sta.z i
// main::@1 // main::@1
__b1: __b1:
// while(MSG1[i]) // while(MSG1[i])
// [6] if((byte) 0!=*((const byte*) MSG1 + (byte) main::i#2)) goto main::@2 -- vbuc1_neq_pbuc2_derefidx_vbuxx_then_la1 // [6] if((byte) 0!=*((const byte*) MSG1 + (byte) main::i#2)) goto main::@2 -- vbuc1_neq_pbuc2_derefidx_vbuz1_then_la1
lda MSG1,x lda #0
cmp #0 ldy.z i
cmp MSG1,y
bne __b2 bne __b2
// main::@3 // main::@3
// SCREEN3[0] = CH // SCREEN2[0] = CH
// [7] *((const byte*) SCREEN3) ← (const byte) CH -- _deref_pbuc1=vbuc2 // [7] *((const byte*) SCREEN2) ← (const byte) CH -- _deref_pbuc1=vbuc2
lda #CH lda #CH
sta SCREEN3 sta SCREEN2
// main::@return // main::@return
// } // }
// [8] return // [8] return
rts rts
// main::@2 // main::@2
__b2: __b2:
// SCREEN1[i] = MSG1[i] // chrout(MSG1[i])
// [9] *((const byte*) SCREEN1 + (byte) main::i#2) ← *((const byte*) MSG1 + (byte) main::i#2) -- pbuc1_derefidx_vbuxx=pbuc2_derefidx_vbuxx // [9] (byte) chrout::petscii#0 ← *((const byte*) MSG1 + (byte) main::i#2) -- vbuaa=pbuc1_derefidx_vbuz1
lda MSG1,x ldy.z i
sta SCREEN1,x lda MSG1,y
// SCREEN2[i] = MSG2[i] // [10] call chrout
// [10] *((const byte*) SCREEN2 + (byte) main::i#2) ← *((const byte*) MSG2 + (byte) main::i#2) -- pbuc1_derefidx_vbuxx=pbuc2_derefidx_vbuxx jsr chrout
lda MSG2,x // main::@4
sta SCREEN2,x // SCREEN1[i] = MSG2[i]
// [11] *((const byte*) SCREEN1 + (byte) main::i#2) ← *((const byte*) MSG2 + (byte) main::i#2) -- pbuc1_derefidx_vbuz1=pbuc2_derefidx_vbuz1
ldy.z i
lda MSG2,y
sta SCREEN1,y
// i++; // i++;
// [11] (byte) main::i#1 ← ++ (byte) main::i#2 -- vbuxx=_inc_vbuxx // [12] (byte) main::i#1 ← ++ (byte) main::i#2 -- vbuz1=_inc_vbuz1
inx inc.z i
// [5] phi from main::@2 to main::@1 [phi:main::@2->main::@1] // [5] phi from main::@4 to main::@1 [phi:main::@4->main::@1]
// [5] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@2->main::@1#0] -- register_copy // [5] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@4->main::@1#0] -- register_copy
jmp __b1 jmp __b1
}
// chrout
// chrout(byte register(A) petscii)
chrout: {
.label mem = $ff
// *mem = petscii
// [13] *((const byte*) chrout::mem) ← (byte) chrout::petscii#0 -- _deref_pbuc1=vbuaa
sta mem
// asm
// asm { ldamem jsr$ffd2 }
jsr $ffd2
// chrout::@return
// }
// [15] return
rts
} }
// File Data // File Data
.encoding "petscii_mixed" .encoding "petscii_mixed"

View File

@ -1,19 +1,25 @@
(label) @1 (label) @1
(label) @begin (label) @begin
(label) @end (label) @end
(const byte) CH = (byte) 'P'su (const byte) CH = (byte) ''su
(const byte*) MSG1[] = (byte*) "cAmElot"pm (const byte*) MSG1[] = (byte*) "cAmElot"pm
(const byte*) MSG2[] = (byte*) "CAMELOT"su (const byte*) MSG2[] = (byte*) "CAMELOT"su
(const byte*) SCREEN1 = (byte*) 1024 (const byte*) SCREEN1 = (byte*) 1024
(const byte*) SCREEN2 = (byte*) 1064 (const byte*) SCREEN2 = (byte*) 1064
(const byte*) SCREEN3 = (byte*) 1064 (void()) chrout((byte) chrout::petscii)
(label) chrout::@return
(const byte*) chrout::mem = (byte*) 255
(byte) chrout::petscii
(byte) chrout::petscii#0 reg byte a 1102.0
(void()) main() (void()) main()
(label) main::@1 (label) main::@1
(label) main::@2 (label) main::@2
(label) main::@3 (label) main::@3
(label) main::@4
(label) main::@return (label) main::@return
(byte) main::i (byte) main::i
(byte) main::i#1 reg byte x 202.0 (byte) main::i#1 i zp[1]:2 202.0
(byte) main::i#2 reg byte x 176.75 (byte) main::i#2 i zp[1]:2 121.2
reg byte x [ main::i#2 main::i#1 ] zp[1]:2 [ main::i#2 main::i#1 ]
reg byte a [ chrout::petscii#0 ]

View File

@ -5,7 +5,7 @@
.pc = $80d "Program" .pc = $80d "Program"
.label SCREEN = $400 .label SCREEN = $400
.encoding "petscii_mixed" .encoding "petscii_mixed"
.const CH = -1 .const CH = '\$ff'
main: { main: {
ldx #0 ldx #0
__b1: __b1:
@ -26,5 +26,5 @@ main: {
inx inx
jmp __b1 jmp __b1
} }
MESSAGE: .text @"qwe\$ffasd\$ferty" MESSAGE: .text @"q\$ffw\$60e\$ddr"
.byte 0 .byte 0

View File

@ -40,8 +40,8 @@ SYMBOL TABLE SSA
(label) @2 (label) @2
(label) @begin (label) @begin
(label) @end (label) @end
(const byte) CH = (byte) '刺'pm (const byte) CH = (byte) ''pm
(const byte*) MESSAGE[] = (byte*) "qwe刺asd茶rty"pm (const byte*) MESSAGE[] = (byte*) "q▒w褐e│r"pm
(const nomodify byte*) SCREEN = (byte*)(number) $400 (const nomodify byte*) SCREEN = (byte*)(number) $400
(void()) main() (void()) main()
(bool~) main::$0 (bool~) main::$0
@ -148,7 +148,7 @@ Target platform is c64basic / MOS6502X
// Global Constants & labels // Global Constants & labels
.label SCREEN = $400 .label SCREEN = $400
.encoding "petscii_mixed" .encoding "petscii_mixed"
.const CH = -1 .const CH = '\$ff'
// @begin // @begin
__bbegin: __bbegin:
// [1] phi from @begin to @1 [phi:@begin->@1] // [1] phi from @begin to @1 [phi:@begin->@1]
@ -206,7 +206,7 @@ main: {
jmp __b1 jmp __b1
} }
// File Data // File Data
MESSAGE: .text @"qwe\$ffasd\$ferty" MESSAGE: .text @"q\$ffw\$60e\$ddr"
.byte 0 .byte 0
REGISTER UPLIFT POTENTIAL REGISTERS REGISTER UPLIFT POTENTIAL REGISTERS
@ -237,7 +237,7 @@ ASSEMBLER BEFORE OPTIMIZATION
// Global Constants & labels // Global Constants & labels
.label SCREEN = $400 .label SCREEN = $400
.encoding "petscii_mixed" .encoding "petscii_mixed"
.const CH = -1 .const CH = '\$ff'
// @begin // @begin
__bbegin: __bbegin:
// [1] phi from @begin to @1 [phi:@begin->@1] // [1] phi from @begin to @1 [phi:@begin->@1]
@ -291,7 +291,7 @@ main: {
jmp __b1 jmp __b1
} }
// File Data // File Data
MESSAGE: .text @"qwe\$ffasd\$ferty" MESSAGE: .text @"q\$ffw\$60e\$ddr"
.byte 0 .byte 0
ASSEMBLER OPTIMIZATIONS ASSEMBLER OPTIMIZATIONS
@ -322,8 +322,8 @@ FINAL SYMBOL TABLE
(label) @1 (label) @1
(label) @begin (label) @begin
(label) @end (label) @end
(const byte) CH = (byte) '刺'pm (const byte) CH = (byte) ''pm
(const byte*) MESSAGE[] = (byte*) "qwe刺asd茶rty"pm (const byte*) MESSAGE[] = (byte*) "q▒w褐e│r"pm
(const nomodify byte*) SCREEN = (byte*) 1024 (const nomodify byte*) SCREEN = (byte*) 1024
(void()) main() (void()) main()
(label) main::@1 (label) main::@1
@ -350,7 +350,7 @@ Score: 267
// Global Constants & labels // Global Constants & labels
.label SCREEN = $400 .label SCREEN = $400
.encoding "petscii_mixed" .encoding "petscii_mixed"
.const CH = -1 .const CH = '\$ff'
// @begin // @begin
// [1] phi from @begin to @1 [phi:@begin->@1] // [1] phi from @begin to @1 [phi:@begin->@1]
// @1 // @1
@ -393,6 +393,6 @@ main: {
jmp __b1 jmp __b1
} }
// File Data // File Data
MESSAGE: .text @"qwe\$ffasd\$ferty" MESSAGE: .text @"q\$ffw\$60e\$ddr"
.byte 0 .byte 0

View File

@ -1,8 +1,8 @@
(label) @1 (label) @1
(label) @begin (label) @begin
(label) @end (label) @end
(const byte) CH = (byte) '刺'pm (const byte) CH = (byte) ''pm
(const byte*) MESSAGE[] = (byte*) "qwe刺asd茶rty"pm (const byte*) MESSAGE[] = (byte*) "q▒w褐e│r"pm
(const nomodify byte*) SCREEN = (byte*) 1024 (const nomodify byte*) SCREEN = (byte*) 1024
(void()) main() (void()) main()
(label) main::@1 (label) main::@1