1
0
mirror of https://github.com/KarolS/millfork.git synced 2024-12-24 15:29:23 +00:00

6502: improve optimizations using undocumented instructions

This commit is contained in:
Karol Stasiak 2019-05-29 14:09:21 +02:00
parent 43686e0c33
commit d23f6e4248
2 changed files with 13 additions and 4 deletions

View File

@ -89,6 +89,11 @@ object UndocumentedOptimizations {
val fragment2 = sax :: ctx.get[List[AssemblyLine]](12)
List(fragment0, fragment1, fragment2).flatten
},
(Elidable & HasOpcode(TXA)) ~
(Elidable & HasOpcode(AND)) ~
(Elidable & HasOpcode(STA) & HasAddrModeIn(SaxModes) & DoesntMatterWhatItDoesWith(State.A, State.Z, State.N)) ~~> { code =>
code(1).copy(opcode = LDA) :: code(2).copy(opcode = SAX) :: code.drop(3)
},
)
def andConstant(const: Constant, mask: Int): Option[Long] = const match {

View File

@ -140,6 +140,10 @@ class IllegalSuite extends FunSuite with Matchers {
| byte c
| b = five(a)
| c = five(a)
| asm {
| iny
| inx
| }
| a = c
| five(a)
| c = a & b
@ -156,9 +160,9 @@ class IllegalSuite extends FunSuite with Matchers {
val m = EmuUndocumentedRun("""
| word output @$c000
| void main () {
| output = five(5)
| output = five(0, 5)
| }
| word five (byte a) {
| word five (byte dummy, byte a) {
| return a:a
| }
""".stripMargin)
@ -169,9 +173,9 @@ class IllegalSuite extends FunSuite with Matchers {
val m = EmuUndocumentedRun("""
| byte output @$c000
| void main () {
| output = five(1)
| output = five(0, 1)
| }
| byte five (byte a) {
| byte five (byte dummy, byte a) {
| byte b
| b = a
| a += 4