diff --git a/.idea/kotlinc.xml b/.idea/kotlinc.xml
deleted file mode 100644
index 9b02d599e..000000000
--- a/.idea/kotlinc.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
index 41548303d..634d0b23e 100644
--- a/.idea/modules.xml
+++ b/.idea/modules.xml
@@ -2,7 +2,8 @@
-
+
+
diff --git a/codeGeneration/build.gradle b/codeGenCpu6502/build.gradle
similarity index 100%
rename from codeGeneration/build.gradle
rename to codeGenCpu6502/build.gradle
diff --git a/codeGenCpu6502/codeGenCpu6502.iml b/codeGenCpu6502/codeGenCpu6502.iml
new file mode 100644
index 000000000..f04990594
--- /dev/null
+++ b/codeGenCpu6502/codeGenCpu6502.iml
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/codeGeneration/src/prog8/codegen/target/cpu6502/codegen/AsmGen.kt b/codeGenCpu6502/src/prog8/codegen/cpu6502/AsmGen.kt
similarity index 99%
rename from codeGeneration/src/prog8/codegen/target/cpu6502/codegen/AsmGen.kt
rename to codeGenCpu6502/src/prog8/codegen/cpu6502/AsmGen.kt
index cb899ea7f..06d170a2b 100644
--- a/codeGeneration/src/prog8/codegen/target/cpu6502/codegen/AsmGen.kt
+++ b/codeGenCpu6502/src/prog8/codegen/cpu6502/AsmGen.kt
@@ -1,4 +1,4 @@
-package prog8.codegen.target.cpu6502.codegen
+package prog8.codegen.cpu6502
import com.github.michaelbull.result.fold
import com.github.michaelbull.result.onSuccess
@@ -7,17 +7,7 @@ import prog8.ast.antlr.escape
import prog8.ast.base.*
import prog8.ast.expressions.*
import prog8.ast.statements.*
-import prog8.codegen.target.AssemblyError
-import prog8.codegen.target.C64Target
-import prog8.codegen.target.Cx16Target
-import prog8.codegen.target.cbm.AssemblyProgram
-import prog8.codegen.target.cbm.loadAsmIncludeFile
-import prog8.codegen.target.cpu6502.codegen.assignment.AsmAssignSource
-import prog8.codegen.target.cpu6502.codegen.assignment.AsmAssignTarget
-import prog8.codegen.target.cpu6502.codegen.assignment.AsmAssignment
-import prog8.codegen.target.cpu6502.codegen.assignment.AssignmentAsmGen
-import prog8.codegen.target.cpu6502.codegen.assignment.SourceStorageKind
-import prog8.codegen.target.cpu6502.codegen.assignment.TargetStorageKind
+import prog8.codegen.cpu6502.assignment.*
import prog8.compilerinterface.*
import prog8.parser.SourceCode
import java.nio.file.Path
@@ -158,7 +148,7 @@ class AsmGen(private val program: Program,
}
internal fun isTargetCpu(cpu: CpuType) = compTarget.machine.cpu == cpu
- internal fun haveFPWR() = compTarget is Cx16Target
+ internal fun haveFPWRcall() = compTarget.name=="cx16"
internal fun asmsubArgsEvalOrder(sub: Subroutine) =
compTarget.asmsubArgsEvalOrder(sub)
@@ -232,12 +222,12 @@ class AsmGen(private val program: Program,
// make sure that on the cx16 and c64, basic rom is banked in again when we exit the program
when(compTarget.name) {
- Cx16Target.name -> {
+ "cx16" -> {
if(options.floats)
out(" lda #4 | sta $01") // to use floats, make sure Basic rom is banked in
out(" jsr main.start | lda #4 | sta $01 | rts")
}
- C64Target.name -> out(" jsr main.start | lda #31 | sta $01 | rts")
+ "c64" -> out(" jsr main.start | lda #31 | sta $01 | rts")
else -> jmp("main.start")
}
}
diff --git a/codeGeneration/src/prog8/codegen/target/cpu6502/codegen/AsmOptimizer.kt b/codeGenCpu6502/src/prog8/codegen/cpu6502/AsmOptimizer.kt
similarity index 99%
rename from codeGeneration/src/prog8/codegen/target/cpu6502/codegen/AsmOptimizer.kt
rename to codeGenCpu6502/src/prog8/codegen/cpu6502/AsmOptimizer.kt
index ce940de6d..9a313ceaf 100644
--- a/codeGeneration/src/prog8/codegen/target/cpu6502/codegen/AsmOptimizer.kt
+++ b/codeGenCpu6502/src/prog8/codegen/cpu6502/AsmOptimizer.kt
@@ -1,4 +1,4 @@
-package prog8.codegen.target.cpu6502.codegen
+package prog8.codegen.cpu6502
import prog8.ast.Program
import prog8.ast.base.VarDeclType
diff --git a/codeGeneration/src/prog8/codegen/target/cbm/AssemblyProgram.kt b/codeGenCpu6502/src/prog8/codegen/cpu6502/AssemblyProgram.kt
similarity index 95%
rename from codeGeneration/src/prog8/codegen/target/cbm/AssemblyProgram.kt
rename to codeGenCpu6502/src/prog8/codegen/cpu6502/AssemblyProgram.kt
index 4968d4cea..37f553bc7 100644
--- a/codeGeneration/src/prog8/codegen/target/cbm/AssemblyProgram.kt
+++ b/codeGenCpu6502/src/prog8/codegen/cpu6502/AssemblyProgram.kt
@@ -1,12 +1,12 @@
-package prog8.codegen.target.cbm
+package prog8.codegen.cpu6502
import com.github.michaelbull.result.Ok
import com.github.michaelbull.result.Result
import com.github.michaelbull.result.mapError
-import prog8.codegen.target.cpu6502.codegen.generatedLabelPrefix
import prog8.compilerinterface.CompilationOptions
import prog8.compilerinterface.IAssemblyProgram
import prog8.compilerinterface.OutputType
+import prog8.compilerinterface.viceMonListName
import prog8.parser.SourceCode
import java.io.File
import java.nio.file.Path
@@ -14,8 +14,6 @@ import kotlin.io.path.Path
import kotlin.io.path.isRegularFile
-internal fun viceMonListName(baseFilename: String) = "$baseFilename.vice-mon-list"
-
class AssemblyProgram(
override val valid: Boolean,
override val name: String,
diff --git a/codeGeneration/src/prog8/codegen/target/cpu6502/codegen/BuiltinFunctionsAsmGen.kt b/codeGenCpu6502/src/prog8/codegen/cpu6502/BuiltinFunctionsAsmGen.kt
similarity index 99%
rename from codeGeneration/src/prog8/codegen/target/cpu6502/codegen/BuiltinFunctionsAsmGen.kt
rename to codeGenCpu6502/src/prog8/codegen/cpu6502/BuiltinFunctionsAsmGen.kt
index 7a2964d50..6d5da5126 100644
--- a/codeGeneration/src/prog8/codegen/target/cpu6502/codegen/BuiltinFunctionsAsmGen.kt
+++ b/codeGenCpu6502/src/prog8/codegen/cpu6502/BuiltinFunctionsAsmGen.kt
@@ -1,4 +1,4 @@
-package prog8.codegen.target.cpu6502.codegen
+package prog8.codegen.cpu6502
import prog8.ast.IFunctionCall
import prog8.ast.Node
@@ -10,9 +10,13 @@ import prog8.ast.statements.DirectMemoryWrite
import prog8.ast.statements.FunctionCallStatement
import prog8.ast.statements.Subroutine
import prog8.ast.toHex
-import prog8.codegen.target.AssemblyError
-import prog8.codegen.target.Cx16Target
-import prog8.codegen.target.cpu6502.codegen.assignment.*
+import prog8.codegen.cpu6502.assignment.*
+import prog8.codegen.cpu6502.assignment.AsmAssignSource
+import prog8.codegen.cpu6502.assignment.AsmAssignTarget
+import prog8.codegen.cpu6502.assignment.AsmAssignment
+import prog8.codegen.cpu6502.assignment.AssignmentAsmGen
+import prog8.codegen.cpu6502.assignment.SourceStorageKind
+import prog8.compilerinterface.AssemblyError
import prog8.compilerinterface.BuiltinFunctions
import prog8.compilerinterface.CpuType
import prog8.compilerinterface.FSignature
@@ -276,7 +280,7 @@ internal class BuiltinFunctionsAsmGen(private val program: Program, private val
}
private fun funcCallFar(fcall: IFunctionCall) {
- if(asmgen.options.compTarget !is Cx16Target)
+ if(asmgen.options.compTarget.name != "cx16")
throw AssemblyError("callfar only works on cx16 target at this time")
val bank = fcall.args[0].constValue(program)?.number?.toInt()
@@ -321,7 +325,7 @@ internal class BuiltinFunctionsAsmGen(private val program: Program, private val
}
private fun funcCallRom(fcall: IFunctionCall) {
- if(asmgen.options.compTarget !is Cx16Target)
+ if(asmgen.options.compTarget.name != "cx16")
throw AssemblyError("callrom only works on cx16 target at this time")
val bank = fcall.args[0].constValue(program)?.number?.toInt()
diff --git a/codeGeneration/src/prog8/codegen/target/cpu6502/codegen/ExpressionsAsmGen.kt b/codeGenCpu6502/src/prog8/codegen/cpu6502/ExpressionsAsmGen.kt
similarity index 99%
rename from codeGeneration/src/prog8/codegen/target/cpu6502/codegen/ExpressionsAsmGen.kt
rename to codeGenCpu6502/src/prog8/codegen/cpu6502/ExpressionsAsmGen.kt
index 4fa0be19b..877005e2e 100644
--- a/codeGeneration/src/prog8/codegen/target/cpu6502/codegen/ExpressionsAsmGen.kt
+++ b/codeGenCpu6502/src/prog8/codegen/cpu6502/ExpressionsAsmGen.kt
@@ -1,4 +1,4 @@
-package prog8.codegen.target.cpu6502.codegen
+package prog8.codegen.cpu6502
import prog8.ast.Program
import prog8.ast.base.*
@@ -6,7 +6,7 @@ import prog8.ast.expressions.*
import prog8.ast.statements.BuiltinFunctionPlaceholder
import prog8.ast.statements.Subroutine
import prog8.ast.toHex
-import prog8.codegen.target.AssemblyError
+import prog8.compilerinterface.AssemblyError
import prog8.compilerinterface.BuiltinFunctions
import prog8.compilerinterface.CpuType
import kotlin.math.absoluteValue
diff --git a/codeGeneration/src/prog8/codegen/target/cpu6502/codegen/ForLoopsAsmGen.kt b/codeGenCpu6502/src/prog8/codegen/cpu6502/ForLoopsAsmGen.kt
similarity index 99%
rename from codeGeneration/src/prog8/codegen/target/cpu6502/codegen/ForLoopsAsmGen.kt
rename to codeGenCpu6502/src/prog8/codegen/cpu6502/ForLoopsAsmGen.kt
index bb466c649..2dcff3e45 100644
--- a/codeGeneration/src/prog8/codegen/target/cpu6502/codegen/ForLoopsAsmGen.kt
+++ b/codeGenCpu6502/src/prog8/codegen/cpu6502/ForLoopsAsmGen.kt
@@ -1,4 +1,4 @@
-package prog8.codegen.target.cpu6502.codegen
+package prog8.codegen.cpu6502
import com.github.michaelbull.result.fold
import prog8.ast.Program
@@ -9,7 +9,7 @@ import prog8.ast.expressions.IdentifierReference
import prog8.ast.expressions.RangeExpression
import prog8.ast.statements.ForLoop
import prog8.ast.toHex
-import prog8.codegen.target.AssemblyError
+import prog8.compilerinterface.AssemblyError
import kotlin.math.absoluteValue
internal class ForLoopsAsmGen(private val program: Program, private val asmgen: AsmGen) {
diff --git a/codeGeneration/src/prog8/codegen/target/cpu6502/codegen/FunctionCallAsmGen.kt b/codeGenCpu6502/src/prog8/codegen/cpu6502/FunctionCallAsmGen.kt
similarity index 98%
rename from codeGeneration/src/prog8/codegen/target/cpu6502/codegen/FunctionCallAsmGen.kt
rename to codeGenCpu6502/src/prog8/codegen/cpu6502/FunctionCallAsmGen.kt
index b2b11e6b8..5db14a623 100644
--- a/codeGeneration/src/prog8/codegen/target/cpu6502/codegen/FunctionCallAsmGen.kt
+++ b/codeGenCpu6502/src/prog8/codegen/cpu6502/FunctionCallAsmGen.kt
@@ -1,4 +1,4 @@
-package prog8.codegen.target.cpu6502.codegen
+package prog8.codegen.cpu6502
import prog8.ast.IFunctionCall
import prog8.ast.Node
@@ -9,11 +9,11 @@ import prog8.ast.expressions.Expression
import prog8.ast.expressions.IdentifierReference
import prog8.ast.expressions.NumericLiteralValue
import prog8.ast.statements.*
-import prog8.codegen.target.AssemblyError
-import prog8.codegen.target.cpu6502.codegen.assignment.AsmAssignSource
-import prog8.codegen.target.cpu6502.codegen.assignment.AsmAssignTarget
-import prog8.codegen.target.cpu6502.codegen.assignment.AsmAssignment
-import prog8.codegen.target.cpu6502.codegen.assignment.TargetStorageKind
+import prog8.codegen.cpu6502.assignment.AsmAssignSource
+import prog8.codegen.cpu6502.assignment.AsmAssignTarget
+import prog8.codegen.cpu6502.assignment.AsmAssignment
+import prog8.codegen.cpu6502.assignment.TargetStorageKind
+import prog8.compilerinterface.AssemblyError
import prog8.compilerinterface.CpuType
diff --git a/codeGeneration/src/prog8/codegen/target/cpu6502/codegen/PostIncrDecrAsmGen.kt b/codeGenCpu6502/src/prog8/codegen/cpu6502/PostIncrDecrAsmGen.kt
similarity index 98%
rename from codeGeneration/src/prog8/codegen/target/cpu6502/codegen/PostIncrDecrAsmGen.kt
rename to codeGenCpu6502/src/prog8/codegen/cpu6502/PostIncrDecrAsmGen.kt
index 7233080e4..d5615db23 100644
--- a/codeGeneration/src/prog8/codegen/target/cpu6502/codegen/PostIncrDecrAsmGen.kt
+++ b/codeGenCpu6502/src/prog8/codegen/cpu6502/PostIncrDecrAsmGen.kt
@@ -1,4 +1,4 @@
-package prog8.codegen.target.cpu6502.codegen
+package prog8.codegen.cpu6502
import prog8.ast.Program
import prog8.ast.base.*
@@ -6,7 +6,7 @@ import prog8.ast.expressions.IdentifierReference
import prog8.ast.expressions.NumericLiteralValue
import prog8.ast.statements.PostIncrDecr
import prog8.ast.toHex
-import prog8.codegen.target.AssemblyError
+import prog8.compilerinterface.AssemblyError
internal class PostIncrDecrAsmGen(private val program: Program, private val asmgen: AsmGen) {
diff --git a/codeGeneration/src/prog8/codegen/target/cpu6502/codegen/assignment/AsmAssignment.kt b/codeGenCpu6502/src/prog8/codegen/cpu6502/assignment/AsmAssignment.kt
similarity index 98%
rename from codeGeneration/src/prog8/codegen/target/cpu6502/codegen/assignment/AsmAssignment.kt
rename to codeGenCpu6502/src/prog8/codegen/cpu6502/assignment/AsmAssignment.kt
index fb9ed3bce..e5f4a2045 100644
--- a/codeGeneration/src/prog8/codegen/target/cpu6502/codegen/assignment/AsmAssignment.kt
+++ b/codeGenCpu6502/src/prog8/codegen/cpu6502/assignment/AsmAssignment.kt
@@ -1,12 +1,12 @@
-package prog8.codegen.target.cpu6502.codegen.assignment
+package prog8.codegen.cpu6502.assignment
import prog8.ast.Program
import prog8.ast.base.*
import prog8.ast.expressions.*
import prog8.ast.statements.*
+import prog8.codegen.cpu6502.AsmGen
+import prog8.compilerinterface.AssemblyError
import prog8.compilerinterface.IMemSizer
-import prog8.codegen.target.AssemblyError
-import prog8.codegen.target.cpu6502.codegen.AsmGen
internal enum class TargetStorageKind {
diff --git a/codeGeneration/src/prog8/codegen/target/cpu6502/codegen/assignment/AssignmentAsmGen.kt b/codeGenCpu6502/src/prog8/codegen/cpu6502/assignment/AssignmentAsmGen.kt
similarity index 99%
rename from codeGeneration/src/prog8/codegen/target/cpu6502/codegen/assignment/AssignmentAsmGen.kt
rename to codeGenCpu6502/src/prog8/codegen/cpu6502/assignment/AssignmentAsmGen.kt
index b8c351715..7f40e1364 100644
--- a/codeGeneration/src/prog8/codegen/target/cpu6502/codegen/assignment/AssignmentAsmGen.kt
+++ b/codeGenCpu6502/src/prog8/codegen/cpu6502/assignment/AssignmentAsmGen.kt
@@ -1,12 +1,12 @@
-package prog8.codegen.target.cpu6502.codegen.assignment
+package prog8.codegen.cpu6502.assignment
import prog8.ast.Program
import prog8.ast.base.*
import prog8.ast.expressions.*
import prog8.ast.statements.*
import prog8.ast.toHex
-import prog8.codegen.target.AssemblyError
-import prog8.codegen.target.cpu6502.codegen.AsmGen
+import prog8.codegen.cpu6502.AsmGen
+import prog8.compilerinterface.AssemblyError
import prog8.compilerinterface.BuiltinFunctions
import prog8.compilerinterface.CpuType
import prog8.compilerinterface.builtinFunctionReturnType
diff --git a/codeGeneration/src/prog8/codegen/target/cpu6502/codegen/assignment/AugmentableAssignmentAsmGen.kt b/codeGenCpu6502/src/prog8/codegen/cpu6502/assignment/AugmentableAssignmentAsmGen.kt
similarity index 99%
rename from codeGeneration/src/prog8/codegen/target/cpu6502/codegen/assignment/AugmentableAssignmentAsmGen.kt
rename to codeGenCpu6502/src/prog8/codegen/cpu6502/assignment/AugmentableAssignmentAsmGen.kt
index 69f559f79..e8bff62ad 100644
--- a/codeGeneration/src/prog8/codegen/target/cpu6502/codegen/assignment/AugmentableAssignmentAsmGen.kt
+++ b/codeGenCpu6502/src/prog8/codegen/cpu6502/assignment/AugmentableAssignmentAsmGen.kt
@@ -1,12 +1,12 @@
-package prog8.codegen.target.cpu6502.codegen.assignment
+package prog8.codegen.cpu6502.assignment
import prog8.ast.Program
import prog8.ast.base.*
import prog8.ast.expressions.*
import prog8.ast.statements.Subroutine
import prog8.ast.toHex
-import prog8.codegen.target.AssemblyError
-import prog8.codegen.target.cpu6502.codegen.AsmGen
+import prog8.codegen.cpu6502.AsmGen
+import prog8.compilerinterface.AssemblyError
import prog8.compilerinterface.CpuType
@@ -1628,7 +1628,7 @@ internal class AugmentableAssignmentAsmGen(private val program: Program,
asmgen.saveRegisterLocal(CpuRegister.X, scope)
when (operator) {
"**" -> {
- if(asmgen.haveFPWR()) {
+ if(asmgen.haveFPWRcall()) {
asmgen.out("""
lda #<$name
ldy #>$name
@@ -1705,7 +1705,7 @@ internal class AugmentableAssignmentAsmGen(private val program: Program,
asmgen.saveRegisterLocal(CpuRegister.X, scope)
when (operator) {
"**" -> {
- if(asmgen.haveFPWR()) {
+ if(asmgen.haveFPWRcall()) {
asmgen.out("""
lda #<$name
ldy #>$name
diff --git a/codeGenTargets/build.gradle b/codeGenTargets/build.gradle
new file mode 100644
index 000000000..7c4ddac06
--- /dev/null
+++ b/codeGenTargets/build.gradle
@@ -0,0 +1,46 @@
+
+plugins {
+ id 'java'
+ id 'application'
+ id "org.jetbrains.kotlin.jvm"
+}
+
+java {
+ toolchain {
+ languageVersion = JavaLanguageVersion.of(javaVersion)
+ }
+}
+
+compileKotlin {
+ kotlinOptions {
+ jvmTarget = javaVersion
+ }
+}
+
+compileTestKotlin {
+ kotlinOptions {
+ jvmTarget = javaVersion
+ }
+}
+
+dependencies {
+ implementation project(':compilerInterfaces')
+ implementation project(':compilerAst')
+ implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
+ // implementation "org.jetbrains.kotlin:kotlin-reflect"
+ implementation "com.michael-bull.kotlin-result:kotlin-result-jvm:1.1.12"
+
+}
+
+sourceSets {
+ main {
+ java {
+ srcDirs = ["${project.projectDir}/src"]
+ }
+ resources {
+ srcDirs = ["${project.projectDir}/res"]
+ }
+ }
+}
+
+// note: there are no unit tests in this module!
diff --git a/codeGeneration/codeGeneration.iml b/codeGenTargets/codeGenTargets.iml
similarity index 100%
rename from codeGeneration/codeGeneration.iml
rename to codeGenTargets/codeGenTargets.iml
diff --git a/codeGeneration/readme-tests.txt b/codeGenTargets/readme-tests.txt
similarity index 100%
rename from codeGeneration/readme-tests.txt
rename to codeGenTargets/readme-tests.txt
diff --git a/codeGeneration/src/prog8/codegen/target/C128Target.kt b/codeGenTargets/src/prog8/codegen/target/C128Target.kt
similarity index 88%
rename from codeGeneration/src/prog8/codegen/target/C128Target.kt
rename to codeGenTargets/src/prog8/codegen/target/C128Target.kt
index 608740412..379475814 100644
--- a/codeGeneration/src/prog8/codegen/target/C128Target.kt
+++ b/codeGenTargets/src/prog8/codegen/target/C128Target.kt
@@ -7,9 +7,9 @@ import prog8.ast.base.WordDatatypes
import prog8.ast.expressions.Expression
import prog8.ast.statements.RegisterOrStatusflag
import prog8.ast.statements.Subroutine
+import prog8.codegen.target.cbm.asmsub6502ArgsEvalOrder
+import prog8.codegen.target.cbm.asmsub6502ArgsHaveRegisterClobberRisk
import prog8.codegen.target.c128.C128MachineDefinition
-import prog8.codegen.target.cpu6502.codegen.asmsub6502ArgsEvalOrder
-import prog8.codegen.target.cpu6502.codegen.asmsub6502ArgsHaveRegisterClobberRisk
import prog8.compilerinterface.ICompilationTarget
import prog8.compilerinterface.IStringEncoding
diff --git a/codeGeneration/src/prog8/codegen/target/C64Target.kt b/codeGenTargets/src/prog8/codegen/target/C64Target.kt
similarity index 88%
rename from codeGeneration/src/prog8/codegen/target/C64Target.kt
rename to codeGenTargets/src/prog8/codegen/target/C64Target.kt
index b8c8489de..f49efb0b8 100644
--- a/codeGeneration/src/prog8/codegen/target/C64Target.kt
+++ b/codeGenTargets/src/prog8/codegen/target/C64Target.kt
@@ -7,9 +7,9 @@ import prog8.ast.base.WordDatatypes
import prog8.ast.expressions.Expression
import prog8.ast.statements.RegisterOrStatusflag
import prog8.ast.statements.Subroutine
+import prog8.codegen.target.cbm.asmsub6502ArgsEvalOrder
+import prog8.codegen.target.cbm.asmsub6502ArgsHaveRegisterClobberRisk
import prog8.codegen.target.c64.C64MachineDefinition
-import prog8.codegen.target.cpu6502.codegen.asmsub6502ArgsEvalOrder
-import prog8.codegen.target.cpu6502.codegen.asmsub6502ArgsHaveRegisterClobberRisk
import prog8.compilerinterface.ICompilationTarget
import prog8.compilerinterface.IStringEncoding
diff --git a/codeGeneration/src/prog8/codegen/target/Cx16Target.kt b/codeGenTargets/src/prog8/codegen/target/Cx16Target.kt
similarity index 88%
rename from codeGeneration/src/prog8/codegen/target/Cx16Target.kt
rename to codeGenTargets/src/prog8/codegen/target/Cx16Target.kt
index 4b08fc7f9..08a8481ef 100644
--- a/codeGeneration/src/prog8/codegen/target/Cx16Target.kt
+++ b/codeGenTargets/src/prog8/codegen/target/Cx16Target.kt
@@ -7,8 +7,8 @@ import prog8.ast.base.WordDatatypes
import prog8.ast.expressions.Expression
import prog8.ast.statements.RegisterOrStatusflag
import prog8.ast.statements.Subroutine
-import prog8.codegen.target.cpu6502.codegen.asmsub6502ArgsEvalOrder
-import prog8.codegen.target.cpu6502.codegen.asmsub6502ArgsHaveRegisterClobberRisk
+import prog8.codegen.target.cbm.asmsub6502ArgsEvalOrder
+import prog8.codegen.target.cbm.asmsub6502ArgsHaveRegisterClobberRisk
import prog8.codegen.target.cx16.CX16MachineDefinition
import prog8.compilerinterface.ICompilationTarget
import prog8.compilerinterface.IStringEncoding
diff --git a/codeGeneration/src/prog8/codegen/target/Encoder.kt b/codeGenTargets/src/prog8/codegen/target/Encoder.kt
similarity index 100%
rename from codeGeneration/src/prog8/codegen/target/Encoder.kt
rename to codeGenTargets/src/prog8/codegen/target/Encoder.kt
diff --git a/codeGeneration/src/prog8/codegen/target/c128/C128MachineDefinition.kt b/codeGenTargets/src/prog8/codegen/target/c128/C128MachineDefinition.kt
similarity index 96%
rename from codeGeneration/src/prog8/codegen/target/c128/C128MachineDefinition.kt
rename to codeGenTargets/src/prog8/codegen/target/c128/C128MachineDefinition.kt
index 602c9944f..b82dd40ff 100644
--- a/codeGeneration/src/prog8/codegen/target/c128/C128MachineDefinition.kt
+++ b/codeGenTargets/src/prog8/codegen/target/c128/C128MachineDefinition.kt
@@ -1,9 +1,7 @@
package prog8.codegen.target.c128
-import prog8.ast.base.DataType
import prog8.codegen.target.c64.normal6502instructions
import prog8.codegen.target.cbm.Mflpt5
-import prog8.codegen.target.cbm.viceMonListName
import prog8.compilerinterface.*
import java.io.IOException
import java.nio.file.Path
diff --git a/codeGeneration/src/prog8/codegen/target/c128/C128Zeropage.kt b/codeGenTargets/src/prog8/codegen/target/c128/C128Zeropage.kt
similarity index 100%
rename from codeGeneration/src/prog8/codegen/target/c128/C128Zeropage.kt
rename to codeGenTargets/src/prog8/codegen/target/c128/C128Zeropage.kt
diff --git a/codeGeneration/src/prog8/codegen/target/c64/C64MachineDefinition.kt b/codeGenTargets/src/prog8/codegen/target/c64/C64MachineDefinition.kt
similarity index 97%
rename from codeGeneration/src/prog8/codegen/target/c64/C64MachineDefinition.kt
rename to codeGenTargets/src/prog8/codegen/target/c64/C64MachineDefinition.kt
index c09f6469c..812b49cf0 100644
--- a/codeGeneration/src/prog8/codegen/target/c64/C64MachineDefinition.kt
+++ b/codeGenTargets/src/prog8/codegen/target/c64/C64MachineDefinition.kt
@@ -1,8 +1,6 @@
package prog8.codegen.target.c64
-import prog8.ast.base.DataType
import prog8.codegen.target.cbm.Mflpt5
-import prog8.codegen.target.cbm.viceMonListName
import prog8.compilerinterface.*
import java.io.IOException
import java.nio.file.Path
diff --git a/codeGeneration/src/prog8/codegen/target/c64/C64Zeropage.kt b/codeGenTargets/src/prog8/codegen/target/c64/C64Zeropage.kt
similarity index 100%
rename from codeGeneration/src/prog8/codegen/target/c64/C64Zeropage.kt
rename to codeGenTargets/src/prog8/codegen/target/c64/C64Zeropage.kt
diff --git a/codeGeneration/src/prog8/codegen/target/cpu6502/codegen/AsmsubHelpers.kt b/codeGenTargets/src/prog8/codegen/target/cbm/AsmsubHelpers.kt
similarity index 98%
rename from codeGeneration/src/prog8/codegen/target/cpu6502/codegen/AsmsubHelpers.kt
rename to codeGenTargets/src/prog8/codegen/target/cbm/AsmsubHelpers.kt
index 33d496c0c..f4ce9510e 100644
--- a/codeGeneration/src/prog8/codegen/target/cpu6502/codegen/AsmsubHelpers.kt
+++ b/codeGenTargets/src/prog8/codegen/target/cbm/AsmsubHelpers.kt
@@ -1,4 +1,4 @@
-package prog8.codegen.target.cpu6502.codegen
+package prog8.codegen.target.cbm
import prog8.ast.base.Cx16VirtualRegisters
import prog8.ast.base.RegisterOrPair
diff --git a/codeGeneration/src/prog8/codegen/target/cbm/IsoEncoding.kt b/codeGenTargets/src/prog8/codegen/target/cbm/IsoEncoding.kt
similarity index 100%
rename from codeGeneration/src/prog8/codegen/target/cbm/IsoEncoding.kt
rename to codeGenTargets/src/prog8/codegen/target/cbm/IsoEncoding.kt
diff --git a/codeGeneration/src/prog8/codegen/target/cbm/Mflpt5.kt b/codeGenTargets/src/prog8/codegen/target/cbm/Mflpt5.kt
similarity index 100%
rename from codeGeneration/src/prog8/codegen/target/cbm/Mflpt5.kt
rename to codeGenTargets/src/prog8/codegen/target/cbm/Mflpt5.kt
diff --git a/codeGeneration/src/prog8/codegen/target/cbm/PetsciiEncoding.kt b/codeGenTargets/src/prog8/codegen/target/cbm/PetsciiEncoding.kt
similarity index 100%
rename from codeGeneration/src/prog8/codegen/target/cbm/PetsciiEncoding.kt
rename to codeGenTargets/src/prog8/codegen/target/cbm/PetsciiEncoding.kt
diff --git a/codeGeneration/src/prog8/codegen/target/cx16/CX16MachineDefinition.kt b/codeGenTargets/src/prog8/codegen/target/cx16/CX16MachineDefinition.kt
similarity index 97%
rename from codeGeneration/src/prog8/codegen/target/cx16/CX16MachineDefinition.kt
rename to codeGenTargets/src/prog8/codegen/target/cx16/CX16MachineDefinition.kt
index f8a2bd689..84e0fffe6 100644
--- a/codeGeneration/src/prog8/codegen/target/cx16/CX16MachineDefinition.kt
+++ b/codeGenTargets/src/prog8/codegen/target/cx16/CX16MachineDefinition.kt
@@ -1,8 +1,6 @@
package prog8.codegen.target.cx16
-import prog8.ast.base.DataType
import prog8.codegen.target.cbm.Mflpt5
-import prog8.codegen.target.cbm.viceMonListName
import prog8.compilerinterface.*
import java.io.IOException
import java.nio.file.Path
diff --git a/codeGeneration/src/prog8/codegen/target/cx16/CX16Zeropage.kt b/codeGenTargets/src/prog8/codegen/target/cx16/CX16Zeropage.kt
similarity index 100%
rename from codeGeneration/src/prog8/codegen/target/cx16/CX16Zeropage.kt
rename to codeGenTargets/src/prog8/codegen/target/cx16/CX16Zeropage.kt
diff --git a/codeGeneration/src/prog8/codegen/target/AssemblyError.kt b/codeGeneration/src/prog8/codegen/target/AssemblyError.kt
deleted file mode 100644
index b3c5a92fd..000000000
--- a/codeGeneration/src/prog8/codegen/target/AssemblyError.kt
+++ /dev/null
@@ -1,3 +0,0 @@
-package prog8.codegen.target
-
-class AssemblyError(msg: String) : RuntimeException(msg)
diff --git a/compiler/build.gradle b/compiler/build.gradle
index b144968db..2df3f84b0 100644
--- a/compiler/build.gradle
+++ b/compiler/build.gradle
@@ -30,7 +30,8 @@ dependencies {
implementation project(':compilerInterfaces')
implementation project(':codeOptimizers')
implementation project(':compilerAst')
- implementation project(':codeGeneration')
+ implementation project(':codeGenTargets')
+ implementation project(':codeGenCpu6502')
implementation 'org.antlr:antlr4-runtime:4.9.2'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
// implementation "org.jetbrains.kotlin:kotlin-reflect"
diff --git a/compiler/compiler.iml b/compiler/compiler.iml
index 9d0945b65..6f83b7a1e 100644
--- a/compiler/compiler.iml
+++ b/compiler/compiler.iml
@@ -16,9 +16,10 @@
-
+
+
\ No newline at end of file
diff --git a/compiler/src/prog8/compiler/Compiler.kt b/compiler/src/prog8/compiler/Compiler.kt
index c994948cc..583771236 100644
--- a/compiler/src/prog8/compiler/Compiler.kt
+++ b/compiler/src/prog8/compiler/Compiler.kt
@@ -9,11 +9,11 @@ import prog8.ast.base.Position
import prog8.ast.expressions.Expression
import prog8.ast.expressions.NumericLiteralValue
import prog8.ast.statements.Directive
+import prog8.codegen.cpu6502.AsmGen
import prog8.codegen.target.C128Target
import prog8.compiler.astprocessing.*
import prog8.codegen.target.C64Target
import prog8.codegen.target.Cx16Target
-import prog8.codegen.target.cpu6502.codegen.AsmGen
import prog8.compilerinterface.*
import prog8.optimizer.*
import prog8.parser.ParseError
diff --git a/compiler/src/prog8/compiler/astprocessing/BeforeAsmAstChanger.kt b/compiler/src/prog8/compiler/astprocessing/BeforeAsmAstChanger.kt
index 877334b2e..fed8a6cec 100644
--- a/compiler/src/prog8/compiler/astprocessing/BeforeAsmAstChanger.kt
+++ b/compiler/src/prog8/compiler/astprocessing/BeforeAsmAstChanger.kt
@@ -10,7 +10,7 @@ import prog8.ast.statements.*
import prog8.ast.walk.AstWalker
import prog8.ast.walk.IAstModification
import prog8.ast.walk.IAstVisitor
-import prog8.codegen.target.AssemblyError
+import prog8.compilerinterface.AssemblyError
import prog8.compilerinterface.CompilationOptions
import prog8.compilerinterface.IErrorReporter
import prog8.compilerinterface.isIOAddress
diff --git a/compiler/test/codegeneration/TestAsmGenSymbols.kt b/compiler/test/codegeneration/TestAsmGenSymbols.kt
index 3dd2adf61..28b42dc1d 100644
--- a/compiler/test/codegeneration/TestAsmGenSymbols.kt
+++ b/compiler/test/codegeneration/TestAsmGenSymbols.kt
@@ -9,9 +9,9 @@ import prog8.ast.expressions.AddressOf
import prog8.ast.expressions.IdentifierReference
import prog8.ast.expressions.NumericLiteralValue
import prog8.ast.statements.*
+import prog8.codegen.cpu6502.AsmGen
import prog8.codegen.target.C64Target
import prog8.codegen.target.c64.C64Zeropage
-import prog8.codegen.target.cpu6502.codegen.AsmGen
import prog8.compilerinterface.*
import prog8.parser.SourceCode
import prog8tests.helpers.DummyFunctions
diff --git a/compiler/test/helpers/compileXyz.kt b/compiler/test/helpers/compileXyz.kt
index aaf369e44..8010730ef 100644
--- a/compiler/test/helpers/compileXyz.kt
+++ b/compiler/test/helpers/compileXyz.kt
@@ -3,12 +3,12 @@ package prog8tests.helpers
import io.kotest.assertions.withClue
import io.kotest.matchers.shouldBe
import prog8.ast.Program
+import prog8.codegen.cpu6502.AsmGen
import prog8.compiler.CompilationResult
import prog8.compiler.CompilerArguments
import prog8.compiler.compileProgram
import prog8.codegen.target.C64Target
import prog8.codegen.target.c64.C64Zeropage
-import prog8.codegen.target.cpu6502.codegen.AsmGen
import prog8.compilerinterface.*
import java.nio.file.Path
import kotlin.io.path.name
diff --git a/compilerInterfaces/src/prog8/compilerinterface/Exceptions.kt b/compilerInterfaces/src/prog8/compilerinterface/Exceptions.kt
index 1d82dc6d8..ad911d7f8 100644
--- a/compilerInterfaces/src/prog8/compilerinterface/Exceptions.kt
+++ b/compilerInterfaces/src/prog8/compilerinterface/Exceptions.kt
@@ -3,3 +3,5 @@ package prog8.compilerinterface
class InternalCompilerException(message: String?) : Exception(message)
class AbortCompilation(message: String?) : Exception(message)
+
+class AssemblyError(msg: String) : RuntimeException(msg)
diff --git a/compilerInterfaces/src/prog8/compilerinterface/IAssemblyGenerator.kt b/compilerInterfaces/src/prog8/compilerinterface/IAssemblyGenerator.kt
index 8d1b58394..ac87649a3 100644
--- a/compilerInterfaces/src/prog8/compilerinterface/IAssemblyGenerator.kt
+++ b/compilerInterfaces/src/prog8/compilerinterface/IAssemblyGenerator.kt
@@ -9,3 +9,5 @@ interface IAssemblyProgram {
val name: String
fun assemble(options: CompilationOptions): Int
}
+
+fun viceMonListName(baseFilename: String) = "$baseFilename.vice-mon-list"
diff --git a/scripts/clean.sh b/scripts/clean.sh
index b84eda5af..361d231a1 100755
--- a/scripts/clean.sh
+++ b/scripts/clean.sh
@@ -2,5 +2,5 @@
rm -f *.jar *.asm *.prg *.vm.txt *.vice-mon-list *.list a.out imgui.ini
rm -rf build out
-rm -rf compiler/build codeGeneration/build codeOptimizers/build compilerInterfaces/build compilerAst/build dbusCompilerService/build httpCompilerService/build parser/build
+rm -rf compiler/build codeGenTargets/build codeGenCpu6502/build codeOptimizers/build compilerInterfaces/build compilerAst/build dbusCompilerService/build httpCompilerService/build parser/build
diff --git a/settings.gradle b/settings.gradle
index 59cbdae7c..b8565579e 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -3,7 +3,8 @@ include(
':compilerInterfaces',
':compilerAst',
':codeOptimizers',
- ':codeGeneration',
+ ':codeGenTargets',
+ ':codeGenCpu6502',
':compiler',
':dbusCompilerService',
':httpCompilerService'