diff --git a/src/main/scala/millfork/compiler/m6809/M6809ExpressionCompiler.scala b/src/main/scala/millfork/compiler/m6809/M6809ExpressionCompiler.scala index 9c502070..1937a4e4 100644 --- a/src/main/scala/millfork/compiler/m6809/M6809ExpressionCompiler.scala +++ b/src/main/scala/millfork/compiler/m6809/M6809ExpressionCompiler.scala @@ -647,13 +647,18 @@ object M6809ExpressionCompiler extends AbstractExpressionCompiler[MLine] { else lines } - def storeB(ctx: CompilationContext, target: LhsExpression): List[MLine] = { + def storeA(ctx: CompilationContext, target: LhsExpression): List[MLine] = store8(ctx, target, stashAIfNeeded, STA) + + def storeB(ctx: CompilationContext, target: LhsExpression): List[MLine] = store8(ctx, target, stashBIfNeeded, STB) + + @inline + private def store8(ctx: CompilationContext, target: LhsExpression, stashIfNeeded: (CompilationContext, List[MLine]) => List[MLine], store: MOpcode.Value): List[MLine] = { target match { case VariableExpression(name) => val variable = ctx.env.get[Variable](name) - List(MLine.variable(ctx, STB, variable)) + List(MLine.variable(ctx, store, variable)) case DerefExpression(inner, offset, _) => - stashBIfNeeded(ctx, compileToX(ctx, inner)) :+ MLine.indexedX(STB, NumericConstant(offset, 2)) + stashIfNeeded(ctx, compileToX(ctx, inner)) :+ MLine.indexedX(store, NumericConstant(offset, 2)) case IndexedExpression(name, index) => ctx.env.getPointy(name) match { case p: ConstantPointy => @@ -664,26 +669,26 @@ object M6809ExpressionCompiler extends AbstractExpressionCompiler[MLine] { val effectiveBase = (p.value + constOffset).quickSimplify variableIndex match { case Some(ix) => - stashBIfNeeded(ctx, compileToX(ctx, ix)) :+ MLine.indexedX(STB, effectiveBase) + stashIfNeeded(ctx, compileToX(ctx, ix)) :+ MLine.indexedX(store, effectiveBase) case None => - List(MLine.absolute(STB, effectiveBase)) + List(MLine.absolute(store, effectiveBase)) } case v: VariablePointy => ctx.env.eval(index) match { - case Some(ix) => List(MLine.absolute(LDX, v.addr), MLine.indexedX(STB, ix * v.elementType.size)) + case Some(ix) => List(MLine.absolute(LDX, v.addr), MLine.indexedX(store, ix * v.elementType.size)) case _ => v.indexType.size match { case 1 | 2 => - stashBIfNeeded(ctx, + stashIfNeeded(ctx, MLine.absolute(LDX, v.addr) :: (compileToD(ctx, index) :+ MLine(LEAX, DAccumulatorIndexed(M6809Register.X, indirect = false), Constant.Zero))) :+ - MLine.indexedX(STB, Constant.Zero) + MLine.indexedX(store, Constant.Zero) } } case v: StackVariablePointy => ctx.env.eval(index) match { - case Some(ix) => List(MLine.variablestack(ctx, LDX, v.offset), MLine.indexedX(STB, ix * v.elementType.size)) + case Some(ix) => List(MLine.variablestack(ctx, LDX, v.offset), MLine.indexedX(store, ix * v.elementType.size)) } } } @@ -694,6 +699,10 @@ object M6809ExpressionCompiler extends AbstractExpressionCompiler[MLine] { case VariableExpression(name) => val variable = ctx.env.get[Variable](name) List(MLine.variable(ctx, STD, variable)) + case SeparateBytesExpression(hi: LhsExpression, lo: LhsExpression) => + val sh = storeA(ctx, hi) + val sl = storeB(ctx, lo) + stashBIfNeeded(ctx, sh) ++ sl // TODO: optimize case DerefExpression(inner, offset, _) => stashDIfNeeded(ctx, compileToX(ctx, inner)) :+ MLine(STD, Indexed(M6809Register.X, indirect = false), NumericConstant(offset, 2)) } diff --git a/src/main/scala/millfork/compiler/m6809/M6809StatementCompiler.scala b/src/main/scala/millfork/compiler/m6809/M6809StatementCompiler.scala index d7dc099d..58261559 100644 --- a/src/main/scala/millfork/compiler/m6809/M6809StatementCompiler.scala +++ b/src/main/scala/millfork/compiler/m6809/M6809StatementCompiler.scala @@ -1,17 +1,18 @@ package millfork.compiler.m6809 -import millfork.assembly.BranchingOpcodeMapping -import millfork.assembly.m6809.{MLine, NonExistent} +import millfork.assembly.{BranchingOpcodeMapping, Elidability} +import millfork.assembly.m6809.{Inherent, MLine, MOpcode, NonExistent} import millfork.compiler.{AbstractCompiler, AbstractExpressionCompiler, AbstractStatementCompiler, BranchSpec, CompilationContext} -import millfork.node.{Assignment, BlackHoleExpression, BreakStatement, ContinueStatement, DoWhileStatement, ExecutableStatement, Expression, ExpressionStatement, ForEachStatement, ForStatement, FunctionCallExpression, IfStatement, M6809AssemblyStatement, MemsetStatement, ReturnDispatchStatement, ReturnStatement, VariableExpression, WhileStatement} +import millfork.node.{Assignment, BlackHoleExpression, BreakStatement, ContinueStatement, DoWhileStatement, ExecutableStatement, Expression, ExpressionStatement, ForEachStatement, ForStatement, FunctionCallExpression, GotoStatement, IfStatement, LabelStatement, LiteralExpression, M6809AssemblyStatement, MemsetStatement, ReturnDispatchStatement, ReturnStatement, VariableExpression, WhileStatement} import millfork.assembly.m6809.MOpcode._ -import millfork.env.{BooleanType, ConstantBooleanType, FatBooleanType, Label, ThingInMemory} +import millfork.env.{BooleanType, ConstantBooleanType, FatBooleanType, Label, MemoryAddressConstant, StructureConstant, ThingInMemory} /** * @author Karol Stasiak */ object M6809StatementCompiler extends AbstractStatementCompiler[MLine] { def compile(ctx: CompilationContext, statement: ExecutableStatement): (List[MLine], List[MLine]) = { + val env = ctx.env val code: (List[MLine], List[MLine]) = statement match { case ReturnStatement(None) => // TODO: clean stack @@ -91,6 +92,14 @@ object M6809StatementCompiler extends AbstractStatementCompiler[MLine] { ctx.log.error("Invalid parameter", expression.position) Nil -> Nil } + case s:LabelStatement => + List(MLine.label(env.prefix + s.name)) -> Nil + case s: GotoStatement => + env.eval(s.target) match { + case Some(e) => List(MLine.absolute(JMP, e)) -> Nil + case None => + (M6809ExpressionCompiler.compileToX(ctx, s.target) :+ MLine.indexedX(JMP, 0)) -> Nil + } case _ => println(statement) ctx.log.error("Not implemented yet", statement.position) @@ -115,9 +124,13 @@ object M6809StatementCompiler extends AbstractStatementCompiler[MLine] { M6809ExpressionCompiler.compile(ctx, expr, MExpressionTarget.NOTHING, branching) } - override def replaceLabel(ctx: CompilationContext, line: MLine, from: String, to: String): MLine = ??? + override def replaceLabel(ctx: CompilationContext, line: MLine, from: String, to: String): MLine = line.parameter match { + case MemoryAddressConstant(Label(l)) if l == from => line.copy(parameter = MemoryAddressConstant(Label(to))) + case StructureConstant(s, List(z, MemoryAddressConstant(Label(l)))) if l == from => line.copy(parameter = StructureConstant(s, List(z, MemoryAddressConstant(Label(to))))) + case _ => line + } - override def returnAssemblyStatement: ExecutableStatement = ??? + override def returnAssemblyStatement: ExecutableStatement = M6809AssemblyStatement(opcode = MOpcode.RTS, Inherent, LiteralExpression(0, 1), Elidability.Elidable ) override def callChunk(label: ThingInMemory): List[MLine] = List(MLine.absolute(JSR, label.toAddress)) diff --git a/src/test/scala/millfork/test/AlignmentSuite.scala b/src/test/scala/millfork/test/AlignmentSuite.scala index acbc2d74..ae02f0e4 100644 --- a/src/test/scala/millfork/test/AlignmentSuite.scala +++ b/src/test/scala/millfork/test/AlignmentSuite.scala @@ -11,7 +11,7 @@ import org.scalatest.{FunSuite, Matchers} class AlignmentSuite extends FunSuite with Matchers { test("Alignment") { - EmuUnoptimizedCrossPlatformRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( + EmuUnoptimizedCrossPlatformRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086, Cpu.Motorola6809)( """ | array output [5] @$c000 | void main () { diff --git a/src/test/scala/millfork/test/ArraySuite.scala b/src/test/scala/millfork/test/ArraySuite.scala index e26c406e..40805f39 100644 --- a/src/test/scala/millfork/test/ArraySuite.scala +++ b/src/test/scala/millfork/test/ArraySuite.scala @@ -84,7 +84,7 @@ class ArraySuite extends FunSuite with Matchers with AppendedClues { } test("Array assignment through a pointer") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086, Cpu.Motorola6809)( """ | array output [3] @$c000 | pointer p @@ -104,7 +104,7 @@ class ArraySuite extends FunSuite with Matchers with AppendedClues { } test("Array in place math") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086, Cpu.Motorola6809)( """ | array output [4] @$c000 | void main () { @@ -132,7 +132,7 @@ class ArraySuite extends FunSuite with Matchers with AppendedClues { } test("Array simple read 2") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086, Cpu.Motorola6809)( """ | word output @$c000 | array a[7] @@ -144,13 +144,12 @@ class ArraySuite extends FunSuite with Matchers with AppendedClues { | output = a[i] | } """.stripMargin){m => - m.readByte(0xc000) should equal(6) - m.readByte(0xc001) should equal(0) + m.readWord(0xc000) should equal(6) } } test("Pointers") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086, Cpu.Motorola6809)( """ | byte output | pointer a @@ -175,7 +174,7 @@ class ArraySuite extends FunSuite with Matchers with AppendedClues { } test("Pointer indexing test") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086, Cpu.Motorola6809)( """ | array output [4] @$c000 | pointer a @@ -192,7 +191,7 @@ class ArraySuite extends FunSuite with Matchers with AppendedClues { } test("Syntax") { - EmuUnoptimizedCrossPlatformRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( + EmuUnoptimizedCrossPlatformRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086, Cpu.Motorola6809)( """ | array a = [1, 2, 3] | array b = "text" ascii @@ -204,7 +203,7 @@ class ArraySuite extends FunSuite with Matchers with AppendedClues { } test("Negative subindex") { - EmuUnoptimizedCrossPlatformRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( + EmuUnoptimizedCrossPlatformRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086, Cpu.Motorola6809)( """ | | array output [$fff] @$c000 @@ -243,7 +242,7 @@ class ArraySuite extends FunSuite with Matchers with AppendedClues { } test("Word subindex 2") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086, Cpu.Motorola6809)( """ | | array output [$fff] @$c000 @@ -265,9 +264,9 @@ class ArraySuite extends FunSuite with Matchers with AppendedClues { } test("Array filters") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086, Cpu.Motorola6809)( """ - | array x = @word [$1144] + | array x = @word_le [$1144] | byte output @$c000 | void main () { | output = x[0] @@ -278,9 +277,9 @@ class ArraySuite extends FunSuite with Matchers with AppendedClues { } test("Array filters 2") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086, Cpu.Motorola6809)( """ - | array x = @long [$1144] + | array x = @long_le [$1144] | byte output @$c000 | void main () { | output = x[0] @@ -291,7 +290,7 @@ class ArraySuite extends FunSuite with Matchers with AppendedClues { } test("Const arrays") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086, Cpu.Motorola6809)( """ | const array square = [0, 1, 4, 9, 16, 25, 36, 49, 64] | byte five() = 5 @@ -318,7 +317,7 @@ class ArraySuite extends FunSuite with Matchers with AppendedClues { } test("Struct array initializers") { - EmuUnoptimizedCrossPlatformRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8086)( + EmuUnoptimizedCrossPlatformRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8086, Cpu.Motorola6809)( """ | struct p { byte x, byte y } | struct line { p from, p to } @@ -383,7 +382,7 @@ class ArraySuite extends FunSuite with Matchers with AppendedClues { } test("Arrays of words") { - EmuUnoptimizedCrossPlatformRun(Cpu.Mos, Cpu.Intel8080, Cpu.Z80)( + EmuUnoptimizedCrossPlatformRun(Cpu.Mos, Cpu.Intel8080, Cpu.Z80, Cpu.Motorola6809)( """ | array(word) words[10] @$c000 | void main () { @@ -406,7 +405,7 @@ class ArraySuite extends FunSuite with Matchers with AppendedClues { } test("Initialized arrays of words") { - EmuUnoptimizedCrossPlatformRun(Cpu.Mos, Cpu.Intel8080, Cpu.Z80)( + EmuUnoptimizedCrossPlatformRun(Cpu.Mos, Cpu.Intel8080, Cpu.Z80, Cpu.Motorola6809)( """ | struct coord { byte x, byte y } | @@ -430,7 +429,7 @@ class ArraySuite extends FunSuite with Matchers with AppendedClues { } test("Pointers to array elements") { - EmuUnoptimizedCrossPlatformRun(Cpu.Mos, Cpu.Intel8080, Cpu.Z80)( + EmuUnoptimizedCrossPlatformRun(Cpu.Mos, Cpu.Intel8080, Cpu.Z80, Cpu.Motorola6809)( """ | struct coord { byte x, byte y } | diff --git a/src/test/scala/millfork/test/AssemblyOptimizationSuite.scala b/src/test/scala/millfork/test/AssemblyOptimizationSuite.scala index 055c916c..f802406d 100644 --- a/src/test/scala/millfork/test/AssemblyOptimizationSuite.scala +++ b/src/test/scala/millfork/test/AssemblyOptimizationSuite.scala @@ -11,7 +11,7 @@ import org.scalatest.{FunSuite, Matchers} class AssemblyOptimizationSuite extends FunSuite with Matchers { test("Duplicate RTS") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086, Cpu.Motorola6809)( """ | void main () { | if 1 == 1 { @@ -22,7 +22,7 @@ class AssemblyOptimizationSuite extends FunSuite with Matchers { } test("Inlining variable") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086, Cpu.Motorola6809)( """ | array output [5] @$C000 | void main () { @@ -37,7 +37,7 @@ class AssemblyOptimizationSuite extends FunSuite with Matchers { } test("Inlining variable 2") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086, Cpu.Motorola6809)( """ | array output [100] @$C000 | void main () { @@ -52,7 +52,7 @@ class AssemblyOptimizationSuite extends FunSuite with Matchers { } test("Loading modified variables") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086, Cpu.Motorola6809)( """ | byte output @$C000 | void main () { @@ -68,7 +68,7 @@ class AssemblyOptimizationSuite extends FunSuite with Matchers { } test("Bit ops") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086, Cpu.Motorola6809)( """ | byte output @$C000 | void main () { @@ -82,7 +82,7 @@ class AssemblyOptimizationSuite extends FunSuite with Matchers { } test("Inlining after a while") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086, Cpu.Motorola6809)( """ | array output [2]@$C000 | void main () { @@ -95,11 +95,14 @@ class AssemblyOptimizationSuite extends FunSuite with Matchers { | } | } | void lol() {} - """.stripMargin)(_.readWord(0xc000) should equal(0x406)) + """.stripMargin){m => + m.readByte(0xc000) should equal(6) + m.readByte(0xc001) should equal(4) + } } test("Tail call") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086, Cpu.Motorola6809)( """ | byte output @$C000 | void main () { @@ -302,7 +305,7 @@ class AssemblyOptimizationSuite extends FunSuite with Matchers { } test("Adding a nonet") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086, Cpu.Motorola6809)( """ | word output @$C000 | byte source @$C002 @@ -321,7 +324,7 @@ class AssemblyOptimizationSuite extends FunSuite with Matchers { } test("Common indexing subexpression elimination") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086, Cpu.Motorola6809)( """ | array output [55] @$C000 | array input = [0,1,2,3,4,5,6,7,8,9,10] @@ -335,12 +338,13 @@ class AssemblyOptimizationSuite extends FunSuite with Matchers { | } | """.stripMargin){m => - m.readWord(0xc003) should equal(3) + m.readByte(0xc003) should equal(3) + m.readByte(0xc004) should equal(0) } } test("Effectively const variable") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086, Cpu.Motorola6809)( """ |byte output @$c000 |void main() { @@ -408,7 +412,7 @@ class AssemblyOptimizationSuite extends FunSuite with Matchers { } test("Constant pointers") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086, Cpu.Motorola6809)( """ |byte output0 @$c000 |byte output1 @$c001 @@ -428,7 +432,7 @@ class AssemblyOptimizationSuite extends FunSuite with Matchers { } test("Low bit") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086, Cpu.Motorola6809)( """ | byte output @$c000 | void main() { @@ -447,7 +451,7 @@ class AssemblyOptimizationSuite extends FunSuite with Matchers { } test("Low bit 2") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086, Cpu.Motorola6809)( """ | byte output @$c000 | void main() { @@ -466,7 +470,7 @@ class AssemblyOptimizationSuite extends FunSuite with Matchers { } test("Low bit 3") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086, Cpu.Motorola6809)( """ | byte output @$c000 | void main() { @@ -488,7 +492,7 @@ class AssemblyOptimizationSuite extends FunSuite with Matchers { } test("Low bit 4") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086, Cpu.Motorola6809)( """ | byte output @$c000 | void main() { @@ -528,7 +532,7 @@ class AssemblyOptimizationSuite extends FunSuite with Matchers { } test("Shift and increase") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086, Cpu.Motorola6809)( """ | byte output @$c000 | void main() { @@ -544,7 +548,7 @@ class AssemblyOptimizationSuite extends FunSuite with Matchers { } test("Add one bit") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086, Cpu.Motorola6809)( """ | byte output @$c000 | void main() { @@ -561,7 +565,7 @@ class AssemblyOptimizationSuite extends FunSuite with Matchers { } test("Shift, mask and increase 1") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Motorola6809)( """ | byte output @$c000 | void main() { @@ -577,7 +581,7 @@ class AssemblyOptimizationSuite extends FunSuite with Matchers { } test("Shift, mask and increase 2") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Motorola6809)( """ | byte output @$c000 | void main() { @@ -593,7 +597,7 @@ class AssemblyOptimizationSuite extends FunSuite with Matchers { } test("Shift, mask, increase and test") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Motorola6809)( """ | byte output @$c000 | void main() { @@ -612,7 +616,7 @@ class AssemblyOptimizationSuite extends FunSuite with Matchers { } test("Double indices") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Motorola6809)( """ | array output[1000] @$c000 | array xbuf[40] @@ -657,7 +661,7 @@ class AssemblyOptimizationSuite extends FunSuite with Matchers { } test("Not using X") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Motorola6809)( """ | word output @$c000 | inline word w() = 300 @@ -672,7 +676,7 @@ class AssemblyOptimizationSuite extends FunSuite with Matchers { } test("Some stuff") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Motorola6809)( """ | array output[256] @ $c000 | void main() { @@ -692,7 +696,7 @@ class AssemblyOptimizationSuite extends FunSuite with Matchers { } test("Simple flags") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Intel8080)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Intel8080, Cpu.Motorola6809)( """ | byte output @ $c000 | void main() { @@ -749,7 +753,7 @@ class AssemblyOptimizationSuite extends FunSuite with Matchers { } test("Optimize load after test") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Intel8080)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Intel8080, Cpu.Motorola6809)( """ | byte output @ $c000 | void main() { diff --git a/src/test/scala/millfork/test/BitPackingSuite.scala b/src/test/scala/millfork/test/BitPackingSuite.scala index 6b80a0b3..5f69cd4b 100644 --- a/src/test/scala/millfork/test/BitPackingSuite.scala +++ b/src/test/scala/millfork/test/BitPackingSuite.scala @@ -11,7 +11,7 @@ import org.scalatest.{FunSuite, Matchers} class BitPackingSuite extends FunSuite with Matchers { test("Unpack bits from a byte") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)(""" + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086, Cpu.Motorola6809)(""" | array output[8] | word output_addr @$c000 | void main () { @@ -40,7 +40,7 @@ class BitPackingSuite extends FunSuite with Matchers { } test("Population count") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos)(""" + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Motorola6809)(""" | byte output @$c000 | noinline byte popcnt(byte x) { | byte result @@ -60,7 +60,7 @@ class BitPackingSuite extends FunSuite with Matchers { } test("Unpack bits from a word") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)(""" + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086, Cpu.Motorola6809)(""" | array output[16] | word output_addr @$c000 | void main () { @@ -97,7 +97,7 @@ class BitPackingSuite extends FunSuite with Matchers { } test("Pack bits into byte") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)(""" + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086, Cpu.Motorola6809)(""" | byte output @$C000 | array input = [$F0, 1, 0, $41, $10, 1, $61, 0] | void main () { @@ -114,7 +114,7 @@ class BitPackingSuite extends FunSuite with Matchers { } test("Pack bits into word") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)(""" + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086, Cpu.Motorola6809)(""" | word output @$C000 | array input = [$F0, 1, 0, $41, $10, 1, $61, 0, | 1, 1, 0, 0, 0, 0, 1, 1] @@ -132,7 +132,7 @@ class BitPackingSuite extends FunSuite with Matchers { } test("Pack bits into byte using plus") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)(""" + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086, Cpu.Motorola6809)(""" | byte output @$C000 | array input = [$F0, 1, 0, $41, $10, 1, $61, 0] | void main () { @@ -149,7 +149,7 @@ class BitPackingSuite extends FunSuite with Matchers { } test("Reverse byte") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)(""" + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086, Cpu.Motorola6809)(""" | word output_addr @$C000 | void main () { | byte i @@ -171,7 +171,7 @@ class BitPackingSuite extends FunSuite with Matchers { } test("Reverse byte 2") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)(""" + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086, Cpu.Motorola6809)(""" | byte output_real @$C000 | void main () { | byte i @@ -192,7 +192,7 @@ class BitPackingSuite extends FunSuite with Matchers { } test("Reverse word") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)(""" + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086, Cpu.Motorola6809)(""" | word output_addr @$C000 | void main () { | byte i diff --git a/src/test/scala/millfork/test/ComparisonSuite.scala b/src/test/scala/millfork/test/ComparisonSuite.scala index 7e6b1b35..9d688691 100644 --- a/src/test/scala/millfork/test/ComparisonSuite.scala +++ b/src/test/scala/millfork/test/ComparisonSuite.scala @@ -560,7 +560,7 @@ class ComparisonSuite extends FunSuite with Matchers with AppendedClues { | } | noinline word id(word x) = x |""".stripMargin - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Sixteen, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)(code) {m => + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Sixteen, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Motorola6809)(code) {m => m.readByte(0xc000) should equal (code.count(_ == '↑')) } } diff --git a/src/test/scala/millfork/test/DeduplicationSuite.scala b/src/test/scala/millfork/test/DeduplicationSuite.scala index 619def0a..390bbd57 100644 --- a/src/test/scala/millfork/test/DeduplicationSuite.scala +++ b/src/test/scala/millfork/test/DeduplicationSuite.scala @@ -31,7 +31,7 @@ class DeduplicationSuite extends FunSuite with Matchers { } test("Subroutine extraction") { - EmuSizeOptimizedCrossPlatformRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Intel8086)( + EmuSizeOptimizedCrossPlatformRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Intel8086, Cpu.Motorola6809)( """ | int24 output @$c000 | void main() { @@ -71,7 +71,7 @@ class DeduplicationSuite extends FunSuite with Matchers { } test("Loop subroutine extraction") { - EmuSizeOptimizedCrossPlatformRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Intel8086)( + EmuSizeOptimizedCrossPlatformRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Intel8086, Cpu.Motorola6809)( """ | array output [8] @$c000 | void main() { diff --git a/src/test/scala/millfork/test/EnumSuite.scala b/src/test/scala/millfork/test/EnumSuite.scala index 01ddc642..ea824225 100644 --- a/src/test/scala/millfork/test/EnumSuite.scala +++ b/src/test/scala/millfork/test/EnumSuite.scala @@ -10,7 +10,7 @@ import org.scalatest.{FunSuite, Matchers} class EnumSuite extends FunSuite with Matchers { test("Enum basic test") { - EmuUnoptimizedCrossPlatformRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( + EmuUnoptimizedCrossPlatformRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086, Cpu.Motorola6809)( """ | enum ugly { | a @@ -32,6 +32,9 @@ class EnumSuite extends FunSuite with Matchers { | #elseif ARCH_I80 | ld ($bfff),a | ret + | #elseif ARCH_6809 + | sta $bfff + | rts | #else | #error | #endif @@ -60,7 +63,7 @@ class EnumSuite extends FunSuite with Matchers { } test("Enum arrays") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086, Cpu.Motorola6809)( """ | enum ugly { | a @@ -79,6 +82,9 @@ class EnumSuite extends FunSuite with Matchers { | #elseif ARCH_I80 | ld ($bfff),a | ret + | #elseif ARCH_6809 + | sta $bfff + | rts | #else | #error | #endif @@ -87,7 +93,7 @@ class EnumSuite extends FunSuite with Matchers { } test("Loops over enums") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086, Cpu.Motorola6809)( """ | enum ugly { | a diff --git a/src/test/scala/millfork/test/ErasthotenesSuite.scala b/src/test/scala/millfork/test/ErasthotenesSuite.scala index 29a94e76..f0604165 100644 --- a/src/test/scala/millfork/test/ErasthotenesSuite.scala +++ b/src/test/scala/millfork/test/ErasthotenesSuite.scala @@ -10,7 +10,7 @@ import org.scalatest.{FunSuite, Matchers} class ErasthotenesSuite extends FunSuite with Matchers { test("Erasthotenes") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086, Cpu.Motorola6809)( """ | const pointer sieve = $C000 | const byte sqrt = 128 diff --git a/src/test/scala/millfork/test/ForArraySuite.scala b/src/test/scala/millfork/test/ForArraySuite.scala index 235fd217..13f2f81e 100644 --- a/src/test/scala/millfork/test/ForArraySuite.scala +++ b/src/test/scala/millfork/test/ForArraySuite.scala @@ -39,7 +39,7 @@ class ForArraySuite extends FunSuite with Matchers { """.stripMargin val m = EmuSuperOptimizedRun(src) m.readByte(0xc000) should equal(18) - EmuCrossPlatformBenchmarkRun(Cpu.Cmos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)(src) { m => + EmuCrossPlatformBenchmarkRun(Cpu.Cmos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086, Cpu.Motorola6809)(src) { m => m.readByte(0xc000) should equal(18) } } diff --git a/src/test/scala/millfork/test/ForLoopSecondSuite.scala b/src/test/scala/millfork/test/ForLoopSecondSuite.scala index 4811fb46..403c9575 100644 --- a/src/test/scala/millfork/test/ForLoopSecondSuite.scala +++ b/src/test/scala/millfork/test/ForLoopSecondSuite.scala @@ -62,7 +62,7 @@ class ForLoopSecondSuite extends FunSuite with Matchers with AppendedClues { subcase("byte", from, dir, to, expectedCount)(Cpu.Mos, Cpu.Z80, Cpu.Motorola6809) } def wordSubcase(from: IterationBound, dir: String, to: IterationBound, expectedCount: Int)(implicit pos: org.scalactic.source.Position, prettifier: Prettifier): Unit = { - subcase("word", from, dir, to, expectedCount)(Cpu.Mos, Cpu.Z80/*, Cpu.Motorola6809*/) + subcase("word", from, dir, to, expectedCount)(Cpu.Mos, Cpu.Z80, Cpu.Motorola6809) } test("Basic iteration count test") { diff --git a/src/test/scala/millfork/test/ForLoopSuite.scala b/src/test/scala/millfork/test/ForLoopSuite.scala index 2270bb49..e509b8bf 100644 --- a/src/test/scala/millfork/test/ForLoopSuite.scala +++ b/src/test/scala/millfork/test/ForLoopSuite.scala @@ -11,7 +11,7 @@ import org.scalatest.{FunSuite, Matchers} class ForLoopSuite extends FunSuite with Matchers { test("For-to") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086, Cpu.Motorola6809)( """ | word output @$c000 | void main () { @@ -21,11 +21,11 @@ class ForLoopSuite extends FunSuite with Matchers { | output += i | } | } - """.stripMargin)(_.readByte(0xc000) should equal(15)) + """.stripMargin)(_.readWord(0xc000) should equal(15)) } test("For-to 2") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086, Cpu.Motorola6809)( """ | word output @$c000 | byte five @@ -40,11 +40,11 @@ class ForLoopSuite extends FunSuite with Matchers { | void init() { | five = 5 | } - """.stripMargin)(_.readByte(0xc000) should equal(15)) + """.stripMargin)(_.readWord(0xc000) should equal(15)) } test("For-downto") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086, Cpu.Motorola6809)( """ | word output @$c000 | void main () { @@ -54,11 +54,11 @@ class ForLoopSuite extends FunSuite with Matchers { | output += i | } | } - """.stripMargin)(_.readByte(0xc000) should equal(15)) + """.stripMargin)(_.readWord(0xc000) should equal(15)) } test("For-downto 2") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086, Cpu.Motorola6809)( """ | array output [55] @$c000 | void main () { @@ -78,7 +78,7 @@ class ForLoopSuite extends FunSuite with Matchers { } test("For-downto 3") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086, Cpu.Motorola6809)( """ | array output [55] @$c000 | void main () { @@ -102,7 +102,7 @@ class ForLoopSuite extends FunSuite with Matchers { } test("For-until") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086, Cpu.Motorola6809)( """ | word output @$c000 | void main () { @@ -112,11 +112,11 @@ class ForLoopSuite extends FunSuite with Matchers { | output += i | } | } - """.stripMargin)(_.readByte(0xc000) should equal(15)) + """.stripMargin)(_.readWord(0xc000) should equal(15)) } test("For-parallelto") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086, Cpu.Motorola6809)( """ | word output @$c000 | void main () { @@ -126,11 +126,11 @@ class ForLoopSuite extends FunSuite with Matchers { | output += i | } | } - """.stripMargin)(_.readByte(0xc000) should equal(15)) + """.stripMargin)(_.readWord(0xc000) should equal(15)) } test("For-paralleluntil") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086, Cpu.Motorola6809)( """ | word output @$c000 | void main () { @@ -140,11 +140,11 @@ class ForLoopSuite extends FunSuite with Matchers { | output += i | } | } - """.stripMargin)(_.readByte(0xc000) should equal(15)) + """.stripMargin)(_.readWord(0xc000) should equal(15)) } test("Various loops") { - EmuUnoptimizedCrossPlatformRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( + EmuUnoptimizedCrossPlatformRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086, Cpu.Motorola6809)( """ | void init() { | zero = 0 @@ -185,7 +185,7 @@ class ForLoopSuite extends FunSuite with Matchers { } test("Memcpy") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086, Cpu.Motorola6809)( """ | array output[5]@$c001 | array input = [0,1,4,9,16,25,36,49] @@ -203,7 +203,7 @@ class ForLoopSuite extends FunSuite with Matchers { } test("Memset with index") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086, Cpu.Motorola6809)( """ | array output[5]@$c001 | void main () { @@ -220,7 +220,7 @@ class ForLoopSuite extends FunSuite with Matchers { } test("Memset with pointer") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086, Cpu.Motorola6809)( """ | array output[5]@$c001 | void main () { @@ -237,7 +237,7 @@ class ForLoopSuite extends FunSuite with Matchers { } test("Screen fill") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086, Cpu.Motorola6809)( """ | array output[$400]@$c000 | void main () { @@ -255,7 +255,7 @@ class ForLoopSuite extends FunSuite with Matchers { } test("Various bulk operations") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086, Cpu.Motorola6809)( """ | array output0[5]@$c000 | array output1[5]@$c010 @@ -290,7 +290,7 @@ class ForLoopSuite extends FunSuite with Matchers { } test("Modifying whole array") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Motorola6809)( """ | array output[$ff]@$c000 | void main () { @@ -355,7 +355,7 @@ class ForLoopSuite extends FunSuite with Matchers { } test("Edge cases - positive") { - EmuUnoptimizedCrossPlatformRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)(""" + EmuUnoptimizedCrossPlatformRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086, Cpu.Motorola6809)(""" | void main() { | byte i | for i,0,until,256 { f() } @@ -410,7 +410,7 @@ class ForLoopSuite extends FunSuite with Matchers { test("For each") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8086)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8086, Cpu.Motorola6809)( """ | array output[$400]@$c000 | void main () { diff --git a/src/test/scala/millfork/test/FunctionPointerSuite.scala b/src/test/scala/millfork/test/FunctionPointerSuite.scala index 5ea2be80..a2b99a7c 100644 --- a/src/test/scala/millfork/test/FunctionPointerSuite.scala +++ b/src/test/scala/millfork/test/FunctionPointerSuite.scala @@ -30,7 +30,7 @@ class FunctionPointerSuite extends FunSuite with Matchers with AppendedClues{ } test("Function pointers 2") { - EmuUnoptimizedCrossPlatformRun (Cpu.Mos, Cpu.Cmos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)( + EmuUnoptimizedCrossPlatformRun (Cpu.Mos, Cpu.Cmos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Motorola6809)( """ | const byte COUNT = 128 | array output0[COUNT] @$c000 diff --git a/src/test/scala/millfork/test/GotoSuite.scala b/src/test/scala/millfork/test/GotoSuite.scala index a6effe0e..47755590 100644 --- a/src/test/scala/millfork/test/GotoSuite.scala +++ b/src/test/scala/millfork/test/GotoSuite.scala @@ -10,7 +10,7 @@ import org.scalatest.{FunSuite, Matchers} class GotoSuite extends FunSuite with Matchers { test("Goto 1") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Cmos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Cmos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Motorola6809)( """ | | byte output @$c000 @@ -34,7 +34,7 @@ class GotoSuite extends FunSuite with Matchers { } test("Cross-loop goto") { - EmuUnoptimizedCrossPlatformRun(Cpu.Mos, Cpu.Z80)( + EmuUnoptimizedCrossPlatformRun(Cpu.Mos, Cpu.Z80, Cpu.Motorola6809)( """ | | byte output @$c000 diff --git a/src/test/scala/millfork/test/InliningSuite.scala b/src/test/scala/millfork/test/InliningSuite.scala index f90c692c..58701f2f 100644 --- a/src/test/scala/millfork/test/InliningSuite.scala +++ b/src/test/scala/millfork/test/InliningSuite.scala @@ -10,7 +10,7 @@ import org.scalatest.{FunSuite, Matchers} class InliningSuite extends FunSuite with Matchers { test("Should inline square") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8086)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8086, Cpu.Motorola6809)( """ | import zp_reg | byte output @$c000 @@ -24,7 +24,7 @@ class InliningSuite extends FunSuite with Matchers { } test("Should inline <<") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8086)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8086, Cpu.Motorola6809)( """ | byte output @$c000 | word output2 @$c006 @@ -46,7 +46,7 @@ class InliningSuite extends FunSuite with Matchers { } test("Should inline this weird thing") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8086)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8086, Cpu.Motorola6809)( """ | byte output @$c000 | inline word square(word x) { @@ -61,7 +61,7 @@ class InliningSuite extends FunSuite with Matchers { } test("Should inline this even weirder thing") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8086)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8086, Cpu.Motorola6809)( """ | byte output@$c000 | inline word square(word x) { diff --git a/src/test/scala/millfork/test/emu/EmuSizeOptimizedCrossPlatformRun.scala b/src/test/scala/millfork/test/emu/EmuSizeOptimizedCrossPlatformRun.scala index 53aa4506..9430b3d6 100644 --- a/src/test/scala/millfork/test/emu/EmuSizeOptimizedCrossPlatformRun.scala +++ b/src/test/scala/millfork/test/emu/EmuSizeOptimizedCrossPlatformRun.scala @@ -11,6 +11,7 @@ object EmuSizeOptimizedCrossPlatformRun { val (_, mm) = if (platforms.contains(Cpu.Mos)) EmuSizeOptimizedRun.apply2(source) else Timings(-1, -1) -> null val (_, mz) = if (platforms.contains(Cpu.Z80)) EmuSizeOptimizedZ80Run.apply2(source) else Timings(-1, -1) -> null val (_, mi) = if (platforms.contains(Cpu.Intel8080)) EmuSizeOptimizedIntel8080Run.apply2(source) else Timings(-1, -1) -> null + val (_, mo) = if (platforms.contains(Cpu.Motorola6809)) EmuOptimizedM6809Run.apply2(source) else Timings(-1, -1) -> null // TODO if (platforms.contains(Cpu.Mos)) { println(f"Running 6502") verifier(mm) @@ -23,5 +24,9 @@ object EmuSizeOptimizedCrossPlatformRun { println(f"Running 8080") verifier(mi) } + if (platforms.contains(Cpu.Motorola6809)) { + println(f"Running 6809") + verifier(mo) + } } }