fix compiler crash sometimes when casting byte to word

This commit is contained in:
Irmen de Jong 2022-09-22 13:00:47 +02:00
parent 97aa91c75e
commit b1e4347e10
3 changed files with 6 additions and 7 deletions

View File

@ -975,8 +975,8 @@ internal class AssignmentAsmGen(private val program: Program,
// byte to byte, just assign
assignExpressionToRegister(value, target.register!!, targetDt==DataType.BYTE || targetDt==DataType.WORD)
} else if(valueDt in ByteDatatypes && targetDt in WordDatatypes) {
// byte to word, assign and zero the msb
TODO("cast byte to word: $value")
// byte to word, just assign
assignExpressionToRegister(value, target.register!!, targetDt==DataType.WORD)
}
else
throw AssemblyError("can't cast $valueDt to $targetDt, this should have been checked in the astchecker")

View File

@ -4,7 +4,6 @@ TODO
For next release
^^^^^^^^^^^^^^^^
- vm: implement remaining sin/cos functions in virtual/math.p8 and merge tables
- fix "can't cast BYTE to UWORD this should have been checked in the astchecker" crash
...

View File

@ -47,9 +47,9 @@ main {
for pixelxb in 0 to 255 {
pixelys = math.cos8(pixelxb) / 2
graphics.plot(pixelxb, pixelys+90 as ubyte as uword) ; TODO fix weird cast error
graphics.plot(pixelxb, pixelys+90 as uword)
pixelys = math.sin8(pixelxb) / 2
graphics.plot(pixelxb, pixelys+90 as ubyte as uword) ; TODO fix weird cast error
graphics.plot(pixelxb, pixelys+90 as uword)
}
}
@ -69,9 +69,9 @@ main {
for pixelxb in 0 to 179 {
pixelys = math.cosr8(pixelxb) / 2
graphics.plot(pixelxb, pixelys+90 as ubyte as uword) ; TODO fix weird cast error
graphics.plot(pixelxb, pixelys+90 as uword)
pixelys = math.sinr8(pixelxb) / 2
graphics.plot(pixelxb, pixelys+90 as ubyte as uword) ; TODO fix weird cast error
graphics.plot(pixelxb, pixelys+90 as uword)
}
}