diff --git a/codeGeneration/src/prog8/codegen/target/cpu6502/codegen/assignment/AssignmentAsmGen.kt b/codeGeneration/src/prog8/codegen/target/cpu6502/codegen/assignment/AssignmentAsmGen.kt index 5ea467aad..6fbed5f94 100644 --- a/codeGeneration/src/prog8/codegen/target/cpu6502/codegen/assignment/AssignmentAsmGen.kt +++ b/codeGeneration/src/prog8/codegen/target/cpu6502/codegen/assignment/AssignmentAsmGen.kt @@ -609,6 +609,11 @@ $containsLabel lda #1 } } + if(target.kind==TargetStorageKind.REGISTER) { + assignExpressionToRegister(value, target.register!!, targetDt==DataType.BYTE || targetDt==DataType.WORD) + return + } + if(targetDt==DataType.FLOAT && (target.register==RegisterOrPair.FAC1 || target.register==RegisterOrPair.FAC2)) { when(valueDt) { DataType.UBYTE -> { diff --git a/compiler/res/version.txt b/compiler/res/version.txt index fa234972b..5942a0d3a 100644 --- a/compiler/res/version.txt +++ b/compiler/res/version.txt @@ -1 +1 @@ -7.8-dev +7.7.1 diff --git a/compiler/test/TestTypecasts.kt b/compiler/test/TestTypecasts.kt index 79428e661..705715f5a 100644 --- a/compiler/test/TestTypecasts.kt +++ b/compiler/test/TestTypecasts.kt @@ -185,4 +185,19 @@ class TestTypecasts: FunSpec({ val statements = result.program.entrypoint.statements statements.size shouldBe 16 } + + test("no infinite typecast loop in assignment asmgen") { + val text = """ + main { + sub start() { + word @shared qq = calculate(33) + } + + sub calculate(ubyte row) -> word { + return (8-(row as byte)) + } + } + """ + compileText(C64Target, false, text, writeAssembly = true).assertSuccess() + } }) diff --git a/docs/source/todo.rst b/docs/source/todo.rst index a5b3b84ca..47cd1a983 100644 --- a/docs/source/todo.rst +++ b/docs/source/todo.rst @@ -3,17 +3,7 @@ TODO For next release ^^^^^^^^^^^^^^^^ -- BUGFIX RELEASE: Fix compiler stack overflow crash: - sub sprite_y_for_row(ubyte row) -> word { - return (8-row as byte) - } - -- move vload() to cx16diskio module -- nameInAssemblyCode() should search smarter -- if char in "string" should fall back to string.find if string is longer than... 12? - also.. is "string" removed from the interned strings? -- add option to memory() to get aligned memory block (word, page aligned) - +... Need help with ^^^^^^^^^^^^^^ @@ -30,6 +20,16 @@ Blocked by an official Commander-x16 r39 release Future Things and Ideas ^^^^^^^^^^^^^^^^^^^^^^^ +- why does this use stack eval on return: + sub sprite_y_for_row(ubyte row) -> word { + return (8-row as byte) + } +- move vload() to cx16diskio module +- nameInAssemblyCode() should search smarter +- if char in "string" should fall back to string.find if string is longer than... 16? + also.. is "string" removed from the interned strings? +- add option to memory() to get aligned memory block (word, page aligned) +- Typecastexpression.isSimple: make it 'expression.isSimple' rather than always false. (this breaks some things atm) - IdentifierReference: fix equality to also include position. CallGraph can then also only store IdentifierRef instead of pair(ident, position) as keys. - Fix: don't report as recursion if code assign address of its own subroutine to something, rather than calling it - allow "xxx" * constexpr (where constexpr is not a number literal, now gives expression error not same type) diff --git a/examples/test.p8 b/examples/test.p8 index 0bc13250f..5067b07bc 100644 --- a/examples/test.p8 +++ b/examples/test.p8 @@ -2,12 +2,20 @@ %zeropage basicsafe main { - sub start() { - byte[3] @shared sprites_x = values - + word ww + ww = calculate(6) + txt.print_w(ww) + txt.nl() + ww = calculate(8) + txt.print_w(ww) + txt.nl() + ww = calculate(10) + txt.print_w(ww) + txt.nl() } - byte[3] values = [1,2,3] - + sub calculate(ubyte row) -> word { + return 8-(row as byte) + } }