1
0
mirror of https://github.com/KarolS/millfork.git synced 2024-06-12 22:29:33 +00:00

6502: Fix word multiplication by 0

This commit is contained in:
Karol Stasiak 2019-08-04 13:42:00 +02:00
parent 1a87929ad3
commit 127cd1b901
2 changed files with 3 additions and 1 deletions

View File

@ -47,6 +47,8 @@ This matches both the CC65 behaviour and the return values from `readkey()`.
* 6502: miscompilation when using the zeropage pseudoregister;
* 6502: stack overflow when inlining local variables into registers;
* 6502: not setting the high byte to 0 when optimizing word multiplication by 0
* 8080/Z80: compiler crash when compiling conditions;

View File

@ -107,7 +107,7 @@ object ZeropageRegisterOptimizations {
(Elidable & HasOpcode(JSR) & RefersTo("__mul_u16u8u16", 0)) ~~> { (code, ctx) =>
val constant = ctx.get[Int](4)
if (constant == 0) {
code.init :+ AssemblyLine.immediate(LDA, 0)
code.init ++ List(AssemblyLine.immediate(LDA, 0), AssemblyLine.immediate(LDX, 0))
} else {
val loAsl = code.head.copy(opcode = ASL, parameter = (code.head.parameter - 2).quickSimplify)
val hiRol = code.head.copy(opcode = ROL, parameter = (code.head.parameter - 1).quickSimplify)