fix TODO crash on uword[0] = uword[0] or 128 (byte register assign to word array)

This commit is contained in:
Irmen de Jong 2023-12-02 21:10:51 +01:00
parent ead8c59bda
commit 48f09f71ab
4 changed files with 21 additions and 15 deletions

View File

@ -2952,9 +2952,21 @@ internal class AssignmentAsmGen(private val program: PtProgram,
storeRegisterAInMemoryAddress(target.memory!!)
}
TargetStorageKind.ARRAY -> {
if(assignAsWord)
TODO("assign register byte as word into Array not yet supported")
assignRegisterByteToByteArray(target, register)
if(assignAsWord) {
when(register) {
CpuRegister.A -> {}
CpuRegister.X -> asmgen.out(" txa")
CpuRegister.Y -> asmgen.out(" tya")
}
if(extendWord) {
asmgen.signExtendAYlsb(if(target.datatype in SignedDatatypes) DataType.BYTE else DataType.UBYTE)
} else {
asmgen.out(" ldy #0")
}
assignRegisterpairWord(target, RegisterOrPair.AY)
} else {
assignRegisterByteToByteArray(target, register)
}
}
TargetStorageKind.REGISTER -> {
when(register) {

View File

@ -7,7 +7,6 @@ import io.kotest.assertions.withClue
import io.kotest.core.spec.style.FunSpec
import io.kotest.matchers.shouldBe
import io.kotest.matchers.shouldNotBe
import io.kotest.matchers.string.shouldContain
import prog8.code.core.Encoding
import prog8.code.core.unescape
import prog8.code.target.C64Target
@ -260,7 +259,7 @@ class TestStringEncodings: FunSpec({
errors.errors.size shouldBe 0
}
test("unsupported string encoding iso for C64 compilationtarget") {
test("iso string encoding also on C64 compilationtarget") {
val source="""
main {
str string1 = "default"
@ -271,12 +270,11 @@ class TestStringEncodings: FunSpec({
}
}"""
val errors = ErrorReporterForTests()
compileText(C64Target(), false, source, errors, writeAssembly = false) shouldBe null
errors.errors.size shouldBe 1
errors.errors[0] shouldContain "text encoding"
compileText(C64Target(), false, source, errors, writeAssembly = false) shouldNotBe null
errors.errors.size shouldBe 0
}
test("unsupported char encoding iso for C64 compilationtarget") {
test("iso char encoding also on C64 compilationtarget") {
val source="""
main {
ubyte char1 = 'd'
@ -287,9 +285,8 @@ class TestStringEncodings: FunSpec({
}
}"""
val errors = ErrorReporterForTests()
compileText(C64Target(), false, source, errors, writeAssembly = false) shouldBe null
errors.errors.size shouldBe 1
errors.errors[0] shouldContain "text encoding"
compileText(C64Target(), false, source, errors, writeAssembly = false) shouldNotBe null
errors.errors.size shouldBe 0
}
test("all encodings supported for Cx16 target") {

View File

@ -55,7 +55,6 @@ internal object AsciiStringEncoder : IStringEncoding {
internal object DummyCompilationTarget : ICompilationTarget {
override val name: String = "dummy"
override val machine: IMachineDefinition = VirtualMachineDefinition() // not really true but I don't want to implement a full dummy machinedef
override val supportedEncodings = setOf(Encoding.PETSCII, Encoding.SCREENCODES, Encoding.ISO)
override val defaultEncoding = Encoding.PETSCII
override fun encodeString(str: String, encoding: Encoding): List<UByte> {

View File

@ -2,8 +2,6 @@
TODO
====
- fix crash on uword[0] = uword[0] or 128
- uword scanline_buf = memory("scanline", 320, 0) different result when inside a sub or outside a sub??! (imageviewer iff module)
- [on branch: shortcircuit] investigate McCarthy evaluation again? this may also reduce code size perhaps for things like if a>4 or a<2 ....
- once VAL_1 is merged into the kernal properly, remove all the workarounds in cx16 floats.parse_f()