From 791dbbab9b60643f2fe0f92bf13166d7d615b42d Mon Sep 17 00:00:00 2001 From: Irmen de Jong Date: Thu, 18 Feb 2021 01:28:33 +0100 Subject: [PATCH] fixed block label itself not getting the correct memory address in the assembly fixed %asmbinary relative path issues --- .../src/prog8/compiler/target/c64/codegen/AsmGen.kt | 13 ++++++------- docs/source/todo.rst | 1 + 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/compiler/src/prog8/compiler/target/c64/codegen/AsmGen.kt b/compiler/src/prog8/compiler/target/c64/codegen/AsmGen.kt index 116d73084..41cec479b 100644 --- a/compiler/src/prog8/compiler/target/c64/codegen/AsmGen.kt +++ b/compiler/src/prog8/compiler/target/c64/codegen/AsmGen.kt @@ -15,6 +15,7 @@ import prog8.compiler.target.c64.codegen.assignment.AsmAssignment import prog8.compiler.target.c64.codegen.assignment.AssignmentAsmGen import java.io.CharConversionException import java.nio.file.Path +import java.nio.file.Paths import java.time.LocalDate import java.time.LocalDateTime import java.util.* @@ -176,14 +177,10 @@ internal class AsmGen(private val program: Program, private fun block2asm(block: Block) { out("\n\n; ---- block: '${block.name}' ----") + if(block.address!=null) + out("* = ${block.address!!.toHex()}") out("${block.name}\t" + (if("force_output" in block.options()) ".block\n" else ".proc\n")) - val addr = block.address - if(addr!=null) { - out(".cerror * > ${addr.toHex()}, 'block address overlaps by ', *-${addr.toHex()},' bytes'") - out("* = ${addr.toHex()}") - } - outputSourceLine(block) zeropagevars2asm(block.statements) memdefs2asm(block.statements) @@ -1254,7 +1251,9 @@ $counterVar .word 0""") "%asmbinary" -> { val offset = if(stmt.args.size>1) ", ${stmt.args[1].int}" else "" val length = if(stmt.args.size>2) ", ${stmt.args[2].int}" else "" - out(" .binary \"${stmt.args[0].str}\" $offset $length") + val includedSourcePath = stmt.definingModule().source.resolveSibling(stmt.args[0].str) + val relPath = Paths.get("").relativize(includedSourcePath) + out(" .binary \"./$relPath\" $offset $length") } "%breakpoint" -> { val label = "_prog8_breakpoint_${breakpointLabels.size+1}" diff --git a/docs/source/todo.rst b/docs/source/todo.rst index 4aa3977a2..350a7a582 100644 --- a/docs/source/todo.rst +++ b/docs/source/todo.rst @@ -2,6 +2,7 @@ TODO ==== +- make blocks without explicit memory address, word-aligned in the assembly. - add sound to the cx16 tehtriz - hoist all variable declarations up to the subroutine scope *before* even the constant folding takes place (to avoid undefined symbol errors when referring to a variable from another nested scope in the subroutine) - refactor the asmgen into their own submodule?