mirror of
https://github.com/KarolS/millfork.git
synced 2025-08-09 10:24:57 +00:00
6502: Fix word multiplication by 0
This commit is contained in:
@@ -48,6 +48,8 @@ This matches both the CC65 behaviour and the return values from `readkey()`.
|
||||
|
||||
* 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;
|
||||
|
||||
* 8080/Z80: miscompilation of code after `if` statements;
|
||||
|
@@ -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)
|
||||
|
Reference in New Issue
Block a user