mirror of
https://gitlab.com/camelot/kickc.git
synced 2024-12-22 06:29:23 +00:00
Upgraded to KickAsm 5.14. Fixed PETSCII encoding problem. Closes #401
This commit is contained in:
parent
cf4d25b5f6
commit
ab10f2184d
@ -1,13 +1,13 @@
|
||||
<component name="libraryTable">
|
||||
<library name="Maven: cml.kickass:kickassembler:5.13">
|
||||
<library name="Maven: cml.kickass:kickassembler:5.14">
|
||||
<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>
|
||||
<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>
|
||||
<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>
|
||||
</library>
|
||||
</component>
|
@ -22,7 +22,7 @@
|
||||
<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: 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" />
|
||||
</component>
|
||||
</module>
|
2
pom.xml
2
pom.xml
@ -44,7 +44,7 @@
|
||||
<dependency>
|
||||
<groupId>cml.kickass</groupId>
|
||||
<artifactId>kickassembler</artifactId>
|
||||
<version>5.13</version>
|
||||
<version>5.14</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>info.picocli</groupId>
|
||||
|
4
repo/cml/kickass/kickassembler/5.14/_remote.repositories
Normal file
4
repo/cml/kickass/kickassembler/5.14/_remote.repositories
Normal 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>=
|
BIN
repo/cml/kickass/kickassembler/5.14/kickassembler-5.14.jar
Normal file
BIN
repo/cml/kickass/kickassembler/5.14/kickassembler-5.14.jar
Normal file
Binary file not shown.
@ -0,0 +1 @@
|
||||
028e2a8db4a5dc8234a977356ad36bbb
|
@ -0,0 +1 @@
|
||||
ced8f6f0a44cc03345cf3094887635b6fd0baeb8
|
@ -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>
|
@ -0,0 +1 @@
|
||||
96c8375a48889a6e4dcd784baf5ed419
|
@ -0,0 +1 @@
|
||||
afd7d9dad7f1730f5c5b76fe2a5def866af06ab7
|
@ -3,10 +3,10 @@
|
||||
<groupId>cml.kickass</groupId>
|
||||
<artifactId>kickassembler</artifactId>
|
||||
<versioning>
|
||||
<release>5.13</release>
|
||||
<release>5.14</release>
|
||||
<versions>
|
||||
<version>5.13</version>
|
||||
<version>5.14</version>
|
||||
</versions>
|
||||
<lastUpdated>20200412054708</lastUpdated>
|
||||
<lastUpdated>20200413071419</lastUpdated>
|
||||
</versioning>
|
||||
</metadata>
|
||||
|
@ -1 +1 @@
|
||||
5e4e6add8965d6e2023c3831d6abc8f0
|
||||
445929e8493b0af34c41e228496dcf1f
|
@ -1 +1 @@
|
||||
07cecbcfd2a194279e0d9bacabdf255ffdc91213
|
||||
7a1f4ed0f91c25dba71cd27f0d23e1e3a71fd05e
|
@ -34,12 +34,8 @@ public class AsmFormat {
|
||||
return getAsmBool(((ConstantBool) value).getBool());
|
||||
} else if(value instanceof ConstantChar) {
|
||||
ConstantChar constantChar = (ConstantChar) value;
|
||||
if(!constantChar.getEncoding().hasEncoding(constantChar.getChar()))
|
||||
return getAsmNumber(constantChar.getInteger());
|
||||
else {
|
||||
String escapedChar = constantChar.getCharEscaped();
|
||||
return "'" + escapedChar + "'";
|
||||
}
|
||||
String escapedChar = constantChar.getCharEscaped();
|
||||
return "'" + escapedChar + "'";
|
||||
} else if(value instanceof ConstantString) {
|
||||
String stringValue = ((ConstantString) value).getValue();
|
||||
String escapedString = ((ConstantString) value).getStringEscaped();
|
||||
|
@ -36,11 +36,12 @@ public class ConstantChar implements ConstantEnumerable<Character> {
|
||||
|
||||
/**
|
||||
* Get the integer value of the character
|
||||
*
|
||||
* @return The integer value (taking encoding into account)
|
||||
*/
|
||||
@Override
|
||||
public Long getInteger() {
|
||||
return encoding.encodedFromChar(value);
|
||||
return (long) encoding.encodedFromChar(value);
|
||||
}
|
||||
|
||||
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).
|
||||
*
|
||||
* @return The character with escapes if needed.
|
||||
*/
|
||||
public String getCharEscaped() {
|
||||
return encoding.asciiToEscape(value, true);
|
||||
return encoding.asciiToEscapedEncoded(value, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -50,7 +50,7 @@ public class ConstantString implements ConstantLiteral<String> {
|
||||
* @return The escaped string.
|
||||
*/
|
||||
public String getStringEscaped() {
|
||||
return encoding.asciiToEscape(value);
|
||||
return encoding.asciiToEscapedEncoded(value);
|
||||
}
|
||||
|
||||
public boolean isZeroTerminated() {
|
||||
|
@ -9,8 +9,8 @@ import java.util.PrimitiveIterator;
|
||||
/** String encoding. */
|
||||
public enum StringEncoding {
|
||||
|
||||
PETSCII_MIXED("petscii_mixed", "pm", CharToPetsciiConverter.charToScreenCode_mixed),
|
||||
PETSCII_UPPER("petscii_upper", "pu", CharToPetsciiConverter.charToScreenCode_upper),
|
||||
PETSCII_MIXED("petscii_mixed", "pm", CharToPetsciiConverter.charToPetscii_mixed),
|
||||
PETSCII_UPPER("petscii_upper", "pu", CharToPetsciiConverter.charToPetscii_mixed),
|
||||
SCREENCODE_MIXED("screencode_mixed", "sm", CharToPetsciiConverter.charToScreenCode_mixed),
|
||||
SCREENCODE_UPPER("screencode_upper", "su", CharToPetsciiConverter.charToScreenCode_upper);
|
||||
|
||||
@ -78,17 +78,18 @@ public enum StringEncoding {
|
||||
* @param aChar The character in UNICODE/ASCII
|
||||
* @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);
|
||||
if(encodedValue != null)
|
||||
return encodedValue.longValue();
|
||||
return encodedValue;
|
||||
else
|
||||
// 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
|
||||
*
|
||||
* @param aChar The char to examine
|
||||
* @return true if the char has a proper encoding. False if it does not.
|
||||
*/
|
||||
@ -161,10 +162,8 @@ public enum StringEncoding {
|
||||
String hexNum = "";
|
||||
hexNum += (char) escapedCharsIterator.nextInt();
|
||||
hexNum += (char) escapedCharsIterator.nextInt();
|
||||
final int hexChar = Integer.parseInt(hexNum, 16);
|
||||
final Character aChar = charFromEncoded((byte) hexChar);
|
||||
if(aChar == null)
|
||||
throw new CompileError("No character 0x" + hexNum + " in encoding " + name);
|
||||
final byte hexEncoding = (byte) Integer.parseInt(hexNum, 16);
|
||||
final Character aChar = charFromEncoded(hexEncoding);
|
||||
return aChar;
|
||||
default:
|
||||
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 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) {
|
||||
case '\n':
|
||||
return "\\n";
|
||||
@ -196,9 +195,10 @@ public enum StringEncoding {
|
||||
case '\\':
|
||||
return "\\\\";
|
||||
}
|
||||
if(aChar >= CHAR_SPECIAL_MIN && aChar <= CHAR_SPECIAL_MAX) {
|
||||
final byte charValue = (byte) (aChar - CHAR_SPECIAL_VAL);
|
||||
return String.format("\\$%x", charValue);
|
||||
if(aChar > 127) {
|
||||
// Encode all large chars - including SPECIAL's
|
||||
final byte encoded = encodedFromChar(aChar);
|
||||
return String.format("\\$%x", encoded);
|
||||
} else
|
||||
return Character.toString(aChar);
|
||||
}
|
||||
@ -209,9 +209,9 @@ public enum StringEncoding {
|
||||
* @param string The string
|
||||
* @return The escaped string.
|
||||
*/
|
||||
public String asciiToEscape(String string) {
|
||||
public String asciiToEscapedEncoded(String string) {
|
||||
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();
|
||||
}
|
||||
|
||||
|
@ -1,2 +1,2 @@
|
||||
#!/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
|
||||
|
@ -1215,10 +1215,10 @@ public class TestPrograms {
|
||||
compileAndCompare("struct-ptr-32.c");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStructPtr31() throws IOException, URISyntaxException {
|
||||
compileAndCompare("struct-ptr-31.c");
|
||||
}
|
||||
@Test
|
||||
public void testStructPtr31() throws IOException, URISyntaxException {
|
||||
compileAndCompare("struct-ptr-31.c");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStructPtr30() throws IOException, URISyntaxException {
|
||||
|
@ -2,16 +2,15 @@
|
||||
// Uses \xnn to add chars by hex-code
|
||||
|
||||
#pragma encoding(petscii_mixed)
|
||||
char MSG1[] = "c\x41m\x45lot";
|
||||
char MSG1[] = "c\xc1mElot";
|
||||
|
||||
#pragma encoding(screencode_upper)
|
||||
char MSG2[] = "C\x01M\x05LOT";
|
||||
|
||||
char CH = '\x10';
|
||||
char CH = '\xde';
|
||||
|
||||
char* SCREEN1 = 0x0400;
|
||||
char* SCREEN2 = 0x0428;
|
||||
char* SCREEN3 = 0x0428;
|
||||
|
||||
void main() {
|
||||
// Show mixed chars on screen
|
||||
@ -19,11 +18,20 @@ void main() {
|
||||
|
||||
char i=0;
|
||||
while(MSG1[i]) {
|
||||
SCREEN1[i] = MSG1[i];
|
||||
SCREEN2[i] = MSG2[i];
|
||||
chrout(MSG1[i]);
|
||||
SCREEN1[i] = MSG2[i];
|
||||
i++;
|
||||
}
|
||||
|
||||
SCREEN3[0] = CH;
|
||||
SCREEN2[0] = CH;
|
||||
|
||||
}
|
||||
|
||||
void chrout(char petscii) {
|
||||
char* mem = 0xff;
|
||||
*mem = petscii;
|
||||
asm {
|
||||
lda mem
|
||||
jsr $ffd2
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,8 @@
|
||||
// Test using some simple supported string escape
|
||||
// Uses \xnn to add chars by hex-code that do not exist with the encoding.
|
||||
|
||||
#pragma encoding(petscii_mixed)
|
||||
char MESSAGE[] = "qwe\xffasd\xferty";
|
||||
#pragma encoding(screencode_mixed)
|
||||
char MESSAGE[] = "q\xffw\x60e\xddr";
|
||||
|
||||
char CH = '\xff';
|
||||
|
||||
|
@ -4,37 +4,51 @@
|
||||
:BasicUpstart(main)
|
||||
.pc = $80d "Program"
|
||||
.encoding "screencode_upper"
|
||||
.const CH = 'P'
|
||||
.const CH = '\$de'
|
||||
.label SCREEN1 = $400
|
||||
.label SCREEN2 = $428
|
||||
.label SCREEN3 = $428
|
||||
main: {
|
||||
.label i = 2
|
||||
// *((char*)0xd018) = 0x17
|
||||
// Show mixed chars on screen
|
||||
lda #$17
|
||||
sta $d018
|
||||
ldx #0
|
||||
lda #0
|
||||
sta.z i
|
||||
__b1:
|
||||
// while(MSG1[i])
|
||||
lda MSG1,x
|
||||
cmp #0
|
||||
lda #0
|
||||
ldy.z i
|
||||
cmp MSG1,y
|
||||
bne __b2
|
||||
// SCREEN3[0] = CH
|
||||
// SCREEN2[0] = CH
|
||||
lda #CH
|
||||
sta SCREEN3
|
||||
sta SCREEN2
|
||||
// }
|
||||
rts
|
||||
__b2:
|
||||
// SCREEN1[i] = MSG1[i]
|
||||
lda MSG1,x
|
||||
sta SCREEN1,x
|
||||
// SCREEN2[i] = MSG2[i]
|
||||
lda MSG2,x
|
||||
sta SCREEN2,x
|
||||
// chrout(MSG1[i])
|
||||
ldy.z i
|
||||
lda MSG1,y
|
||||
jsr chrout
|
||||
// SCREEN1[i] = MSG2[i]
|
||||
ldy.z i
|
||||
lda MSG2,y
|
||||
sta SCREEN1,y
|
||||
// i++;
|
||||
inx
|
||||
inc.z i
|
||||
jmp __b1
|
||||
}
|
||||
// chrout(byte register(A) petscii)
|
||||
chrout: {
|
||||
.label mem = $ff
|
||||
// *mem = petscii
|
||||
sta mem
|
||||
// asm
|
||||
jsr $ffd2
|
||||
// }
|
||||
rts
|
||||
}
|
||||
.encoding "petscii_mixed"
|
||||
MSG1: .text "cAmElot"
|
||||
.byte 0
|
||||
|
@ -12,18 +12,30 @@
|
||||
main: scope:[main] from @1
|
||||
[4] *((byte*) 53272) ← (byte) $17
|
||||
to:main::@1
|
||||
main::@1: scope:[main] from main main::@2
|
||||
[5] (byte) main::i#2 ← phi( main/(byte) 0 main::@2/(byte) main::i#1 )
|
||||
main::@1: scope:[main] from main main::@4
|
||||
[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
|
||||
to:main::@3
|
||||
main::@3: scope:[main] from main::@1
|
||||
[7] *((const byte*) SCREEN3) ← (const byte) CH
|
||||
[7] *((const byte*) SCREEN2) ← (const byte) CH
|
||||
to:main::@return
|
||||
main::@return: scope:[main] from main::@3
|
||||
[8] return
|
||||
to:@return
|
||||
main::@2: scope:[main] from main::@1
|
||||
[9] *((const byte*) SCREEN1 + (byte) main::i#2) ← *((const byte*) MSG1 + (byte) main::i#2)
|
||||
[10] *((const byte*) SCREEN2 + (byte) main::i#2) ← *((const byte*) MSG2 + (byte) main::i#2)
|
||||
[11] (byte) main::i#1 ← ++ (byte) main::i#2
|
||||
[9] (byte) chrout::petscii#0 ← *((const byte*) MSG1 + (byte) main::i#2)
|
||||
[10] call chrout
|
||||
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
|
||||
|
||||
(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
|
||||
|
@ -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*) SCREEN1
|
||||
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::@5
|
||||
Culled Empty Block (label) main::@6
|
||||
Culled Empty Block (label) @1
|
||||
|
||||
CONTROL FLOW GRAPH SSA
|
||||
@begin: scope:[] from
|
||||
to:@1
|
||||
to:@2
|
||||
|
||||
(void()) main()
|
||||
main: scope:[main] from @1
|
||||
main: scope:[main] from @2
|
||||
*((byte*)(number) $d018) ← (number) $17
|
||||
(byte) main::i#0 ← (byte) 0
|
||||
to:main::@1
|
||||
main::@1: scope:[main] from main main::@2
|
||||
(byte) main::i#2 ← phi( main/(byte) main::i#0 main::@2/(byte) main::i#1 )
|
||||
(bool~) main::$0 ← (number) 0 != *((const byte*) MSG1 + (byte) main::i#2)
|
||||
if((bool~) main::$0) goto main::@2
|
||||
main::@1: scope:[main] from main main::@7
|
||||
(byte) main::i#2 ← phi( main/(byte) main::i#0 main::@7/(byte) main::i#1 )
|
||||
(bool~) main::$1 ← (number) 0 != *((const byte*) MSG1 + (byte) main::i#2)
|
||||
if((bool~) main::$1) goto main::@2
|
||||
to:main::@3
|
||||
main::@2: scope:[main] from main::@1
|
||||
(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)
|
||||
*((const byte*) SCREEN2 + (byte) main::i#3) ← *((const byte*) MSG2 + (byte) main::i#3)
|
||||
(byte) main::i#1 ← ++ (byte) main::i#3
|
||||
(byte) chrout::petscii#0 ← *((const byte*) MSG1 + (byte) main::i#3)
|
||||
call chrout
|
||||
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
|
||||
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
|
||||
main::@return: scope:[main] from main::@3
|
||||
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
|
||||
to:@2
|
||||
@2: scope:[] from @1
|
||||
to:@3
|
||||
@3: scope:[] from @2
|
||||
to:@end
|
||||
@end: scope:[] from @2
|
||||
@end: scope:[] from @3
|
||||
|
||||
SYMBOL TABLE SSA
|
||||
(label) @1
|
||||
(label) @2
|
||||
(label) @3
|
||||
(label) @begin
|
||||
(label) @end
|
||||
(const byte) CH = (byte) 'P'su
|
||||
(const byte) CH = (byte) ''su
|
||||
(const byte*) MSG1[] = (byte*) "cAmElot"pm
|
||||
(const byte*) MSG2[] = (byte*) "CAMELOT"su
|
||||
(const byte*) SCREEN1 = (byte*)(number) $400
|
||||
(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()
|
||||
(bool~) main::$0
|
||||
(bool~) main::$1
|
||||
(label) main::@1
|
||||
(label) main::@2
|
||||
(label) main::@3
|
||||
(label) main::@7
|
||||
(label) main::@return
|
||||
(byte) main::i
|
||||
(byte) main::i#0
|
||||
(byte) main::i#1
|
||||
(byte) main::i#2
|
||||
(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) 0 in (bool~) main::$0 ← (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 (bool~) main::$1 ← (number) 0 != *((const byte*) MSG1 + (byte) main::i#2)
|
||||
Adding number conversion cast (unumber) 0 in *((const byte*) SCREEN2 + (number) 0) ← (const byte) CH
|
||||
Successful SSA optimization PassNAddNumberTypeConversions
|
||||
Inlining cast *((byte*)(number) $d018) ← (unumber)(number) $17
|
||||
Successful SSA optimization Pass2InlineCast
|
||||
Simplifying constant pointer cast (byte*) 255
|
||||
Simplifying constant pointer cast (byte*) 1024
|
||||
Simplifying constant pointer cast (byte*) 1064
|
||||
Simplifying constant pointer cast (byte*) 1064
|
||||
Simplifying constant integer cast $17
|
||||
Simplifying constant pointer cast (byte*) 53272
|
||||
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
|
||||
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
|
||||
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
|
||||
Constant (const byte) main::i#0 = 0
|
||||
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
|
||||
Inlining constant with var siblings (const byte) main::i#0
|
||||
Constant inlined main::i#0 = (byte) 0
|
||||
Successful SSA optimization Pass2ConstantInlining
|
||||
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 @3
|
||||
Adding NOP phi() at start of @end
|
||||
CALL GRAPH
|
||||
Calls in [] to main:2
|
||||
Calls in [main] to chrout:11
|
||||
|
||||
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
|
||||
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 @1
|
||||
Adding NOP phi() at start of @end
|
||||
@ -122,34 +149,52 @@ FINAL CONTROL FLOW GRAPH
|
||||
main: scope:[main] from @1
|
||||
[4] *((byte*) 53272) ← (byte) $17
|
||||
to:main::@1
|
||||
main::@1: scope:[main] from main main::@2
|
||||
[5] (byte) main::i#2 ← phi( main/(byte) 0 main::@2/(byte) main::i#1 )
|
||||
main::@1: scope:[main] from main main::@4
|
||||
[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
|
||||
to:main::@3
|
||||
main::@3: scope:[main] from main::@1
|
||||
[7] *((const byte*) SCREEN3) ← (const byte) CH
|
||||
[7] *((const byte*) SCREEN2) ← (const byte) CH
|
||||
to:main::@return
|
||||
main::@return: scope:[main] from main::@3
|
||||
[8] return
|
||||
to:@return
|
||||
main::@2: scope:[main] from main::@1
|
||||
[9] *((const byte*) SCREEN1 + (byte) main::i#2) ← *((const byte*) MSG1 + (byte) main::i#2)
|
||||
[10] *((const byte*) SCREEN2 + (byte) main::i#2) ← *((const byte*) MSG2 + (byte) main::i#2)
|
||||
[11] (byte) main::i#1 ← ++ (byte) main::i#2
|
||||
[9] (byte) chrout::petscii#0 ← *((const byte*) MSG1 + (byte) main::i#2)
|
||||
[10] call chrout
|
||||
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
|
||||
|
||||
(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
|
||||
(void()) chrout((byte) chrout::petscii)
|
||||
(byte) chrout::petscii
|
||||
(byte) chrout::petscii#0 1102.0
|
||||
(void()) main()
|
||||
(byte) main::i
|
||||
(byte) main::i#1 202.0
|
||||
(byte) main::i#2 176.75
|
||||
(byte) main::i#2 121.2
|
||||
|
||||
Initial phi equivalence classes
|
||||
[ main::i#2 main::i#1 ]
|
||||
Added variable chrout::petscii#0 to live range equivalence class [ chrout::petscii#0 ]
|
||||
Complete equivalence classes
|
||||
[ main::i#2 main::i#1 ]
|
||||
[ chrout::petscii#0 ]
|
||||
Allocated zp[1]:2 [ main::i#2 main::i#1 ]
|
||||
Allocated zp[1]:3 [ chrout::petscii#0 ]
|
||||
|
||||
INITIAL ASM
|
||||
Target platform is c64basic / MOS6502X
|
||||
@ -162,10 +207,9 @@ Target platform is c64basic / MOS6502X
|
||||
.pc = $80d "Program"
|
||||
// Global Constants & labels
|
||||
.encoding "screencode_upper"
|
||||
.const CH = 'P'
|
||||
.const CH = '\$de'
|
||||
.label SCREEN1 = $400
|
||||
.label SCREEN2 = $428
|
||||
.label SCREEN3 = $428
|
||||
// @begin
|
||||
__bbegin:
|
||||
// [1] phi from @begin to @1 [phi:@begin->@1]
|
||||
@ -203,9 +247,9 @@ main: {
|
||||
jmp __b3
|
||||
// main::@3
|
||||
__b3:
|
||||
// [7] *((const byte*) SCREEN3) ← (const byte) CH -- _deref_pbuc1=vbuc2
|
||||
// [7] *((const byte*) SCREEN2) ← (const byte) CH -- _deref_pbuc1=vbuc2
|
||||
lda #CH
|
||||
sta SCREEN3
|
||||
sta SCREEN2
|
||||
jmp __breturn
|
||||
// main::@return
|
||||
__breturn:
|
||||
@ -213,20 +257,42 @@ main: {
|
||||
rts
|
||||
// main::@2
|
||||
__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
|
||||
lda MSG1,y
|
||||
sta SCREEN1,y
|
||||
// [10] *((const byte*) SCREEN2 + (byte) main::i#2) ← *((const byte*) MSG2 + (byte) main::i#2) -- pbuc1_derefidx_vbuz1=pbuc2_derefidx_vbuz1
|
||||
sta.z chrout.petscii
|
||||
// [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
|
||||
lda MSG2,y
|
||||
sta SCREEN2,y
|
||||
// [11] (byte) main::i#1 ← ++ (byte) main::i#2 -- vbuz1=_inc_vbuz1
|
||||
sta SCREEN1,y
|
||||
// [12] (byte) main::i#1 ← ++ (byte) main::i#2 -- vbuz1=_inc_vbuz1
|
||||
inc.z i
|
||||
// [5] phi from main::@2 to main::@1 [phi:main::@2->main::@1]
|
||||
__b1_from___b2:
|
||||
// [5] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@2->main::@1#0] -- register_copy
|
||||
// [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
|
||||
}
|
||||
// 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
|
||||
.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 [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 ]
|
||||
Statement [7] *((const byte*) SCREEN3) ← (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 [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 [7] *((const byte*) SCREEN2) ← (const byte) CH [ ] ( main: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 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 [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 [7] *((const byte*) SCREEN3) ← (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 [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
|
||||
Potential registers zp[1]:2 [ main::i#2 main::i#1 ] : zp[1]:2 , reg byte x , reg byte y ,
|
||||
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*) SCREEN2) ← (const byte) CH [ ] ( main: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 [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
|
||||
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
|
||||
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 []
|
||||
|
||||
Uplifting [main] best 443 combination reg byte x [ main::i#2 main::i#1 ]
|
||||
Uplifting [] best 443 combination
|
||||
Uplifting [chrout] best 656 combination reg byte a [ chrout::petscii#0 ]
|
||||
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
|
||||
// File Comments
|
||||
@ -267,10 +341,9 @@ ASSEMBLER BEFORE OPTIMIZATION
|
||||
.pc = $80d "Program"
|
||||
// Global Constants & labels
|
||||
.encoding "screencode_upper"
|
||||
.const CH = 'P'
|
||||
.const CH = '\$de'
|
||||
.label SCREEN1 = $400
|
||||
.label SCREEN2 = $428
|
||||
.label SCREEN3 = $428
|
||||
// @begin
|
||||
__bbegin:
|
||||
// [1] phi from @begin to @1 [phi:@begin->@1]
|
||||
@ -287,27 +360,30 @@ __bend_from___b1:
|
||||
__bend:
|
||||
// main
|
||||
main: {
|
||||
.label i = 2
|
||||
// [4] *((byte*) 53272) ← (byte) $17 -- _deref_pbuc1=vbuc2
|
||||
// Show mixed chars on screen
|
||||
lda #$17
|
||||
sta $d018
|
||||
// [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
|
||||
// [5] phi (byte) main::i#2 = (byte) 0 [phi:main->main::@1#0] -- vbuz1=vbuc1
|
||||
lda #0
|
||||
sta.z i
|
||||
jmp __b1
|
||||
// main::@1
|
||||
__b1:
|
||||
// [6] if((byte) 0!=*((const byte*) MSG1 + (byte) main::i#2)) goto main::@2 -- vbuc1_neq_pbuc2_derefidx_vbuxx_then_la1
|
||||
lda MSG1,x
|
||||
cmp #0
|
||||
// [6] if((byte) 0!=*((const byte*) MSG1 + (byte) main::i#2)) goto main::@2 -- vbuc1_neq_pbuc2_derefidx_vbuz1_then_la1
|
||||
lda #0
|
||||
ldy.z i
|
||||
cmp MSG1,y
|
||||
bne __b2
|
||||
jmp __b3
|
||||
// main::@3
|
||||
__b3:
|
||||
// [7] *((const byte*) SCREEN3) ← (const byte) CH -- _deref_pbuc1=vbuc2
|
||||
// [7] *((const byte*) SCREEN2) ← (const byte) CH -- _deref_pbuc1=vbuc2
|
||||
lda #CH
|
||||
sta SCREEN3
|
||||
sta SCREEN2
|
||||
jmp __breturn
|
||||
// main::@return
|
||||
__breturn:
|
||||
@ -315,18 +391,39 @@ main: {
|
||||
rts
|
||||
// main::@2
|
||||
__b2:
|
||||
// [9] *((const byte*) SCREEN1 + (byte) main::i#2) ← *((const byte*) MSG1 + (byte) main::i#2) -- pbuc1_derefidx_vbuxx=pbuc2_derefidx_vbuxx
|
||||
lda MSG1,x
|
||||
sta SCREEN1,x
|
||||
// [10] *((const byte*) SCREEN2 + (byte) main::i#2) ← *((const byte*) MSG2 + (byte) main::i#2) -- pbuc1_derefidx_vbuxx=pbuc2_derefidx_vbuxx
|
||||
lda MSG2,x
|
||||
sta SCREEN2,x
|
||||
// [11] (byte) main::i#1 ← ++ (byte) main::i#2 -- vbuxx=_inc_vbuxx
|
||||
inx
|
||||
// [5] phi from main::@2 to main::@1 [phi:main::@2->main::@1]
|
||||
__b1_from___b2:
|
||||
// [5] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@2->main::@1#0] -- register_copy
|
||||
// [9] (byte) chrout::petscii#0 ← *((const byte*) MSG1 + (byte) main::i#2) -- vbuaa=pbuc1_derefidx_vbuz1
|
||||
ldy.z i
|
||||
lda MSG1,y
|
||||
// [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
|
||||
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
|
||||
}
|
||||
// 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
|
||||
.encoding "petscii_mixed"
|
||||
@ -342,7 +439,11 @@ Removing instruction jmp __bend
|
||||
Removing instruction jmp __b1
|
||||
Removing instruction jmp __b3
|
||||
Removing instruction jmp __breturn
|
||||
Removing instruction jmp __b4
|
||||
Removing instruction jmp __breturn
|
||||
Succesful ASM optimization Pass5NextJumpElimination
|
||||
Removing instruction lda mem
|
||||
Succesful ASM optimization Pass5UnnecesaryLoadElimination
|
||||
Removing instruction __b1_from___bbegin:
|
||||
Removing instruction __b1:
|
||||
Removing instruction __bend_from___b1:
|
||||
@ -351,7 +452,9 @@ Removing instruction __bend:
|
||||
Removing instruction __b1_from_main:
|
||||
Removing instruction __b3:
|
||||
Removing instruction __breturn:
|
||||
Removing instruction __b1_from___b2:
|
||||
Removing instruction __b4:
|
||||
Removing instruction __b1_from___b4:
|
||||
Removing instruction __breturn:
|
||||
Succesful ASM optimization Pass5UnusedLabelElimination
|
||||
Updating BasicUpstart to call main directly
|
||||
Removing instruction jsr main
|
||||
@ -363,26 +466,32 @@ FINAL SYMBOL TABLE
|
||||
(label) @1
|
||||
(label) @begin
|
||||
(label) @end
|
||||
(const byte) CH = (byte) 'P'su
|
||||
(const byte) CH = (byte) ''su
|
||||
(const byte*) MSG1[] = (byte*) "cAmElot"pm
|
||||
(const byte*) MSG2[] = (byte*) "CAMELOT"su
|
||||
(const byte*) SCREEN1 = (byte*) 1024
|
||||
(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()
|
||||
(label) main::@1
|
||||
(label) main::@2
|
||||
(label) main::@3
|
||||
(label) main::@4
|
||||
(label) main::@return
|
||||
(byte) main::i
|
||||
(byte) main::i#1 reg byte x 202.0
|
||||
(byte) main::i#2 reg byte x 176.75
|
||||
(byte) main::i#1 i zp[1]:2 202.0
|
||||
(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
|
||||
Score: 368
|
||||
Score: 544
|
||||
|
||||
// File Comments
|
||||
// Test using some simple supported string escape
|
||||
@ -393,10 +502,9 @@ Score: 368
|
||||
.pc = $80d "Program"
|
||||
// Global Constants & labels
|
||||
.encoding "screencode_upper"
|
||||
.const CH = 'P'
|
||||
.const CH = '\$de'
|
||||
.label SCREEN1 = $400
|
||||
.label SCREEN2 = $428
|
||||
.label SCREEN3 = $428
|
||||
// @begin
|
||||
// [1] phi from @begin to @1 [phi:@begin->@1]
|
||||
// @1
|
||||
@ -405,46 +513,68 @@ Score: 368
|
||||
// @end
|
||||
// main
|
||||
main: {
|
||||
.label i = 2
|
||||
// *((char*)0xd018) = 0x17
|
||||
// [4] *((byte*) 53272) ← (byte) $17 -- _deref_pbuc1=vbuc2
|
||||
// Show mixed chars on screen
|
||||
lda #$17
|
||||
sta $d018
|
||||
// [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 (byte) main::i#2 = (byte) 0 [phi:main->main::@1#0] -- vbuz1=vbuc1
|
||||
lda #0
|
||||
sta.z i
|
||||
// main::@1
|
||||
__b1:
|
||||
// while(MSG1[i])
|
||||
// [6] if((byte) 0!=*((const byte*) MSG1 + (byte) main::i#2)) goto main::@2 -- vbuc1_neq_pbuc2_derefidx_vbuxx_then_la1
|
||||
lda MSG1,x
|
||||
cmp #0
|
||||
// [6] if((byte) 0!=*((const byte*) MSG1 + (byte) main::i#2)) goto main::@2 -- vbuc1_neq_pbuc2_derefidx_vbuz1_then_la1
|
||||
lda #0
|
||||
ldy.z i
|
||||
cmp MSG1,y
|
||||
bne __b2
|
||||
// main::@3
|
||||
// SCREEN3[0] = CH
|
||||
// [7] *((const byte*) SCREEN3) ← (const byte) CH -- _deref_pbuc1=vbuc2
|
||||
// SCREEN2[0] = CH
|
||||
// [7] *((const byte*) SCREEN2) ← (const byte) CH -- _deref_pbuc1=vbuc2
|
||||
lda #CH
|
||||
sta SCREEN3
|
||||
sta SCREEN2
|
||||
// main::@return
|
||||
// }
|
||||
// [8] return
|
||||
rts
|
||||
// main::@2
|
||||
__b2:
|
||||
// SCREEN1[i] = MSG1[i]
|
||||
// [9] *((const byte*) SCREEN1 + (byte) main::i#2) ← *((const byte*) MSG1 + (byte) main::i#2) -- pbuc1_derefidx_vbuxx=pbuc2_derefidx_vbuxx
|
||||
lda MSG1,x
|
||||
sta SCREEN1,x
|
||||
// SCREEN2[i] = MSG2[i]
|
||||
// [10] *((const byte*) SCREEN2 + (byte) main::i#2) ← *((const byte*) MSG2 + (byte) main::i#2) -- pbuc1_derefidx_vbuxx=pbuc2_derefidx_vbuxx
|
||||
lda MSG2,x
|
||||
sta SCREEN2,x
|
||||
// chrout(MSG1[i])
|
||||
// [9] (byte) chrout::petscii#0 ← *((const byte*) MSG1 + (byte) main::i#2) -- vbuaa=pbuc1_derefidx_vbuz1
|
||||
ldy.z i
|
||||
lda MSG1,y
|
||||
// [10] call chrout
|
||||
jsr chrout
|
||||
// main::@4
|
||||
// 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++;
|
||||
// [11] (byte) main::i#1 ← ++ (byte) main::i#2 -- vbuxx=_inc_vbuxx
|
||||
inx
|
||||
// [5] phi from main::@2 to main::@1 [phi:main::@2->main::@1]
|
||||
// [5] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@2->main::@1#0] -- register_copy
|
||||
// [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]
|
||||
// [5] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@4->main::@1#0] -- register_copy
|
||||
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
|
||||
.encoding "petscii_mixed"
|
||||
|
@ -1,19 +1,25 @@
|
||||
(label) @1
|
||||
(label) @begin
|
||||
(label) @end
|
||||
(const byte) CH = (byte) 'P'su
|
||||
(const byte) CH = (byte) ''su
|
||||
(const byte*) MSG1[] = (byte*) "cAmElot"pm
|
||||
(const byte*) MSG2[] = (byte*) "CAMELOT"su
|
||||
(const byte*) SCREEN1 = (byte*) 1024
|
||||
(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()
|
||||
(label) main::@1
|
||||
(label) main::@2
|
||||
(label) main::@3
|
||||
(label) main::@4
|
||||
(label) main::@return
|
||||
(byte) main::i
|
||||
(byte) main::i#1 reg byte x 202.0
|
||||
(byte) main::i#2 reg byte x 176.75
|
||||
(byte) main::i#1 i zp[1]:2 202.0
|
||||
(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 ]
|
||||
|
@ -5,7 +5,7 @@
|
||||
.pc = $80d "Program"
|
||||
.label SCREEN = $400
|
||||
.encoding "petscii_mixed"
|
||||
.const CH = -1
|
||||
.const CH = '\$ff'
|
||||
main: {
|
||||
ldx #0
|
||||
__b1:
|
||||
@ -26,5 +26,5 @@ main: {
|
||||
inx
|
||||
jmp __b1
|
||||
}
|
||||
MESSAGE: .text @"qwe\$ffasd\$ferty"
|
||||
MESSAGE: .text @"q\$ffw\$60e\$ddr"
|
||||
.byte 0
|
||||
|
@ -40,8 +40,8 @@ SYMBOL TABLE SSA
|
||||
(label) @2
|
||||
(label) @begin
|
||||
(label) @end
|
||||
(const byte) CH = (byte) '刺'pm
|
||||
(const byte*) MESSAGE[] = (byte*) "qwe刺asd茶rty"pm
|
||||
(const byte) CH = (byte) '▒'pm
|
||||
(const byte*) MESSAGE[] = (byte*) "q▒w褐e│r"pm
|
||||
(const nomodify byte*) SCREEN = (byte*)(number) $400
|
||||
(void()) main()
|
||||
(bool~) main::$0
|
||||
@ -148,7 +148,7 @@ Target platform is c64basic / MOS6502X
|
||||
// Global Constants & labels
|
||||
.label SCREEN = $400
|
||||
.encoding "petscii_mixed"
|
||||
.const CH = -1
|
||||
.const CH = '\$ff'
|
||||
// @begin
|
||||
__bbegin:
|
||||
// [1] phi from @begin to @1 [phi:@begin->@1]
|
||||
@ -206,7 +206,7 @@ main: {
|
||||
jmp __b1
|
||||
}
|
||||
// File Data
|
||||
MESSAGE: .text @"qwe\$ffasd\$ferty"
|
||||
MESSAGE: .text @"q\$ffw\$60e\$ddr"
|
||||
.byte 0
|
||||
|
||||
REGISTER UPLIFT POTENTIAL REGISTERS
|
||||
@ -237,7 +237,7 @@ ASSEMBLER BEFORE OPTIMIZATION
|
||||
// Global Constants & labels
|
||||
.label SCREEN = $400
|
||||
.encoding "petscii_mixed"
|
||||
.const CH = -1
|
||||
.const CH = '\$ff'
|
||||
// @begin
|
||||
__bbegin:
|
||||
// [1] phi from @begin to @1 [phi:@begin->@1]
|
||||
@ -291,7 +291,7 @@ main: {
|
||||
jmp __b1
|
||||
}
|
||||
// File Data
|
||||
MESSAGE: .text @"qwe\$ffasd\$ferty"
|
||||
MESSAGE: .text @"q\$ffw\$60e\$ddr"
|
||||
.byte 0
|
||||
|
||||
ASSEMBLER OPTIMIZATIONS
|
||||
@ -322,8 +322,8 @@ FINAL SYMBOL TABLE
|
||||
(label) @1
|
||||
(label) @begin
|
||||
(label) @end
|
||||
(const byte) CH = (byte) '刺'pm
|
||||
(const byte*) MESSAGE[] = (byte*) "qwe刺asd茶rty"pm
|
||||
(const byte) CH = (byte) '▒'pm
|
||||
(const byte*) MESSAGE[] = (byte*) "q▒w褐e│r"pm
|
||||
(const nomodify byte*) SCREEN = (byte*) 1024
|
||||
(void()) main()
|
||||
(label) main::@1
|
||||
@ -350,7 +350,7 @@ Score: 267
|
||||
// Global Constants & labels
|
||||
.label SCREEN = $400
|
||||
.encoding "petscii_mixed"
|
||||
.const CH = -1
|
||||
.const CH = '\$ff'
|
||||
// @begin
|
||||
// [1] phi from @begin to @1 [phi:@begin->@1]
|
||||
// @1
|
||||
@ -393,6 +393,6 @@ main: {
|
||||
jmp __b1
|
||||
}
|
||||
// File Data
|
||||
MESSAGE: .text @"qwe\$ffasd\$ferty"
|
||||
MESSAGE: .text @"q\$ffw\$60e\$ddr"
|
||||
.byte 0
|
||||
|
||||
|
@ -1,8 +1,8 @@
|
||||
(label) @1
|
||||
(label) @begin
|
||||
(label) @end
|
||||
(const byte) CH = (byte) '刺'pm
|
||||
(const byte*) MESSAGE[] = (byte*) "qwe刺asd茶rty"pm
|
||||
(const byte) CH = (byte) '▒'pm
|
||||
(const byte*) MESSAGE[] = (byte*) "q▒w褐e│r"pm
|
||||
(const nomodify byte*) SCREEN = (byte*) 1024
|
||||
(void()) main()
|
||||
(label) main::@1
|
||||
|
Loading…
Reference in New Issue
Block a user