diff --git a/.idea/libraries/Maven__cml_kickass_kickassembler_4_19.xml b/.idea/libraries/Maven__cml_kickass_kickassembler_5_7.xml similarity index 57% rename from .idea/libraries/Maven__cml_kickass_kickassembler_4_19.xml rename to .idea/libraries/Maven__cml_kickass_kickassembler_5_7.xml index e4469154b..115e15aa8 100644 --- a/.idea/libraries/Maven__cml_kickass_kickassembler_4_19.xml +++ b/.idea/libraries/Maven__cml_kickass_kickassembler_5_7.xml @@ -1,13 +1,14 @@ - + - + - + - + + \ No newline at end of file diff --git a/kickc.iml b/kickc.iml index 41129d6c5..dbd71816b 100644 --- a/kickc.iml +++ b/kickc.iml @@ -22,7 +22,7 @@ - + \ No newline at end of file diff --git a/pom.xml b/pom.xml index 740edc9a1..3d02eeb37 100644 --- a/pom.xml +++ b/pom.xml @@ -44,7 +44,7 @@ cml.kickass kickassembler - 4.19 + 5.7 info.picocli @@ -84,6 +84,7 @@ false all 5 + false diff --git a/repo/cml/kickass/kickassembler/4.19/_remote.repositories b/repo/cml/kickass/kickassembler/4.19/_remote.repositories new file mode 100644 index 000000000..9a3aecc96 --- /dev/null +++ b/repo/cml/kickass/kickassembler/4.19/_remote.repositories @@ -0,0 +1,3 @@ +#NOTE: This is a Maven Resolver internal implementation file, its format can be changed without prior notice. +#Sun Jul 07 13:12:08 CEST 2019 +kickassembler-4.19.jar>= diff --git a/repo/cml/kickass/kickassembler/5.7/_remote.repositories b/repo/cml/kickass/kickassembler/5.7/_remote.repositories new file mode 100644 index 000000000..5d195d0e6 --- /dev/null +++ b/repo/cml/kickass/kickassembler/5.7/_remote.repositories @@ -0,0 +1,4 @@ +#NOTE: This is a Maven Resolver internal implementation file, its format can be changed without prior notice. +#Sun Jul 07 13:17:44 CEST 2019 +kickassembler-5.7.jar>= +kickassembler-5.7.pom>= diff --git a/repo/cml/kickass/kickassembler/5.7/kickassembler-5.7.jar b/repo/cml/kickass/kickassembler/5.7/kickassembler-5.7.jar new file mode 100644 index 000000000..0908f891f Binary files /dev/null and b/repo/cml/kickass/kickassembler/5.7/kickassembler-5.7.jar differ diff --git a/repo/cml/kickass/kickassembler/5.7/kickassembler-5.7.jar.md5 b/repo/cml/kickass/kickassembler/5.7/kickassembler-5.7.jar.md5 new file mode 100644 index 000000000..ba41426cc --- /dev/null +++ b/repo/cml/kickass/kickassembler/5.7/kickassembler-5.7.jar.md5 @@ -0,0 +1 @@ +5185c4b9ba60f3e39d5cb665245136e5 \ No newline at end of file diff --git a/repo/cml/kickass/kickassembler/5.7/kickassembler-5.7.jar.sha1 b/repo/cml/kickass/kickassembler/5.7/kickassembler-5.7.jar.sha1 new file mode 100644 index 000000000..d45e27d3c --- /dev/null +++ b/repo/cml/kickass/kickassembler/5.7/kickassembler-5.7.jar.sha1 @@ -0,0 +1 @@ +56f3815f668ba13bf8c2d735a1f77c9fa250b134 \ No newline at end of file diff --git a/repo/cml/kickass/kickassembler/5.7/kickassembler-5.7.pom b/repo/cml/kickass/kickassembler/5.7/kickassembler-5.7.pom new file mode 100644 index 000000000..b6905e88d --- /dev/null +++ b/repo/cml/kickass/kickassembler/5.7/kickassembler-5.7.pom @@ -0,0 +1,9 @@ + + + 4.0.0 + cml.kickass + kickassembler + 5.7 + POM was created from install:install-file + diff --git a/repo/cml/kickass/kickassembler/5.7/kickassembler-5.7.pom.md5 b/repo/cml/kickass/kickassembler/5.7/kickassembler-5.7.pom.md5 new file mode 100644 index 000000000..9df482305 --- /dev/null +++ b/repo/cml/kickass/kickassembler/5.7/kickassembler-5.7.pom.md5 @@ -0,0 +1 @@ +0044934e3e63a8f780e7573b5add4b1f \ No newline at end of file diff --git a/repo/cml/kickass/kickassembler/5.7/kickassembler-5.7.pom.sha1 b/repo/cml/kickass/kickassembler/5.7/kickassembler-5.7.pom.sha1 new file mode 100644 index 000000000..2225703d4 --- /dev/null +++ b/repo/cml/kickass/kickassembler/5.7/kickassembler-5.7.pom.sha1 @@ -0,0 +1 @@ +16520c872098ba177df082fbb11a6a21f42b342c \ No newline at end of file diff --git a/repo/cml/kickass/kickassembler/maven-metadata.xml b/repo/cml/kickass/kickassembler/maven-metadata.xml index 18adafc9f..6376ddbc3 100644 --- a/repo/cml/kickass/kickassembler/maven-metadata.xml +++ b/repo/cml/kickass/kickassembler/maven-metadata.xml @@ -3,10 +3,11 @@ cml.kickass kickassembler - 4.19 + 5.7 + 5.7 4.19 - 20180212211902 + 20190707111222 diff --git a/repo/cml/kickass/kickassembler/maven-metadata.xml.md5 b/repo/cml/kickass/kickassembler/maven-metadata.xml.md5 index aee75c74d..638176d20 100644 --- a/repo/cml/kickass/kickassembler/maven-metadata.xml.md5 +++ b/repo/cml/kickass/kickassembler/maven-metadata.xml.md5 @@ -1 +1 @@ -9199b475bc277b5f48523801dea7cd23 \ No newline at end of file +371050487d0341b8ad5e5115a28669c1 \ No newline at end of file diff --git a/repo/cml/kickass/kickassembler/maven-metadata.xml.sha1 b/repo/cml/kickass/kickassembler/maven-metadata.xml.sha1 index 8be78e388..bbabb5016 100644 --- a/repo/cml/kickass/kickassembler/maven-metadata.xml.sha1 +++ b/repo/cml/kickass/kickassembler/maven-metadata.xml.sha1 @@ -1 +1 @@ -2ca5f01c38aeb3757a88f908c4a73017974c0286 \ No newline at end of file +9e1e537f5927907ac635f4784fc82d467d20b70e \ No newline at end of file diff --git a/src/main/java/dk/camelot64/kickc/KickC.java b/src/main/java/dk/camelot64/kickc/KickC.java index 60c3336b0..70ae1c43a 100644 --- a/src/main/java/dk/camelot64/kickc/KickC.java +++ b/src/main/java/dk/camelot64/kickc/KickC.java @@ -205,7 +205,14 @@ public class KickC implements Callable { System.out.println("Assembling to " + prgPath.toString()); ByteArrayOutputStream kasmLogOutputStream = new ByteArrayOutputStream(); System.setOut(new PrintStream(kasmLogOutputStream)); - int kasmResult = KickAssembler.main2(new String[]{asmPath.toString(), "-log", kasmLogPath.toString(), "-o", prgPath.toString(), "-vicesymbols", "-showmem"}); + int kasmResult = -1; + try { + kasmResult = KickAssembler.main2(new String[]{asmPath.toString(), "-log", kasmLogPath.toString(), "-o", prgPath.toString(), "-vicesymbols", "-showmem"}); + } catch (Throwable e) { + throw new CompileError("KickAssembling file failed! " , e); + } finally { + System.setOut(new PrintStream(new FileOutputStream(FileDescriptor.out))); + } System.setOut(new PrintStream(new FileOutputStream(FileDescriptor.out))); if(kasmResult != 0) { throw new CompileError("KickAssembling file failed! " + kasmLogOutputStream.toString()); diff --git a/src/main/java/dk/camelot64/kickc/passes/Pass5FixLongBranches.java b/src/main/java/dk/camelot64/kickc/passes/Pass5FixLongBranches.java index 82b6d83f5..a4cc12dfb 100644 --- a/src/main/java/dk/camelot64/kickc/passes/Pass5FixLongBranches.java +++ b/src/main/java/dk/camelot64/kickc/passes/Pass5FixLongBranches.java @@ -80,8 +80,14 @@ public class Pass5FixLongBranches extends Pass5AsmOptimization { File asmPrgFile = getTmpFile(fileName, ".prg"); ByteArrayOutputStream kickAssOut = new ByteArrayOutputStream(); System.setOut(new PrintStream(kickAssOut)); - int asmRes = KickAssembler.main2(new String[]{asmFile.getAbsolutePath(), "-o", asmPrgFile.getAbsolutePath()}); - System.setOut(new PrintStream(new FileOutputStream(FileDescriptor.out))); + int asmRes = -1; + try { + asmRes = KickAssembler.main2(new String[]{asmFile.getAbsolutePath(), "-o", asmPrgFile.getAbsolutePath()}); + } catch(Throwable e) { + throw new CompileError("Error! KickAssembler failed, while trying to fix long branch. " + e); + } finally { + System.setOut(new PrintStream(new FileOutputStream(FileDescriptor.out))); + } String output = kickAssOut.toString(); // Look for a long branch distance error diff --git a/src/main/repo/mvn-repo-install.sh b/src/main/repo/mvn-repo-install.sh new file mode 100644 index 000000000..542fde7d3 --- /dev/null +++ b/src/main/repo/mvn-repo-install.sh @@ -0,0 +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.7 \ No newline at end of file diff --git a/src/test/java/dk/camelot64/kickc/test/TestKickAssRun.java b/src/test/java/dk/camelot64/kickc/test/TestKickAssRun.java new file mode 100644 index 000000000..2bdf10a14 --- /dev/null +++ b/src/test/java/dk/camelot64/kickc/test/TestKickAssRun.java @@ -0,0 +1,46 @@ +package dk.camelot64.kickc.test; + +import kickass.KickAssembler; +import org.junit.Test; + +import java.io.*; +import java.net.URI; +import java.net.URISyntaxException; +import java.nio.file.FileSystems; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; + +public class TestKickAssRun { + + @Test + public void testKickAssRun() throws IOException, URISyntaxException { + ReferenceHelper asmHelper = new ReferenceHelperFolder("src/test/java/dk/camelot64/kickc/test/"); + URI asmUri = asmHelper.loadReferenceFile("kickasstest", ".asm"); + Path asmPath = Paths.get(asmUri); + File asmPrgFile = getTmpFile("kickasstest", ".prg"); + ByteArrayOutputStream kickAssOut = new ByteArrayOutputStream(); + System.setOut(new PrintStream(kickAssOut)); + try { + KickAssembler.main2(new String[]{asmPath.toAbsolutePath().toString(), "-o", asmPrgFile.getAbsolutePath()}); + } catch (AssertionError e) { + System.setOut(new PrintStream(new FileOutputStream(FileDescriptor.out))); + String output = kickAssOut.toString(); + System.out.println(output); + throw e; + } finally { + System.setOut(new PrintStream(new FileOutputStream(FileDescriptor.out))); + } + String output = kickAssOut.toString(); + System.out.println(output); + } + + + public File getTmpFile(String fileName, String extension) throws IOException { + Path tmpDir = Files.createTempDirectory("kickc"); + Path kcPath = FileSystems.getDefault().getPath(fileName); + return new File(tmpDir.toFile(), kcPath.getFileName().toString() + extension); + } + + +} diff --git a/src/test/java/dk/camelot64/kickc/test/TestPrograms.java b/src/test/java/dk/camelot64/kickc/test/TestPrograms.java index a1d387e50..a66f5b18a 100644 --- a/src/test/java/dk/camelot64/kickc/test/TestPrograms.java +++ b/src/test/java/dk/camelot64/kickc/test/TestPrograms.java @@ -2614,8 +2614,14 @@ public class TestPrograms { File asmLogFile = getBinFile(fileName, ".log"); ByteArrayOutputStream kickAssOut = new ByteArrayOutputStream(); System.setOut(new PrintStream(kickAssOut)); - int asmRes = KickAssembler.main2(new String[]{asmFile.getAbsolutePath(), "-log", asmLogFile.getAbsolutePath(), "-o", asmPrgFile.getAbsolutePath(), "-vicesymbols", "-showmem"}); - System.setOut(new PrintStream(new FileOutputStream(FileDescriptor.out))); + int asmRes = -1; + try { + asmRes = KickAssembler.main2(new String[]{asmFile.getAbsolutePath(), "-log", asmLogFile.getAbsolutePath(), "-o", asmPrgFile.getAbsolutePath(), "-vicesymbols", "-showmem"}); + } catch(Throwable e) { + fail("KickAssembling file failed! " + e.getMessage()); + } finally { + System.setOut(new PrintStream(new FileOutputStream(FileDescriptor.out))); + } if(asmRes != 0) { fail("KickAssembling file failed! " + kickAssOut.toString()); } diff --git a/src/test/java/dk/camelot64/kickc/test/kickasstest.asm b/src/test/java/dk/camelot64/kickc/test/kickasstest.asm new file mode 100644 index 000000000..b4bdb5933 --- /dev/null +++ b/src/test/java/dk/camelot64/kickc/test/kickasstest.asm @@ -0,0 +1,15 @@ +// Minimal if() test +.pc = $801 "Basic" +:BasicUpstart(main) +.pc = $80d "Program" + .label SCREEN = $400 +main: { + ldx #0 + lda #'a' + b1: + sta SCREEN,x + inx + cpx #40 + bcc b1 + rts +}