From e1c77ce23633704d32b5ef4fc71f4b7f6896ae2a Mon Sep 17 00:00:00 2001 From: Irmen de Jong Date: Sat, 2 Jul 2022 23:27:08 +0200 Subject: [PATCH] fix pop() name scoping --- .../src/prog8/codegen/cpu6502/AsmGen.kt | 2 +- compiler/test/TestBuiltinFunctions.kt | 17 +++++++++++++++++ docs/source/todo.rst | 1 - 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/codeGenCpu6502/src/prog8/codegen/cpu6502/AsmGen.kt b/codeGenCpu6502/src/prog8/codegen/cpu6502/AsmGen.kt index 14eb698c2..2cf797931 100644 --- a/codeGenCpu6502/src/prog8/codegen/cpu6502/AsmGen.kt +++ b/codeGenCpu6502/src/prog8/codegen/cpu6502/AsmGen.kt @@ -2874,7 +2874,7 @@ $repeatLabel lda $counterVar } } } else { - val tgt = AsmAssignTarget(TargetStorageKind.VARIABLE, program, this, target.datatype, scope, variableAsmName = asmVariableName(target.name)) + val tgt = AsmAssignTarget(TargetStorageKind.VARIABLE, program, this, target.datatype, scope, variableAsmName = asmVariableName(target.scopedName)) if (dt in ByteDatatypes) { out(" pla") assignRegister(RegisterOrPair.A, tgt) diff --git a/compiler/test/TestBuiltinFunctions.kt b/compiler/test/TestBuiltinFunctions.kt index a107924b3..760cbf884 100644 --- a/compiler/test/TestBuiltinFunctions.kt +++ b/compiler/test/TestBuiltinFunctions.kt @@ -2,13 +2,30 @@ package prog8tests import io.kotest.core.spec.style.FunSpec import io.kotest.matchers.shouldBe +import io.kotest.matchers.shouldNotBe import prog8.code.core.DataType import prog8.code.core.NumericDatatypes import prog8.code.core.RegisterOrPair +import prog8.code.target.C64Target +import prog8.code.target.Cx16Target import prog8.compiler.BuiltinFunctions +import prog8tests.helpers.compileText class TestBuiltinFunctions: FunSpec({ + test("push pop") { + val src=""" + main { + sub start () { + pushw(cx16.r0) + push(cx16.r1L) + pop(cx16.r1L) + popw(cx16.r0) + } + }""" + compileText(Cx16Target(), false, src, writeAssembly = true) shouldNotBe null + } + test("pure func with fixed type") { val func = BuiltinFunctions.getValue("sgn") func.name shouldBe "sgn" diff --git a/docs/source/todo.rst b/docs/source/todo.rst index c217503f2..9fc81c272 100644 --- a/docs/source/todo.rst +++ b/docs/source/todo.rst @@ -3,7 +3,6 @@ TODO For next release ^^^^^^^^^^^^^^^^ -- fix push() pop() of vera registers - if passing a subroutine or label name as an uword argument, without &, add the addressof automatically - convert the sounds in cx16 tehtriz to use the psg module instead - notify petaxian that it could use the psg module too?