From d88c09b0988742e0349be55b3272146e728bfca5 Mon Sep 17 00:00:00 2001 From: Irmen de Jong Date: Tue, 17 Oct 2023 22:51:49 +0200 Subject: [PATCH] fix signed byte to word casting issue uw = 8888 + (bb as ubyte) --- .../codegen/cpu6502/assignment/AssignmentAsmGen.kt | 5 +++-- docs/source/todo.rst | 3 --- examples/test.p8 | 10 +++------- gradle.properties | 2 +- 4 files changed, 7 insertions(+), 13 deletions(-) diff --git a/codeGenCpu6502/src/prog8/codegen/cpu6502/assignment/AssignmentAsmGen.kt b/codeGenCpu6502/src/prog8/codegen/cpu6502/assignment/AssignmentAsmGen.kt index aedf7b9c0..a5c576faf 100644 --- a/codeGenCpu6502/src/prog8/codegen/cpu6502/assignment/AssignmentAsmGen.kt +++ b/codeGenCpu6502/src/prog8/codegen/cpu6502/assignment/AssignmentAsmGen.kt @@ -1830,8 +1830,9 @@ internal class AssignmentAsmGen(private val program: PtProgram, RegisterOrPair.AY, RegisterOrPair.XY, in Cx16VirtualRegisters -> { - // cast an ubyte value to a 16 bits register, just assign it and make use of the value extension - return assignExpressionToRegister(value, target.register!!, false) + assignExpressionToRegister(value, RegisterOrPair.A, false) + assignRegisterByte(target, CpuRegister.A, false) + return } else -> {} } diff --git a/docs/source/todo.rst b/docs/source/todo.rst index 64d705980..d08da022f 100644 --- a/docs/source/todo.rst +++ b/docs/source/todo.rst @@ -1,9 +1,6 @@ TODO ==== -- fix codegen signed byte to word casting issue uw = 8888 + (bb as ubyte) - -- remove after(assignment from BeforeAsmAstChanger permanently once issues above fixed - gfx2/monogfx: use vera auto in/decrement in the flood fill routine (getpixels) - gfx2: use vera fx fill for horizontal_line of sufficient length? diff --git a/examples/test.p8 b/examples/test.p8 index 788fabd4f..87c047047 100644 --- a/examples/test.p8 +++ b/examples/test.p8 @@ -4,15 +4,11 @@ main { sub start() { - uword @shared uw = 5555 byte @shared bb = -44 - - uw = (bb as ubyte) as uword - txt.print_uw(uw) ; 212 - txt.nl() - - uw = 8888 + (bb as ubyte) ; TODO fix 6502 codegen + uword uw = 8888 + (bb as ubyte) txt.print_uw(uw) ; 9100 txt.nl() + txt.print_uw(8888 + (bb as ubyte)) ; 9100 + txt.nl() } } diff --git a/gradle.properties b/gradle.properties index a050c2090..4a9e26d7b 100644 --- a/gradle.properties +++ b/gradle.properties @@ -5,4 +5,4 @@ org.gradle.daemon=true kotlin.code.style=official javaVersion=11 kotlinVersion=1.9.10 -version=9.5 +version=9.5.1