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:
parent
43686e0c33
commit
d23f6e4248
@ -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 {
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user