1
0
mirror of https://gitlab.com/camelot/kickc.git synced 2025-04-08 14:37:40 +00:00

Merge remote-tracking branch 'origin/master' into master

# Conflicts:
#	src/main/fragment/cache/fragment-cache-csg65ce02.asm
#	src/main/fragment/cache/fragment-cache-mega45gs02.asm
#	src/main/fragment/cache/fragment-cache-mos6502.asm
#	src/main/fragment/cache/fragment-cache-mos6502x.asm
#	src/main/fragment/cache/fragment-cache-wdc65c02.asm
This commit is contained in:
jespergravgaard 2020-12-03 01:38:25 +01:00
commit 63bc6e0a8e
342 changed files with 69609 additions and 55368 deletions
.idea/libraries
README.mdkickc.imlpom.xml
repo/dk/camelot64/kickass/xexplugin/kickassxexformat
src/main

@ -0,0 +1,13 @@
<component name="libraryTable">
<library name="Maven: dk.camelot64.kickass.xexplugin:kickassxexformat:1.2">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/dk/camelot64/kickass/xexplugin/kickassxexformat/1.2/kickassxexformat-1.2.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/dk/camelot64/kickass/xexplugin/kickassxexformat/1.2/kickassxexformat-1.2-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/dk/camelot64/kickass/xexplugin/kickassxexformat/1.2/kickassxexformat-1.2-sources.jar!/" />
</SOURCES>
</library>
</component>

@ -1,13 +1,13 @@
<component name="libraryTable">
<library name="Maven: info.picocli:picocli:4.2.0">
<library name="Maven: info.picocli:picocli:4.5.2">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/info/picocli/picocli/4.2.0/picocli-4.2.0.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/info/picocli/picocli/4.5.2/picocli-4.5.2.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/info/picocli/picocli/4.2.0/picocli-4.2.0-javadoc.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/info/picocli/picocli/4.5.2/picocli-4.5.2-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/info/picocli/picocli/4.2.0/picocli-4.2.0-sources.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/info/picocli/picocli/4.5.2/picocli-4.5.2-sources.jar!/" />
</SOURCES>
</library>
</component>

