1
0
mirror of https://github.com/KarolS/millfork.git synced 2025-01-17 07:30:04 +00:00

6502: Add KIL instruction (fixes #37)

This commit is contained in:
Karol Stasiak 2020-01-18 00:09:06 +01:00
parent 7672ba008d
commit 6774c283ae
7 changed files with 95 additions and 3 deletions

View File

@ -24,6 +24,8 @@ Millfork supports multiple mnemonics per opcode. The default one is given first:
* **ISC**, INS
* **KIL**
* **LAS**
* **LAX**

View File

@ -358,7 +358,7 @@ object OpcodeClasses {
STZ, PHX, PHY, PLX, PLY, TSB, TRB,
STZ_W, PHX_W, PHY_W, PLX_W, PLY_W, TSB_W, TRB_W,
SLO, RLA, SRE, RRA, SAX, LAX, DCP, ISC,
ANC, ALR, ARR, XAA, LXA, SBX,
ANC, ALR, ARR, XAA, LXA, SBX, KIL,
CPZ, LDZ, INZ, DEZ,
TAZ, TZA, TYS, TSY,
TBA,

View File

@ -72,7 +72,7 @@ object Opcode extends Enumeration {
// illegals:
LXA, XAA, ANC, ARR, ALR, SBX,
LAX, SAX, RLA, RRA, SLO, SRE, DCP, ISC,
TAS, LAS, SHX, SHY, AHX,
TAS, LAS, SHX, SHY, AHX, KIL,
// 65C02:
STZ, PHX, PHY, PLX, PLY,
@ -222,6 +222,7 @@ object Opcode extends Enumeration {
case "ISC" => ISC
case "JMP" => JMP
case "JSR" => JSR
case "KIL" => KIL
case "LAS" => LAS
case "LAX" => LAX
case "LDA" => LDA

View File

@ -15,6 +15,7 @@ object FlowAnalyzerForImplied {
RTI -> identity,
SEI -> identity,
CLI -> identity,
KIL -> identity,
TXS -> (_.copy(eqSX = true, eqSpX = false)),
PHP -> (_.copy(eqSX = false)),
PHA -> (_.copy(eqSX = false)),

View File

@ -38,6 +38,12 @@ object ReverseFlowAnalyzerPerImpiedOpcode {
CLI -> identity,
WAI -> identity,
STP -> identity,
KIL -> (_ => CpuImportance(
a = Unimportant, ah = Unimportant,
x = Unimportant, y = Unimportant, iz = Unimportant,
r0 = Unimportant, r1 = Unimportant, r2 = Unimportant, r3 = Unimportant,
z = Unimportant, n = Unimportant, c = Unimportant, v = Unimportant, d = Unimportant,
m = Unimportant, w = Unimportant)),
BRK -> (_ => finalImportance),
COP -> (_ => finalImportance),
RTS -> (_ => finalImportance),

View File

@ -542,6 +542,8 @@ object MosAssembler {
op(STY, ZeroPageX, 0x94)
op(STY, Absolute, 0x8C)
il(KIL, Implied, 0x02) // there are multiple candidates and some others could be a better choice, but whatever, 02 is fine
il(LAX, ZeroPage, 0xA7)
il(LAX, ZeroPageY, 0xB7)
il(LAX, Absolute, 0xAF)

View File

@ -1,6 +1,6 @@
package millfork.test
import millfork.Cpu
import millfork.test.emu.{EmuBenchmarkRun, EmuCrossPlatformBenchmarkRun, EmuOptimizedCmosRun, EmuOptimizedHudsonRun, EmuOptimizedRun, EmuUnoptimizedHudsonRun}
import millfork.test.emu.{EmuBenchmarkRun, EmuCrossPlatformBenchmarkRun, EmuOptimizedCmosRun, EmuOptimizedHudsonRun, EmuOptimizedRun, EmuUndocumentedRun, EmuUnoptimizedCrossPlatformRun, EmuUnoptimizedHudsonRun}
import org.scalatest.{AppendedClues, FunSuite, Matchers}
/**
@ -226,6 +226,86 @@ class AssemblySuite extends FunSuite with Matchers with AppendedClues {
}
}
test("Undocumented opcodes") {
EmuUndocumentedRun(
"""
| asm void main() {
| rts
| kil
| slo $4
| slo $400
| slo $4,x
| slo $400,x
| slo $400,y
| slo ($4,x)
| slo ($4),y
| rla $4
| rla $400
| rla $4,x
| rla $400,x
| rla $400,y
| rla ($4,x)
| rla ($4),y
| rra $4
| rra $400
| rra $4,x
| rra $400,x
| rra $400,y
| rra ($4,x)
| rra ($4),y
| sre $4
| sre $400
| sre $4,x
| sre $400,x
| sre $400,y
| sre ($4,x)
| sre ($4),y
| dcp $4
| dcp $400
| dcp $4,x
| dcp $400,x
| dcp $400,y
| dcp ($4,x)
| dcp ($4),y
| isc $4
| isc $400
| isc $4,x
| isc $400,x
| isc $400,y
| isc ($4,x)
| isc ($4),y
| lax $4
| lax $4,y
| lax $400
| lax $400,y
| lax ($4,x)
| lax ($4),y
| sax $4
| sax $4,y
| sax $400
| sax ($4,x)
| anc #$4
| alr #$4
| arr #$4
| xaa #$4
| lxa #$4
| sbx #$4
| ahx ($4),y
| ahx $400,y
| shy $400,x
| shx $400,y
| tas $400,y
| las $400,y
| bne $300
| brk #4
| bne #4
| rts
| }
|
|""".stripMargin
)
}
test("HuC6280 opcodes") {
EmuOptimizedHudsonRun(
"""