1
0
mirror of https://github.com/KarolS/millfork.git synced 2024-07-03 10:29:58 +00:00

6502: Fix fatal failure when considering undocumented optimizations (fixes #38)

This commit is contained in:
Karol Stasiak 2020-01-18 22:06:50 +01:00
parent 6774c283ae
commit f247516187
3 changed files with 28 additions and 1 deletions

View File

@ -134,7 +134,7 @@ object UndocumentedOptimizations {
(Elidable & HasOpcode(INX) & DoesntMatterWhatItDoesWith(State.A)).+.captureLength(0) ~
Where(_.get[Int](0) > 2) ~~> ((_, ctx) => List(
AssemblyLine.implied(TXA),
AssemblyLine.immediate(SBX, Constant.Zero - ctx.get[Constant](0)),
AssemblyLine.immediate(SBX, Constant.Zero - ctx.get[Int](0)),
)),
HasOpcode(TXA) ~
(Elidable & HasOpcode(CLC)).? ~

View File

@ -261,4 +261,27 @@ class IllegalSuite extends FunSuite with Matchers {
""".stripMargin)
m.readLong(0xc000) should equal(1)
}
test("Test issue #38") {
val m = EmuUndocumentedRun(
"""
|array(byte) input [16] @ $c300
|const byte COUNT = 16
|byte output @$c000
|void main() {
| inner()
|}
|
|void inner() {
| byte j
| for j,0,until,COUNT {
| if input[j] == 0 {
| continue
| }
| //output += 1
| }
|}
|
|""".stripMargin)
}
}

View File

@ -13,6 +13,10 @@ object EmuUndocumentedRun extends EmuRun(
UndocumentedOptimizations.All ++
OptimizationPresets.Good ++ LaterOptimizations.Nmos ++
UndocumentedOptimizations.All ++
OptimizationPresets.AssOpt ++ LaterOptimizations.Nmos ++
UndocumentedOptimizations.All ++
OptimizationPresets.AssOpt ++ LaterOptimizations.Nmos ++
UndocumentedOptimizations.All ++
OptimizationPresets.Good) {
override def emitIllegals = true