mirror of
https://github.com/KarolS/millfork.git
synced 2024-12-29 02:31:45 +00:00
6809: Update emulators and fix decimal subtraction
This commit is contained in:
parent
e77811c67c
commit
b7a34457fb
@ -56,7 +56,7 @@ Test suite is useful if you plan on modifying the compiler. Some test dependenci
|
||||
https://github.com/sethm/symon/tree/71905fdb1998ee4f142260879504bc46cf27648f
|
||||
https://github.com/andrew-hoffman/halfnes/tree/061
|
||||
https://github.com/trekawek/coffee-gb/tree/coffee-gb-1.0.0
|
||||
https://github.com/sorenroug/osnine-java/tree/1b4e059c5886fe01e8901c70684f7eedefe65010
|
||||
https://github.com/sorenroug/osnine-java/tree/b77349a6c314e1362e69b7158c385ac6f89b7ab8
|
||||
|
||||
* for each of them, run `maven package` and `maven install`
|
||||
|
||||
|
@ -22,7 +22,7 @@ libraryDependencies += "NeatMonster" % "Intel8086" % "1.0" % "test" from "https:
|
||||
// https://github.com/sethm/symon/tree/71905fdb1998ee4f142260879504bc46cf27648f
|
||||
// https://github.com/andrew-hoffman/halfnes/tree/061
|
||||
// https://github.com/trekawek/coffee-gb/tree/coffee-gb-1.0.0
|
||||
// https://github.com/sorenroug/osnine-java/tree/1b4e059c5886fe01e8901c70684f7eedefe65010
|
||||
// https://github.com/sorenroug/osnine-java/tree/b77349a6c314e1362e69b7158c385ac6f89b7ab8
|
||||
|
||||
libraryDependencies += "com.loomcom.symon" % "symon" % "1.3.0-SNAPSHOT" % "test"
|
||||
|
||||
@ -30,7 +30,7 @@ libraryDependencies += "com.grapeshot" % "halfnes" % "061" % "test"
|
||||
|
||||
libraryDependencies += "eu.rekawek.coffeegb" % "coffee-gb" % "1.0.0" % "test"
|
||||
|
||||
libraryDependencies += "roug.org.osnine" % "osnine-core" % "1.0-SNAPSHOT" % "test"
|
||||
libraryDependencies += "roug.org.osnine" % "osnine-core" % "2.0-SNAPSHOT" % "test"
|
||||
|
||||
mainClass in Compile := Some("millfork.Main")
|
||||
|
||||
|
@ -116,6 +116,7 @@ object M6809LargeBuiltins {
|
||||
}
|
||||
val sizeInBytes = AbstractExpressionCompiler.getExpressionType(ctx, target).size
|
||||
val byteLoads = M6809ExpressionCompiler.compileToByteReads(ctx, argument, sizeInBytes)
|
||||
val needsAPreserved = byteLoads.tails.toList.tail.map(_.exists(_.exists(_.readsRegister(M6809Register.A))))
|
||||
val result = new ListBuffer[MLine]()
|
||||
val targetAddr: Option[Constant] = M6809ExpressionCompiler.compileAddressToX(ctx, target) match {
|
||||
case List(MLine(LDX, Immediate, addr, _, _)) => Some(addr)
|
||||
@ -152,17 +153,28 @@ object M6809LargeBuiltins {
|
||||
case (SUBA, _) =>
|
||||
targetAddr match {
|
||||
case Some(addr) =>
|
||||
if (i == firstNonzeroByte) {
|
||||
result ++= ldb
|
||||
} else {
|
||||
result ++= M6809ExpressionCompiler.stashCarryIfNeeded(ctx, ldb)
|
||||
val stashCC = i != firstNonzeroByte
|
||||
if (stashCC) result += MLine.pp(PSHS, M6809Register.CC)
|
||||
result ++= ldb
|
||||
if (needsAPreserved(i)) {
|
||||
// TODO: optimize?
|
||||
result += MLine.pp(PSHS, M6809Register.A)
|
||||
}
|
||||
result += MLine.pp(PSHS, M6809Register.B)
|
||||
result += MLine.immediate(LDA, if (i == firstNonzeroByte) 0x9a else 0x99)
|
||||
result += MLine.accessAndPullS(SUBA)
|
||||
if (needsAPreserved(i)) {
|
||||
// TODO: optimize?
|
||||
result += MLine.pp(PULS, M6809Register.B)
|
||||
}
|
||||
if (stashCC) result += MLine.pp(PULS, M6809Register.CC)
|
||||
result += MLine.absolute(if (i == firstNonzeroByte) ADDA else ADCA, addr + (sizeInBytes - 1 - i))
|
||||
result += MLine.inherent(DAA)
|
||||
result += MLine.absolute(STA, addr + (sizeInBytes - 1 - i))
|
||||
if (needsAPreserved(i)) {
|
||||
// TODO: optimize?
|
||||
result += MLine.tfr(M6809Register.B, M6809Register.A)
|
||||
}
|
||||
case None =>
|
||||
result ++= M6809ExpressionCompiler.stashXIfNeeded(ctx, ldb)
|
||||
result += MLine.pp(PSHS, M6809Register.B)
|
||||
|
@ -152,8 +152,7 @@ class ByteDecimalMathSuite extends FunSuite with Matchers with AppendedClues {
|
||||
}
|
||||
|
||||
test("In-place decimal word subtraction") {
|
||||
// TODO: enable 6809 after the DAA bug in the emulator is fixed
|
||||
EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Ricoh, Cpu.Intel8086/*, Cpu.Motorola6809*/)(
|
||||
EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Ricoh, Cpu.Intel8086, Cpu.Motorola6809)(
|
||||
"""
|
||||
| word output @$c000
|
||||
| word a
|
||||
@ -167,8 +166,7 @@ class ByteDecimalMathSuite extends FunSuite with Matchers with AppendedClues {
|
||||
}
|
||||
|
||||
test("In-place decimal long subtraction") {
|
||||
// TODO: enable 6809 after the DAA bug in the emulator is fixed
|
||||
EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Ricoh, Cpu.Intel8086/*, Cpu.Motorola6809*/)(
|
||||
EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Ricoh, Cpu.Intel8086, Cpu.Motorola6809)(
|
||||
"""
|
||||
| long output @$c000
|
||||
| word a
|
||||
@ -245,8 +243,7 @@ class ByteDecimalMathSuite extends FunSuite with Matchers with AppendedClues {
|
||||
}
|
||||
|
||||
test("Decimal left shift test 3") {
|
||||
// TODO: enable 6809 after the DAA bug in the emulator is fixed
|
||||
EmuUnoptimizedCrossPlatformRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Ricoh, Cpu.Intel8086/*, Cpu.Motorola6809*/)(
|
||||
EmuUnoptimizedCrossPlatformRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Ricoh, Cpu.Intel8086, Cpu.Motorola6809)(
|
||||
"""
|
||||
| word output @$c000
|
||||
| void main () {
|
||||
@ -260,8 +257,7 @@ class ByteDecimalMathSuite extends FunSuite with Matchers with AppendedClues {
|
||||
}
|
||||
|
||||
test("Decimal left shift test 4") {
|
||||
// TODO: enable 6809 after the DAA bug in the emulator is fixed
|
||||
EmuUnoptimizedCrossPlatformRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Ricoh, Cpu.Intel8086/*, Cpu.Motorola6809*/)(
|
||||
EmuUnoptimizedCrossPlatformRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Ricoh, Cpu.Intel8086, Cpu.Motorola6809)(
|
||||
"""
|
||||
| long output @$c000
|
||||
| void main () {
|
||||
|
@ -15,8 +15,9 @@ import millfork.error.ConsoleLogger
|
||||
import millfork.node.opt.NodeOptimization
|
||||
import millfork.node.{Program, StandardCallGraph}
|
||||
import millfork.output.{M6809Assembler, MemoryBank}
|
||||
import millfork.parser.{M6809Parser, MosParser, PreprocessingResult, Preprocessor, Z80Parser}
|
||||
import org.roug.osnine.{BusStraight, MC6809}
|
||||
import millfork.parser.{M6809Parser, PreprocessingResult, Preprocessor}
|
||||
import org.roug.usim.mc6809.MC6809
|
||||
import org.roug.usim.BusStraight
|
||||
import org.scalatest.Matchers
|
||||
|
||||
import scala.collection.JavaConverters._
|
||||
|
@ -1,7 +1,7 @@
|
||||
package millfork.test.emu
|
||||
|
||||
import millfork.output.MemoryBank
|
||||
import org.roug.osnine.{Bus8Motorola, MemorySegment}
|
||||
import org.roug.usim.MemorySegment
|
||||
|
||||
/**
|
||||
* @author Karol Stasiak
|
||||
|
Loading…
Reference in New Issue
Block a user