From 402884b5ce6b6d13222c5d1eb50cbce79325c1ff Mon Sep 17 00:00:00 2001 From: meisl Date: Sat, 17 Jul 2021 12:17:31 +0200 Subject: [PATCH] * fix #54 / step 2: the path stated with assembler directive .binary must be *relative to the .asm file*, not the working directory --- .../compiler/target/cpu6502/codegen/AsmGen.kt | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/compiler/src/prog8/compiler/target/cpu6502/codegen/AsmGen.kt b/compiler/src/prog8/compiler/target/cpu6502/codegen/AsmGen.kt index 6513f0deb..2a4b30b58 100644 --- a/compiler/src/prog8/compiler/target/cpu6502/codegen/AsmGen.kt +++ b/compiler/src/prog8/compiler/target/cpu6502/codegen/AsmGen.kt @@ -1309,19 +1309,26 @@ $repeatLabel lda $counterVar } } + /** + * TODO: %asminclude and %asmbinary should be done earlier than code gen (-> put content into AST) + */ private fun translate(stmt: Directive) { when(stmt.directive) { "%asminclude" -> { - val sourcecode = loadAsmIncludeFile(stmt.args[0].str!!, stmt.definingModule().source) + val includedName = stmt.args[0].str!! + val sourcePath = stmt.definingModule().source // FIXME: %asminclude inside non-library, non-filesystem module + val sourcecode = loadAsmIncludeFile(includedName, sourcePath) assemblyLines.add(sourcecode.trimEnd().trimStart('\n')) } "%asmbinary" -> { val includedName = stmt.args[0].str!! val offset = if(stmt.args.size>1) ", ${stmt.args[1].int}" else "" val length = if(stmt.args.size>2) ", ${stmt.args[2].int}" else "" - val includedPath = stmt.definingModule().source.resolveSibling(includedName) - val pathForAssembler = Paths.get("") - .absolute() // avoid IllegalArgumentExc in case non-absolute path .relativize(absolute path) + val sourcePath = stmt.definingModule().source // FIXME: %asmbinary inside non-library, non-filesystem module + val includedPath = sourcePath.resolveSibling(includedName) + + val pathForAssembler = outputDir // 64tass needs the path *relative to the .asm file* + .absolute() // avoid IllegalArgumentExc due to non-absolute path .relativize(absolute path) .relativize(includedPath) out(" .binary \"$pathForAssembler\" $offset $length") }