mirror of
https://github.com/KarolS/millfork.git
synced 2025-04-02 09:29:30 +00:00
6502: Fix fatal failure when considering undocumented optimizations (fixes #38)
This commit is contained in:
parent
6774c283ae
commit
f247516187
src
main/scala/millfork/assembly/mos/opt
test/scala/millfork/test
@ -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)).? ~
|
||||
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user