From 178e60bba084fcd053ba4737291c15466ada835a Mon Sep 17 00:00:00 2001 From: Irmen de Jong Date: Sun, 3 Nov 2024 15:04:53 +0100 Subject: [PATCH] fix ast source gen for romsub --- .../src/prog8/codegen/intermediate/IRCodeGen.kt | 2 +- compilerAst/src/prog8/ast/AstToSourceTextConverter.kt | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/codeGenIntermediate/src/prog8/codegen/intermediate/IRCodeGen.kt b/codeGenIntermediate/src/prog8/codegen/intermediate/IRCodeGen.kt index 17e20014e..4ebced472 100644 --- a/codeGenIntermediate/src/prog8/codegen/intermediate/IRCodeGen.kt +++ b/codeGenIntermediate/src/prog8/codegen/intermediate/IRCodeGen.kt @@ -1716,7 +1716,7 @@ class IRCodeGen( ) irBlock += IRAsmSubroutine( child.name, - child.address, + null, child.clobbers, child.parameters.map { IRAsmSubroutine.IRAsmParam(it.first, it.second.type) }, // note: the name of the asmsub param is not used here anymore child.returns.map { IRAsmSubroutine.IRAsmParam(it.first, it.second)}, diff --git a/compilerAst/src/prog8/ast/AstToSourceTextConverter.kt b/compilerAst/src/prog8/ast/AstToSourceTextConverter.kt index e14db94a1..6c95abf5c 100644 --- a/compilerAst/src/prog8/ast/AstToSourceTextConverter.kt +++ b/compilerAst/src/prog8/ast/AstToSourceTextConverter.kt @@ -180,7 +180,11 @@ class AstToSourceTextConverter(val output: (text: String) -> Unit, val program: if(subroutine.inline) output("inline ") if(subroutine.isAsmSubroutine) { - output("asmsub ${subroutine.name} (") + if(subroutine.asmAddress!=null) { + output("romsub ${subroutine.asmAddress.toHex()} = ${subroutine.name} (") + } + else + output("asmsub ${subroutine.name} (") for(param in subroutine.parameters.zip(subroutine.asmParameterRegisters)) { val reg = when { @@ -227,9 +231,7 @@ class AstToSourceTextConverter(val output: (text: String) -> Unit, val program: output("-> $rts ") } } - if(subroutine.asmAddress!=null) - outputln("= ${subroutine.asmAddress.toHex()}") - else { + if (subroutine.asmAddress == null) { outputln("{ ") scopelevel++ outputStatements(subroutine.statements.filter { it !is VarDecl || it.origin!=VarDeclOrigin.SUBROUTINEPARAM})