From 0204002d9b8d06122f0b2c638323bf4f605cd684 Mon Sep 17 00:00:00 2001 From: Irmen de Jong Date: Fri, 8 Oct 2021 04:14:43 +0200 Subject: [PATCH] bugfix: non-existing asm function was sometimes called to swap floats --- .../cpu6502/codegen/BuiltinFunctionsAsmGen.kt | 8 +-- examples/test.p8 | 72 +++++++++---------- 2 files changed, 40 insertions(+), 40 deletions(-) diff --git a/compiler/src/prog8/compiler/target/cpu6502/codegen/BuiltinFunctionsAsmGen.kt b/compiler/src/prog8/compiler/target/cpu6502/codegen/BuiltinFunctionsAsmGen.kt index 7ba1b61fa..1e2edf3ab 100644 --- a/compiler/src/prog8/compiler/target/cpu6502/codegen/BuiltinFunctionsAsmGen.kt +++ b/compiler/src/prog8/compiler/target/cpu6502/codegen/BuiltinFunctionsAsmGen.kt @@ -888,7 +888,7 @@ internal class BuiltinFunctionsAsmGen(private val program: Program, private val sta P8ZP_SCRATCH_W2 lda #>(${arrayVarName2}+$index2) sta P8ZP_SCRATCH_W2+1 - jsr floats.swap_floats + jsr floats.func_swap_f """) } else -> throw AssemblyError("invalid aray elt type") @@ -961,7 +961,7 @@ internal class BuiltinFunctionsAsmGen(private val program: Program, private val sta P8ZP_SCRATCH_W2 bcc + inc P8ZP_SCRATCH_W2+1 -+ jsr floats.swap_floats ++ jsr floats.func_swap_f """) } else -> throw AssemblyError("invalid aray elt type") @@ -1019,7 +1019,7 @@ internal class BuiltinFunctionsAsmGen(private val program: Program, private val sta P8ZP_SCRATCH_W1 bcc + inc P8ZP_SCRATCH_W1+1 -+ jsr floats.swap_floats ++ jsr floats.func_swap_f """) } else -> throw AssemblyError("invalid aray elt type") @@ -1077,7 +1077,7 @@ internal class BuiltinFunctionsAsmGen(private val program: Program, private val sta P8ZP_SCRATCH_W2 lda #>(${arrayVarName2}+$index2) sta P8ZP_SCRATCH_W2+1 - jsr floats.swap_floats + jsr floats.func_swap_f """) } else -> throw AssemblyError("invalid aray elt type") diff --git a/examples/test.p8 b/examples/test.p8 index d84387a30..1bce15bdb 100644 --- a/examples/test.p8 +++ b/examples/test.p8 @@ -1,47 +1,47 @@ %import textio -%zeropage dontuse +%import floats +%import test_stack +%zeropage basicsafe main { label: sub start() { - txt.print("hey\n") - %breakpoint - txt.print("hey2\n") + ubyte ub1 + ubyte ub2 + uword uw1 + uword uw2 + float fl1 + float fl2 + ubyte[10] ubarr + uword[10] uwarr + float[10] flarr -; sub2(&label) -; sub2(&label_local) -; sub2(&main.sub2.label_in_sub2) -; uword xx = &label_local -; txt.print_uwhex(xx, true) -; txt.nl() -; xx = &label -; txt.print_uwhex(xx, true) -; txt.nl() -; xx = &main.label -; txt.print_uwhex(xx, true) -; txt.nl() -; xx = &main.sub2.label_in_sub2 -; txt.print_uwhex(xx, true) -; txt.nl() -; xx = main.sub2.sub2var -; txt.print_uwhex(xx, true) -; txt.nl() -; xx = &main.start.label_local -; txt.print_uwhex(xx, true) -; txt.nl() + swap(ub1, ub2) + swap(uw1, uw2) + swap(fl1, fl2) + swap(ubarr[1], ubarr[2]) + swap(uwarr[1], uwarr[2]) + swap(flarr[1], flarr[2]) -label_local: - return + ubyte ix1 + ubyte ix2 + + swap(ubarr[ix1], ubarr[ix2]) + swap(uwarr[ix1], uwarr[ix2]) + swap(flarr[ix1], flarr[ix2]) + swap(flarr[ix1], flarr[2]) + swap(flarr[2], flarr[ix2]) + + swap(ubarr[ix1], ubarr[ix1+2]) + swap(uwarr[ix1], uwarr[ix1+2]) + swap(flarr[ix1], flarr[ix1+2]) + + uword ptr = $c000 + swap(@(ptr+1), @(ptr+2)) + swap(@(ptr+ub1), @(ptr+ub2)) + + test_stack.test() } - -; sub sub2(uword ad) { -; uword sub2var = 42 -; -; txt.print_uwhex(ad,true) -; txt.nl() -;label_in_sub2: -; txt.nl() -; } }