From 3d1b0eb843f9c053fea227160259b40ba2f0a6ad Mon Sep 17 00:00:00 2001 From: Irmen de Jong Date: Sun, 23 Jan 2022 01:28:16 +0100 Subject: [PATCH] fixed compiler crash when using cx16.r0H as function call argument --- .../compiler/astprocessing/AstChecker.kt | 4 +-- .../src/prog8/compilerinterface/CallGraph.kt | 3 +- docs/source/todo.rst | 26 +++++++++++++++- examples/test.p8 | 30 ++++++++++--------- 4 files changed, 44 insertions(+), 19 deletions(-) diff --git a/compiler/src/prog8/compiler/astprocessing/AstChecker.kt b/compiler/src/prog8/compiler/astprocessing/AstChecker.kt index 67e1f1012..43bd7245c 100644 --- a/compiler/src/prog8/compiler/astprocessing/AstChecker.kt +++ b/compiler/src/prog8/compiler/astprocessing/AstChecker.kt @@ -1084,9 +1084,7 @@ internal class AstChecker(private val program: Program, } if(ident!=null && ident.nameInSource[0] == "cx16" && ident.nameInSource[1].startsWith("r")) { var regname = ident.nameInSource[1].uppercase() - if(regname.endsWith('L')) - regname=regname.substring(0, regname.length-1) - if(regname.endsWith('s')) + if(regname.endsWith('L') || regname.endsWith('H') || regname.endsWith('s')) regname=regname.substring(0, regname.length-1) val reg = RegisterOrPair.valueOf(regname) val same = params.filter { it.value.registerOrPair==reg } diff --git a/compilerInterfaces/src/prog8/compilerinterface/CallGraph.kt b/compilerInterfaces/src/prog8/compilerinterface/CallGraph.kt index 707d98ec5..0a04a6dde 100644 --- a/compilerInterfaces/src/prog8/compilerinterface/CallGraph.kt +++ b/compilerInterfaces/src/prog8/compilerinterface/CallGraph.kt @@ -222,7 +222,8 @@ class CallGraph(private val program: Program) : IAstVisitor { return allIdentifiersAndTargets.filter { decl===it.value }.map{ it.key.first } } - private fun nameInAssemblyCode(name: String) = allAssemblyNodes.any { it.assembly.contains(name) } + private fun nameInAssemblyCode(name: String) = + allAssemblyNodes.any { it.assembly.contains(name) } // TODO be smarter about what to search in assembly (only labels starting in column 0?) inline fun unused(label: Label) = false // just always output labels diff --git a/docs/source/todo.rst b/docs/source/todo.rst index 9433e9e0a..e0bcbd2f0 100644 --- a/docs/source/todo.rst +++ b/docs/source/todo.rst @@ -3,7 +3,31 @@ TODO For next release ^^^^^^^^^^^^^^^^ -... +- FIx: cx16.r0 = $1fc0f compiler crash +- Fix: uword addr = label ; addr will be 0! required to use &label! +- Fix compiler stack overflow crash: + sub sprite_y_for_row(ubyte row) -> word { + return (8-row as byte) + } +- fix crash: + word[33] sprites_x = sprites.sprites_x + word[33] sprites_y = sprites.sprites_y +- fix assignment code generated for: (memcopying manuall does work correctly) + word[33] sprites_x + word[33] sprites_y + sprites_x = sprites.sprites_x + sprites_y = sprites.sprites_y +- Fix: better error message for len() in: + ubyte[64] chessboard + sub init() { + ubyte xx=len(board) + sys.memset(chessboard, len(board), 0) + } +- 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 diff --git a/examples/test.p8 b/examples/test.p8 index 4ac786e99..5896a9d49 100644 --- a/examples/test.p8 +++ b/examples/test.p8 @@ -3,20 +3,22 @@ main { sub start() { - txt.print("yo\n") - uword jumps = $4000 - if_cc - goto jumps + move() + } - goto jumps + sub move() { + ubyte mb = cx16.mouse_pos() + ubyte @shared xx = cx16.r0H + ubyte @shared yy = cx16.r0L + func(cx16.r0H) + func(cx16.r0L) + cx16.vpoke(1, $fc08+2, cx16.r0H) + cx16.vpoke(1, $fc08+3, cx16.r0L) + } + + asmsub func(ubyte qq @A) { + %asm {{ + rts + }} } } - -test $4000 { - %option force_output - -jumper: - %asm {{ - rts - }} -}