@ -4,7 +4,7 @@ KickC is a C-compiler for creating optimized and readable 6502 assembler code.
The KickC language is classic C with some limitations, some modifications and some extensions to ensure an optimal fit for creating 6502 assembler code.
* [Download](https://gitlab.com/camelot/kickc/releases) the newest Release
* [Download](https://gitlab.com/camelot/kickc/-/releases) the newest Release
* [Read](https://docs.google.com/document/d/1JE-Lt5apM-g4tZN3LS4TDbPKYgXuBz294enS9Oc4HXM/edit?usp=sharing) the Reference Manual

@ -22,9 +22,10 @@
<orderEntry type="library" scope="TEST" name="Maven: org.opentest4j:opentest4j:1.2.0" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.junit.platform:junit-platform-commons:1.6.2" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.junit.jupiter:junit-jupiter-api:5.6.2" level="project" />
<orderEntry type="library" name="Maven: cml.kickass:kickassembler:5.16-65ce02.h" level="project" />
<orderEntry type="library" name="Maven: info.picocli:picocli:4.2.0" level="project" />
<orderEntry type="library" name="Maven: info.picocli:picocli:4.5.2" level="project" />
<orderEntry type="library" name="Maven: javax.json:javax.json-api:1.1.4" level="project" />
<orderEntry type="library" name="Maven: org.glassfish:javax.json:1.1.4" level="project" />
<orderEntry type="library" name="Maven: cml.kickass:kickassembler:5.16-65ce02.h" level="project" />
<orderEntry type="library" name="Maven: dk.camelot64.kickass.xexplugin:kickassxexformat:1.2" level="project" />
</component>
</module>

17
pom.xml

@ -41,15 +41,10 @@
<version>5.6.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>cml.kickass</groupId>
<artifactId>kickassembler</artifactId>
<version>5.16-65ce02.h</version>
</dependency>
<dependency>
<groupId>info.picocli</groupId>
<artifactId>picocli</artifactId>
<version>4.2.0</version>
<version>4.5.2</version>
</dependency>
<dependency>
<groupId>javax.json</groupId>
@ -61,6 +56,16 @@
<artifactId>javax.json</artifactId>
<version>1.1.4</version>
</dependency>
<dependency>
<groupId>cml.kickass</groupId>
<artifactId>kickassembler</artifactId>
<version>5.16-65ce02.h</version>
</dependency>
<dependency>
<groupId>dk.camelot64.kickass.xexplugin</groupId>
<artifactId>kickassxexformat</artifactId>
<version>1.2</version>
</dependency>
</dependencies>
<build>

@ -0,0 +1,4 @@
#NOTE: This is a Maven Resolver internal implementation file, its format can be changed without prior notice.
#Sun Nov 15 00:38:04 CET 2020
kickassxexformat-1.0.jar>=
kickassxexformat-1.0.pom>=

@ -0,0 +1 @@
94a44ac4f920430017256c0adc7c907f

@ -0,0 +1 @@
fcd40077f803f35d9bed3de427db21e92ba039a0

@ -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>dk.camelot64.kickass.xexplugin</groupId>
<artifactId>kickassxexformat</artifactId>
<version>1.0</version>
<description>POM was created from install:install-file</description>
</project>

@ -0,0 +1 @@
df3752a1ed930cd6074d32aa8805977a

@ -0,0 +1 @@
11aa7e9264382c8b9e96034541035884887c94ec

@ -0,0 +1,4 @@
#NOTE: This is a Maven Resolver internal implementation file, its format can be changed without prior notice.
#Sun Nov 15 09:50:50 CET 2020
kickassxexformat-1.1.jar>=
kickassxexformat-1.1.pom>=

@ -0,0 +1 @@
1201db12a8d649e9628019b9b983eb6f

@ -0,0 +1 @@
4cce302cdbccf560c08f13295ac789136603844a

@ -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>dk.camelot64.kickass.xexplugin</groupId>
<artifactId>kickassxexformat</artifactId>
<version>1.1</version>
<description>POM was created from install:install-file</description>
</project>

@ -0,0 +1 @@
61fb4ac35772777c2e9901c22410e8ae

@ -0,0 +1 @@
0bf6368d2e7dc168cfd09c6112617d317f5b4f36

@ -0,0 +1,4 @@
#NOTE: This is a Maven Resolver internal implementation file, its format can be changed without prior notice.
#Wed Nov 18 17:48:28 CET 2020
kickassxexformat-1.2.jar>=
kickassxexformat-1.2.pom>=

@ -0,0 +1 @@
092dfeaff56fdc74bc72b701cff3f9ef

@ -0,0 +1 @@
e7e7587b423fb6152aece2c69173ea6c90e6f4ab

@ -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>dk.camelot64.kickass.xexplugin</groupId>
<artifactId>kickassxexformat</artifactId>
<version>1.2</version>
<description>POM was created from install:install-file</description>
</project>

@ -0,0 +1 @@
7e02897843b4f5b6f6f991878f196a5e

@ -0,0 +1 @@
a6800b865b17c215b652bae5a5eca8454f8951d6

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<metadata>
<groupId>dk.camelot64.kickass.xexplugin</groupId>
<artifactId>kickassxexformat</artifactId>
<versioning>
<release>1.2</release>
<versions>
<version>1.0</version>
<version>1.1</version>
<version>1.2</version>
</versions>
<lastUpdated>20201118164828</lastUpdated>
</versioning>
</metadata>

@ -0,0 +1 @@
b4b709d72a8051aae14cae9fb1386164

@ -0,0 +1 @@
980ed2ad1b45b3b008686eaedb5cffab6d468449

@ -0,0 +1,9 @@
lda {c1}
sta $fe
lda {c1}+1
sta $ff
lda #<c2
sta ($fe),y
iny
lda #>c2
sta ($fe),y

@ -0,0 +1,9 @@
lda {c1}
sta $fe
lda {c1}+1
sta $ff
lda m1
sta ($fe),y
iny
lda m1+1
sta ($fe),y

@ -0,0 +1,2 @@
clc
adc {m1}+1

@ -0,0 +1,5 @@
cmp {m1}
bcc !+
lda {m1}+1
beq {la1}
!:

@ -0,0 +1,4 @@
lsr
sta {m1}
lda #0
sta {m1}+1

@ -0,0 +1,4 @@
ldy {m1}+1
bne {la1}
cmp {m1}
bcc {la1}

@ -1,7 +1,5 @@
lda {m1}+1
bne {la1}
lda {m1}
cmp #{c1}
beq !+
bcs {la1}
!:
lda #{c1}
cmp {m1}
bcc {la1}

@ -0,0 +1,4 @@
lda {m1}+1
bne {la1}
cpx {m1}
bcc {la1}

@ -0,0 +1,4 @@
lda {m1}+1
bne {la1}
cpy {m1}
bcc {la1}

@ -53,6 +53,9 @@ public class KickC implements Callable<Integer> {
@CommandLine.Option(names = {"-a"}, description = "Assemble the output file using KickAssembler. Produces a binary file.")
private boolean assemble = false;
@CommandLine.Option(names = {"-Xassembler"}, description = "Passes the next option to the assembler. The option should generally be quoted. This option can be repeated to pass multiple options.")
private List<String> assemblerOptions = null;
@CommandLine.Option(names = {"-e"}, description = "Execute the assembled binary file using an appropriate emulator. The emulator chosen depends on the target platform.")
private boolean execute = false;
@ -181,6 +184,8 @@ public class KickC implements Callable<Integer> {
public static void main(String[] args) {
final CommandLine commandLine = new CommandLine(new KickC());
commandLine.setTrimQuotes(true);
commandLine.setUnmatchedOptionsAllowedAsOptionParameters(true);
final int exitCode = commandLine.execute(args);
System.exit(exitCode);
}
@ -379,7 +384,7 @@ public class KickC implements Callable<Integer> {
compiler.compile(cFiles, effectiveDefines);
} catch(CompileError e) {
// Print the error and exit with compile error
System.err.println(e.getMessage());
System.err.println(e.format());
return COMPILE_ERROR;
}
@ -438,6 +443,10 @@ public class KickC implements Callable<Integer> {
assembleCommand.add("-vicesymbols");
assembleCommand.add("-showmem");
assembleCommand.add("-debugdump");
// Add passed options
if(assemblerOptions !=null)
assembleCommand.addAll(assemblerOptions);
if(verbose) {
System.out.print("Assembling command: java -jar KickAss.jar ");
for(String cmd : assembleCommand) {
@ -454,18 +463,19 @@ public class KickC implements Callable<Integer> {
CharToPetsciiConverter.setCurrentEncoding("screencode_mixed");
kasmResult = KickAssembler65CE02.main2(assembleCommand.toArray(new String[0]));
} catch(Throwable e) {
throw new CompileError("KickAssembling file failed! ", e);
System.err.println("KickAssembling file failed! "+e.getMessage());
return COMPILE_ERROR;
} finally {
System.setOut(new PrintStream(new FileOutputStream(FileDescriptor.out)));
}
if(kasmResult != 0) {
throw new CompileError("KickAssembling file failed! " + kasmLogOutputStream.toString());
System.err.println("KickAssembling file failed! " + kasmLogOutputStream.toString());
return COMPILE_ERROR;
}
}
// Execute the binary file if instructed
if(emulator != null) {
// Find commandline options for the emulator
String emuOptions = "";
if(emulator.equals("C64Debugger")) {
@ -478,14 +488,18 @@ public class KickC implements Callable<Integer> {
Path viceSymbolsPath = outputDir.resolve(outputFileNameBase + ".vs");
emuOptions = "-moncommands " + viceSymbolsPath.toAbsolutePath().toString() + " ";
}
System.out.println("Executing " + outputBinaryFilePath + " using " + emulator);
String executeCommand = emulator + " " + emuOptions + outputBinaryFilePath.toAbsolutePath().toString();
if(verbose) {
System.out.println("Executing command: " + executeCommand);
}
Process process = Runtime.getRuntime().exec(executeCommand);
process.waitFor();
try {
Process process = Runtime.getRuntime().exec(executeCommand);
process.waitFor();
} catch(Throwable e) {
System.err.println("Executing emulator failed! "+e.getMessage());
return COMPILE_ERROR;
}
}
}

@ -19,6 +19,14 @@ public class SourceLoader {
* @return The file if found. null if not.
*/
public static File loadFile(String fileName, Path currentPath, List<String> searchPaths) {
File fileAbs = new File(fileName);
if(fileAbs.isAbsolute())
if(fileAbs.exists())
return fileAbs;
else
return null;
// File name is relative - look through search paths
List<String> allSearchPaths = new ArrayList<>();
if(currentPath != null)
allSearchPaths.add(currentPath.toString());

@ -84,8 +84,7 @@ public class TmpDirManager {
Path todoPath = new File(todoPathAbs).toPath();
boolean success = deleteTmpDir(todoPath);
if(!success) {
failedDirs.add(todoPath);
//System.out.println("Cannot delete postponed temporary folder - postponing again " + todoPathAbs);
System.err.println("Cannot delete postponed temporary folder - skipping " + todoPathAbs);
} else {
//System.out.println("Successfully deleted postponed temporary folder " + todoPathAbs);
}

@ -99,7 +99,7 @@ public class AsmFormat {
")";
}
// Handle non-associative operators - only handle right side since parser is left-associativeA-B-C = (A-B)-C
// Handle non-associative operators - only handle right side since parser is left-associative A-B-C = (A-B)-C
boolean rightParenthesis = false;
if(!operator.isAssociative()) {
if(right instanceof ConstantBinary && ((ConstantBinary) right).getOperator().equals(operator)) {

@ -79,7 +79,7 @@ public class AsmFragmentTemplate {
*/
private void initAsm() {
// Parse the body ASM
this.bodyAsm = AsmParser.parseAsm(this.body, new StatementSource(signature + ".asm", 1, this.body, 0, 0));
this.bodyAsm = AsmParser.parseAsm(this.body, new StatementSource(signature + ".asm", 1, 1, this.body, -1, -1));
// Generate a dummy instance to find clobber & cycles
ProgramScope scope = new ProgramScope();
LinkedHashMap<String, Value> bindings = new LinkedHashMap<>();

@ -362,6 +362,8 @@ class AsmFragmentTemplateSynthesisRule {
String rvalAa = ".*=.*aa.*|.*_.*aa.*|...aa_(lt|gt|le|ge|eq|neq)_.*";
String rvalXx = ".*=.*xx.*|.*_.*xx.*|...xx_(lt|gt|le|ge|eq|neq)_.*";
String rvalYy = ".*=.*yy.*|.*_.*yy.*|...yy_(lt|gt|le|ge|eq|neq)_.*";
String rvalYy2 = ".*=.*yy.*";
String rvalXx2 = ".*=.*xx.*";
String rvalZz = ".*=.*zz.*|.*_.*zz.*|...zz_(lt|gt|le|ge|eq|neq)_.*";
String rvalZ1 = ".*=.*z1.*|.*_.*z1.*|...z1_(lt|gt|le|ge|eq|neq)_.*";
String rvalZ2 = ".*=.*z2.*|.*_.*z2.*|...z2_(lt|gt|le|ge|eq|neq)_.*";
@ -775,17 +777,23 @@ class AsmFragmentTemplateSynthesisRule {
// Rewrite left-size C1,y to use AA and a STA C1,y
synths.add(new AsmFragmentTemplateSynthesisRule("pb(.)c1_derefidx_vbuyy=(.*)", null, null, "vb$1aa=$2", "sta {c1},y", null, "yy"));
// Rewrite C1,y to save and reload YY from $FF
synths.add(new AsmFragmentTemplateSynthesisRule("pb(.)c1_derefidx_vbuyy=(.*)", null, "sty $ff\n" , "vb$1aa=$2", "ldy $ff\nsta {c1},y", null));
synths.add(new AsmFragmentTemplateSynthesisRule("pb(.)c1_derefidx_vbuyy=(.*)", null, "sty $ff" , "vb$1aa=$2", "ldy $ff\nsta {c1},y", null));
// Rewrite C1,y to use AA
synths.add(new AsmFragmentTemplateSynthesisRule("pb(.)c1_derefidx_vbuyy=(.*)", null, null , "vb$1aa=$2", "sta {c1},y", null, "yy"));
// Rewrite (Z1),y to save and reload YY from $FF
synths.add(new AsmFragmentTemplateSynthesisRule("pb(.)z1_derefidx_vbuyy=(.*)", twoZM1, "sty $ff\n" , "vb$1aa=$2", "ldy $ff\nsta ({z1}),y", mapZM1));
synths.add(new AsmFragmentTemplateSynthesisRule("pb(.)z1_derefidx_vbuyy=(.*)", twoZM1, "sty $ff" , "vb$1aa=$2", "ldy $ff\nsta ({z1}),y", mapZM1));
// Rewrite (Z1),y to use AA
synths.add(new AsmFragmentTemplateSynthesisRule("pb(.)z1_derefidx_vbuyy=(.*)", twoZM1, null , "vb$1aa=$2", "sta ({z1}),y", mapZM1, "yy"));
if(targetCpu.getCpu65xx().hasRegisterZ())
// Rewrite (Z1),z to save and reload ZZ from $FF
synths.add(new AsmFragmentTemplateSynthesisRule("pb(.)z1_derefidx_vbuzz=(.*)", twoZM1, "stz $ff\n" , "vb$1aa=$2", "ldz $ff\nsta ({z1}),z", mapZM1));
synths.add(new AsmFragmentTemplateSynthesisRule("pb(.)z1_derefidx_vbuzz=(.*)", twoZM1, "stz $ff" , "vb$1aa=$2", "ldz $ff\nsta ({z1}),z", mapZM1));
// Rewrite left-size C1,x to use AA and a STA C1,x
synths.add(new AsmFragmentTemplateSynthesisRule("pb(.)c1_derefidx_vbuxx=(.*)", null, null, "vb$1aa=$2", "sta {c1},x", null, "xx"));
// Rewrite C1,x to save and reload XX from $FF
synths.add(new AsmFragmentTemplateSynthesisRule("pb(.)c1_derefidx_vbuxx=(.*)", null, "stx $ff\n" , "vb$1aa=$2", "ldx $ff\nsta {c1},x", null));
synths.add(new AsmFragmentTemplateSynthesisRule("pb(.)c1_derefidx_vbuxx=(.*)", null, "stx $ff" , "vb$1aa=$2", "ldx $ff\nsta {c1},x", null));
// Rewrite C1,x to use AA
synths.add(new AsmFragmentTemplateSynthesisRule("pb(.)c1_derefidx_vbuxx=(.*)", null, null , "vb$1aa=$2", "sta {c1},x", null, "xx"));
// Rewrite (Z1),x to save Y to $FF and reload it into YY
synths.add(new AsmFragmentTemplateSynthesisRule("pb(.)z1_derefidx_vbuxx=(.*)", twoZM1, "stx $ff" , "vb$1aa=$2", "ldy $ff\nsta ({z1}),y", mapZM1));
if(targetCpu.getCpu65xx().hasRegisterZ())
@ -904,6 +912,11 @@ class AsmFragmentTemplateSynthesisRule {
// Remove any parenthesis ending up around values
synths.add(new AsmFragmentTemplateSynthesisRule("(.*)\\(([vp][bwd][us][mzcaxy][123456axyz])\\)(.*)", null, null, "$1$2$3", null, null));
// Rewrite (pbuc1_derefidx_vbuxx) to use YY
synths.add(new AsmFragmentTemplateSynthesisRule("(.*)\\(pb(.)c1_derefidx_vbuxx\\)(.*)", rvalYy+"|"+twoC1, "ldy {c1},x" , "$1vb$2yy$3", null, mapC1, "yy"));
// Rewrite 2 * (pbuc1_derefidx_vbuxx) to use YY
synths.add(new AsmFragmentTemplateSynthesisRule("(.*)\\(pb(.)c1_derefidx_vbuxx\\)(.*)\\(pb(.)c1_derefidx_vbuxx\\)(.*)", rvalYy+"|"+threeC1, "ldy {c1},x" , "$1vb$2yy$3vb$4yy$5", null, mapC1, "yy"));
synths.add(new AsmFragmentTemplateSynthesisRule("(.*)_derefidx_vbuz1_(.*)", rvalYy+"|"+twoZM1, "ldy {z1}", "$1_derefidx_vbuyy_$2", null, mapZM1));
if(targetCpu.getCpu65xx().hasRegisterZ())
synths.add(new AsmFragmentTemplateSynthesisRule("(.*)_derefidx_vbuz1_(.*)", rvalZz+"|"+twoZM1, "ldz {z1}", "$1_derefidx_vbuzz_$2", null, mapZM1));

@ -7,15 +7,15 @@ import org.antlr.v4.runtime.Token;
/** Signals some error in the code (or compilation) */
public class CompileError extends RuntimeException {
private String source;
private StatementSource source;
public CompileError(String message) {
super(message);
}
public CompileError(String message, StatementSource source) {
super(message+"\n"+(source==null?"":source.toString()));
this.source = (source==null?"":source.toString());
super(message);
this.source = source;
}
public CompileError(String message, Token token) {
@ -30,8 +30,25 @@ public class CompileError extends RuntimeException {
super(message, cause);
}
public String getSource() {
public StatementSource getSource() {
return source;
}
/**
* Formats the CompileError using the GCC format, so that it may be easily parsed by IDEs and automated tools.
* See https://www.gnu.org/prep/standards/html_node/Errors.html
* <ul>
* <li> sourcefile:lineno: message
* <li> sourcefile:lineno:column: message
* </ul>
*/
public String format() {
StatementSource source = getSource();
if(source != null && source.getFileName() != null) {
return source.format() + " error: " + getMessage();
} else {
return getMessage();
}
}
}

@ -38,7 +38,7 @@ public class Initializers {
} else {
// Add an zero-filled array initializer
if(typeSpec.getArraySpec().getArraySize() == null) {
throw new CompileError("Error! Array has no declared size. ", statementSource);
throw new CompileError("Array has no declared size.", statementSource);
}
return new ConstantArrayFilled(typePointer.getElementType(), typeSpec.getArraySpec().getArraySize());
}
@ -130,7 +130,7 @@ public class Initializers {
if(SymbolTypeConversion.assignmentTypeMatch(typeSpec.getType(), inferredType))
initValue = new CastValue(typeSpec.getType(), initValue);
else
throw new CompileError("ERROR! Type mismatch (" + typeSpec.getType().getTypeName() + ") cannot be assigned from (" + inferredType.getTypeName() + ").", source);
throw new CompileError("Type mismatch (" + typeSpec.getType().getTypeName() + ") cannot be assigned from (" + inferredType.getTypeName() + ").", source);
}
}
}

@ -47,8 +47,6 @@ public class Program {
/** Enable live ranges per call path optimization, which limits memory usage and code, but takes a lot of compile time. */
private boolean enableLiveRangeCallPath = true;
/** Absolute start address of the code. Null to start ad 0x080d. PASS 0-5 (STATIC) */
private Number programPc;
/** Reserved ZP addresses that the compiler cannot use. PASS 0-5 (STATIC) */
private List<Integer> reservedZps;
/** Resource files that should be copied to the output folder to be compiled with the generated ASM. PASS 0-5 (STATIC) */
@ -226,7 +224,6 @@ public class Program {
return getTargetPlatform().getCpu();
}
public StructVariableMemberUnwinding getStructVariableMemberUnwinding() {
return structVariableMemberUnwinding;
}
@ -513,19 +510,6 @@ public class Program {
this.reservedZps = reservedZps;
}
/**
* Set the absolute position of the program code
*
* @param programPc The address
*/
public void setProgramPc(Number programPc) {
this.programPc = programPc;
}
public Number getProgramPc() {
return programPc;
}
public CompileLog getLog() {
return log;
}
@ -534,7 +518,6 @@ public class Program {
this.log = log;
}
/**
* Get information about the size of the program
*

@ -26,6 +26,9 @@ public class TargetPlatform {
/** The target CPU. */
private TargetCpu cpu;
/** The default program start address. */
private Number startAddress;
/** The link script file. */
private File linkScriptFile;
@ -71,6 +74,14 @@ public class TargetPlatform {
this.cpu = cpu;
}
public Number getStartAddress() {
return startAddress;
}
public void setStartAddress(Number startAddress) {
this.startAddress = startAddress;
}
public File getLinkScriptFile() {
return linkScriptFile;
}

@ -177,7 +177,7 @@ public class VariableBuilderConfig {
Optimization optimization = getOptimization(paramElements);
MemoryArea memoryArea = getMemoryArea(paramElements);
if((memoryArea == null && optimization == null) || paramElements.size() > 0)
throw new CompileError("Error! Malformed var_model parameter " + pragmaParam, statementSource);
throw new CompileError("Malformed var_model parameter " + pragmaParam, statementSource);
for(Scope scope : scopes) {
for(Type type : types) {
MemoryArea mem = (memoryArea != null) ? memoryArea : getSetting(scope, type).memoryArea;

@ -4,7 +4,7 @@ import dk.camelot64.kickc.model.types.SymbolType;
import dk.camelot64.kickc.model.types.SymbolTypePointer;
import dk.camelot64.kickc.model.types.SymbolTypeStruct;
/** Constainer for all the expression operators */
/** Container for all the expression operators */
public class Operators {
public static final OperatorUnary INCREMENT = new OperatorIncrement(1);

@ -10,6 +10,8 @@ import org.antlr.v4.runtime.tree.ParseTree;
import org.antlr.v4.runtime.tree.TerminalNode;
import java.io.Serializable;
import java.nio.file.Path;
import java.nio.file.Paths;
/** Contains information about the source of a program statement */
public class StatementSource implements Serializable {
@ -18,6 +20,8 @@ public class StatementSource implements Serializable {
private String fileName;
/** The line number of the start of the source. */
private Integer lineNumber;
/** The char position on the line of the start of the source. */
private Integer charPosInLine;
/** The source code. */
private String code;
/** The index of the first char of the source in the file. */
@ -25,24 +29,26 @@ public class StatementSource implements Serializable {
/** The index of the last char of the source in the file. */
private int stopIndex;
public StatementSource(String fileName, Integer lineNumber, String code, int startIndex, int stopIndex) {
public StatementSource(String fileName, Integer lineNumber, Integer charPosInLine, String code, int startIndex, int stopIndex) {
this.fileName = fileName;
this.lineNumber = lineNumber;
this.charPosInLine = charPosInLine;
this.code = code;
this.startIndex = startIndex;
this.stopIndex = stopIndex;
}
/** An empty statement source. */
public static StatementSource NONE = new StatementSource(null, null, null, 0, 0);
public static StatementSource NONE = new StatementSource(null, null, null, null, -1, -1);
public StatementSource(Token tokenStart, Token tokenStop) {
if(tokenStart != null && tokenStart.getStartIndex() != 0) {
if(tokenStart != null && tokenStart.getStartIndex() >= 0) {
this.startIndex = tokenStart.getStartIndex();
CharStream stream = tokenStart.getInputStream();
this.fileName = stream.getSourceName();
this.lineNumber = tokenStart.getLine();
if(tokenStop != null && tokenStop.getStopIndex() != 0) {
this.charPosInLine = tokenStart.getCharPositionInLine();
if(tokenStop != null && tokenStop.getStopIndex() >= this.startIndex) {
this.stopIndex = tokenStop.getStopIndex();
Interval interval = getInterval();
this.code = stream.getText(interval);
@ -198,6 +204,10 @@ public class StatementSource implements Serializable {
return lineNumber;
}
public Integer getCharPosInLine() {
return charPosInLine;
}
public String getCode() {
return code;
}
@ -212,22 +222,28 @@ public class StatementSource implements Serializable {
@Override
public String toString() {
if(getFileName() != null) {
return "File " + getFileName() + "\nLine " + getLineNumber() + "\n" + getCode();
} else {
return "";
}
return format();
}
public String toStringShort() {
if(getFileName() != null) {
String fileName = getFileName();
final int slashIdx = fileName.lastIndexOf("/");
if(slashIdx>0)
fileName = fileName.substring(slashIdx+1);
return "File " + fileName + "\nLine " + getLineNumber() + "\n" + getCode();
} else {
/**
* Format the statement source in GCC format
* https://www.gnu.org/prep/standards/html_node/Errors.html
* <li> sourcefile:lineno:
* <li> sourcefile:lineno:column:
*
* @return The formatted source location
*/
public String format() {
if(getFileName() == null)
return "";
Path sourcePath = Paths.get(getFileName());
String relativeFileName = sourcePath.toAbsolutePath().toString();
if(getCharPosInLine() == null || getCharPosInLine() == 0) {
// No relevant column idx - format without
return String.format("%s:%s:", relativeFileName, getLineNumber());
} else {
// Format with column idx
return String.format("%s:%s:%s:", relativeFileName, getLineNumber(), getCharPosInLine() + 1);
}
}

@ -66,14 +66,20 @@ public enum StringEncoding {
return PETSCII_MIXED;
} else if(suffix.contains("pu")) {
return PETSCII_UPPER;
} else if(suffix.contains("p")) {
return PETSCII_MIXED;
} else if(suffix.contains("sm")) {
return SCREENCODE_MIXED;
} else if(suffix.contains("su")) {
return SCREENCODE_UPPER;
} else if(suffix.contains("as")) {
return ASCII;
} else if(suffix.contains("at")) {
return ATASCII;
} else if(suffix.contains("sa")) {
return SCREENCODE_ATARI;
} else if(suffix.contains("s")) {
return SCREENCODE_MIXED;
} else if(suffix.contains("p")) {
return PETSCII_MIXED;
} else {
return defaultEncoding;
}

@ -22,7 +22,7 @@ public class AsmParser {
@Override
public void syntaxError(Recognizer<?, ?> recognizer, Object offendingSymbol, int line, int charPositionInLine, String msg, RecognitionException e) {
StatementSource subSource =
new StatementSource(source.getFileName(), source.getLineNumber() + line, source.getCode(), source.getStartIndex(), source.getStopIndex());
new StatementSource(source.getFileName(), source.getLineNumber() + line, charPositionInLine, source.getCode(), source.getStartIndex(), source.getStopIndex());
throw new CompileError("Error parsing assembler. " + msg, subSource);
}

@ -5,6 +5,7 @@ import dk.camelot64.kickc.SourceLoader;
import dk.camelot64.kickc.model.CompileError;
import dk.camelot64.kickc.model.Program;
import dk.camelot64.kickc.model.TargetPlatform;
import dk.camelot64.kickc.model.statements.StatementSource;
import dk.camelot64.kickc.preprocessor.CPreprocessor;
import org.antlr.v4.runtime.*;
@ -38,7 +39,7 @@ public class CParser {
public static final String PRAGMA_ENCODING = "encoding";
public static final String PRAGMA_CODE_SEG = "code_seg";
public static final String PRAGMA_DATA_SEG = "data_seg";
public static final String PRAGMA_PC = "pc";
public static final String PRAGMA_START_ADDRESS = "start_address";
public static final String PRAGMA_CALLING = "calling";
public static final String PRAGMA_ZP_RESERVE = "zp_reserve";
public static final String PRAGMA_CONSTRUCTOR_FOR = "constructor_for";
@ -95,7 +96,8 @@ public class CParser {
int charPositionInLine,
String msg,
RecognitionException e) {
throw new CompileError("Error parsing file " + recognizer.getInputStream().getSourceName() + "\n - Line: " + line + "\n - Message: " + msg);
StatementSource source = new StatementSource(recognizer.getInputStream().getSourceName(), line, charPositionInLine, null, -1, -1);
throw new CompileError("Error parsing file: " + msg, source);
}
});
}
@ -290,7 +292,8 @@ public class CParser {
int charPositionInLine,
String msg,
RecognitionException e) {
throw new CompileError("Error parsing file " + charStream.getSourceName() + "\n - Line: " + line + "\n - Message: " + msg);
StatementSource source = new StatementSource(charStream.getSourceName(), line, charPositionInLine, null, -1,-1);
throw new CompileError("Error parsing file: " + msg, source);
}
});
return lexer;

@ -28,7 +28,6 @@ public class CTargetPlatformParser {
/** The file extension used for target platform files. */
public static final String FILE_EXTENSION = "tgt";
public static TargetPlatform parseTargetPlatformFile(String platformName, File platformFile, Path currentFolder, List<String> platformSearchPaths) {
try {
final JsonReader jsonReader = Json.createReader(new BufferedInputStream(new FileInputStream(platformFile)));
@ -44,6 +43,13 @@ public class CTargetPlatformParser {
if(linkScriptName != null)
targetPlatform.setLinkScriptFile(SourceLoader.loadFile(linkScriptName, currentFolder, platformSearchPaths));
}
{
final String startAddress = platformJson.getString("start_address", null);
if(startAddress != null) {
final Number startAddressNumber = NumberParser.parseLiteral(startAddress);
targetPlatform.setStartAddress(startAddressNumber.intValue());
}
}
{
final String emulatorCommand = platformJson.getString("emulator", null);
if(emulatorCommand != null)

@ -143,7 +143,7 @@ fragment NAME_START : [a-zA-Z_];
fragment NAME_CHAR : [a-zA-Z0-9_];
// Strings and chars
STRING : '"' ('\\"' | ~'"')* '"' [z]?([ps][mu]?)?[z]? ;
STRING : '"' ('\\"' | ~'"')* '"' [z]?([aps][tsmua]?)?[z]? ;
CHAR : '\'' ('\\'(['"rfn]|'x'[0-9a-f][0-9a-f]) | ~'\'' ) '\'';
// White space on hidden channel 1

File diff suppressed because one or more lines are too long

@ -446,98 +446,98 @@ public class KickCLexer extends Lexer {
"\u0093\u0135\2\u0137\2\u0139\u0094\u013b\u0095\u013d\u0096\u013f\u0097"+
"\u0141\u0098\u0143\u0099\u0145\u009a\u0147\u009b\5\2\3\4\25\4\2uuww\7"+
"\2dfkknnuuyy\4\2DDdd\3\2\62\63\3\2\62;\5\2\62;CHch\5\2C\\aac|\6\2\62;"+
"C\\aac|\3\2$$\3\2||\4\2rruu\4\2ooww\7\2$$))hhpptt\4\2\62;ch\3\2))\6\2"+
"\13\f\17\17\"\"\u00a2\u00a2\4\2\f\f\17\17\4\2--//\7\2/;C\\^^aac|\2\u0854"+
"\2\5\3\2\2\2\2\7\3\2\2\2\2\t\3\2\2\2\2\13\3\2\2\2\2\r\3\2\2\2\2\17\3\2"+
"\2\2\2\21\3\2\2\2\2\23\3\2\2\2\2\25\3\2\2\2\2\27\3\2\2\2\2\31\3\2\2\2"+
"\2\33\3\2\2\2\2\35\3\2\2\2\2\37\3\2\2\2\2!\3\2\2\2\2#\3\2\2\2\2%\3\2\2"+
"\2\2\'\3\2\2\2\2)\3\2\2\2\2+\3\2\2\2\2-\3\2\2\2\2/\3\2\2\2\2\61\3\2\2"+
"\2\2\63\3\2\2\2\2\65\3\2\2\2\2\67\3\2\2\2\29\3\2\2\2\2;\3\2\2\2\2=\3\2"+
"\2\2\2?\3\2\2\2\2A\3\2\2\2\2C\3\2\2\2\2E\3\2\2\2\2G\3\2\2\2\2I\3\2\2\2"+
"\2K\3\2\2\2\2M\3\2\2\2\2O\3\2\2\2\2Q\3\2\2\2\2S\3\2\2\2\2U\3\2\2\2\2W"+
"\3\2\2\2\2Y\3\2\2\2\2[\3\2\2\2\2]\3\2\2\2\2_\3\2\2\2\2a\3\2\2\2\2c\3\2"+
"\2\2\2e\3\2\2\2\2g\3\2\2\2\2i\3\2\2\2\2k\3\2\2\2\2m\3\2\2\2\2o\3\2\2\2"+
"\2q\3\2\2\2\2s\3\2\2\2\2u\3\2\2\2\2w\3\2\2\2\2y\3\2\2\2\2{\3\2\2\2\2}"+
"\3\2\2\2\2\177\3\2\2\2\2\u0081\3\2\2\2\2\u0083\3\2\2\2\2\u0085\3\2\2\2"+
"\2\u0087\3\2\2\2\2\u0089\3\2\2\2\2\u008b\3\2\2\2\2\u008d\3\2\2\2\2\u008f"+
"\3\2\2\2\2\u0091\3\2\2\2\2\u0093\3\2\2\2\2\u0095\3\2\2\2\2\u0097\3\2\2"+
"\2\2\u0099\3\2\2\2\2\u009b\3\2\2\2\2\u009d\3\2\2\2\2\u009f\3\2\2\2\2\u00a1"+
"\3\2\2\2\2\u00a3\3\2\2\2\2\u00a5\3\2\2\2\2\u00a7\3\2\2\2\2\u00a9\3\2\2"+
"\2\2\u00ab\3\2\2\2\2\u00ad\3\2\2\2\2\u00af\3\2\2\2\2\u00b1\3\2\2\2\2\u00b3"+
"\3\2\2\2\2\u00b5\3\2\2\2\2\u00b7\3\2\2\2\2\u00b9\3\2\2\2\2\u00bb\3\2\2"+
"\2\2\u00bd\3\2\2\2\2\u00bf\3\2\2\2\2\u00c1\3\2\2\2\2\u00c3\3\2\2\2\2\u00c5"+
"\3\2\2\2\2\u00c7\3\2\2\2\2\u00c9\3\2\2\2\2\u00cb\3\2\2\2\2\u00cd\3\2\2"+
"\2\2\u00cf\3\2\2\2\2\u00d1\3\2\2\2\2\u00d3\3\2\2\2\2\u00d5\3\2\2\2\2\u00dd"+
"\3\2\2\2\2\u00e3\3\2\2\2\2\u00e5\3\2\2\2\2\u00e7\3\2\2\2\2\u00e9\3\2\2"+
"\2\2\u00eb\3\2\2\2\3\u00ed\3\2\2\2\3\u00ef\3\2\2\2\3\u00f1\3\2\2\2\3\u00f3"+
"\3\2\2\2\3\u00f5\3\2\2\2\3\u00f7\3\2\2\2\3\u00f9\3\2\2\2\3\u00fb\3\2\2"+
"\2\3\u00fd\3\2\2\2\3\u00ff\3\2\2\2\3\u0101\3\2\2\2\3\u0103\3\2\2\2\3\u0105"+
"\3\2\2\2\3\u0107\3\2\2\2\3\u0109\3\2\2\2\3\u010b\3\2\2\2\3\u010d\3\2\2"+
"\2\3\u010f\3\2\2\2\3\u0111\3\2\2\2\3\u0113\3\2\2\2\3\u0115\3\2\2\2\3\u0117"+
"\3\2\2\2\3\u0119\3\2\2\2\3\u011b\3\2\2\2\3\u011d\3\2\2\2\3\u011f\3\2\2"+
"\2\3\u0121\3\2\2\2\3\u0123\3\2\2\2\3\u0125\3\2\2\2\3\u012d\3\2\2\2\3\u012f"+
"\3\2\2\2\3\u0131\3\2\2\2\3\u0133\3\2\2\2\3\u0139\3\2\2\2\3\u013b\3\2\2"+
"\2\3\u013d\3\2\2\2\4\u013f\3\2\2\2\4\u0141\3\2\2\2\4\u0143\3\2\2\2\4\u0145"+
"\3\2\2\2\4\u0147\3\2\2\2\5\u0149\3\2\2\2\7\u014c\3\2\2\2\t\u014e\3\2\2"+
"\2\13\u0150\3\2\2\2\r\u0152\3\2\2\2\17\u0154\3\2\2\2\21\u0156\3\2\2\2"+
"\23\u0158\3\2\2\2\25\u015a\3\2\2\2\27\u015c\3\2\2\2\31\u015f\3\2\2\2\33"+
"\u0163\3\2\2\2\35\u0165\3\2\2\2\37\u0167\3\2\2\2!\u016a\3\2\2\2#\u016c"+
"\3\2\2\2%\u016e\3\2\2\2\'\u0170\3\2\2\2)\u0172\3\2\2\2+\u0174\3\2\2\2"+
"-\u0177\3\2\2\2/\u017a\3\2\2\2\61\u017c\3\2\2\2\63\u017e\3\2\2\2\65\u0180"+
"\3\2\2\2\67\u0182\3\2\2\29\u0185\3\2\2\2;\u0188\3\2\2\2=\u018b\3\2\2\2"+
"?\u018e\3\2\2\2A\u0190\3\2\2\2C\u0193\3\2\2\2E\u0196\3\2\2\2G\u0198\3"+
"\2\2\2I\u019b\3\2\2\2K\u019e\3\2\2\2M\u01b6\3\2\2\2O\u01b8\3\2\2\2Q\u01c0"+
"\3\2\2\2S\u01c6\3\2\2\2U\u01cd\3\2\2\2W\u01d4\3\2\2\2Y\u01da\3\2\2\2["+
"\u01e1\3\2\2\2]\u01ea\3\2\2\2_\u01f1\3\2\2\2a\u01fb\3\2\2\2c\u0204\3\2"+
"\2\2e\u0211\3\2\2\2g\u021b\3\2\2\2i\u0220\3\2\2\2k\u0226\3\2\2\2m\u022c"+
"\3\2\2\2o\u0231\3\2\2\2q\u0251\3\2\2\2s\u0253\3\2\2\2u\u0256\3\2\2\2w"+
"\u025b\3\2\2\2y\u0261\3\2\2\2{\u0264\3\2\2\2}\u0268\3\2\2\2\177\u026f"+
"\3\2\2\2\u0081\u0276\3\2\2\2\u0083\u027c\3\2\2\2\u0085\u0285\3\2\2\2\u0087"+
"\u028b\3\2\2\2\u0089\u0293\3\2\2\2\u008b\u0298\3\2\2\2\u008d\u029f\3\2"+
"\2\2\u008f\u02a4\3\2\2\2\u0091\u02ab\3\2\2\2\u0093\u02b2\3\2\2\2\u0095"+
"\u02ba\3\2\2\2\u0097\u02c2\3\2\2\2\u0099\u02cb\3\2\2\2\u009b\u02d0\3\2"+
"\2\2\u009d\u02d9\3\2\2\2\u009f\u02df\3\2\2\2\u00a1\u02e6\3\2\2\2\u00a3"+
"\u02f6\3\2\2\2\u00a5\u031d\3\2\2\2\u00a7\u0328\3\2\2\2\u00a9\u032a\3\2"+
"\2\2\u00ab\u0336\3\2\2\2\u00ad\u0340\3\2\2\2\u00af\u034b\3\2\2\2\u00b1"+
"\u0353\3\2\2\2\u00b3\u0360\3\2\2\2\u00b5\u0362\3\2\2\2\u00b7\u0369\3\2"+
"\2\2\u00b9\u0370\3\2\2\2\u00bb\u0378\3\2\2\2\u00bd\u037c\3\2\2\2\u00bf"+
"\u0382\3\2\2\2\u00c1\u0388\3\2\2\2\u00c3\u038f\3\2\2\2\u00c5\u0398\3\2"+
"\2\2\u00c7\u039d\3\2\2\2\u00c9\u03a4\3\2\2\2\u00cb\u03b5\3\2\2\2\u00cd"+
"\u03c3\3\2\2\2\u00cf\u03d4\3\2\2\2\u00d1\u03e8\3\2\2\2\u00d3\u03eb\3\2"+
"\2\2\u00d5\u03f4\3\2\2\2\u00d7\u03fb\3\2\2\2\u00d9\u03fd\3\2\2\2\u00db"+
"\u03ff\3\2\2\2\u00dd\u0401\3\2\2\2\u00df\u040a\3\2\2\2\u00e1\u040c\3\2"+
"\2\2\u00e3\u040e\3\2\2\2\u00e5\u0424\3\2\2\2\u00e7\u0432\3\2\2\2\u00e9"+
"\u0438\3\2\2\2\u00eb\u0443\3\2\2\2\u00ed\u0451\3\2\2\2\u00ef\u067d\3\2"+
"\2\2\u00f1\u067f\3\2\2\2\u00f3\u0681\3\2\2\2\u00f5\u0683\3\2\2\2\u00f7"+
"\u0685\3\2\2\2\u00f9\u0687\3\2\2\2\u00fb\u0689\3\2\2\2\u00fd\u068b\3\2"+
"\2\2\u00ff\u068d\3\2\2\2\u0101\u068f\3\2\2\2\u0103\u0692\3\2\2\2\u0105"+
"\u0695\3\2\2\2\u0107\u0697\3\2\2\2\u0109\u0699\3\2\2\2\u010b\u069b\3\2"+
"\2\2\u010d\u069d\3\2\2\2\u010f\u069f\3\2\2\2\u0111\u06a1\3\2\2\2\u0113"+
"\u06a4\3\2\2\2\u0115\u06a9\3\2\2\2\u0117\u06ae\3\2\2\2\u0119\u06b0\3\2"+
"\2\2\u011b\u06c0\3\2\2\2\u011d\u06c9\3\2\2\2\u011f\u06d9\3\2\2\2\u0121"+
"\u06db\3\2\2\2\u0123\u06e2\3\2\2\2\u0125\u06e6\3\2\2\2\u0127\u06ec\3\2"+
"\2\2\u0129\u06ee\3\2\2\2\u012b\u06f0\3\2\2\2\u012d\u06f2\3\2\2\2\u012f"+
"\u06fa\3\2\2\2\u0131\u0700\3\2\2\2\u0133\u0707\3\2\2\2\u0135\u070e\3\2"+
"\2\2\u0137\u0710\3\2\2\2\u0139\u0713\3\2\2\2\u013b\u0719\3\2\2\2\u013d"+
"\u0724\3\2\2\2\u013f\u0732\3\2\2\2\u0141\u073b\3\2\2\2\u0143\u0748\3\2"+
"\2\2\u0145\u074e\3\2\2\2\u0147\u0759\3\2\2\2\u0149\u014a\7}\2\2\u014a"+
"\u014b\b\2\2\2\u014b\6\3\2\2\2\u014c\u014d\7\177\2\2\u014d\b\3\2\2\2\u014e"+
"\u014f\7]\2\2\u014f\n\3\2\2\2\u0150\u0151\7_\2\2\u0151\f\3\2\2\2\u0152"+
"\u0153\7*\2\2\u0153\16\3\2\2\2\u0154\u0155\7+\2\2\u0155\20\3\2\2\2\u0156"+
"\u0157\7=\2\2\u0157\22\3\2\2\2\u0158\u0159\7<\2\2\u0159\24\3\2\2\2\u015a"+
"\u015b\7.\2\2\u015b\26\3\2\2\2\u015c\u015d\7\60\2\2\u015d\u015e\7\60\2"+
"\2\u015e\30\3\2\2\2\u015f\u0160\7\60\2\2\u0160\u0161\7\60\2\2\u0161\u0162"+
"\7\60\2\2\u0162\32\3\2\2\2\u0163\u0164\7A\2\2\u0164\34\3\2\2\2\u0165\u0166"+
"\7\60\2\2\u0166\36\3\2\2\2\u0167\u0168\7/\2\2\u0168\u0169\7@\2\2\u0169"+
" \3\2\2\2\u016a\u016b\7-\2\2\u016b\"\3\2\2\2\u016c\u016d\7/\2\2\u016d"+
"$\3\2\2\2\u016e\u016f\7,\2\2\u016f&\3\2\2\2\u0170\u0171\7\61\2\2\u0171"+
"(\3\2\2\2\u0172\u0173\7\'\2\2\u0173*\3\2\2\2\u0174\u0175\7-\2\2\u0175"+
"\u0176\7-\2\2\u0176,\3\2\2\2\u0177\u0178\7/\2\2\u0178\u0179\7/\2\2\u0179"+
".\3\2\2\2\u017a\u017b\7(\2\2\u017b\60\3\2\2\2\u017c\u017d\7\u0080\2\2"+
"\u017d\62\3\2\2\2\u017e\u017f\7`\2\2\u017f\64\3\2\2\2\u0180\u0181\7~\2"+
"\2\u0181\66\3\2\2\2\u0182\u0183\7>\2\2\u0183\u0184\7>\2\2\u01848\3\2\2"+
"\2\u0185\u0186\7@\2\2\u0186\u0187\7@\2\2\u0187:\3\2\2\2\u0188\u0189\7"+
"?\2\2\u0189\u018a\7?\2\2\u018a<\3\2\2\2\u018b\u018c\7#\2\2\u018c\u018d"+
"C\\aac|\3\2$$\3\2||\5\2ccrruu\5\2ccoouw\7\2$$))hhpptt\4\2\62;ch\3\2))"+
"\6\2\13\f\17\17\"\"\u00a2\u00a2\4\2\f\f\17\17\4\2--//\7\2/;C\\^^aac|\2"+
"\u0854\2\5\3\2\2\2\2\7\3\2\2\2\2\t\3\2\2\2\2\13\3\2\2\2\2\r\3\2\2\2\2"+
"\17\3\2\2\2\2\21\3\2\2\2\2\23\3\2\2\2\2\25\3\2\2\2\2\27\3\2\2\2\2\31\3"+
"\2\2\2\2\33\3\2\2\2\2\35\3\2\2\2\2\37\3\2\2\2\2!\3\2\2\2\2#\3\2\2\2\2"+
"%\3\2\2\2\2\'\3\2\2\2\2)\3\2\2\2\2+\3\2\2\2\2-\3\2\2\2\2/\3\2\2\2\2\61"+
"\3\2\2\2\2\63\3\2\2\2\2\65\3\2\2\2\2\67\3\2\2\2\29\3\2\2\2\2;\3\2\2\2"+
"\2=\3\2\2\2\2?\3\2\2\2\2A\3\2\2\2\2C\3\2\2\2\2E\3\2\2\2\2G\3\2\2\2\2I"+
"\3\2\2\2\2K\3\2\2\2\2M\3\2\2\2\2O\3\2\2\2\2Q\3\2\2\2\2S\3\2\2\2\2U\3\2"+
"\2\2\2W\3\2\2\2\2Y\3\2\2\2\2[\3\2\2\2\2]\3\2\2\2\2_\3\2\2\2\2a\3\2\2\2"+
"\2c\3\2\2\2\2e\3\2\2\2\2g\3\2\2\2\2i\3\2\2\2\2k\3\2\2\2\2m\3\2\2\2\2o"+
"\3\2\2\2\2q\3\2\2\2\2s\3\2\2\2\2u\3\2\2\2\2w\3\2\2\2\2y\3\2\2\2\2{\3\2"+
"\2\2\2}\3\2\2\2\2\177\3\2\2\2\2\u0081\3\2\2\2\2\u0083\3\2\2\2\2\u0085"+
"\3\2\2\2\2\u0087\3\2\2\2\2\u0089\3\2\2\2\2\u008b\3\2\2\2\2\u008d\3\2\2"+
"\2\2\u008f\3\2\2\2\2\u0091\3\2\2\2\2\u0093\3\2\2\2\2\u0095\3\2\2\2\2\u0097"+
"\3\2\2\2\2\u0099\3\2\2\2\2\u009b\3\2\2\2\2\u009d\3\2\2\2\2\u009f\3\2\2"+
"\2\2\u00a1\3\2\2\2\2\u00a3\3\2\2\2\2\u00a5\3\2\2\2\2\u00a7\3\2\2\2\2\u00a9"+
"\3\2\2\2\2\u00ab\3\2\2\2\2\u00ad\3\2\2\2\2\u00af\3\2\2\2\2\u00b1\3\2\2"+
"\2\2\u00b3\3\2\2\2\2\u00b5\3\2\2\2\2\u00b7\3\2\2\2\2\u00b9\3\2\2\2\2\u00bb"+
"\3\2\2\2\2\u00bd\3\2\2\2\2\u00bf\3\2\2\2\2\u00c1\3\2\2\2\2\u00c3\3\2\2"+
"\2\2\u00c5\3\2\2\2\2\u00c7\3\2\2\2\2\u00c9\3\2\2\2\2\u00cb\3\2\2\2\2\u00cd"+
"\3\2\2\2\2\u00cf\3\2\2\2\2\u00d1\3\2\2\2\2\u00d3\3\2\2\2\2\u00d5\3\2\2"+
"\2\2\u00dd\3\2\2\2\2\u00e3\3\2\2\2\2\u00e5\3\2\2\2\2\u00e7\3\2\2\2\2\u00e9"+
"\3\2\2\2\2\u00eb\3\2\2\2\3\u00ed\3\2\2\2\3\u00ef\3\2\2\2\3\u00f1\3\2\2"+
"\2\3\u00f3\3\2\2\2\3\u00f5\3\2\2\2\3\u00f7\3\2\2\2\3\u00f9\3\2\2\2\3\u00fb"+
"\3\2\2\2\3\u00fd\3\2\2\2\3\u00ff\3\2\2\2\3\u0101\3\2\2\2\3\u0103\3\2\2"+
"\2\3\u0105\3\2\2\2\3\u0107\3\2\2\2\3\u0109\3\2\2\2\3\u010b\3\2\2\2\3\u010d"+
"\3\2\2\2\3\u010f\3\2\2\2\3\u0111\3\2\2\2\3\u0113\3\2\2\2\3\u0115\3\2\2"+
"\2\3\u0117\3\2\2\2\3\u0119\3\2\2\2\3\u011b\3\2\2\2\3\u011d\3\2\2\2\3\u011f"+
"\3\2\2\2\3\u0121\3\2\2\2\3\u0123\3\2\2\2\3\u0125\3\2\2\2\3\u012d\3\2\2"+
"\2\3\u012f\3\2\2\2\3\u0131\3\2\2\2\3\u0133\3\2\2\2\3\u0139\3\2\2\2\3\u013b"+
"\3\2\2\2\3\u013d\3\2\2\2\4\u013f\3\2\2\2\4\u0141\3\2\2\2\4\u0143\3\2\2"+
"\2\4\u0145\3\2\2\2\4\u0147\3\2\2\2\5\u0149\3\2\2\2\7\u014c\3\2\2\2\t\u014e"+
"\3\2\2\2\13\u0150\3\2\2\2\r\u0152\3\2\2\2\17\u0154\3\2\2\2\21\u0156\3"+
"\2\2\2\23\u0158\3\2\2\2\25\u015a\3\2\2\2\27\u015c\3\2\2\2\31\u015f\3\2"+
"\2\2\33\u0163\3\2\2\2\35\u0165\3\2\2\2\37\u0167\3\2\2\2!\u016a\3\2\2\2"+
"#\u016c\3\2\2\2%\u016e\3\2\2\2\'\u0170\3\2\2\2)\u0172\3\2\2\2+\u0174\3"+
"\2\2\2-\u0177\3\2\2\2/\u017a\3\2\2\2\61\u017c\3\2\2\2\63\u017e\3\2\2\2"+
"\65\u0180\3\2\2\2\67\u0182\3\2\2\29\u0185\3\2\2\2;\u0188\3\2\2\2=\u018b"+
"\3\2\2\2?\u018e\3\2\2\2A\u0190\3\2\2\2C\u0193\3\2\2\2E\u0196\3\2\2\2G"+
"\u0198\3\2\2\2I\u019b\3\2\2\2K\u019e\3\2\2\2M\u01b6\3\2\2\2O\u01b8\3\2"+
"\2\2Q\u01c0\3\2\2\2S\u01c6\3\2\2\2U\u01cd\3\2\2\2W\u01d4\3\2\2\2Y\u01da"+
"\3\2\2\2[\u01e1\3\2\2\2]\u01ea\3\2\2\2_\u01f1\3\2\2\2a\u01fb\3\2\2\2c"+
"\u0204\3\2\2\2e\u0211\3\2\2\2g\u021b\3\2\2\2i\u0220\3\2\2\2k\u0226\3\2"+
"\2\2m\u022c\3\2\2\2o\u0231\3\2\2\2q\u0251\3\2\2\2s\u0253\3\2\2\2u\u0256"+
"\3\2\2\2w\u025b\3\2\2\2y\u0261\3\2\2\2{\u0264\3\2\2\2}\u0268\3\2\2\2\177"+
"\u026f\3\2\2\2\u0081\u0276\3\2\2\2\u0083\u027c\3\2\2\2\u0085\u0285\3\2"+
"\2\2\u0087\u028b\3\2\2\2\u0089\u0293\3\2\2\2\u008b\u0298\3\2\2\2\u008d"+
"\u029f\3\2\2\2\u008f\u02a4\3\2\2\2\u0091\u02ab\3\2\2\2\u0093\u02b2\3\2"+
"\2\2\u0095\u02ba\3\2\2\2\u0097\u02c2\3\2\2\2\u0099\u02cb\3\2\2\2\u009b"+
"\u02d0\3\2\2\2\u009d\u02d9\3\2\2\2\u009f\u02df\3\2\2\2\u00a1\u02e6\3\2"+
"\2\2\u00a3\u02f6\3\2\2\2\u00a5\u031d\3\2\2\2\u00a7\u0328\3\2\2\2\u00a9"+
"\u032a\3\2\2\2\u00ab\u0336\3\2\2\2\u00ad\u0340\3\2\2\2\u00af\u034b\3\2"+
"\2\2\u00b1\u0353\3\2\2\2\u00b3\u0360\3\2\2\2\u00b5\u0362\3\2\2\2\u00b7"+
"\u0369\3\2\2\2\u00b9\u0370\3\2\2\2\u00bb\u0378\3\2\2\2\u00bd\u037c\3\2"+
"\2\2\u00bf\u0382\3\2\2\2\u00c1\u0388\3\2\2\2\u00c3\u038f\3\2\2\2\u00c5"+
"\u0398\3\2\2\2\u00c7\u039d\3\2\2\2\u00c9\u03a4\3\2\2\2\u00cb\u03b5\3\2"+
"\2\2\u00cd\u03c3\3\2\2\2\u00cf\u03d4\3\2\2\2\u00d1\u03e8\3\2\2\2\u00d3"+
"\u03eb\3\2\2\2\u00d5\u03f4\3\2\2\2\u00d7\u03fb\3\2\2\2\u00d9\u03fd\3\2"+
"\2\2\u00db\u03ff\3\2\2\2\u00dd\u0401\3\2\2\2\u00df\u040a\3\2\2\2\u00e1"+
"\u040c\3\2\2\2\u00e3\u040e\3\2\2\2\u00e5\u0424\3\2\2\2\u00e7\u0432\3\2"+
"\2\2\u00e9\u0438\3\2\2\2\u00eb\u0443\3\2\2\2\u00ed\u0451\3\2\2\2\u00ef"+
"\u067d\3\2\2\2\u00f1\u067f\3\2\2\2\u00f3\u0681\3\2\2\2\u00f5\u0683\3\2"+
"\2\2\u00f7\u0685\3\2\2\2\u00f9\u0687\3\2\2\2\u00fb\u0689\3\2\2\2\u00fd"+
"\u068b\3\2\2\2\u00ff\u068d\3\2\2\2\u0101\u068f\3\2\2\2\u0103\u0692\3\2"+
"\2\2\u0105\u0695\3\2\2\2\u0107\u0697\3\2\2\2\u0109\u0699\3\2\2\2\u010b"+
"\u069b\3\2\2\2\u010d\u069d\3\2\2\2\u010f\u069f\3\2\2\2\u0111\u06a1\3\2"+
"\2\2\u0113\u06a4\3\2\2\2\u0115\u06a9\3\2\2\2\u0117\u06ae\3\2\2\2\u0119"+
"\u06b0\3\2\2\2\u011b\u06c0\3\2\2\2\u011d\u06c9\3\2\2\2\u011f\u06d9\3\2"+
"\2\2\u0121\u06db\3\2\2\2\u0123\u06e2\3\2\2\2\u0125\u06e6\3\2\2\2\u0127"+
"\u06ec\3\2\2\2\u0129\u06ee\3\2\2\2\u012b\u06f0\3\2\2\2\u012d\u06f2\3\2"+
"\2\2\u012f\u06fa\3\2\2\2\u0131\u0700\3\2\2\2\u0133\u0707\3\2\2\2\u0135"+
"\u070e\3\2\2\2\u0137\u0710\3\2\2\2\u0139\u0713\3\2\2\2\u013b\u0719\3\2"+
"\2\2\u013d\u0724\3\2\2\2\u013f\u0732\3\2\2\2\u0141\u073b\3\2\2\2\u0143"+
"\u0748\3\2\2\2\u0145\u074e\3\2\2\2\u0147\u0759\3\2\2\2\u0149\u014a\7}"+
"\2\2\u014a\u014b\b\2\2\2\u014b\6\3\2\2\2\u014c\u014d\7\177\2\2\u014d\b"+
"\3\2\2\2\u014e\u014f\7]\2\2\u014f\n\3\2\2\2\u0150\u0151\7_\2\2\u0151\f"+
"\3\2\2\2\u0152\u0153\7*\2\2\u0153\16\3\2\2\2\u0154\u0155\7+\2\2\u0155"+
"\20\3\2\2\2\u0156\u0157\7=\2\2\u0157\22\3\2\2\2\u0158\u0159\7<\2\2\u0159"+
"\24\3\2\2\2\u015a\u015b\7.\2\2\u015b\26\3\2\2\2\u015c\u015d\7\60\2\2\u015d"+
"\u015e\7\60\2\2\u015e\30\3\2\2\2\u015f\u0160\7\60\2\2\u0160\u0161\7\60"+
"\2\2\u0161\u0162\7\60\2\2\u0162\32\3\2\2\2\u0163\u0164\7A\2\2\u0164\34"+
"\3\2\2\2\u0165\u0166\7\60\2\2\u0166\36\3\2\2\2\u0167\u0168\7/\2\2\u0168"+
"\u0169\7@\2\2\u0169 \3\2\2\2\u016a\u016b\7-\2\2\u016b\"\3\2\2\2\u016c"+
"\u016d\7/\2\2\u016d$\3\2\2\2\u016e\u016f\7,\2\2\u016f&\3\2\2\2\u0170\u0171"+
"\7\61\2\2\u0171(\3\2\2\2\u0172\u0173\7\'\2\2\u0173*\3\2\2\2\u0174\u0175"+
"\7-\2\2\u0175\u0176\7-\2\2\u0176,\3\2\2\2\u0177\u0178\7/\2\2\u0178\u0179"+
"\7/\2\2\u0179.\3\2\2\2\u017a\u017b\7(\2\2\u017b\60\3\2\2\2\u017c\u017d"+
"\7\u0080\2\2\u017d\62\3\2\2\2\u017e\u017f\7`\2\2\u017f\64\3\2\2\2\u0180"+
"\u0181\7~\2\2\u0181\66\3\2\2\2\u0182\u0183\7>\2\2\u0183\u0184\7>\2\2\u0184"+
"8\3\2\2\2\u0185\u0186\7@\2\2\u0186\u0187\7@\2\2\u0187:\3\2\2\2\u0188\u0189"+
"\7?\2\2\u0189\u018a\7?\2\2\u018a<\3\2\2\2\u018b\u018c\7#\2\2\u018c\u018d"+
"\7?\2\2\u018d>\3\2\2\2\u018e\u018f\7>\2\2\u018f@\3\2\2\2\u0190\u0191\7"+
">\2\2\u0191\u0192\7?\2\2\u0192B\3\2\2\2\u0193\u0194\7@\2\2\u0194\u0195"+
"\7?\2\2\u0195D\3\2\2\2\u0196\u0197\7@\2\2\u0197F\3\2\2\2\u0198\u0199\7"+

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

@ -133,16 +133,16 @@ public class Pass0GenerateStatementSequence extends KickCParserBaseVisitor<Objec
for(KickCParser.PragmaContext pragmaConstructorFor : pragmaConstructorFors) {
final List<KickCParser.PragmaParamContext> names = pragmaConstructorFor.pragmaParam();
if(names.size() < 2)
throw new CompileError("Error! #pragma constructor_for requires at least 2 parameters.", new StatementSource(pragmaConstructorFor));
throw new CompileError("#pragma constructor_for requires at least 2 parameters.", new StatementSource(pragmaConstructorFor));
final String constructorProcName = pragmaParamName(names.get(0));
final Procedure constructorProc = program.getScope().getLocalProcedure(constructorProcName);
if(constructorProc == null)
throw new CompileError("Error! Constructor procedure not found " + constructorProcName, new StatementSource(pragmaConstructorFor));
throw new CompileError("Constructor procedure not found " + constructorProcName, new StatementSource(pragmaConstructorFor));
for(int i = 1; i < names.size(); i++) {
final String procName = pragmaParamName(names.get(i));
final Procedure proc = program.getScope().getLocalProcedure(procName);
if(proc == null)
throw new CompileError("Error! Procedure not found " + procName, new StatementSource(pragmaConstructorFor));
throw new CompileError("Procedure not found " + procName, new StatementSource(pragmaConstructorFor));
if(program.getLog().isVerboseParse())
program.getLog().append("Added constructor procedure " + constructorProc.getRef().toString() + " to procedure " + proc.getRef().toString());
proc.getConstructorRefs().add(constructorProc.getRef());
@ -243,9 +243,9 @@ public class Pass0GenerateStatementSequence extends KickCParserBaseVisitor<Objec
case CParser.PRAGMA_DATA_SEG:
this.currentDataSegment = pragmaParamName(pragmaParamSingle(ctx));
break;
case CParser.PRAGMA_PC:
Number programPc = pragmaParamNumber(pragmaParamSingle(ctx));
program.setProgramPc(programPc);
case CParser.PRAGMA_START_ADDRESS:
Number startAddress = pragmaParamNumber(pragmaParamSingle(ctx));
program.getTargetPlatform().setStartAddress(startAddress);
break;
case CParser.PRAGMA_CALLING:
currentCallingConvention = pragmaParamCallingConvention(pragmaParamSingle(ctx));
@ -272,7 +272,7 @@ public class Pass0GenerateStatementSequence extends KickCParserBaseVisitor<Objec
*/
private static KickCParser.PragmaParamContext pragmaParamSingle(KickCParser.PragmaContext ctx) {
if(ctx.pragmaParam().size() != 1)
throw new CompileError("Error! #pragma expects a single parameter!", new StatementSource(ctx));
throw new CompileError("#pragma expects a single parameter!", new StatementSource(ctx));
return ctx.pragmaParam().get(0);
}
@ -285,10 +285,10 @@ public class Pass0GenerateStatementSequence extends KickCParserBaseVisitor<Objec
*/
private static Number pragmaParamNumber(KickCParser.PragmaParamContext paramCtx) {
if(!(paramCtx instanceof KickCParser.PragmaParamNumberContext))
throw new CompileError("Error! Expected a NUMBER parameter. Found '" + paramCtx.getText() + "'.", new StatementSource(paramCtx.getParent()));
throw new CompileError("Expected a NUMBER parameter. Found '" + paramCtx.getText() + "'.", new StatementSource(paramCtx.getParent()));
final Number number = NumberParser.parseLiteral(((KickCParser.PragmaParamNumberContext) paramCtx).NUMBER().getText());
if(number == null)
throw new CompileError("Error! Expected a NUMBER parameter. Found '" + paramCtx.getText() + "'.", new StatementSource(paramCtx.getParent()));
throw new CompileError("Expected a NUMBER parameter. Found '" + paramCtx.getText() + "'.", new StatementSource(paramCtx.getParent()));
return number;
}
@ -301,11 +301,11 @@ public class Pass0GenerateStatementSequence extends KickCParserBaseVisitor<Objec
*/
private static Procedure.CallingConvention pragmaParamCallingConvention(KickCParser.PragmaParamContext paramCtx) {
if(!(paramCtx instanceof KickCParser.PragmaParamCallingConventionContext))
throw new CompileError("Error! Expected a CALLINGCONVENTION parameter. Found '" + paramCtx.getText() + "'.", new StatementSource(paramCtx.getParent()));
throw new CompileError("Expected a CALLINGCONVENTION parameter. Found '" + paramCtx.getText() + "'.", new StatementSource(paramCtx.getParent()));
final String callingConventionName = ((KickCParser.PragmaParamCallingConventionContext) paramCtx).CALLINGCONVENTION().getText();
final Procedure.CallingConvention callingConvention = Procedure.CallingConvention.getCallingConvension(callingConventionName);
if(callingConvention == null)
throw new CompileError("Error! Expected a CALLINGCONVENTION parameter. Found '" + paramCtx.getText() + "'.", new StatementSource(paramCtx.getParent()));
throw new CompileError("Expected a CALLINGCONVENTION parameter. Found '" + paramCtx.getText() + "'.", new StatementSource(paramCtx.getParent()));
return callingConvention;
}
@ -319,7 +319,7 @@ public class Pass0GenerateStatementSequence extends KickCParserBaseVisitor<Objec
*/
private static String pragmaParamName(KickCParser.PragmaParamContext paramCtx) {
if(!(paramCtx instanceof KickCParser.PragmaParamNameContext))
throw new CompileError("Error! Expected a NAME parameter. Found '" + paramCtx.getText() + "'.", new StatementSource(paramCtx.getParent()));
throw new CompileError("Expected a NAME parameter. Found '" + paramCtx.getText() + "'.", new StatementSource(paramCtx.getParent()));
return ((KickCParser.PragmaParamNameContext) paramCtx).NAME().getText();
}
@ -332,7 +332,7 @@ public class Pass0GenerateStatementSequence extends KickCParserBaseVisitor<Objec
*/
private static String pragmaParamString(KickCParser.PragmaParamContext paramCtx) {
if(!(paramCtx instanceof KickCParser.PragmaParamStringContext))
throw new CompileError("Error! Expected a STRING parameter. Found '" + paramCtx.getText() + "'.", new StatementSource(paramCtx.getParent()));
throw new CompileError("Expected a STRING parameter. Found '" + paramCtx.getText() + "'.", new StatementSource(paramCtx.getParent()));
final String stringLiteral = ((KickCParser.PragmaParamStringContext) paramCtx).STRING().getText();
return stringLiteral.substring(1, stringLiteral.length() - 1);
}
@ -363,7 +363,7 @@ public class Pass0GenerateStatementSequence extends KickCParserBaseVisitor<Objec
zp++;
}
} else {
throw new CompileError("Error! Expected a NUMBER or RANGE parameter. Found '" + reserveCtx.getText() + "'.", new StatementSource(reserveCtx.getParent()));
throw new CompileError("Expected a NUMBER or RANGE parameter. Found '" + reserveCtx.getText() + "'.", new StatementSource(reserveCtx.getParent()));
}
}
return reservedZps;
@ -409,7 +409,7 @@ public class Pass0GenerateStatementSequence extends KickCParserBaseVisitor<Objec
if(existingSymbol != null) {
// Already declared - check equality
if(!(existingSymbol instanceof Procedure) || !SymbolTypeConversion.procedureDeclarationMatch((Procedure) existingSymbol, procedure))
throw new CompileError("Error! Conflicting declarations for: " + procedure.getFullName(), new StatementSource(ctx));
throw new CompileError("Conflicting declarations for: " + procedure.getFullName(), new StatementSource(ctx));
} else {
// Not declared before - add it
program.getScope().add(procedure);
@ -429,7 +429,7 @@ public class Pass0GenerateStatementSequence extends KickCParserBaseVisitor<Objec
// Check that the body has not already been added
final StatementSequence statementSequence = getCurrentProcedureCompilation().getStatementSequence();
if(statementSequence != null && statementSequence.getStatements().size() > 0)
throw new CompileError("Error! Redefinition of function: " + procedure.getFullName(), StatementSource.procedureBegin(ctx));
throw new CompileError("Redefinition of function: " + procedure.getFullName(), StatementSource.procedureBegin(ctx));
// Add the body
addStatement(new StatementProcedureBegin(procedure.getRef(), StatementSource.procedureBegin(ctx), Comment.NO_COMMENTS));
// Add parameter assignments
@ -729,7 +729,7 @@ public class Pass0GenerateStatementSequence extends KickCParserBaseVisitor<Objec
String clobberString = ctx.STRING().getText().toUpperCase(Locale.ENGLISH);
clobberString = clobberString.substring(1, clobberString.length() - 1);
if(!clobberString.matches("[AXY]*")) {
throw new CompileError("Error! Illegal clobber value " + clobberString, new StatementSource(ctx));
throw new CompileError("Illegal clobber value " + clobberString, new StatementSource(ctx));
}
CpuClobber clobber = new CpuClobber(clobberString);
return new AsmDirectiveClobber(clobber);
@ -1668,7 +1668,7 @@ public class Pass0GenerateStatementSequence extends KickCParserBaseVisitor<Objec
} else {
lValue = getCurrentScope().findVariable(varName);
if(lValue == null) {
throw new CompileError("Error! Loop variable not declared " + varName, statementSource);
throw new CompileError("Loop variable not declared " + varName, statementSource);
}
}
boolean initialAssignment = (varDecl.getEffectiveType() != null);
@ -1869,7 +1869,7 @@ public class Pass0GenerateStatementSequence extends KickCParserBaseVisitor<Objec
RValue rValue;
if(exprCtx != null) {
if(SymbolType.VOID.equals(procedure.getReturnType())) {
throw new CompileError("Error! Return value from void function " + procedure.getFullName(), new StatementSource(ctx));
throw new CompileError("Return value from void function " + procedure.getFullName(), new StatementSource(ctx));
}
PrePostModifierHandler.addPreModifiers(this, exprCtx, new StatementSource(ctx));
rValue = (RValue) this.visit(exprCtx);
@ -2096,7 +2096,7 @@ public class Pass0GenerateStatementSequence extends KickCParserBaseVisitor<Objec
varDecl.setVarDeclType(arrayDeclType);
return null;
} else {
throw new CompileError("ERROR! Non-standard array declaration. Allow using commandline option -Warraytype", new StatementSource(ctx));
throw new CompileError("Non-standard array declaration. Allow using commandline option -Warraytype", new StatementSource(ctx));
}
}
@ -2187,7 +2187,7 @@ public class Pass0GenerateStatementSequence extends KickCParserBaseVisitor<Objec
throw new CompileError("const variable may not be modified " + val.toString(), new StatementSource(ctx));
}
if(!(val instanceof LValue)) {
throw new CompileError("Error! Illegal assignment Lvalue " + val.toString(), new StatementSource(ctx));
throw new CompileError("Illegal assignment Lvalue " + val.toString(), new StatementSource(ctx));
}
LValue lValue = (LValue) val;
if(lValue instanceof VariableRef && ((VariableRef) lValue).isIntermediate()) {
@ -2207,7 +2207,7 @@ public class Pass0GenerateStatementSequence extends KickCParserBaseVisitor<Objec
// Assignment (rValue/lValue)
Object value = visit(ctx.expr(0));
if(!(value instanceof LValue)) {
throw new CompileError("Error! Illegal assignment Lvalue " + value.toString(), new StatementSource(ctx));
throw new CompileError("Illegal assignment Lvalue " + value.toString(), new StatementSource(ctx));
}
LValue lValue = (LValue) value;
if(lValue instanceof VariableRef && ((VariableRef) lValue).isIntermediate()) {
@ -2616,7 +2616,7 @@ public class Pass0GenerateStatementSequence extends KickCParserBaseVisitor<Objec
// Either forward reference or a non-existing variable. Create a forward reference for later resolving.
return new ForwardVariableRef(ctx.NAME().getText());
}
throw new CompileError("Error! Unhandled symbol " + symbol.toString(program));
throw new CompileError("Unhandled symbol " + symbol.toString(program));
}
/**

@ -24,20 +24,20 @@ public class Pass1AssertInterrupts extends Pass1Base {
ProcedureRef procedureRef = ((StatementCalling) statement).getProcedure();
Procedure procedure = getScope().getProcedure(procedureRef);
if(procedure.getInterruptType()!=null) {
throw new CompileError("Error! Interrupts cannot be called.", statement.getSource());
throw new CompileError("Interrupts cannot be called.", statement.getSource());
}
}
}
for(Procedure procedure : getScope().getAllProcedures(true)) {
if(procedure.getInterruptType()!=null) {
if(procedure.isDeclaredInline()) {
throw new CompileError("Error! Interrupts cannot be inlined. " + procedure.toString());
throw new CompileError("Interrupts cannot be inlined. " + procedure.toString());
}
if(procedure.getParameters().size()>0) {
throw new CompileError("Error! Interrupts cannot have parameters. " + procedure.toString());
throw new CompileError("Interrupts cannot have parameters. " + procedure.toString());
}
if(!SymbolType.VOID.equals(procedure.getReturnType())) {
throw new CompileError("Error! Interrupts cannot return anything. " + procedure.toString());
throw new CompileError("Interrupts cannot return anything. " + procedure.toString());
}
}
}

@ -31,7 +31,7 @@ public class Pass1AssertNoLValueIntermediate extends Pass1Base {
VariableRef intermediateVar = ((LvalueIntermediate) lValue).getVariable();
final List<VarAssignments.VarAssignment> varAssignments = VarAssignments.get(intermediateVar, getGraph(), getScope());
final VarAssignments.VarAssignment varAssignment = varAssignments.get(0);
throw new CompileError("Error! LValue is illegal. " + statement + " - definition of lValue " + varAssignment, varAssignment.getSource());
throw new CompileError("LValue is illegal. " + statement + " - definition of lValue " + varAssignment, varAssignment.getSource());
}
}
}

@ -26,7 +26,7 @@ public class Pass1AssertNoModifyVars extends Pass1Base {
if(!statementLValue.isInitialAssignment() && statementLValue.getlValue() instanceof VariableRef) {
Variable assignedVar = getScope().getVariable((VariableRef) statementLValue.getlValue());
if(assignedVar.isNoModify())
throw new CompileError("Error! const variable may not be modified! " + assignedVar.toString(), statement);
throw new CompileError("const variable may not be modified! " + assignedVar.toString(), statement);
}
}
}

@ -76,7 +76,7 @@ public class Pass1AssertUsedVars extends Pass1Base {
Collection<VariableRef> used = referenceInfos.getUsedVars(statement);
for(VariableRef usedRef : used) {
if(!defined.contains(usedRef)) {
throw new CompileError("Error! Variable used before being defined " + usedRef.toString(getProgram()) + " in " + statement.toString(getProgram(), false), statement.getSource());
throw new CompileError("Variable used before being defined " + usedRef.toString(getProgram()) + " in " + statement.toString(getProgram(), false), statement.getSource());
}
}
Collection<VariableRef> defd = referenceInfos.getDefinedVars(statement);
@ -143,7 +143,7 @@ public class Pass1AssertUsedVars extends Pass1Base {
// Found used variables - check that they are defined
for(SymbolVariableRef usedRef : used) {
if(!defined.contains(usedRef)) {
throw new CompileError("Error! Variable used before being defined " + usedRef.toString(getProgram()) + " in " + phiBlock.toString(getProgram(), false), phiBlock.getSource());
throw new CompileError("Variable used before being defined " + usedRef.toString(getProgram()) + " in " + phiBlock.toString(getProgram(), false), phiBlock.getSource());
}
}
// Add all variables fefined by the PHI block

@ -43,7 +43,7 @@ public class Pass1CallVoidReturns extends Pass2SsaOptimization {
if(usages.size() > 0) {
final Integer usageIdx = usages.iterator().next();
final Statement usage = getProgram().getStatementInfos().getStatement(usageIdx);
throw new CompileError("Error! Function " + procedure.getLocalName() + " does not return a value! ", usage);
throw new CompileError("Function " + procedure.getLocalName() + " does not return a value! ", usage);
} else {
// Delete the temporary variable
final Variable var = getScope().getVar(tmpVar);

@ -64,10 +64,10 @@ public class Pass1PrintfIntrinsicRewrite extends Pass2SsaOptimization {
final List<RValue> parameters = printfCall.getParameters();
final RValue formatParameter = getParameterValue(parameters, 0, printfCall);
if(!(formatParameter instanceof ConstantValue))
throw new CompileError("Error! Only constant printf() format parameter supported!", statement);
throw new CompileError("Only constant printf() format parameter supported!", statement);
final ConstantLiteral formatLiteral = ((ConstantValue) formatParameter).calculateLiteral(getProgram().getScope());
if(!(formatLiteral instanceof ConstantString))
throw new CompileError("Error! printf() format parameter must be a string!", statement);
throw new CompileError("printf() format parameter must be a string!", statement);
final String formatString = ((ConstantString) formatLiteral).getString();
final StringEncoding formatEncoding = ((ConstantString) formatLiteral).getEncoding();
@ -103,10 +103,10 @@ public class Pass1PrintfIntrinsicRewrite extends Pass2SsaOptimization {
final String paramField = matcher.group(1);
// Ensure that all fields use parameter index syntax!
if(paramField == null && fieldParamIdx && !typeField.equals("%"))
throw new CompileError("Error! If any single printf() placeholder specifies a parameter, all the rest of the placeholders must also specify a parameter!", statement);
throw new CompileError("If any single printf() placeholder specifies a parameter, all the rest of the placeholders must also specify a parameter!", statement);
if(paramField != null) {
if(!fieldParamIdx && paramIdx > 1)
throw new CompileError("Error! If any single printf() placeholder specifies a parameter, all the rest of the placeholders must also specify a parameter!", statement);
throw new CompileError("If any single printf() placeholder specifies a parameter, all the rest of the placeholders must also specify a parameter!", statement);
fieldParamIdx = true;
paramIdx = Integer.parseInt(paramField.substring(0, paramField.length() - 1));
}
@ -256,7 +256,7 @@ public class Pass1PrintfIntrinsicRewrite extends Pass2SsaOptimization {
*/
private RValue getParameterValue(List<RValue> parameters, int paramIdx, StatementCall printfCall) {
if(parameters.size()<=paramIdx)
throw new CompileError("Error! printf missing parameter with index "+paramIdx, printfCall);
throw new CompileError("printf missing parameter with index "+paramIdx, printfCall);
return parameters.get(paramIdx);
}

@ -29,7 +29,7 @@ public class Pass1ResolveForwardReferences extends Pass1Base {
programValue.set(symbol.getRef());
} else {
getLog().append("ERROR! Unknown variable " + varName);
throw new CompileError("ERROR! Unknown variable " + varName, currentStmt.getSource());
throw new CompileError("Unknown variable " + varName, currentStmt.getSource());
}
}
});

@ -38,10 +38,10 @@ public class Pass2RangeResolving extends Pass2SsaOptimization {
ConstantLiteral firstLiteral = ((ConstantValue) rangeValue.getRangeFirst()).calculateLiteral(getScope());
ConstantLiteral lastLiteral = ((ConstantValue) rangeValue.getRangeLast()).calculateLiteral(getScope());
if(!(firstLiteral instanceof ConstantEnumerable)) {
throw new CompileError("Error! Ranged for() has non-integer first value in the range " + currentStmt.getSource().toString());
throw new CompileError("Ranged for() has non-integer first value in the range " + currentStmt.getSource().toString(), currentStmt);
}
if(!(lastLiteral instanceof ConstantEnumerable)) {
throw new CompileError("Error! Ranged for() has non-integer first value in the range " + currentStmt.getSource().toString());
throw new CompileError("Ranged for() has non-integer first value in the range " + currentStmt.getSource().toString(), currentStmt);
}
ConstantEnumerable first = (ConstantEnumerable) firstLiteral;

@ -38,11 +38,11 @@ public class Pass3AssertConstants extends Pass2SsaAssertion {
if(statement instanceof StatementKickAsm) {
RValue bytes = ((StatementKickAsm) statement).getBytes();
if(bytes != null && !(bytes instanceof ConstantValue)) {
throw new CompileError("Error! KickAssembler bytes is not constant " + bytes.toString(), statement);
throw new CompileError("KickAssembler bytes is not constant " + bytes.toString(), statement);
}
RValue cycles = ((StatementKickAsm) statement).getCycles();
if(cycles != null && !(cycles instanceof ConstantValue)) {
throw new CompileError("Error! KickAssembler cycles is not constant " + cycles.toString(), statement);
throw new CompileError("KickAssembler cycles is not constant " + cycles.toString(), statement);
}
} else if(statement instanceof StatementAsm) {
StatementAsm statementAsm = (StatementAsm) statement;
@ -60,14 +60,14 @@ public class Pass3AssertConstants extends Pass2SsaAssertion {
// Referencing load/store is fine!
continue;
else
throw new CompileError("Error! Inline ASM reference is not constant " + label, statement);
throw new CompileError("Inline ASM reference is not constant " + label, statement);
}
} else if(statement instanceof StatementKickAsm) {
StatementKickAsm statementAsm = (StatementKickAsm) statement;
List<SymbolRef> uses = statementAsm.getUses();
for(SymbolRef use : uses) {
if(!(use instanceof ConstantRef)) {
throw new CompileError("Error! Inline KickAsm reference is not constant " + use, statement);
throw new CompileError("Inline KickAsm reference is not constant " + use, statement);
}
}
}

@ -23,13 +23,13 @@ public class Pass3AssertNoMulDivMod extends Pass2SsaAssertion {
if(statement instanceof StatementAssignment) {
StatementAssignment assignment = (StatementAssignment) statement;
if(Operators.MULTIPLY.equals(assignment.getOperator())) {
throw new CompileError("ERROR! Runtime multiplication not supported. "+statement.toString(getProgram(), false), statement.getSource());
throw new CompileError("Runtime multiplication not supported. "+statement.toString(getProgram(), false), statement.getSource());
}
if(Operators.DIVIDE.equals(assignment.getOperator())) {
throw new CompileError("ERROR! Runtime division not supported. "+statement.toString(getProgram(), false), statement.getSource());
throw new CompileError("Runtime division not supported. "+statement.toString(getProgram(), false), statement.getSource());
}
if(Operators.MODULO.equals(assignment.getOperator())) {
throw new CompileError("ERROR! Runtime modulo not supported. "+statement.toString(getProgram(), false), statement.getSource());
throw new CompileError("Runtime modulo not supported. "+statement.toString(getProgram(), false), statement.getSource());
}
}

@ -96,9 +96,9 @@ public class Pass4CodeGeneration {
linkScriptBody = linkScriptBody.replace("%^O", outputFileName.toUpperCase());
String entryName = program.getStartProcedure().getFullName();
linkScriptBody = linkScriptBody.replace("%E", entryName);
Number programPc = program.getProgramPc();
if(programPc == null) programPc = 0x080d;
linkScriptBody = linkScriptBody.replace("%P", AsmFormat.getAsmNumber(programPc));
Number startAddress = program.getTargetPlatform().getStartAddress();
if(startAddress!=null)
linkScriptBody = linkScriptBody.replace("%P", AsmFormat.getAsmNumber(startAddress));
asm.addLine(new AsmInlineKickAsm(linkScriptBody, 0L, 0L));
// If the link script contains ".segment" then generate segments!
@ -804,7 +804,7 @@ public class Pass4CodeGeneration {
generateStatementAsm(asm, block, statement, aluState, true);
} catch(AsmFragmentTemplateSynthesizer.UnknownFragmentException e) {
if(warnFragmentMissing) {
program.getLog().append("Warning! Unknown fragment for statement " + statement.toString(program, false) + "\nMissing ASM fragment " + e.getFragmentSignature() + "\n" + statement.getSource().toStringShort());
program.getLog().append("Warning! Unknown fragment for statement " + statement.toString(program, false) + "\nMissing ASM fragment " + e.getFragmentSignature() + "\n" + statement.getSource().format());
asm.addLine(new AsmInlineKickAsm(".assert \"Missing ASM fragment " + e.getFragmentSignature() + "\", 0, 1", 0L, 0L));
} else {
throw new CompileError("Unknown fragment for statement " + statement.toString(program, false) + "\nMissing ASM fragment " + e.getFragmentSignature(), statement.getSource());

@ -25,7 +25,7 @@ public class PassNAssertTypeDeref extends Pass2SsaAssertion {
RValue pointer = ((PointerDereference) programValue.get()).getPointer();
SymbolType pointertype = SymbolTypeInference.inferType(getProgram().getScope(), pointer);
if(!SymbolType.VAR.equals(pointertype) && !(pointertype instanceof SymbolTypePointer))
throw new CompileError("Error! Dereferencing a non-pointer type "+pointertype.getTypeName(), currentStmt);
throw new CompileError("Dereferencing a non-pointer type "+pointertype.getTypeName(), currentStmt);
}
});
}

@ -40,7 +40,7 @@ public class PassNAssertTypeMatch extends Pass2SsaAssertion {
if(SymbolTypeConversion.assignmentTypeMatch(lValueType, rValueType)) return;
// Types do not match
getLog().append("ERROR! Type mismatch (" + lValueType.getTypeName() + ") cannot be assigned from (" + rValueType.getTypeName() + "). In " + statement.toString(getProgram(), false));
throw new CompileError("ERROR! Type mismatch (" + lValueType.getTypeName() + ") cannot be assigned from (" + rValueType.getTypeName() + "). In " + statement.toString(getProgram(), false), statement.getSource());
throw new CompileError("Type mismatch (" + lValueType.getTypeName() + ") cannot be assigned from (" + rValueType.getTypeName() + "). In " + statement.toString(getProgram(), false), statement.getSource());
}
}

@ -260,7 +260,7 @@ public class CPreprocessor implements TokenSource {
final String fileName = fileNameToken.getText();
cParser.includeCFile(fileName, true);
} else {
throw new CompileError("Error! #include not followed by file!", new StatementSource(inputToken, fileNameToken));
throw new CompileError("#include not followed by file!", new StatementSource(inputToken, fileNameToken));
}
}
@ -286,7 +286,7 @@ public class CPreprocessor implements TokenSource {
final Token paramToken = cTokenSource.nextToken();
if(paramToken.getType() == KickCLexer.PAR_END) {
if(!commaNext && macroParameters.size() > 0)
throw new CompileError("Error! #define declared parameter list ends with COMMA.", paramToken);
throw new CompileError("#define declared parameter list ends with COMMA.", paramToken);
// We reached the end of the parameters
break;
} else if(!commaNext && paramToken.getType() == KickCLexer.NAME) {
@ -298,7 +298,7 @@ public class CPreprocessor implements TokenSource {
commaNext = false;
else
// Unexpected token
throw new CompileError("Error! #define declared parameter not a NAME.", paramToken);
throw new CompileError("#define declared parameter not a NAME.", paramToken);
}
}
final ArrayList<Token> macroBody = readBody(cTokenSource);

@ -86,13 +86,13 @@ void pwrMEMbyFAC(char* mem);
void intFAC();
// FAC = sin(FAC)
// Set FAC to sinus of the FAC - sin(FAC)
// Sinus is calculated on radians (0-2*PI)
// Set FAC to sine of the FAC - sin(FAC)
// Sine is calculated on radians (0-2*PI)
void sinFAC();
// FAC = cos(FAC)
// Set FAC to cosinus of the FAC - cos(FAC)
// Cosinus is calculated on radians (0-2*PI)
// Set FAC to cosine of the FAC - cos(FAC)
// Cosine is calculated on radians (0-2*PI)
void cosFAC();
// FAC = tan(FAC)

@ -27,7 +27,7 @@ extern char PLEX_YPOS[PLEX_COUNT];
extern char PLEX_PTR[PLEX_COUNT];
// The address of the sprite pointers on the current screen (screen+0x3f8).
extern char* PLEX_SCREEN_PTR;
extern char* volatile PLEX_SCREEN_PTR;
// Indexes of the plex-sprites sorted by sprite y-position. Each call to plexSort() will fix the sorting if changes to the Y-positions have ruined it.
extern char PLEX_SORTED_IDX[PLEX_COUNT];

@ -1,8 +1,8 @@
// Sinus Generator functions using only multiplication, addition and bit shifting
// Sine Generator functions using only multiplication, addition and bit shifting
// Uses a single division for converting the wavelength to a reciprocal.
// Generates sinus using the series sin(x) = x - x^/3! + x^-5! - x^7/7! ...
// Generates sine using the series sin(x) = x - x^/3! + x^-5! - x^7/7! ...
// Uses the approximation sin(x) = x - x^/6 + x^/128
// Optimization possibility: Use symmetries when generating sinustables. wavelength%2==0 -> mirror symmetry over PI, wavelength%4==0 -> mirror symmetry over PI/2.
// Optimization possibility: Use symmetries when generating sine tables. wavelength%2==0 -> mirror symmetry over PI, wavelength%4==0 -> mirror symmetry over PI/2.
// PI*2 in u[4.28] format
extern const unsigned long PI2_u4f28;
@ -18,27 +18,27 @@ extern const unsigned int PI_u4f12;
// PI/2 in u[4.12] format
extern const unsigned int PI_HALF_u4f12;
// Generate signed (large) unsigned int sinus table - on the full -$7fff - $7fff range
// Generate signed (large) unsigned int sine table - on the full -$7fff - $7fff range
// sintab - the table to generate into
// wavelength - the number of sinus points in a total sinus wavelength (the size of the table)
// wavelength - the number of sine points in a total sine wavelength (the size of the table)
void sin16s_gen(int* sintab, unsigned int wavelength);
// Generate signed int sinus table - with values in the range min-max.
// Generate signed int sine table - with values in the range min-max.
// sintab - the table to generate into
// wavelength - the number of sinus points in a total sinus wavelength (the size of the table)
// wavelength - the number of sine points in a total sine wavelength (the size of the table)
void sin16s_gen2(int* sintab, unsigned int wavelength, int min, int max);
// Generate signed char sinus table - on the full -$7f - $7f range
// Generate signed char sine table - on the full -$7f - $7f range
// sintab - the table to generate into
// wavelength - the number of sinus points in a total sinus wavelength (the size of the table)
// wavelength - the number of sine points in a total sine wavelength (the size of the table)
void sin8s_gen(signed char* sintab, unsigned int wavelength);
// Calculate signed int sinus sin(x)
// Calculate signed int sine sin(x)
// x: unsigned long input u[4.28] in the interval $00000000 - PI2_u4f28
// result: signed int sin(x) s[0.15] - using the full range -$7fff - $7fff
int sin16s(unsigned long x);
// Calculate signed char sinus sin(x)
// Calculate signed char sine sin(x)
// x: unsigned int input u[4.12] in the interval $0000 - PI2_u4f12
// result: signed char sin(x) s[0.7] - using the full range -$7f - $7f
signed char sin8s(unsigned int x);

@ -200,8 +200,8 @@ void intFAC() {
}
// FAC = sin(FAC)
// Set FAC to sinus of the FAC - sin(FAC)
// Sinus is calculated on radians (0-2*PI)
// Set FAC to sine of the FAC - sin(FAC)
// Sine is calculated on radians (0-2*PI)
void sinFAC() {
asm {
jsr $e26b
@ -209,8 +209,8 @@ void sinFAC() {
}
// FAC = cos(FAC)
// Set FAC to cosinus of the FAC - cos(FAC)
// Cosinus is calculated on radians (0-2*PI)
// Set FAC to cosine of the FAC - cos(FAC)
// Cosine is calculated on radians (0-2*PI)
void cosFAC() {
asm {
jsr $e264

@ -16,6 +16,18 @@ const char CONIO_TEXTCOLOR_DEFAULT = LIGHT_BLUE;
// Use the shared CMB flat memory implementation
#include "conio-cbm-shared.c"
// Initializer for conio.h on C64
#pragma constructor_for(conio_c64_init, cputc, clrscr, cscroll)
// Set initial cursor position
void conio_c64_init() {
// Position cursor at current line
char * const BASIC_CURSOR_LINE = 0xD6;
char line = *BASIC_CURSOR_LINE;
if(line>=CONIO_HEIGHT) line=CONIO_HEIGHT-1;
gotoxy(0, line);
}
// Return true if there's a key waiting, return false if not
unsigned char kbhit (void) {
// CIA#1 Port A: keyboard matrix columns and joystick #2

@ -47,7 +47,7 @@ void conio_mega65_init() {
// Position cursor at current line
char * const BASIC_CURSOR_LINE = 0xeb;
char line = *BASIC_CURSOR_LINE+1;
if(line>24) line=24;
if(line>=CONIO_HEIGHT) line=CONIO_HEIGHT-1;
gotoxy(0, line);
}

@ -16,6 +16,18 @@ const char CONIO_TEXTCOLOR_DEFAULT = 0;
// Use the shared CMB flat memory implementation
#include "conio-cbm-shared.c"
// Initializer for conio.h on PLUS4
#pragma constructor_for(conio_plus4_init, cputc, clrscr, cscroll)
// Set initial cursor position
void conio_plus4_init() {
// Position cursor at current line
char * const BASIC_CURSOR_LINE = 0xCD;
char line = *BASIC_CURSOR_LINE;
if(line>=CONIO_HEIGHT) line=CONIO_HEIGHT-1;
gotoxy(0, line);
}
// Return true if there's a key waiting, return false if not
unsigned char kbhit (void) {
// Read all keyboard matrix rows

@ -16,6 +16,18 @@ const char CONIO_TEXTCOLOR_DEFAULT = BLUE;
// Use the shared CMB flat memory implementation
#include "conio-cbm-shared.c"
// Initializer for conio.h on VIC20
#pragma constructor_for(conio_vic20_init, cputc, clrscr, cscroll)
// Set initial cursor position
void conio_vic20_init() {
// Position cursor at current line
char * const BASIC_CURSOR_LINE = 0xD6;
char line = *BASIC_CURSOR_LINE;
if(line>=CONIO_HEIGHT) line=CONIO_HEIGHT-1;
gotoxy(0, line);
}
// Return true if there's a key waiting, return false if not
unsigned char kbhit (void) {
// Read all keyboard matrix rows

@ -28,7 +28,7 @@ char PLEX_YPOS[PLEX_COUNT];
char PLEX_PTR[PLEX_COUNT];
// The address of the sprite pointers on the current screen (screen+0x3f8).
char* PLEX_SCREEN_PTR = 0x400+0x3f8;
char* volatile PLEX_SCREEN_PTR = 0x400+0x3f8;
// Indexes of the plex-sprites sorted by sprite y-position. Each call to plexSort() will fix the sorting if changes to the Y-positions have ruined it.
char PLEX_SORTED_IDX[PLEX_COUNT];

@ -1,10 +1,10 @@
// Sinus Generator functions using only multiplication, addition and bit shifting
// Sine Generator functions using only multiplication, addition and bit shifting
// Uses a single division for converting the wavelength to a reciprocal.
// Generates sinus using the series sin(x) = x - x^/3! + x^-5! - x^7/7! ...
// Generates sine using the series sin(x) = x - x^/3! + x^-5! - x^7/7! ...
// Uses the approximation sin(x) = x - x^/6 + x^/128
// Optimization possibility: Use symmetries when generating sinustables. wavelength%2==0 -> mirror symmetry over PI, wavelength%4==0 -> mirror symmetry over PI/2.
// Optimization possibility: Use symmetries when generating sine tables. wavelength%2==0 -> mirror symmetry over PI, wavelength%4==0 -> mirror symmetry over PI/2.
#include <sinus.h>
#include <sine.h>
#include <division.h>
#include <multiply.h>
@ -22,9 +22,9 @@ const unsigned int PI_u4f12 = $3244;
// PI/2 in u[4.12] format
const unsigned int PI_HALF_u4f12 = $1922;
// Generate signed (large) unsigned int sinus table - on the full -$7fff - $7fff range
// Generate signed (large) unsigned int sine table - on the full -$7fff - $7fff range
// sintab - the table to generate into
// wavelength - the number of sinus points in a total sinus wavelength (the size of the table)
// wavelength - the number of sine points in a total sine wavelength (the size of the table)
void sin16s_gen(signed int* sintab, unsigned int wavelength) {
// u[4.28] step = PI*2/wavelength
unsigned long step = div32u16u(PI2_u4f28, wavelength); // u[4.28]
@ -36,9 +36,9 @@ void sin16s_gen(signed int* sintab, unsigned int wavelength) {
}
}
// Generate signed int sinus table - with values in the range min-max.
// Generate signed int sine table - with values in the range min-max.
// sintab - the table to generate into
// wavelength - the number of sinus points in a total sinus wavelength (the size of the table)
// wavelength - the number of sine points in a total sine wavelength (the size of the table)
void sin16s_gen2(signed int* sintab, unsigned int wavelength, signed int min, signed int max) {
signed int ampl = max-min;
signed int offs = min + ampl>>1; // ampl is always positive so shifting left does not alter the sign
@ -52,9 +52,9 @@ void sin16s_gen2(signed int* sintab, unsigned int wavelength, signed int min, si
}
}
// Generate signed char sinus table - on the full -$7f - $7f range
// Generate signed char sine table - on the full -$7f - $7f range
// sintab - the table to generate into
// wavelength - the number of sinus points in a total sinus wavelength (the size of the table)
// wavelength - the number of sine points in a total sine wavelength (the size of the table)
void sin8s_gen(signed char* sintab, unsigned int wavelength) {
// u[4.28] step = PI*2/wavelength
unsigned int step = div16u(PI2_u4f12, wavelength); // u[4.12]
@ -66,11 +66,11 @@ void sin8s_gen(signed char* sintab, unsigned int wavelength) {
}
}
// Calculate signed int sinus sin(x)
// Calculate signed int sine sin(x)
// x: unsigned long input u[4.28] in the interval $00000000 - PI2_u4f28
// result: signed int sin(x) s[0.15] - using the full range -$7fff - $7fff
signed int sin16s(unsigned long x) {
// Move x1 into the range 0-PI/2 using sinus mirror symmetries
// Move x1 into the range 0-PI/2 using sine mirror symmetries
char isUpper = 0;
if(x >= PI_u4f28 ) {
x = x - PI_u4f28;
@ -96,11 +96,11 @@ signed int sin16s(unsigned long x) {
return sinx;
}
// Calculate signed char sinus sin(x)
// Calculate signed char sine sin(x)
// x: unsigned int input u[4.12] in the interval $0000 - PI2_u4f12
// result: signed char sin(x) s[0.7] - using the full range -$7f - $7f
signed char sin8s(unsigned int x) {
// Move x1 into the range 0-PI/2 using sinus mirror symmetries
// Move x1 into the range 0-PI/2 using sine mirror symmetries
char isUpper = 0;
if(x >= PI_u4f12 ) {
x = x - PI_u4f12;

@ -1,6 +1,7 @@
{
"extension": "prg",
"link": "asm6502.ld",
"start_address": "0x2000",
"cpu": "MOS6502X",
"emulator": "x64sc"
}

@ -1,22 +1,8 @@
// Atari XL/XE executable XEX file with a single segment
// https://www.atarimax.com/jindroush.atari.org/afmtexe.html
.plugin "dk.camelot64.kickass.xexplugin.AtariXex"
.file [name="%O", type="bin", segments="XexFile"]
.segmentdef XexFile
.segment XexFile
// Binary File Header
.byte $ff, $ff
// Program segment [start address, end address, data]
.word ProgramStart, ProgramEnd-1
.segmentout [ segments="Program" ]
// RunAd - Run Address Segment [start address, end address, data]
.word $02e0, $02e1
.word %E
.segmentdef Program [segments="ProgramStart, Code, Data, ProgramEnd"]
.segmentdef ProgramStart [start=$2000]
.segment ProgramStart
ProgramStart:
.segmentdef Code [startAfter="ProgramStart"]
.segmentdef Data [startAfter="Code"]
.segmentdef ProgramEnd [startAfter="Data"]
.segment ProgramEnd
ProgramEnd:
.segmentdef XexFile [segments="Program", modify="XexFormat", _RunAddr=%E]
.segmentdef Program [segments="Code, Data"]
.segmentdef Code [start=%P]
.segmentdef Data [startAfter="Code"]

@ -1,11 +1,13 @@
{
"description": "Atari XL/XE executable XEX file with a single segment.",
"extension": "xex",
"link": "atarixl.ld",
"cpu": "MOS6502X",
"encoding": "screencode_atari",
"link": "atarixl.ld",
"start_address": "0x2000",
"zp_reserve": [ "0x00..0x7f" ],
"encoding": "atascii",
"extension": "xex",
"emulator": "atari800 -xl",
"defines": {
"__ATARIXL__": 1
},
"emulator": "atari800 -xl"
}
}

@ -2,7 +2,7 @@
.file [name="%O", type="prg", segments="Program"]
.segmentdef Program [segments="Basic, Code, Data"]
.segmentdef Basic [start=$0801]
.segmentdef Code [start=$080d]
.segmentdef Code [start=%P]
.segmentdef Data [startAfter="Code"]
.segment Basic
:BasicUpstart(%E)

@ -2,6 +2,7 @@
"description": "Commodore 64 PRG executable file.",
"extension": "prg",
"link": "c64.ld",
"start_address": "0x080d",
"cpu": "MOS6502X",
"emulator": "x64sc",
"defines": {

@ -1,6 +1,7 @@
{
"extension": "prg",
"link": "c64basic.ld",
"start_address": "0x080d",
"cpu": "MOS6502X",
"emulator": "x64sc",
"defines": {

@ -2,7 +2,7 @@
.file [name="%O", type="prg", segments="Program"]
.segmentdef Program [segments="Basic, Code, Data"]
.segmentdef Basic [start=$2001]
.segmentdef Code [start=$2017]
.segmentdef Code [start=%P]
.segmentdef Data [startAfter="Code"]
.segment Basic
.byte $0a, $20, $0a, $00, $fe, $02, $20, $30, $00 // 10 BANK 0

@ -2,6 +2,7 @@
"description": "MEGA65 platform PRG executable starting in MEGA65 mode.",
"extension": "prg",
"link": "mega65.ld",
"start_address": "0x2017",
"cpu": "MEGA45GS02",
"emulator": "xmega65 -prg",
"defines": {

@ -2,7 +2,7 @@
.file [name="%O", type="prg", segments="Program"]
.segmentdef Program [segments="Basic, Code, Data"]
.segmentdef Basic [start=$0801]
.segmentdef Code [start=$080d]
.segmentdef Code [start=%P]
.segmentdef Data [startAfter="Code"]
.segment Basic
:BasicUpstart(%E)

@ -2,6 +2,7 @@
"description": "MEGA65 platform executable starting in C64 mode.",
"extension": "prg",
"link": "mega65_c64.ld",
"start_address": "0x080d",
"cpu": "MEGA45GS02",
"emulator": "xmega65 -prg",
"defines": {

@ -2,7 +2,7 @@
.file [name="%O", type="prg", segments="Program"]
.segmentdef Program [segments="Basic, Code, Data"]
.segmentdef Basic [start=$1001]
.segmentdef Code [start=$100d]
.segmentdef Code [start=%P]
.segmentdef Data [startAfter="Code"]
.segment Basic
:BasicUpstart(%E)

@ -2,6 +2,7 @@
"description": "Commodore 16 / Plus/4 executable PRG file",
"extension": "prg",
"link": "plus4.ld",
"start_address": "0x100d",
"cpu": "MOS6502X",
"emulator": "xplus4",
"defines": {

@ -1,3 +1,3 @@
.pc = $1001 "Basic"
:BasicUpstart(%E)
.pc = $100d "Program"
.pc = %P "Program"

@ -1,6 +1,7 @@
{
"extension": "prg",
"link": "plus4basic.ld",
"start_address": "0x100d",
"cpu": "MOS6502X",
"emulator": "xplus4",
"defines": {

@ -2,7 +2,7 @@
.file [name="%O", type="prg", segments="Program"]
.segmentdef Program [segments="Basic, Code, Data"]
.segmentdef Basic [start=$1001]
.segmentdef Code [start=$100e]
.segmentdef Code [start=%P]
.segmentdef Data [startAfter="Code"]
.segment Basic
:BasicUpstart(%E)

Some files were not shown because too many files have changed in this diff Show More