From 1cb3b672b170a4e145bcc093d4b35c0f48bda773 Mon Sep 17 00:00:00 2001 From: Karol Stasiak Date: Fri, 31 May 2019 17:03:35 +0200 Subject: [PATCH] Add 8080-to-8086 translation --- CHANGELOG.md | 2 + README.md | 2 + build.sbt | 3 + docs/abi/calling-convention.md | 42 ++ docs/abi/undocumented.md | 4 + docs/abi/variable-storage.md | 3 + docs/api/custom-platform.md | 3 + docs/api/target-platforms.md | 2 + docs/faq.md | 5 +- docs/lang/functions.md | 3 +- docs/lang/preprocessor.md | 4 + docs/lang/syntax.md | 2 +- docs/lang/x86disclaimer.md | 78 ++++ include/dos_com.ini | 25 ++ include/pc_dos.mfk | 37 ++ include/random.mfk | 3 + include/stdlib.mfk | 5 +- .../scala/millfork/CompilationOptions.scala | 25 +- src/main/scala/millfork/Main.scala | 34 ++ .../scala/millfork/assembly/z80/ZLine.scala | 169 ++++++++ src/main/scala/millfork/env/Environment.scala | 2 + .../millfork/output/AbstractAssembler.scala | 9 +- .../output/Z80ToX86Crossassembler.scala | 392 ++++++++++++++++++ .../scala/millfork/test/AlgorithmSuite.scala | 2 +- .../scala/millfork/test/AlignmentSuite.scala | 2 +- src/test/scala/millfork/test/ArraySuite.scala | 30 +- .../test/AssemblyOptimizationSuite.scala | 34 +- .../scala/millfork/test/BasicSymonTest.scala | 18 +- src/test/scala/millfork/test/BitOpSuite.scala | 8 +- .../scala/millfork/test/BitPackingSuite.scala | 16 +- .../scala/millfork/test/BooleanSuite.scala | 10 +- .../millfork/test/BreakContinueSuite.scala | 12 +- .../millfork/test/ByteDecimalMathSuite.scala | 46 +- .../scala/millfork/test/ByteMathSuite.scala | 26 +- .../scala/millfork/test/ComparisonSuite.scala | 44 +- .../scala/millfork/test/ConstantSuite.scala | 2 +- .../millfork/test/DeduplicationSuite.scala | 4 +- src/test/scala/millfork/test/DerefSuite.scala | 6 +- src/test/scala/millfork/test/EnumSuite.scala | 6 +- .../millfork/test/ErasthotenesSuite.scala | 2 +- .../scala/millfork/test/FarwordTest.scala | 20 +- .../scala/millfork/test/ForArraySuite.scala | 2 +- .../scala/millfork/test/ForLoopSuite.scala | 32 +- .../scala/millfork/test/InliningSuite.scala | 8 +- src/test/scala/millfork/test/LongTest.scala | 28 +- src/test/scala/millfork/test/MacroSuite.scala | 2 +- .../scala/millfork/test/MemsetSuite.scala | 2 +- .../millfork/test/NodeOptimizationSuite.scala | 2 +- src/test/scala/millfork/test/NonetSuite.scala | 10 +- .../scala/millfork/test/PointerSuite.scala | 18 +- .../millfork/test/ReturnDispatchSuite.scala | 6 +- .../SecondAssemblyOptimizationSuite.scala | 8 +- .../millfork/test/SeparateBytesSuite.scala | 16 +- src/test/scala/millfork/test/ShiftSuite.scala | 16 +- .../millfork/test/SignExtensionSuite.scala | 8 +- .../scala/millfork/test/StackVarSuite.scala | 26 +- .../test/StatementOptimizationSuite.scala | 4 +- .../scala/millfork/test/StructSuite.scala | 8 +- src/test/scala/millfork/test/TypeSuite.scala | 2 +- .../millfork/test/TypeWideningSuite.scala | 2 +- .../scala/millfork/test/VolatileSuite.scala | 2 +- .../scala/millfork/test/WordMathSuite.scala | 48 +-- .../millfork/test/Z80AssemblySuite.scala | 39 +- .../millfork/test/emu/EmuBenchmarkRun.scala | 24 +- .../scala/millfork/test/emu/EmuI86Run.scala | 213 ++++++++++ .../test/emu/EmuOptimizedInlinedRun.scala | 4 + .../millfork/test/emu/EmuOptimizedRun.scala | 2 + .../scala/millfork/test/emu/EmuPlatform.scala | 2 +- .../emu/EmuUnoptimizedCrossPlatformRun.scala | 5 + .../millfork/test/emu/EmuUnoptimizedRun.scala | 2 + .../scala/millfork/test/emu/Settings.scala | 30 ++ 71 files changed, 1422 insertions(+), 291 deletions(-) create mode 100644 docs/lang/x86disclaimer.md create mode 100644 include/dos_com.ini create mode 100644 include/pc_dos.mfk create mode 100644 src/main/scala/millfork/output/Z80ToX86Crossassembler.scala create mode 100644 src/test/scala/millfork/test/emu/EmuI86Run.scala create mode 100644 src/test/scala/millfork/test/emu/Settings.scala diff --git a/CHANGELOG.md b/CHANGELOG.md index ec09e7ae..810ea5b4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,8 @@ * Preliminary experimental Game Boy support. +* Super experimental and very incomplete Intel 8086 support via 8080-to-8086 translation. + * Added `memory_barrier` macro. * Added `random` module. diff --git a/README.md b/README.md index 6c6dcb83..57fc9a89 100644 --- a/README.md +++ b/README.md @@ -38,6 +38,8 @@ For binary releases, see: https://github.com/KarolS/millfork/releases * Atari 2600 (experimental) * Game Boy (experimental) + + * MS-DOS (very experimental, via 8080-to-8086 translation) * inline assembly diff --git a/build.sbt b/build.sbt index 7487554b..3978ee6c 100644 --- a/build.sbt +++ b/build.sbt @@ -14,6 +14,9 @@ libraryDependencies += "org.scalatest" %% "scalatest" % "3.0.4" % "test" libraryDependencies += "com.codingrodent.microprocessor" % "Z80Processor" % "2.0.2" % "test" +// see: https://github.com/NeatMonster/Intel8086 +libraryDependencies += "NeatMonster" % "Intel8086" % "1.0" % "test" from "https://github.com/NeatMonster/Intel8086/raw/master/IBMPC.jar" + // these three are not in Maven Central or any other public repo // get them from the following links or just build millfork without tests: // https://github.com/sethm/symon/tree/71905fdb1998ee4f142260879504bc46cf27648f diff --git a/docs/abi/calling-convention.md b/docs/abi/calling-convention.md index 161b1357..864dfb5a 100644 --- a/docs/abi/calling-convention.md +++ b/docs/abi/calling-convention.md @@ -76,3 +76,45 @@ and the most significant word is passed via the DE register pair * callee may clobber all registers except for IX, IY and shadow registers +## 8086 + +The Intel 8086 calling conventions is based on the Intel 8080 calling convention, +plus it uses the BP register in the same role as the IX register of Z80. + +#### Parameters: + +* if the function has one parameter of size one byte, it is passed via the AL register + +* if the function has one parameter of size two bytes, it is passed via the BX register + +* if the function has one parameter of size three bytes, +its least significant two bytes are passed via the BX register +and the most significant byte is passed via the DL register + +* if the function has one parameter of size four bytes, +its least significant word is passed via the BX register +and the most significant word is passed via the DX register + +* otherwise, all parameters are passed via static locations + +#### Return values: + +* one-byte return values are passed via the AL register + +* two-byte return values are passed via the BX register + +* in case of three-byte return values, +its least significant two bytes are passed via the BX register +and the most significant byte is passed via the DL register + +* in case of four-byte return values, +its least significant word is passed via the BX register +and the most significant word is passed via the DX register + +* otherwise, the return value is passed via a static location + +#### Register preservation: + +* callee may clobber all flags + +* callee may clobber all registers except for BP diff --git a/docs/abi/undocumented.md b/docs/abi/undocumented.md index ae3a9ebb..f066c9d4 100644 --- a/docs/abi/undocumented.md +++ b/docs/abi/undocumented.md @@ -69,3 +69,7 @@ AHX, LAS, LXA, SHX, SHY, TAS, XAA. Original Z80 processors accidentally supported a bunch of extra undocumented instructions. Millfork will not emit them. The only exception is SLL, which will be emitted if it occurs in a handwritten assembly block. + +## 8086 + +Undocumented instructions are not supported. diff --git a/docs/abi/variable-storage.md b/docs/abi/variable-storage.md index 7055edd2..cff120ed 100644 --- a/docs/abi/variable-storage.md +++ b/docs/abi/variable-storage.md @@ -63,6 +63,9 @@ this makes stack-allocated variables independent from other stack operations and allows for optimizing them by inlining them into registers (this can be disabled, so the 8080 method is used, or switched to use IY instead) +* on 8086, the BP register is used as the base pointer, behaving similarly to the IX register on Z80 +(this can be disabled, so the 8080 method is used, with the target address register being BX instead of HL) + ## Automatic variables Automatic variables have lifetime starting with the beginning of the function they're in diff --git a/docs/api/custom-platform.md b/docs/api/custom-platform.md index 1f406626..c28f075d 100644 --- a/docs/api/custom-platform.md +++ b/docs/api/custom-platform.md @@ -32,6 +32,9 @@ if a line ends with a backslash character, the value continues to the next line. * `i8080` (Intel 8080; experimental, buggy and very incomplete) * `gameboy` (Sharp LR35902; experimental, buggy and very incomplete) + + * `i8086` (Intel 8086; very experimental, very buggy and very, very incomplete – + see the [8086 support disclaimer](../lang/x86disclaimer.md)) * `encoding` – default encoding for console I/O, one of `ascii`, `pet`/`petscii`, `petscr`/`cbmscr`, `atascii`, `bbc`, `jis`/`jisx`, `apple2`, diff --git a/docs/api/target-platforms.md b/docs/api/target-platforms.md index 16bdafb3..06f52f77 100644 --- a/docs/api/target-platforms.md +++ b/docs/api/target-platforms.md @@ -87,6 +87,8 @@ The compiler emits COM files. * `cpm_z80` – CP/M on Z80 +* `dos_com` – a COM file for DOS on IBM PC. (very experimental) + The primary and most tested platform is Commodore 64. Currently, targets that assume that the program will be loaded from disk or tape are better tested. diff --git a/docs/faq.md b/docs/faq.md index bf018cd3..c6c9b35b 100644 --- a/docs/faq.md +++ b/docs/faq.md @@ -18,7 +18,7 @@ The goal of Millfork is to succeed where Atalan failed. Large programs in Millfork have been developed for Commodore 64. Millfork was also tested (via emulators) to run trivial programs on other 8-bit Commodore computers, -Atari 8-bit computers, Apple II, BBC Micro, ZX Spectrum 48k, NEC PC-88, CP/M, NES, Game Boy and Atari 2600. +Atari 8-bit computers, Apple II, BBC Micro, ZX Spectrum 48k, NEC PC-88, CP/M, NES, Game Boy, Atari 2600 and MS-DOS. Support for other devices using supported processors can be easily added, usually without even modifying the compiler. @@ -28,6 +28,9 @@ Support for other devices using supported processors can be easily added, usuall * Intel 8080, Zilog Z80, Sharp LR35902 (also known as GBZ80) +* There is also partial experimental support for Intel 8086, via automatic 8080-to-8086 translation. +The generated code is very large and very slow. + ### Why Millfork when I can use assembly? * Assembly will not be portable. If you want to target both 6502 and Z80, you'd have to maintain two separate codebases. diff --git a/docs/lang/functions.md b/docs/lang/functions.md index ca85dbdc..92674f0e 100644 --- a/docs/lang/functions.md +++ b/docs/lang/functions.md @@ -16,7 +16,8 @@ Syntax: * `asm` – the function is written in assembly, not in Millfork (obligatory for `extern` functions), see [Using 6502 assembly within Millfork programs#Assembly functions](./assembly.md#assembly-functions) - or [Using 8080/LR35902/Z80 assembly within Millfork programs#Assembly functions](./assemblyz80.md#assembly-functions) + or [Using 8080/LR35902/Z80 assembly within Millfork programs#Assembly functions](./assemblyz80.md#assembly-functions); + for 8086, see the [8086 support disclaimer](./x86disclaimer.md). * `macro` – the function is a macro, see [Macros_and inlining#Macros](../abi/inlining.md#macros) diff --git a/docs/lang/preprocessor.md b/docs/lang/preprocessor.md index a1803ad9..7ff97808 100644 --- a/docs/lang/preprocessor.md +++ b/docs/lang/preprocessor.md @@ -38,6 +38,8 @@ The following features are defined based on the chosen CPU and compilation optio * `ARCH_I80` – 1 if compiling for Intel 8080-like processor, 0 otherwise +* `ARCH_X86` – 1 if compiling for Intel 8086-like processor, 0 otherwise + * `CPU_65C02`, `CPU_65CE02`, `CPU_65816`, `CPU_HUC6280`, `CPU_8080`, `CPU_GAMEBOY`, `CPU_Z80` – 1 if compiling for the exact given processor, 0 otherwise @@ -86,6 +88,8 @@ The following features are defined based on the chosen CPU and compilation optio * `CPM` – 1 if the target is CP/M, 0 otherwise +* `IBM_PC` – 1 if the target is IBM PC, 0 otherwise + * `NTSC` – 1 if the target is NTSC, 0 otherwise * `PAL` – 1 if the target is PAL, 0 otherwise diff --git a/docs/lang/syntax.md b/docs/lang/syntax.md index def0f176..40d7f6bb 100644 --- a/docs/lang/syntax.md +++ b/docs/lang/syntax.md @@ -324,4 +324,4 @@ continue See [Using 6502 assembly within Millfork programs](./assembly.md) or [Using 8080/LR35902/Z80 assembly within Millfork programs](./assemblyz80.md). - \ No newline at end of file +**Work in progress**: For 8086, see the [8086 support disclaimer](./x86disclaimer.md). diff --git a/docs/lang/x86disclaimer.md b/docs/lang/x86disclaimer.md new file mode 100644 index 00000000..020ebf37 --- /dev/null +++ b/docs/lang/x86disclaimer.md @@ -0,0 +1,78 @@ +[< back to index](../index.md) + +# 8086 support disclaimer + +Millfork does not support Intel 8086 directly. +Instead, it generates Intel 8080 code and translates it automatically to 8086 machine code. +For convenience, Z80 instructions using `IX` are also translated. + +This means that: + +* code is going to be large and slow; + +* there is no support for writing 8086 assembly; + +* Millfork currently translates majority of Intel 8080 assembly instructions to 8086 machine code, +so you can write 8080/Z80 assembly instead. + +For example, code like + + asm { + LD HL, x + LD BC, i + ADD HL, BC + JP C, skip + LD A, IX(5) + LD (HL), A + skip: + } + +is compiled to + + MOV BX, x + MOV CX, i + ADD BX, CX + JNC .next + JMP skip + .next: + MOV AL, BYTE PTR [BP+5] + MOV BYTE PTR [BX], AL + skip: + +Generated assembly output uses Intel 8086 syntax. + +#### Major deficiencies of generated code + +* hardware multiplication is not used + +* many 16-bit operations are not used + +* many operations are restricted to the `AL` register + +* the overflow flag is not used + +* `DAS` is not used + +* conditional jumps are never optimized to short 2-byte jumps and always use 5 bytes + +* the `SI` register is reloaded before every use + +* the converter translates the `DAD` instruction (16-bit `ADD` on Z80) to `ADD`, +which may change behaviour of assembly code, +as 8080's `DAD` changes only the carry flag, and 8086's `ADD` changes many flags. +Luckily, this is not an issue with Millfork code, as the optimizer does not assume anything about flags after that instruction. +The proper sequence is `LAHF`/`ADD r1,r2`/`RCR SI,1`/`SAHF`/`RCL SI,1`, but it is obviously too slow. + +#### Register mapping + +The registers are translated as following: + + A → AL + B → CH C → CL BC → CX + D → DH E → DL DE → DX + H → BH L → BL HL → BX + SP → SP + IX → BP + +The `SI` register is used as a temporary register for holding the address in `LDAX`/`STAX` +(`LD (DE),A`/`LD(BC),A`/`LD A,(DE)`/`LD A,(BC)` on Z80). diff --git a/include/dos_com.ini b/include/dos_com.ini new file mode 100644 index 00000000..d082abc9 --- /dev/null +++ b/include/dos_com.ini @@ -0,0 +1,25 @@ +;a COM program for DOS +[compilation] +arch=i8086 +encoding=ascii +modules=default_panic,stdlib,pc_dos + +[allocation] +segment_default_start=$100 +segment_default_datastart=after_code +segment_default_end=$ffff +; TODO: actual end? + +[define] +IBM_PC=1 +WIDESCREEN=1 +KEYBOARD=1 +JOYSTICKS=0 +HAS_BITMAP_MODE=0 + +[output] +style=single +format=allocated +extension=com + + diff --git a/include/pc_dos.mfk b/include/pc_dos.mfk new file mode 100644 index 00000000..f9b318b7 --- /dev/null +++ b/include/pc_dos.mfk @@ -0,0 +1,37 @@ +#pragma intel_syntax + +import default_readword + +inline asm void exit() { + [$b4, 0, $cd, $21] + ? ret +} +inline asm void putchar (byte e) { + [$b4, 2, $cd, $21] + ? ret +} + +inline void new_line() { + putchar(13) + putchar(10) +} + +inline asm byte getchar() { + [$b4, 1, $cd, $21] + ? ret +} + +array __readline_out[83] +const pointer readline_out = __readline_out.addr + 2 + +pointer readline() { + __readline_out[0] = 81 + __readline_out[1] = 0 + asm { + ? lxi d, __readline_out.addr + [$b4, $0a, $cd, $21] + } + __readline_out[__readline_out[1] + 2] = 0 + new_line() + return __readline_out + 2 +} diff --git a/include/random.mfk b/include/random.mfk index e305203c..4711aff9 100644 --- a/include/random.mfk +++ b/include/random.mfk @@ -5,6 +5,9 @@ word rand_seed import random_6502 #elseif ARCH_I80 import random_i80 +#elseif ARCH_X86 +#warn 8086 is a partially supported architecture +import random_i80 #else #warn Unsupported architecture #endif diff --git a/include/stdlib.mfk b/include/stdlib.mfk index 53b64ab5..90a82ba5 100644 --- a/include/stdlib.mfk +++ b/include/stdlib.mfk @@ -4,8 +4,9 @@ import stdlib_6502 #elseif ARCH_I80 import stdlib_i80 -#else -#warn Unsupported architecture +#elseif ARCH_X86 +#warn 8086 is a partially supported architecture +import stdlib_i80 #endif #if PAL && NTSC diff --git a/src/main/scala/millfork/CompilationOptions.scala b/src/main/scala/millfork/CompilationOptions.scala index 1516e7fa..9c55e920 100644 --- a/src/main/scala/millfork/CompilationOptions.scala +++ b/src/main/scala/millfork/CompilationOptions.scala @@ -37,9 +37,12 @@ case class CompilationOptions(platform: Platform, EmitCmosOpcodes, EmitCmosNopOpcodes, EmitHudsonOpcodes, Emit65CE02Opcodes, EmitEmulation65816Opcodes, EmitNative65816Opcodes, PreventJmpIndirectBug, LargeCode, ReturnWordsViaAccumulator, LUnixRelocatableCode, RorWarning, SoftwareStack) + if (CpuFamily.forType(platform.cpu) != CpuFamily.I80 && CpuFamily.forType(platform.cpu) != CpuFamily.I86) invalids ++= Set( + EmitIntel8080Opcodes, UseIxForStack, UseIntelSyntaxForInput, UseIntelSyntaxForOutput) + if (CpuFamily.forType(platform.cpu) != CpuFamily.I80) invalids ++= Set( - EmitExtended80Opcodes, EmitZ80Opcodes, EmitSharpOpcodes, EmitIntel8080Opcodes, EmitEZ80Opcodes, - UseIxForStack, UseIyForStack, UseShadowRegistersForInterrupts, UseIntelSyntaxForInput, UseIntelSyntaxForOutput) + EmitExtended80Opcodes, EmitZ80Opcodes, EmitSharpOpcodes, EmitEZ80Opcodes, + UseIyForStack, UseShadowRegistersForInterrupts) invalids = invalids.filter(flags) @@ -162,6 +165,10 @@ case class CompilationOptions(platform: Platform, log.error("Intel 8080 opcodes enabled for architecture that doesn't support them") } } + case CpuFamily.I86 => + if (flags(EmitIllegals)) { + log.error("Illegal opcodes enabled for architecture that doesn't support them") + } } } @@ -221,13 +228,14 @@ object CpuFamily extends Enumeration { cpu match { case Mos | StrictMos | Ricoh | StrictRicoh | Cmos | HuC6280 | CE02 | Sixteen => M6502 case Intel8080 | Sharp | Z80 | EZ80 => I80 + case Intel8086 => I86 } } } object Cpu extends Enumeration { - val Mos, StrictMos, Ricoh, StrictRicoh, Cmos, HuC6280, CE02, Sixteen, Intel8080, Z80, EZ80, Sharp = Value + val Mos, StrictMos, Ricoh, StrictRicoh, Cmos, HuC6280, CE02, Sixteen, Intel8080, Z80, EZ80, Sharp, Intel8086, Intel80186 = Value val CmosCompatible = Set(Cmos, HuC6280, CE02, Sixteen) @@ -266,6 +274,8 @@ object Cpu extends Enumeration { i80AlwaysDefaultFlags ++ Set(EmitIntel8080Opcodes, EmitExtended80Opcodes, EmitZ80Opcodes, UseIxForStack, UseShadowRegistersForInterrupts, EmitEZ80Opcodes) case Sharp => i80AlwaysDefaultFlags ++ Set(EmitExtended80Opcodes, EmitSharpOpcodes) + case Intel8086 | Intel80186 => + i80AlwaysDefaultFlags ++ Set(EmitIntel8080Opcodes, UseIxForStack) } def fromString(name: String)(implicit log: Logger): Cpu.Value = name match { @@ -305,6 +315,15 @@ object Cpu extends Enumeration { case "8080" => Intel8080 case "i8080" => Intel8080 case "intel8080" => Intel8080 + case "intel8086" => Intel8086 + case "i8086" => Intel8086 + case "8086" => Intel8086 + case "intel80186" => Intel80186 + case "i80186" => Intel80186 + case "80186" => Intel80186 + case "intel80286" => Intel80186 + case "i80286" => Intel80186 + case "80286" => Intel80186 case _ => log.fatal("Unknown CPU achitecture: " + name) } diff --git a/src/main/scala/millfork/Main.scala b/src/main/scala/millfork/Main.scala index 52eb2f4f..26570191 100644 --- a/src/main/scala/millfork/Main.scala +++ b/src/main/scala/millfork/Main.scala @@ -82,6 +82,7 @@ object Main { val result: AssemblerOutput = CpuFamily.forType(platform.cpu) match { case CpuFamily.M6502 => assembleForMos(c, platform, options) case CpuFamily.I80 => assembleForI80(c, platform, options) + case CpuFamily.I86 => assembleForI86(c, platform, options) } if (c.outputAssembly) { @@ -274,6 +275,39 @@ object Main { result } + private def assembleForI86(c: Context, platform: Platform, options: CompilationOptions): AssemblerOutput = { + val optLevel = c.optimizationLevel.getOrElse(0) + val unoptimized = new ZSourceLoadingQueue( + initialFilenames = c.inputFileNames, + includePath = c.includePath, + options = options).run() + + val program = if (optLevel > 0) { + OptimizationPresets.NodeOpt.foldLeft(unoptimized)((p, opt) => p.applyNodeOptimization(opt, options)) + } else { + OptimizationPresets.NodeOpt0.foldLeft(unoptimized)((p, opt) => p.applyNodeOptimization(opt, options)) + } + val callGraph = new StandardCallGraph(program, options.log) + + val env = new Environment(None, "", platform.cpuFamily, options) + env.collectDeclarations(program, options) + + val assemblyOptimizations = optLevel match { + case 0 => Nil + case _ => Z80OptimizationPresets.GoodForIntel8080 + } + + // compile + val assembler = new Z80ToX86Crossassembler(program, env, platform) + val result = assembler.assemble(callGraph, assemblyOptimizations, options) + options.log.assertNoErrors("Codegen failed") + options.log.debug(f"Unoptimized code size: ${assembler.unoptimizedCodeSize}%5d B") + options.log.debug(f"Optimized code size: ${assembler.optimizedCodeSize}%5d B") + options.log.debug(f"Gain: ${(100L * (assembler.unoptimizedCodeSize - assembler.optimizedCodeSize) / assembler.unoptimizedCodeSize.toDouble).round}%5d%%") + options.log.debug(f"Initialized variables: ${assembler.initializedVariablesSize}%5d B") + result + } + //noinspection NameBooleanParameters private def parser(errorReporting: Logger): CliParser[Context] = new CliParser[Context] { diff --git a/src/main/scala/millfork/assembly/z80/ZLine.scala b/src/main/scala/millfork/assembly/z80/ZLine.scala index 657ab1d9..2e5b23a6 100644 --- a/src/main/scala/millfork/assembly/z80/ZLine.scala +++ b/src/main/scala/millfork/assembly/z80/ZLine.scala @@ -323,6 +323,28 @@ case class ZLine(opcode: ZOpcode.Value, registers: ZRegisters, parameter: Consta case _ => "???" } + private def asIntel8086AssemblyString(r: ZRegister.Value): String = r match { + case ZRegister.A => "AL" + case ZRegister.B => "CH" + case ZRegister.C => "CL" + case ZRegister.D => "DH" + case ZRegister.E => "DL" + case ZRegister.H => "BH" + case ZRegister.L => "BL" + case ZRegister.AF => "AX" + case ZRegister.BC => "CX" + case ZRegister.DE => "DX" + case ZRegister.HL => "BX" + case ZRegister.SP => "SP" + case ZRegister.IX => "BP" + case ZRegister.MEM_ABS_8 => s"BYTE PTR [${parameter.toIntelString}]" + case ZRegister.MEM_ABS_16 => s"WORD PTR [${parameter.toIntelString}]" + case ZRegister.IMM_8 => parameter.toIntelString + case ZRegister.IMM_16 => parameter.toIntelString + case ZRegister.MEM_HL => "BYTE PTR [BX]" + case _ => "???" + } + override def toString: String = { import ZOpcode._ val raw = opcode match { @@ -584,6 +606,153 @@ case class ZLine(opcode: ZOpcode.Value, registers: ZRegisters, parameter: Consta if (result.contains("???")) s" ??? (${this.toString.stripPrefix(" ")})" else result } + + + def toIntel8086String: String = { + import ZOpcode._ + import ZRegister._ + val result = opcode match { + case LABEL => parameter.toString + ":" + case DISCARD_A => " ; DISCARD_AL" + case DISCARD_HL => " ; DISCARD_BX" + case DISCARD_F => " ; DISCARD_F" + case DISCARD_BC => " ; DISCARD_CX" + case DISCARD_DE => " ; DISCARD_DX" + case DISCARD_IX => " ; DISCARD_BP" + case BYTE => " DB " + parameter.toString + case LD | LD_16 => registers match { + case TwoRegisters(MEM_DE, A) => s" MOV SI, DX\n MOV BYTE PTR [SI], AL" + case TwoRegisters(MEM_BC, A) => s" MOV SI, CX\n MOV BYTE PTR [SI], AL" + case TwoRegisters(A, MEM_DE) => s" MOV SI, DX\n MOV AL, BYTE PTR [SI]" + case TwoRegisters(A, MEM_BC) => s" MOV SI, CX\n MOV AL, BYTE PTR [SI]" + case TwoRegistersOffset(MEM_IX_D, IMM_8, offset) => s" MOV BYTE PTR [BP+$offset}], ${parameter.toIntelString}" + case TwoRegisters(target, IMM_16 | IMM_8) => s" MOV ${asIntel8086AssemblyString(target)}, ${parameter.toIntelString}" + case TwoRegistersOffset(MEM_IX_D, source, offset) => s" MOV BYTE PTR [BP+$offset}], ${asIntel8086AssemblyString(source)}" + case TwoRegistersOffset(target, MEM_IX_D, offset) => s" MOV ${asIntel8086AssemblyString(target)}, BYTE PTR [BP+$offset}]" + case TwoRegisters(target, source) => s" MOV ${asIntel8086AssemblyString(target)}, ${asIntel8086AssemblyString(source)}" + case _ => "???" + } + case ADD_16 => registers match { + case TwoRegisters(target, source) => s" ADD ${asIntel8086AssemblyString(target)}, ${asIntel8086AssemblyString(source)}" + case _ => "???" + } + case DEC|DEC_16 => registers match { + case OneRegister(register) => s" DEC ${asIntel8086AssemblyString(register)}" + case _ => "???" + } + case INC|INC_16 => registers match { + case OneRegister(register) => s" INC ${asIntel8086AssemblyString(register)}" + case _ => "???" + } + case PUSH => registers match { + case OneRegister(AF) => s" LAHF\n XCHG AH,AL\n PUSH AX\n XCHG AH, AL" + case OneRegister(register) => s" PUSH ${asIntel8086AssemblyString(register)}" + case _ => "???" + } + case POP => registers match { + case OneRegister(AF) => s" POP AX\n XCHG AH, AL\n SAHF" + case OneRegister(register) => s" POP ${asIntel8086AssemblyString(register)}" + case _ => "???" + } + case DAA => " DAA" + case RLA => " RCL AL" + case RLCA => " ROL AL" + case RRA => " RCL AL" + case RRCA => " ROR AL" + case HALT => " HLT" + case RET | JP | CALL => + val (prefix, suffix) = registers match { + case NoRegisters => " " -> "" + case OneRegister(_) => " " -> "" + case IfFlagClear(ZFlag.C) => " JB .next\n " -> "\n.next:" + case IfFlagClear(ZFlag.Z) => " JE .next\n " -> "\n.next:" + case IfFlagClear(ZFlag.S) => " JS .next\n " -> "\n.next:" + case IfFlagClear(ZFlag.P) => " JPE .next\n " -> "\n.next:" + case IfFlagSet(ZFlag.C) => " JAE .next\n " -> "\n.next:" + case IfFlagSet(ZFlag.Z) => " JNE .next\n " -> "\n.next:" + case IfFlagSet(ZFlag.S) => " JNS .next\n " -> "\n.next:" + case IfFlagSet(ZFlag.P) => " JPO .next\n " -> "\n.next:" + case _ => " ???" -> "" + } + prefix + (opcode match { + case RET => "RET" + case JP => registers match { + case OneRegister(HL) => "JMP BX" + case _ => "JMP " + parameter.toIntelString + } + case CALL => "CALL " + parameter.toIntelString + }) + suffix + case ADD => registers match { + case OneRegister(IMM_8) => s" ADD AL, ${parameter.toIntelString}" + case OneRegister(register) => s" ADD AL, ${asIntel8086AssemblyString(register)}" + case OneRegisterOffset(MEM_IX_D, offset) => s" ADD AL, BYTE PTR[BP+$offset]" + case _ => "???" + } + case ADC => registers match { + case OneRegister(IMM_8) => s" ADC AL, ${parameter.toIntelString}" + case OneRegister(register) => s" ADC AL, ${asIntel8086AssemblyString(register)}" + case OneRegisterOffset(MEM_IX_D, offset) => s" ADC AL, BYTE PTR[BP+$offset]" + case _ => "???" + } + case SUB => registers match { + case OneRegister(IMM_8) => s" SUB AL, ${parameter.toIntelString}" + case OneRegister(register) => s" SUB AL, ${asIntel8086AssemblyString(register)}" + case OneRegisterOffset(MEM_IX_D, offset) => s" SUB AL, BYTE PTR[BP+$offset]" + case _ => "???" + } + case SBC => registers match { + case OneRegister(IMM_8) => s" SBB AL, ${parameter.toIntelString}" + case OneRegister(register) => s" SBB AL, ${asIntel8086AssemblyString(register)}" + case OneRegisterOffset(MEM_IX_D, offset) => s" SBB AL, BYTE PTR[BP+$offset]" + case _ => "???" + } + case AND => registers match { + case OneRegister(IMM_8) => s" AND AL, ${parameter.toIntelString}" + case OneRegister(register) => s" AND AL, ${asIntel8086AssemblyString(register)}" + case OneRegisterOffset(MEM_IX_D, offset) => s" AND AL, BYTE PTR[BP+$offset]" + case _ => "???" + } + case OR => registers match { + case OneRegister(IMM_8) => s" OR AL, ${parameter.toIntelString}" + case OneRegister(register) => s" OR AL, ${asIntel8086AssemblyString(register)}" + case OneRegisterOffset(MEM_IX_D, offset) => s" OR AL, BYTE PTR[BP+$offset]" + case _ => "???" + } + case XOR => registers match { + case OneRegister(IMM_8) => s" XOR AL, ${parameter.toIntelString}" + case OneRegister(register) => s" XOR AL, ${asIntel8086AssemblyString(register)}" + case OneRegisterOffset(MEM_IX_D, offset) => s" XOR AL, BYTE PTR[BP+$offset]" + case _ => "???" + } + case CP => registers match { + case OneRegister(IMM_8) => s" CMP AL, ${parameter.toIntelString}" + case OneRegister(register) => s" CMP AL, ${asIntel8086AssemblyString(register)}" + case OneRegisterOffset(MEM_IX_D, offset) => s" CMP AL, BYTE PTR[BP+$offset]" + case _ => "???" + } + case EX_SP => registers match { + case OneRegister(HL) => s" XCHG BX, [SP]" + case OneRegister(IX) => s" XCHG BP, [SP]" + case _ => "???" + } + case RST => parameter match { + case NumericConstant(n, _) if n % 8 == 0 => s" RST ${n / 8}" // TODO + case _ => "???" + } + case IN_IMM => s" IN ${parameter.toIntelString}" // TODO + case OUT_IMM => s" OUT ${parameter.toIntelString}" // TODO + case EI => " STI" + case DI => " CLI" + case EX_DE_HL => " XCHG BX, DX" + case NOP => " NOP" + case CPL => " NOT AL" + case SCF => " STC" + case CCF => " CMC" + case _ => "???" + } + if (result.contains("???")) s" ??? (${this.toString.stripPrefix(" ")})" else result + } + def readsRegister(r: ZRegister.Value): Boolean = { import ZOpcode._ import ZRegister._ diff --git a/src/main/scala/millfork/env/Environment.scala b/src/main/scala/millfork/env/Environment.scala index 9c9e410a..51497eb2 100644 --- a/src/main/scala/millfork/env/Environment.scala +++ b/src/main/scala/millfork/env/Environment.scala @@ -30,6 +30,7 @@ class Environment(val parent: Option[Environment], val prefix: String, val cpuFa private var baseStackOffset: Int = cpuFamily match { case CpuFamily.M6502 => 0x101 case CpuFamily.I80 => 0 + case CpuFamily.I86 => 0 } def errorConstant(msg: String, position: Option[Position] = None): Constant = { @@ -1739,6 +1740,7 @@ class Environment(val parent: Option[Environment], val prefix: String, val cpuFa things("memory_barrier") = MacroFunction("memory_barrier", v, NormalParamSignature(Nil), this, CpuFamily.forType(options.platform.cpu) match { case CpuFamily.M6502 => List(MosAssemblyStatement(Opcode.CHANGED_MEM, AddrMode.DoesNotExist, LiteralExpression(0, 1), Elidability.Fixed)) case CpuFamily.I80 => List(Z80AssemblyStatement(ZOpcode.CHANGED_MEM, NoRegisters, None, LiteralExpression(0, 1), Elidability.Fixed)) + case CpuFamily.I86 => List(Z80AssemblyStatement(ZOpcode.CHANGED_MEM, NoRegisters, None, LiteralExpression(0, 1), Elidability.Fixed)) case _ => ??? }) } diff --git a/src/main/scala/millfork/output/AbstractAssembler.scala b/src/main/scala/millfork/output/AbstractAssembler.scala index 2ac0f842..fbf5b111 100644 --- a/src/main/scala/millfork/output/AbstractAssembler.scala +++ b/src/main/scala/millfork/output/AbstractAssembler.scala @@ -521,7 +521,14 @@ abstract class AbstractAssembler[T <: AbstractCode](private val program: Program } } } - val line = if (options.flag(CompilationFlag.UseIntelSyntaxForOutput)) { + val line = if (options.platform.cpuFamily == CpuFamily.I86) { + instr match { + case zline: ZLine => + zline.toIntel8086String + case _ => + instr.toString + } + } else if (options.flag(CompilationFlag.UseIntelSyntaxForOutput)) { instr match { case zline: ZLine => zline.toIntelString diff --git a/src/main/scala/millfork/output/Z80ToX86Crossassembler.scala b/src/main/scala/millfork/output/Z80ToX86Crossassembler.scala new file mode 100644 index 00000000..245d671c --- /dev/null +++ b/src/main/scala/millfork/output/Z80ToX86Crossassembler.scala @@ -0,0 +1,392 @@ +package millfork.output + +import millfork.{CompilationFlag, CompilationOptions, Cpu, Platform} +import millfork.assembly.z80._ +import millfork.assembly.z80.opt.{ConditionalInstructions, JumpFollowing, JumpShortening} +import millfork.compiler.z80.Z80Compiler +import millfork.env._ +import millfork.node.{NiceFunctionProperty, Program, ZRegister} + +import scala.collection.mutable + + +/** + * @author Karol Stasiak + */ +class Z80ToX86Crossassembler(program: Program, + rootEnv: Environment, + platform: Platform) extends AbstractAssembler[ZLine](program, rootEnv, platform, Z80InliningCalculator, Z80Compiler) { + override def performFinalOptimizationPass(f: NormalFunction, actuallyOptimize: Boolean, options: CompilationOptions, code: List[ZLine]): List[ZLine] = { + if (actuallyOptimize) { + JumpShortening(f, ConditionalInstructions(options, JumpFollowing(options, code)), options) + } else code + } + + override def injectLabels(labelMap: Map[String, Int], code: List[ZLine]): List[ZLine] = code // TODO + + override def quickSimplify(code: List[ZLine]): List[ZLine] = code.map(a => a.copy(parameter = a.parameter.quickSimplify)) + + override def gatherNiceFunctionProperties(niceFunctionProperties: mutable.Set[(NiceFunctionProperty, String)], functionName: String, code: List[ZLine]): Unit = { + // do nothing yet + } + + override def bytePseudoopcode: String = "DB" + + override def deduplicate(options: CompilationOptions, compiledFunctions: mutable.Map[String, CompiledFunction[ZLine]]): Unit = + new Z80Deduplicate(rootEnv, options).apply(compiledFunctions) + + private def registerIndex(r: ZRegister.Value) = { + import ZRegister._ + r match { + case A => 0 + case C => 1 + case E => 2 + case L => 3 + case B => 5 + case D => 6 + case H => 7 + case AF => 0 + case BC => 1 + case DE => 2 + case HL => 3 + case SP => 4 + case IX => 5 + } + } + + private def flagSkip(flag: ZRegisters): Int = flag match { + case IfFlagSet(ZFlag.C) => 0x73 // JAE + case IfFlagClear(ZFlag.C) => 0x72 // JB + case IfFlagSet(ZFlag.S) => 0x79 // JNS + case IfFlagClear(ZFlag.S) => 0x78 // JS + case IfFlagSet(ZFlag.Z) => 0x75 // JNE + case IfFlagClear(ZFlag.Z) => 0x74 // JE + case IfFlagSet(ZFlag.P) => 0x7b // JPO + case IfFlagClear(ZFlag.P) => 0x7a // JPE + } + + override def emitInstruction(bank: String, options: CompilationOptions, index: Int, instr: ZLine): Int = { + import millfork.assembly.z80.ZOpcode._ + import ZRegister._ + import CompilationFlag._ + import Z80ToX86Crossassembler._ + instr match { + case ZLine0(LABEL, NoRegisters, MemoryAddressConstant(Label(labelName))) => + labelMap(labelName) = index + index + case ZLine0(BYTE, NoRegisters, param) => + writeByte(bank, index, param) + index + 1 + case ZLine0(DISCARD_F | DISCARD_HL | DISCARD_BC | DISCARD_DE | DISCARD_IX | DISCARD_IY | DISCARD_A | CHANGED_MEM, NoRegisters, _) => + index + case ZLine0(LABEL | BYTE | DISCARD_F | DISCARD_HL | DISCARD_BC | DISCARD_DE | DISCARD_IX | DISCARD_IY | DISCARD_A | CHANGED_MEM, _, _) => + ??? + case ZLine0(op, NoRegisters, _) if implieds.contains(op) && implieds(op) != 666 => + writeByte(bank, index, implieds(op)) + index + 1 + + case ZLine0(JP, NoRegisters, param) => + writeByte(bank, index, 0xe9) + writeWord(bank, index + 1, param + (- 3 - index)) + index + 3 + case ZLine0(JP, OneRegister(HL), param) => + writeByte(bank, index, 0xff) + writeByte(bank, index + 1, 0xe3) + index + 2 + case ZLine0(CALL, NoRegisters, param) => + writeByte(bank, index, 0xe8) + writeWord(bank, index + 1, param + (- 3 -index)) + index + 3 + + case ZLine0(RET, flag@(IfFlagSet(_) | IfFlagClear(_)), _) => + writeByte(bank, index, flagSkip(flag)) + writeByte(bank, index + 1, 1) + writeByte(bank, index + 2, 0xc3) + index + 3 + case ZLine0(JP, flag@(IfFlagSet(_) | IfFlagClear(_)), param) => + writeByte(bank, index, flagSkip(flag)) + writeByte(bank, index + 1, 3) + writeByte(bank, index + 2, 0xe9) + writeWord(bank, index + 3, param + (- 5 - index)) + index + 5 + case ZLine0(CALL, flag@(IfFlagSet(_) | IfFlagClear(_)), param) => + writeByte(bank, index, flagSkip(flag)) + writeByte(bank, index + 1, 3) + writeByte(bank, index + 2, 0xe8) + writeWord(bank, index + 3, param + (- 5 - index)) + index + 5 + + case ZLine0(PUSH, OneRegister(AF), _) => + writeByte(bank, index, 0x9f) + writeByte(bank, index+1, 0x86) + writeByte(bank, index+2, 0xc4) + writeByte(bank, index+3, 0x50) + writeByte(bank, index+4, 0x86) + writeByte(bank, index+5, 0xc4) + index + 6 + case ZLine0(POP, OneRegister(AF), _) => + writeByte(bank, index, 0x58) + writeByte(bank, index+1, 0x86) + writeByte(bank, index+2, 0xc4) + writeByte(bank, index+3, 0x9e) + index + 4 + case ZLine0(PUSH, OneRegister(reg), _) => + writeByte(bank, index, 0x50 + registerIndex(reg)) + index + 1 + case ZLine0(POP, OneRegister(reg), _) => + writeByte(bank, index, 0x58 + registerIndex(reg)) + index + 1 + + case ZLine0(LD, TwoRegisters(MEM_HL, IMM_8), param) => + writeByte(bank, index, 0xc6) + writeByte(bank, index+1, 0x07) + writeByte(bank, index+2, param) + index + 3 + case ZLine0(LD, TwoRegisters(MEM_ABS_8, A), param) => + writeByte(bank, index, 0xa2) + writeWord(bank, index+1, param) + index + 3 + case ZLine0(LD, TwoRegisters(A, MEM_ABS_8), param) => + writeByte(bank, index, 0xa0) + writeWord(bank, index+1, param) + index + 3 + case ZLine0(LD, TwoRegistersOffset(MEM_IX_D, IMM_8, offset), param) => + writeByte(bank, index, 0xc6) + writeByte(bank, index+1, 0x46) + writeByte(bank, index+2, offset) + writeByte(bank, index+3, param) + index + 4 + case ZLine0(LD, TwoRegistersOffset(MEM_IX_D, reg, offset), param) => + writeByte(bank, index, 0x88) + writeByte(bank, index + 1, 0x46 + registerIndex(reg) * 8) + writeByte(bank, index + 2, offset) + index + 3 + case ZLine0(LD, TwoRegistersOffset(reg, MEM_IX_D, offset), param) => + writeByte(bank, index, 0x8a) + writeByte(bank, index + 1, 0x46 + registerIndex(reg) * 8) + writeByte(bank, index + 2, offset) + index + 3 + + case ZLine0(LD, TwoRegisters(MEM_HL, reg), param) => + writeByte(bank, index, 0x88) + writeByte(bank, index + 1, 0x7 + registerIndex(reg) * 8) + index + 2 + case ZLine0(LD, TwoRegisters(reg, MEM_HL), param) => + writeByte(bank, index, 0x8a) + writeByte(bank, index + 1, 0x7 + registerIndex(reg) * 8) + index + 2 + + case ZLine0(LD, TwoRegisters(MEM_DE, A), param) => + writeByte(bank, index, 0x89) + writeByte(bank, index + 1, 0xd6) + writeByte(bank, index + 2, 0x88) + writeByte(bank, index + 3, 0x04) + index + 4 + case ZLine0(LD, TwoRegisters(A, MEM_DE), param) => + writeByte(bank, index, 0x89) + writeByte(bank, index + 1, 0xd6) + writeByte(bank, index + 2, 0x8a) + writeByte(bank, index + 3, 0x04) + index + 4 + case ZLine0(LD, TwoRegisters(MEM_BC, A), param) => + writeByte(bank, index, 0x89) + writeByte(bank, index + 1, 0xde) + writeByte(bank, index + 2, 0x88) + writeByte(bank, index + 3, 0x04) + index + 4 + case ZLine0(LD, TwoRegisters(A, MEM_BC), param) => + writeByte(bank, index, 0x89) + writeByte(bank, index + 1, 0xde) + writeByte(bank, index + 2, 0x8a) + writeByte(bank, index + 3, 0x04) + index + 4 + + case ZLine0(LD, TwoRegisters(reg, IMM_8), param) => + writeByte(bank, index, 0xb0 + registerIndex(reg)) + writeByte(bank, index + 1, param) + index + 2 + case ZLine0(LD, TwoRegisters(target, source), param) => + writeByte(bank, index, 0x88) + writeByte(bank, index + 1, 0xc0 + registerIndex(source) * 8 + registerIndex(target)) + index + 2 + + case ZLine0(LD_16, TwoRegisters(reg, MEM_ABS_16), param) => + writeByte(bank, index, 0x8b) + writeByte(bank, index + 1, 0x6 + registerIndex(reg) * 8) + writeWord(bank, index + 2, param) + index + 4 + case ZLine0(LD_16, TwoRegisters(MEM_ABS_16, reg), param) => + writeByte(bank, index, 0x89) + writeByte(bank, index + 1, 0x6 + registerIndex(reg) * 8) + writeWord(bank, index + 2, param) + index + 4 + case ZLine0(LD_16, TwoRegisters(reg, IMM_16), param) => + writeByte(bank, index, 0xb8 + registerIndex(reg)) + writeWord(bank, index + 1, param) + index + 3 + case ZLine0(LD_16, TwoRegisters(SP, HL), param) => + writeByte(bank, index, 0x89) + writeByte(bank, index + 1, 0xdc) + index + 2 + case ZLine0(LD_16, TwoRegisters(SP, IX), param) => + writeByte(bank, index, 0x89) + writeByte(bank, index + 1, 0xec) + index + 2 + // TODO: other loads + + case ZLine0(CPL, _, _) => + writeByte(bank, index, 0xf6) + writeByte(bank, index + 1, 0xd0) + index + 2 + case ZLine0(op, OneRegister(IMM_8), param) if arith.contains(op) => + writeByte(bank, index, arith(op)+4) + writeByte(bank, index + 1, param) + index + 2 + case ZLine0(op, OneRegisterOffset(MEM_IX_D, offset), _) if arith.contains(op) => + writeByte(bank, index, arith(op)+2) + writeByte(bank, index + 1, 0x46) + writeByte(bank, index + 2, offset) + index + 3 + case ZLine0(op, OneRegister(MEM_HL), _) if arith.contains(op) => + writeByte(bank, index, arith(op)+2) + writeByte(bank, index + 1, 0x07) + index + 2 + case ZLine0(op, OneRegister(reg), _) if arith.contains(op) => + writeByte(bank, index, arith(op)) + writeByte(bank, index + 1, 0xc0 + registerIndex(reg) * 8) + index + 2 + + case ZLine0(INC, OneRegisterOffset(MEM_IX_D, offset), _) => + writeByte(bank, index, 0xfe) + writeByte(bank, index + 1, 0x46) + writeByte(bank, index + 2, offset) + index + 3 + case ZLine0(INC, OneRegister(MEM_HL), _) => + writeByte(bank, index, 0xfe) + writeByte(bank, index + 1, 0x07) + index + 2 + case ZLine0(INC, OneRegister(reg), _) => + writeByte(bank, index, 0xfe) + writeByte(bank, index + 1, 0xc0 + registerIndex(reg)) + index + 2 + case ZLine0(DEC, OneRegisterOffset(MEM_IX_D, offset), _) => + writeByte(bank, index, 0xfe) + writeByte(bank, index + 1, 0x4e) + writeByte(bank, index + 2, offset) + index + 3 + case ZLine0(DEC, OneRegister(MEM_HL), _) => + writeByte(bank, index, 0xfe) + writeByte(bank, index + 1, 0x0f) + index + 2 + case ZLine0(DEC, OneRegister(reg), _) => + writeByte(bank, index, 0xfe) + writeByte(bank, index + 1, 0xc8 + registerIndex(reg)) + index + 2 + + case ZLine0(INC_16, OneRegister(reg), _) => + writeByte(bank, index, 0x40 + registerIndex(reg)) + index + 1 + case ZLine0(DEC_16, OneRegister(reg), _) => + writeByte(bank, index, 0x48 + registerIndex(reg)) + index + 1 + + case ZLine0(ADD_16, TwoRegisters(HL, reg), _) => + writeByte(bank, index, 0x1) + writeByte(bank, index + 1, 0xc3 + registerIndex(reg) * 8) + index + 2 + case ZLine0(ADD_16, TwoRegisters(IX, reg), _) => + writeByte(bank, index, 0x1) + writeByte(bank, index + 1, 0xc5 + registerIndex(reg) * 8) + index + 2 + + case ZLine0(EX_DE_HL, _, _) => + writeByte(bank, index, 0x87) + writeByte(bank, index + 1, 0xd3) + index + 2 + + case ZLine0(EX_SP, OneRegister(HL), _) => + writeByte(bank, index, 0x89) + writeByte(bank, index + 1, 0x86) + writeByte(bank, index + 2, 0x87) + writeByte(bank, index + 3, 0x1c) + index + 2 + + case ZLine0(EX_SP, OneRegister(IX), _) => + writeByte(bank, index, 0x89) + writeByte(bank, index + 1, 0x86) + writeByte(bank, index + 2, 0x87) + writeByte(bank, index + 3, 0x2c) + index + 2 + + case ZLine0(RRA, _, _) => + writeByte(bank, index, 0xd0) + writeByte(bank, index + 1, 0xd8) + index + 2 + case ZLine0(RRCA, _, _) => + writeByte(bank, index, 0xd0) + writeByte(bank, index + 1, 0xc8) + index + 2 + case ZLine0(RLA, _, _) => + writeByte(bank, index, 0xd0) + writeByte(bank, index + 1, 0xd0) + index + 2 + case ZLine0(RLCA, _, _) => + writeByte(bank, index, 0xd0) + writeByte(bank, index + 1, 0xc0) + index + 2 + + case ZLine0(IN_IMM, _, param) => + writeByte(bank, index, 0xe4) + writeByte(bank, index + 1, param) + index + 2 + case ZLine0(OUT_IMM, _, param) => + writeByte(bank, index, 0xe6) + writeByte(bank, index + 1, param) + index + 2 + + case _ => + println("TODO: " + instr) + ??? + } + } +} + +object Z80ToX86Crossassembler { + + case class One(opcode: Int, multiplier: Int) + + val implieds = mutable.Map[ZOpcode.Value, Int]() + val arith = mutable.Map[ZOpcode.Value, Int]() + val edImplieds = mutable.Map[ZOpcode.Value, Int]() + val oneRegister = mutable.Map[ZOpcode.Value, One]() + val cbOneRegister = mutable.Map[ZOpcode.Value, One]() + + do { + import ZOpcode._ + implieds(NOP) = 0x90 + implieds(DAA) = 0x27 + implieds(SCF) = 0xf9 + implieds(CPL) = 666 + implieds(CCF) = 0xf5 + implieds(RET) = 0xc3 + implieds(EI) = 0xfb + implieds(DI) = 0xfa + implieds(HALT) = 0xf4 + implieds(RLCA) = 666 + implieds(RRCA) = 666 + implieds(RLA) = 666 + implieds(RRA) = 666 + + arith(ADD) = 0x00 + arith(ADC) = 0x10 + arith(SUB) = 0x28 + arith(SBC) = 0x18 + arith(AND) = 0x20 + arith(XOR) = 0x30 + arith(OR) = 0x08 + arith(CP) = 0x38 + + } while (false) + +} + diff --git a/src/test/scala/millfork/test/AlgorithmSuite.scala b/src/test/scala/millfork/test/AlgorithmSuite.scala index 489e7978..8f55a47b 100644 --- a/src/test/scala/millfork/test/AlgorithmSuite.scala +++ b/src/test/scala/millfork/test/AlgorithmSuite.scala @@ -10,7 +10,7 @@ import org.scalatest.{FunSuite, Matchers} class AlgorithmSuite extends FunSuite with Matchers { test("RLE decoding") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( """ | array output [4000] @$c000 | array input = [ diff --git a/src/test/scala/millfork/test/AlignmentSuite.scala b/src/test/scala/millfork/test/AlignmentSuite.scala index 504554b9..acbc2d74 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)( + EmuUnoptimizedCrossPlatformRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( """ | 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 fb7319ee..0f7ca860 100644 --- a/src/test/scala/millfork/test/ArraySuite.scala +++ b/src/test/scala/millfork/test/ArraySuite.scala @@ -28,7 +28,7 @@ class ArraySuite extends FunSuite with Matchers { m.readByte(0xc000) should equal(5) m.readByte(0xc001) should equal(6) m.readByte(0xc002) should equal(7) - EmuCrossPlatformBenchmarkRun(Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)(src) { m => + EmuCrossPlatformBenchmarkRun(Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)(src) { m => m.readByte(0xc000) should equal(5) m.readByte(0xc001) should equal(6) m.readByte(0xc002) should equal(7) @@ -53,7 +53,7 @@ class ArraySuite extends FunSuite with Matchers { m.readByte(0xc002) should equal(1) m.readByte(0xc007) should equal(6) } - EmuCrossPlatformBenchmarkRun(Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)(src) { m => + EmuCrossPlatformBenchmarkRun(Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)(src) { m => m.readByte(0xc002) should equal(1) m.readByte(0xc007) should equal(6) } @@ -78,7 +78,7 @@ class ArraySuite extends FunSuite with Matchers { } test("Array assignment through a pointer") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( """ | array output [3] @$c000 | pointer p @@ -98,7 +98,7 @@ class ArraySuite extends FunSuite with Matchers { } test("Array in place math") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( """ | array output [4] @$c000 | void main () { @@ -112,7 +112,7 @@ class ArraySuite extends FunSuite with Matchers { } test("Array simple read") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( """ | byte output @$c000 | array a[7] @@ -126,7 +126,7 @@ class ArraySuite extends FunSuite with Matchers { } test("Array simple read 2") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( """ | word output @$c000 | array a[7] @@ -144,7 +144,7 @@ class ArraySuite extends FunSuite with Matchers { } test("Pointers") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( """ | byte output | pointer a @@ -169,7 +169,7 @@ class ArraySuite extends FunSuite with Matchers { } test("Pointer indexing test") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( """ | array output [4] @$c000 | pointer a @@ -186,7 +186,7 @@ class ArraySuite extends FunSuite with Matchers { } test("Syntax") { - EmuUnoptimizedCrossPlatformRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)( + EmuUnoptimizedCrossPlatformRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( """ | array a = [1, 2, 3] | array b = "text" ascii @@ -198,7 +198,7 @@ class ArraySuite extends FunSuite with Matchers { } test("Negative subindex") { - EmuUnoptimizedCrossPlatformRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)( + EmuUnoptimizedCrossPlatformRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( """ | | array output [$fff] @$c000 @@ -237,7 +237,7 @@ class ArraySuite extends FunSuite with Matchers { } test("Word subindex 2") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( """ | | array output [$fff] @$c000 @@ -259,7 +259,7 @@ class ArraySuite extends FunSuite with Matchers { } test("Array filters") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( """ | array x = @word [$1144] | byte output @$c000 @@ -272,7 +272,7 @@ class ArraySuite extends FunSuite with Matchers { } test("Array filters 2") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( """ | array x = @long [$1144] | byte output @$c000 @@ -285,7 +285,7 @@ class ArraySuite extends FunSuite with Matchers { } test("Const arrays") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( """ | const array square = [0, 1, 4, 9, 16, 25, 36, 49, 64] | byte five() = 5 @@ -312,7 +312,7 @@ class ArraySuite extends FunSuite with Matchers { } test("Struct array initializers") { - EmuUnoptimizedCrossPlatformRun(Cpu.Mos, Cpu.Z80)( + EmuUnoptimizedCrossPlatformRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8086)( """ | struct p { byte x, byte y } | struct line { p from, p to } diff --git a/src/test/scala/millfork/test/AssemblyOptimizationSuite.scala b/src/test/scala/millfork/test/AssemblyOptimizationSuite.scala index 7b0f9cfc..3213c90e 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)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( """ | 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)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( """ | 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)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( """ | 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)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( """ | 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)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( """ | 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)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( """ | array output [2]@$C000 | void main () { @@ -99,7 +99,7 @@ class AssemblyOptimizationSuite extends FunSuite with Matchers { } test("Tail call") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( """ | byte output @$C000 | void main () { @@ -302,7 +302,7 @@ class AssemblyOptimizationSuite extends FunSuite with Matchers { } test("Adding a nonet") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( """ | word output @$C000 | byte source @$C002 @@ -321,7 +321,7 @@ class AssemblyOptimizationSuite extends FunSuite with Matchers { } test("Common indexing subexpression elimination") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( """ | array output [55] @$C000 | array input = [0,1,2,3,4,5,6,7,8,9,10] @@ -340,7 +340,7 @@ class AssemblyOptimizationSuite extends FunSuite with Matchers { } test("Effectively const variable") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( """ |byte output @$c000 |void main() { @@ -408,7 +408,7 @@ class AssemblyOptimizationSuite extends FunSuite with Matchers { } test("Constant pointers") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( """ |byte output0 @$c000 |byte output1 @$c001 @@ -428,7 +428,7 @@ class AssemblyOptimizationSuite extends FunSuite with Matchers { } test("Low bit") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( """ | byte output @$c000 | void main() { @@ -447,7 +447,7 @@ class AssemblyOptimizationSuite extends FunSuite with Matchers { } test("Low bit 2") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( """ | byte output @$c000 | void main() { @@ -466,7 +466,7 @@ class AssemblyOptimizationSuite extends FunSuite with Matchers { } test("Low bit 3") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( """ | byte output @$c000 | void main() { @@ -488,7 +488,7 @@ class AssemblyOptimizationSuite extends FunSuite with Matchers { } test("Low bit 4") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( """ | byte output @$c000 | void main() { @@ -528,7 +528,7 @@ class AssemblyOptimizationSuite extends FunSuite with Matchers { } test("Shift and increase") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( """ | byte output @$c000 | void main() { @@ -544,7 +544,7 @@ class AssemblyOptimizationSuite extends FunSuite with Matchers { } test("Add one bit") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( """ | byte output @$c000 | void main() { diff --git a/src/test/scala/millfork/test/BasicSymonTest.scala b/src/test/scala/millfork/test/BasicSymonTest.scala index b775cf4f..58cb1b5f 100644 --- a/src/test/scala/millfork/test/BasicSymonTest.scala +++ b/src/test/scala/millfork/test/BasicSymonTest.scala @@ -9,7 +9,7 @@ import org.scalatest.{FunSuite, Matchers} */ class BasicSymonTest extends FunSuite with Matchers { test("Empty test") { - EmuUnoptimizedCrossPlatformRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)( + EmuUnoptimizedCrossPlatformRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( """ | void main () { | @@ -80,13 +80,13 @@ class BasicSymonTest extends FunSuite with Matchers { output += 1 } """ - EmuUnoptimizedCrossPlatformRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)(src){m => + EmuUnoptimizedCrossPlatformRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)(src){m => m.readByte(0xc000) should equal(src.count(_ == '+')) } } test("Byte assignment") { - EmuUnoptimizedCrossPlatformRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)( + EmuUnoptimizedCrossPlatformRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( """ | byte output @$c000 | void main () { @@ -98,7 +98,7 @@ class BasicSymonTest extends FunSuite with Matchers { } test("Preallocated variables") { - EmuUnoptimizedCrossPlatformRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)( + EmuUnoptimizedCrossPlatformRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( """ | array output [2] @$c000 | byte number = 4 @@ -114,7 +114,7 @@ class BasicSymonTest extends FunSuite with Matchers { } test("Preallocated variables 2") { - EmuUnoptimizedCrossPlatformRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)( + EmuUnoptimizedCrossPlatformRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( """ | word output @$c000 | word number = 344 @@ -127,7 +127,7 @@ class BasicSymonTest extends FunSuite with Matchers { } test("Else if") { - EmuUnoptimizedCrossPlatformRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)( + EmuUnoptimizedCrossPlatformRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( """ | byte output @$c000 | void main () { @@ -145,7 +145,7 @@ class BasicSymonTest extends FunSuite with Matchers { } test("Segment syntax") { - EmuUnoptimizedCrossPlatformRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)( + EmuUnoptimizedCrossPlatformRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( """ | segment(default)byte output @$c000 | segment(default)array x[3] @@ -155,7 +155,7 @@ class BasicSymonTest extends FunSuite with Matchers { } test("Alias test") { - EmuUnoptimizedCrossPlatformRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)( + EmuUnoptimizedCrossPlatformRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( """ | alias small = byte | alias big = word @@ -174,7 +174,7 @@ class BasicSymonTest extends FunSuite with Matchers { } test("Deep alias test") { - EmuUnoptimizedCrossPlatformRun(Cpu.Mos, Cpu.Z80)( + EmuUnoptimizedCrossPlatformRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8086)( """ | word output @$c000 | alias a = output diff --git a/src/test/scala/millfork/test/BitOpSuite.scala b/src/test/scala/millfork/test/BitOpSuite.scala index ad47c3c5..0efbb016 100644 --- a/src/test/scala/millfork/test/BitOpSuite.scala +++ b/src/test/scala/millfork/test/BitOpSuite.scala @@ -10,7 +10,7 @@ import org.scalatest.{FunSuite, Matchers} class BitOpSuite extends FunSuite with Matchers { test("Word AND") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)(""" + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)(""" | word output @$c000 | void main () { | byte b @@ -21,7 +21,7 @@ class BitOpSuite extends FunSuite with Matchers { """.stripMargin)(_.readWord(0xc000) should equal(0x44)) } test("Long AND and EOR") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)(""" + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)(""" | long output @$c000 | void main () { | byte b @@ -36,7 +36,7 @@ class BitOpSuite extends FunSuite with Matchers { } test("Smart bit set/reset") { - EmuCrossPlatformBenchmarkRun(Cpu.Cmos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)(""" + EmuCrossPlatformBenchmarkRun(Cpu.Cmos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)(""" | byte output @$c000 | void main () { | output = 5 @@ -50,7 +50,7 @@ class BitOpSuite extends FunSuite with Matchers { } test("Smart bit set/reset 2") { - EmuCrossPlatformBenchmarkRun(Cpu.Cmos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)(""" + EmuCrossPlatformBenchmarkRun(Cpu.Cmos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)(""" | byte output @$c000 | void main () { | output = 5 diff --git a/src/test/scala/millfork/test/BitPackingSuite.scala b/src/test/scala/millfork/test/BitPackingSuite.scala index 5246f05c..6b80a0b3 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)(""" + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)(""" | array output[8] | word output_addr @$c000 | void main () { @@ -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)(""" + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)(""" | 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)(""" + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)(""" | 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)(""" + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)(""" | 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)(""" + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)(""" | 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)(""" + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)(""" | 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)(""" + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)(""" | 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)(""" + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)(""" | word output_addr @$C000 | void main () { | byte i diff --git a/src/test/scala/millfork/test/BooleanSuite.scala b/src/test/scala/millfork/test/BooleanSuite.scala index d58f9e82..50fcdb59 100644 --- a/src/test/scala/millfork/test/BooleanSuite.scala +++ b/src/test/scala/millfork/test/BooleanSuite.scala @@ -1,7 +1,7 @@ package millfork.test import millfork.Cpu -import millfork.test.emu.EmuCrossPlatformBenchmarkRun +import millfork.test.emu.{EmuCrossPlatformBenchmarkRun, EmuUnoptimizedCrossPlatformRun} import org.scalatest.{FunSuite, Matchers} /** @@ -10,7 +10,7 @@ import org.scalatest.{FunSuite, Matchers} class BooleanSuite extends FunSuite with Matchers { test("Not") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( """ | byte output @$c000 | array input = [5,6,7] @@ -26,7 +26,7 @@ class BooleanSuite extends FunSuite with Matchers { test("And") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( """ | byte output @$c000 | array input = [5,6,7] @@ -45,7 +45,7 @@ class BooleanSuite extends FunSuite with Matchers { test("Or") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( """ | byte output @$c000 | array input = [5,6,7] @@ -87,6 +87,6 @@ class BooleanSuite extends FunSuite with Matchers { | inline void pass() { output += 1 } | noinline void fail() { outside[0] = 0 } """.stripMargin - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)(code)(_.readByte(0xc000) should equal(code.sliding(4).count(_ == "pass"))) + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)(code)(_.readByte(0xc000) should equal(code.sliding(4).count(_ == "pass"))) } } diff --git a/src/test/scala/millfork/test/BreakContinueSuite.scala b/src/test/scala/millfork/test/BreakContinueSuite.scala index 441df9d2..e76135ef 100644 --- a/src/test/scala/millfork/test/BreakContinueSuite.scala +++ b/src/test/scala/millfork/test/BreakContinueSuite.scala @@ -10,7 +10,7 @@ import org.scalatest.{FunSuite, Matchers} class BreakContinueSuite extends FunSuite with Matchers { test("Break from one-iteration loop 1") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( """ | byte output @$c000 | void main () { @@ -24,7 +24,7 @@ class BreakContinueSuite extends FunSuite with Matchers { } test("Break from one-iteration loop 2") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( """ | byte output @$c000 | void main () { @@ -39,7 +39,7 @@ class BreakContinueSuite extends FunSuite with Matchers { } test("Break from infinite loop 1") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( """ | byte output @$c000 | void main () { @@ -54,7 +54,7 @@ class BreakContinueSuite extends FunSuite with Matchers { } test("Break and continue from infinite loop 1") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( """ | byte output @$c000 | void main () { @@ -70,7 +70,7 @@ class BreakContinueSuite extends FunSuite with Matchers { } test("Nested break") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( """ | byte output @$c000 | void main () { @@ -87,7 +87,7 @@ class BreakContinueSuite extends FunSuite with Matchers { } test("Continue in for loop 1") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( """ | byte output @$c000 | byte counter @$c001 diff --git a/src/test/scala/millfork/test/ByteDecimalMathSuite.scala b/src/test/scala/millfork/test/ByteDecimalMathSuite.scala index 6ac9e2bc..12052f46 100644 --- a/src/test/scala/millfork/test/ByteDecimalMathSuite.scala +++ b/src/test/scala/millfork/test/ByteDecimalMathSuite.scala @@ -10,7 +10,7 @@ import org.scalatest.{FunSuite, Matchers} class ByteDecimalMathSuite extends FunSuite with Matchers { test("Decimal byte addition") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Ricoh)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Ricoh, Cpu.Intel8086)( """ | byte output @$c000 | byte a @@ -22,7 +22,7 @@ class ByteDecimalMathSuite extends FunSuite with Matchers { } test("Decimal byte addition 2") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Ricoh)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Ricoh, Cpu.Intel8086)( """ | byte output @$c000 | byte a @@ -62,7 +62,7 @@ class ByteDecimalMathSuite extends FunSuite with Matchers { } test("Decimal byte subtraction") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Ricoh)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Ricoh, Cpu.Intel8086)( """ | byte output @$c000 | byte a @@ -74,7 +74,7 @@ class ByteDecimalMathSuite extends FunSuite with Matchers { } test("In-place decimal byte addition") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Ricoh)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Ricoh, Cpu.Intel8086)( """ | array output[3] @$c000 | byte a @@ -88,7 +88,7 @@ class ByteDecimalMathSuite extends FunSuite with Matchers { } test("In-place decimal byte addition 2") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Ricoh)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Ricoh, Cpu.Intel8086)( """ | array output[3] @$c000 | void main () { @@ -108,7 +108,7 @@ class ByteDecimalMathSuite extends FunSuite with Matchers { } test("In-place decimal byte subtraction") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Ricoh)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Ricoh, Cpu.Intel8086)( """ | byte output @$c000 | byte a @@ -120,7 +120,7 @@ class ByteDecimalMathSuite extends FunSuite with Matchers { } test("Decimal word addition") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Ricoh)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Ricoh, Cpu.Intel8086)( """ | word output @$c000 | void main () { @@ -136,7 +136,7 @@ class ByteDecimalMathSuite extends FunSuite with Matchers { } test("Decimal word subtraction") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Ricoh)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Ricoh, Cpu.Intel8086)( """ | word output @$c000 | void main () { @@ -152,7 +152,7 @@ class ByteDecimalMathSuite extends FunSuite with Matchers { } test("In-place decimal word subtraction") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Ricoh)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Ricoh, Cpu.Intel8086)( """ | word output @$c000 | word a @@ -166,7 +166,7 @@ class ByteDecimalMathSuite extends FunSuite with Matchers { } test("In-place decimal long subtraction") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Ricoh)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Ricoh, Cpu.Intel8086)( """ | long output @$c000 | word a @@ -181,7 +181,7 @@ class ByteDecimalMathSuite extends FunSuite with Matchers { } test("Flag switching test") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Ricoh)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Ricoh, Cpu.Intel8086)( """ | byte output @$c000 | void main () { @@ -192,7 +192,7 @@ class ByteDecimalMathSuite extends FunSuite with Matchers { } test("Flag switching test 2") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Ricoh)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Ricoh, Cpu.Intel8086)( """ | byte output @$c000 | void main () { @@ -203,7 +203,7 @@ class ByteDecimalMathSuite extends FunSuite with Matchers { } test("Flag switching test 3") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Ricoh)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Ricoh, Cpu.Intel8086)( """ | byte output @$c000 | void main () { @@ -214,7 +214,7 @@ class ByteDecimalMathSuite extends FunSuite with Matchers { } test("Decimal left shift test") { - EmuUnoptimizedCrossPlatformRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Ricoh)( + EmuUnoptimizedCrossPlatformRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Ricoh, Cpu.Intel8086)( """ | byte output @$c000 | void main () { @@ -229,7 +229,7 @@ class ByteDecimalMathSuite extends FunSuite with Matchers { } test("Decimal left shift test 2") { - EmuUnoptimizedCrossPlatformRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Ricoh)( + EmuUnoptimizedCrossPlatformRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Ricoh, Cpu.Intel8086)( """ | byte output @$c000 | void main () { @@ -243,7 +243,7 @@ class ByteDecimalMathSuite extends FunSuite with Matchers { } test("Decimal left shift test 3") { - EmuUnoptimizedCrossPlatformRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Ricoh)( + EmuUnoptimizedCrossPlatformRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Ricoh, Cpu.Intel8086)( """ | word output @$c000 | void main () { @@ -257,7 +257,7 @@ class ByteDecimalMathSuite extends FunSuite with Matchers { } test("Decimal left shift test 4") { - EmuUnoptimizedCrossPlatformRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Ricoh)( + EmuUnoptimizedCrossPlatformRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Ricoh, Cpu.Intel8086)( """ | long output @$c000 | void main () { @@ -271,7 +271,7 @@ class ByteDecimalMathSuite extends FunSuite with Matchers { } test("Decimal right shift test") { - EmuUnoptimizedCrossPlatformRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Ricoh)( + EmuUnoptimizedCrossPlatformRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Ricoh, Cpu.Intel8086)( """ | byte output @$c000 | void main () { @@ -286,7 +286,7 @@ class ByteDecimalMathSuite extends FunSuite with Matchers { } test("Decimal right shift test 2") { - EmuUnoptimizedCrossPlatformRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Ricoh)( + EmuUnoptimizedCrossPlatformRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Ricoh, Cpu.Intel8086)( """ | byte output @$c000 | void main () { @@ -300,7 +300,7 @@ class ByteDecimalMathSuite extends FunSuite with Matchers { } test("Decimal right shift test 3") { - EmuUnoptimizedCrossPlatformRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Ricoh)( + EmuUnoptimizedCrossPlatformRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Ricoh, Cpu.Intel8086)( """ | word output @$c000 | void main () { @@ -335,7 +335,7 @@ class ByteDecimalMathSuite extends FunSuite with Matchers { test("Decimal word right-shift comprehensive suite") { for (i <- List(0, 1, 10, 100, 1000, 2000, 500, 200, 280, 300, 5234, 7723, 7344, 9, 16, 605, 1111, 2222, 3333, 9999, 8888, 8100)) { - EmuUnoptimizedCrossPlatformRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Ricoh)( + EmuUnoptimizedCrossPlatformRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Ricoh, Cpu.Intel8086)( """ | word output @$c000 | void main () { @@ -351,7 +351,7 @@ class ByteDecimalMathSuite extends FunSuite with Matchers { test("Decimal byte multiplication comprehensive suite") { val numbers = List(0, 1, 2, 3, 6, 8, 10, 11, 12, 14, 15, 16, 20, 40, 73, 81, 82, 98, 99) for (i <- numbers; j <- numbers) { - EmuUnoptimizedCrossPlatformRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Ricoh)( + EmuUnoptimizedCrossPlatformRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Ricoh, Cpu.Intel8086)( """ | byte output @$c000 | void main () { @@ -369,7 +369,7 @@ class ByteDecimalMathSuite extends FunSuite with Matchers { test("Decimal comparison") { // CMP#0 shouldn't be elided after a decimal operation. // Currently no emulator used for testing can catch that. - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Ricoh)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Ricoh, Cpu.Intel8086)( """ | byte output @$c000 | void main () { diff --git a/src/test/scala/millfork/test/ByteMathSuite.scala b/src/test/scala/millfork/test/ByteMathSuite.scala index 03f88bee..6f182726 100644 --- a/src/test/scala/millfork/test/ByteMathSuite.scala +++ b/src/test/scala/millfork/test/ByteMathSuite.scala @@ -10,7 +10,7 @@ import org.scalatest.{AppendedClues, FunSuite, Matchers} class ByteMathSuite extends FunSuite with Matchers with AppendedClues { test("Complex expression") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( """ | byte output @$c000 | void main () { @@ -23,7 +23,7 @@ class ByteMathSuite extends FunSuite with Matchers with AppendedClues { } test("Complex expression 2") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( """ | byte output @$c000 | void main () { @@ -41,7 +41,7 @@ class ByteMathSuite extends FunSuite with Matchers with AppendedClues { } test("Byte addition") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( """ | byte output @$c000 | byte a @@ -53,7 +53,7 @@ class ByteMathSuite extends FunSuite with Matchers with AppendedClues { } test("Byte addition 2") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( """ | byte output @$c000 | byte a @@ -65,7 +65,7 @@ class ByteMathSuite extends FunSuite with Matchers with AppendedClues { } test("In-place byte addition") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( """ | array output[3] @$c000 | byte a @@ -79,7 +79,7 @@ class ByteMathSuite extends FunSuite with Matchers with AppendedClues { } test("LHS evaluation during in-place byte addition") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( """ | array output[1] @$c000 | byte call_count @$c001 @@ -99,7 +99,7 @@ class ByteMathSuite extends FunSuite with Matchers with AppendedClues { } test("Parameter order") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( """ | byte output @$c000 | array arr[6] @@ -119,7 +119,7 @@ class ByteMathSuite extends FunSuite with Matchers with AppendedClues { } test("In-place byte addition 2") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( """ | array output[3] @$c000 | void main () { @@ -155,7 +155,7 @@ class ByteMathSuite extends FunSuite with Matchers with AppendedClues { } private def multiplyCase1(x: Int, y: Int): Unit = { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( s""" | byte output @$$c000 | void main () { @@ -183,7 +183,7 @@ class ByteMathSuite extends FunSuite with Matchers with AppendedClues { } private def multiplyCase2(x: Int, y: Int): Unit = { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( s""" | byte output @$$c000 | void main () { @@ -242,6 +242,10 @@ class ByteMathSuite extends FunSuite with Matchers with AppendedClues { | if output1 != 20 { asm { ld a,($bfff) }} | if output2 != 27 { asm { ld a,($bfff) }} | if output3 != 15 { asm { ld a,($bfff) }} + | #elseif ARCH_X86 + | if output1 != 20 { asm { ld a,($bfff) }} + | if output2 != 27 { asm { ld a,($bfff) }} + | if output3 != 15 { asm { ld a,($bfff) }} | #else | #error unsupported architecture | #endif @@ -270,7 +274,7 @@ class ByteMathSuite extends FunSuite with Matchers with AppendedClues { } private def multiplyCase3(x: Int, y: Int): Unit = { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( s""" | import zp_reg | byte output @$$c000 diff --git a/src/test/scala/millfork/test/ComparisonSuite.scala b/src/test/scala/millfork/test/ComparisonSuite.scala index 3bc36291..358c1d80 100644 --- a/src/test/scala/millfork/test/ComparisonSuite.scala +++ b/src/test/scala/millfork/test/ComparisonSuite.scala @@ -10,7 +10,7 @@ import org.scalatest.{FunSuite, Matchers} class ComparisonSuite extends FunSuite with Matchers { test("Equality and inequality") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( """ | byte output @$c000 | void main () { @@ -28,7 +28,7 @@ class ComparisonSuite extends FunSuite with Matchers { } test("Less") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( """ | byte output @$c000 | void main () { @@ -41,7 +41,7 @@ class ComparisonSuite extends FunSuite with Matchers { } test("Compare to zero") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( """ | byte output @$c000 | void main () { @@ -76,7 +76,7 @@ class ComparisonSuite extends FunSuite with Matchers { } test("Does it even work") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( """ | word output @$c000 | void main () { @@ -99,7 +99,7 @@ class ComparisonSuite extends FunSuite with Matchers { | if 2222 == 3333 { output -= 1 } | } """.stripMargin - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)(src)(_.readByte(0xc000) should equal(src.count(_ == '+'))) + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)(src)(_.readByte(0xc000) should equal(src.count(_ == '+'))) } test("Word comparison == and !=") { @@ -122,7 +122,7 @@ class ComparisonSuite extends FunSuite with Matchers { | if a != 0 { output += 1 } | } """.stripMargin - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)(src)(_.readByte(0xc000) should equal(src.count(_ == '+'))) + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)(src)(_.readByte(0xc000) should equal(src.count(_ == '+'))) } test("Word comparison <=") { @@ -143,7 +143,7 @@ class ComparisonSuite extends FunSuite with Matchers { | if a <= c { output += 1 } | } """.stripMargin - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)(src)(_.readByte(0xc000) should equal(src.count(_ == '+'))) + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)(src)(_.readByte(0xc000) should equal(src.count(_ == '+'))) } test("Word comparison <") { val src = @@ -162,7 +162,7 @@ class ComparisonSuite extends FunSuite with Matchers { | if a < 257 { output += 1 } | } """.stripMargin - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)(src)(_.readByte(0xc000) should equal(src.count(_ == '+'))) + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)(src)(_.readByte(0xc000) should equal(src.count(_ == '+'))) } @@ -183,7 +183,7 @@ class ComparisonSuite extends FunSuite with Matchers { | if c > 0 { output += 1 } | } """.stripMargin - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)(src)(_.readByte(0xc000) should equal(src.count(_ == '+'))) + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)(src)(_.readByte(0xc000) should equal(src.count(_ == '+'))) } test("Word comparison >=") { @@ -206,7 +206,7 @@ class ComparisonSuite extends FunSuite with Matchers { | if a >= 0 { output += 1 } | } """.stripMargin - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)(src)(_.readByte(0xc000) should equal(src.count(_ == '+'))) + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)(src)(_.readByte(0xc000) should equal(src.count(_ == '+'))) } test("Signed comparison >=") { @@ -229,7 +229,7 @@ class ComparisonSuite extends FunSuite with Matchers { | if a >= 0 { output += 1 } | } """.stripMargin - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)(src)(_.readByte(0xc000) should equal(src.count(_ == '+'))) + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)(src)(_.readByte(0xc000) should equal(src.count(_ == '+'))) } test("Signed comparison with overflow") { @@ -263,7 +263,7 @@ class ComparisonSuite extends FunSuite with Matchers { | if c > -1 { output += 1 } | } """.stripMargin - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)(src)(_.readByte(0xc000) should equal(src.count(_ == '+'))) + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)(src)(_.readByte(0xc000) should equal(src.count(_ == '+'))) } test("Signed comparison < and <=") { @@ -295,11 +295,11 @@ class ComparisonSuite extends FunSuite with Matchers { | if c <= -1 { output -= 7 } | } """.stripMargin - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)(src)(_.readByte(0xc000) should equal(src.count(_ == '+'))) + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)(src)(_.readByte(0xc000) should equal(src.count(_ == '+'))) } test("Multiple params for equality") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( """ | byte output @$c000 | void main () { @@ -315,7 +315,7 @@ class ComparisonSuite extends FunSuite with Matchers { } test("Multiple params for inequality") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( """ | byte output @$c000 | void main () { @@ -331,7 +331,7 @@ class ComparisonSuite extends FunSuite with Matchers { } test("Warnings") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( """ | byte output @$c000 | void main () { @@ -373,7 +373,7 @@ class ComparisonSuite extends FunSuite with Matchers { | if c > 335444 { output += 1 } | } """.stripMargin - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)(src)(_.readByte(0xc000) should equal(src.count(_ == '+'))) + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)(src)(_.readByte(0xc000) should equal(src.count(_ == '+'))) } test("Mixed type comparison") { @@ -391,7 +391,7 @@ class ComparisonSuite extends FunSuite with Matchers { | if x < z { output += 1 } | } """.stripMargin - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)(src)(_.readByte(0xc000) should equal(1)) + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)(src)(_.readByte(0xc000) should equal(1)) } test("Compare beyond 2.2") { @@ -419,7 +419,7 @@ class ComparisonSuite extends FunSuite with Matchers { } test("Compare to $ffff") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8086)( """ | byte output @$c000 | void main() { @@ -439,7 +439,7 @@ class ComparisonSuite extends FunSuite with Matchers { } test("Compare to 0") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8086)( """ | byte output @$c000 | void main() { @@ -459,7 +459,7 @@ class ComparisonSuite extends FunSuite with Matchers { } test("Signed compare to 0") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8086)( """ | byte output @$c000 | void main() { @@ -477,7 +477,7 @@ class ComparisonSuite extends FunSuite with Matchers { } test("Signed compare to 1") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8086)( """ | byte output @$c000 | void main() { diff --git a/src/test/scala/millfork/test/ConstantSuite.scala b/src/test/scala/millfork/test/ConstantSuite.scala index 5d19fa6a..64e40d59 100644 --- a/src/test/scala/millfork/test/ConstantSuite.scala +++ b/src/test/scala/millfork/test/ConstantSuite.scala @@ -10,7 +10,7 @@ import org.scalatest.{FunSuite, Matchers} class ConstantSuite extends FunSuite with Matchers { test("Constants should fold") { - EmuUnoptimizedCrossPlatformRun(Cpu.Mos, Cpu.Z80)( + EmuUnoptimizedCrossPlatformRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8086)( """ | array Sieve[4] | array __screen[4] diff --git a/src/test/scala/millfork/test/DeduplicationSuite.scala b/src/test/scala/millfork/test/DeduplicationSuite.scala index b97bf7fd..619def0a 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)( + EmuSizeOptimizedCrossPlatformRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Intel8086)( """ | 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)( + EmuSizeOptimizedCrossPlatformRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Intel8086)( """ | array output [8] @$c000 | void main() { diff --git a/src/test/scala/millfork/test/DerefSuite.scala b/src/test/scala/millfork/test/DerefSuite.scala index 38417900..bf12e46d 100644 --- a/src/test/scala/millfork/test/DerefSuite.scala +++ b/src/test/scala/millfork/test/DerefSuite.scala @@ -9,7 +9,7 @@ import org.scalatest.{FunSuite, Matchers} */ class DerefSuite extends FunSuite with Matchers { test("Basic deref test") { - EmuUnoptimizedCrossPlatformRun(Cpu.Mos, Cpu.Z80)( + EmuUnoptimizedCrossPlatformRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8086)( """ | | byte output @$c000 @@ -33,7 +33,7 @@ class DerefSuite extends FunSuite with Matchers { } test("Byte arithmetic deref test") { - EmuUnoptimizedCrossPlatformRun(Cpu.Mos, Cpu.Z80)( + EmuUnoptimizedCrossPlatformRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8086)( """ | | byte output1 @$c000 @@ -59,7 +59,7 @@ class DerefSuite extends FunSuite with Matchers { } test("Word arithmetic deref test") { - EmuUnoptimizedCrossPlatformRun(Cpu.Mos, Cpu.Z80)( + EmuUnoptimizedCrossPlatformRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8086)( """ | | word output1 @$c000 diff --git a/src/test/scala/millfork/test/EnumSuite.scala b/src/test/scala/millfork/test/EnumSuite.scala index 8d6f28bb..37d09604 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)( + EmuUnoptimizedCrossPlatformRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( """ | enum ugly { | a @@ -40,7 +40,7 @@ class EnumSuite extends FunSuite with Matchers { } test("Enum arrays") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( """ | enum ugly { | a @@ -67,7 +67,7 @@ class EnumSuite extends FunSuite with Matchers { } test("Loops over enums") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( """ | enum ugly { | a diff --git a/src/test/scala/millfork/test/ErasthotenesSuite.scala b/src/test/scala/millfork/test/ErasthotenesSuite.scala index eb97b7cb..29a94e76 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)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( """ | const pointer sieve = $C000 | const byte sqrt = 128 diff --git a/src/test/scala/millfork/test/FarwordTest.scala b/src/test/scala/millfork/test/FarwordTest.scala index a154435c..be7e0a3d 100644 --- a/src/test/scala/millfork/test/FarwordTest.scala +++ b/src/test/scala/millfork/test/FarwordTest.scala @@ -10,7 +10,7 @@ import org.scalatest.{FunSuite, Matchers} class FarwordTest extends FunSuite with Matchers { test("Farword assignment") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( """ | farword output3 @$c000 | farword output2 @$c004 @@ -29,7 +29,7 @@ class FarwordTest extends FunSuite with Matchers { } } test("Farword assignment 2") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( """ | farword output3 @$c000 | farword output2 @$c004 @@ -53,7 +53,7 @@ class FarwordTest extends FunSuite with Matchers { } test("Farword assignment 3") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( """ | farword output0 @$c000 | farword output1 @$c003 @@ -70,7 +70,7 @@ class FarwordTest extends FunSuite with Matchers { } } test("Farword addition") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( """ | farword output @$c000 | void main () { @@ -90,7 +90,7 @@ class FarwordTest extends FunSuite with Matchers { } } test("Farword addition 2") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( """ | farword output @$c000 | void main () { @@ -104,7 +104,7 @@ class FarwordTest extends FunSuite with Matchers { } } test("Farword subtraction") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( """ | farword output @$c000 | void main () { @@ -124,7 +124,7 @@ class FarwordTest extends FunSuite with Matchers { } } test("Farword subtraction 2") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( """ | farword output @$c000 | void main () { @@ -138,7 +138,7 @@ class FarwordTest extends FunSuite with Matchers { } } test("Farword subtraction 3") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( """ | farword output @$c000 | void main () { @@ -158,7 +158,7 @@ class FarwordTest extends FunSuite with Matchers { } test("Farword AND") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( """ | farword output @$c000 | void main () { @@ -178,7 +178,7 @@ class FarwordTest extends FunSuite with Matchers { } test("Farword INC/DEC") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( """ | farword output0 @$c000 | farword output1 @$c004 diff --git a/src/test/scala/millfork/test/ForArraySuite.scala b/src/test/scala/millfork/test/ForArraySuite.scala index ee9f4798..235fd217 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)(src) { m => + EmuCrossPlatformBenchmarkRun(Cpu.Cmos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)(src) { m => m.readByte(0xc000) should equal(18) } } diff --git a/src/test/scala/millfork/test/ForLoopSuite.scala b/src/test/scala/millfork/test/ForLoopSuite.scala index 1bc2096f..40ce177c 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)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( """ | word output @$c000 | void main () { @@ -25,7 +25,7 @@ class ForLoopSuite extends FunSuite with Matchers { } test("For-to 2") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( """ | word output @$c000 | byte five @@ -44,7 +44,7 @@ class ForLoopSuite extends FunSuite with Matchers { } test("For-downto") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( """ | word output @$c000 | void main () { @@ -58,7 +58,7 @@ class ForLoopSuite extends FunSuite with Matchers { } test("For-downto 2") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( """ | 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)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( """ | 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)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( """ | word output @$c000 | void main () { @@ -116,7 +116,7 @@ class ForLoopSuite extends FunSuite with Matchers { } test("For-parallelto") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( """ | word output @$c000 | void main () { @@ -130,7 +130,7 @@ class ForLoopSuite extends FunSuite with Matchers { } test("For-paralleluntil") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( """ | word output @$c000 | void main () { @@ -144,7 +144,7 @@ class ForLoopSuite extends FunSuite with Matchers { } test("Various loops") { - EmuUnoptimizedCrossPlatformRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)( + EmuUnoptimizedCrossPlatformRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( """ | void init() { | zero = 0 @@ -183,7 +183,7 @@ class ForLoopSuite extends FunSuite with Matchers { } test("Memcpy") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( """ | array output[5]@$c001 | array input = [0,1,4,9,16,25,36,49] @@ -201,7 +201,7 @@ class ForLoopSuite extends FunSuite with Matchers { } test("Memset with index") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( """ | array output[5]@$c001 | void main () { @@ -218,7 +218,7 @@ class ForLoopSuite extends FunSuite with Matchers { } test("Memset with pointer") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( """ | array output[5]@$c001 | void main () { @@ -235,7 +235,7 @@ class ForLoopSuite extends FunSuite with Matchers { } test("Screen fill") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( """ | array output[$400]@$c000 | void main () { @@ -253,7 +253,7 @@ class ForLoopSuite extends FunSuite with Matchers { } test("Various bulk operations") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( """ | array output0[5]@$c000 | array output1[5]@$c010 @@ -288,7 +288,7 @@ class ForLoopSuite extends FunSuite with Matchers { } test("Edge cases - positive") { - EmuUnoptimizedCrossPlatformRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)(""" + EmuUnoptimizedCrossPlatformRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)(""" | void main() { | byte i | for i,0,until,256 { f() } @@ -343,7 +343,7 @@ class ForLoopSuite extends FunSuite with Matchers { test("For each") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8086)( """ | array output[$400]@$c000 | void main () { diff --git a/src/test/scala/millfork/test/InliningSuite.scala b/src/test/scala/millfork/test/InliningSuite.scala index a47e5870..f90c692c 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)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8086)( """ | import zp_reg | byte output @$c000 @@ -24,7 +24,7 @@ class InliningSuite extends FunSuite with Matchers { } test("Should inline <<") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8086)( """ | 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)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8086)( """ | 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)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8086)( """ | byte output@$c000 | inline word square(word x) { diff --git a/src/test/scala/millfork/test/LongTest.scala b/src/test/scala/millfork/test/LongTest.scala index 77ab64a2..aea2126b 100644 --- a/src/test/scala/millfork/test/LongTest.scala +++ b/src/test/scala/millfork/test/LongTest.scala @@ -10,7 +10,7 @@ import org.scalatest.{FunSuite, Matchers} class LongTest extends FunSuite with Matchers { test("Long assignment") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( """ | long output4 @$c000 | long output2 @$c004 @@ -29,7 +29,7 @@ class LongTest extends FunSuite with Matchers { } } test("Long assignment 2") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( """ | long output4 @$c000 | long output2 @$c004 @@ -52,7 +52,7 @@ class LongTest extends FunSuite with Matchers { } } test("Long addition") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( """ | long output @$c000 | void main () { @@ -72,7 +72,7 @@ class LongTest extends FunSuite with Matchers { } } test("Long addition 2") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( """ | long output @$c000 | void main () { @@ -86,7 +86,7 @@ class LongTest extends FunSuite with Matchers { } } test("Long addition 3") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( """ | long output @$c000 | void main () { @@ -103,7 +103,7 @@ class LongTest extends FunSuite with Matchers { } } test("Extralong addition") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( """ | int128 output @$c000 | void main () { @@ -120,7 +120,7 @@ class LongTest extends FunSuite with Matchers { } } test("Long subtraction") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( """ | long output @$c000 | void main () { @@ -140,7 +140,7 @@ class LongTest extends FunSuite with Matchers { } } test("Long subtraction 2") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( """ | long output @$c000 | void main () { @@ -154,7 +154,7 @@ class LongTest extends FunSuite with Matchers { } } test("Long subtraction 3") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( """ | long output @$c000 | void main () { @@ -174,7 +174,7 @@ class LongTest extends FunSuite with Matchers { } test("Long AND") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( """ | long output @$c000 | void main () { @@ -194,7 +194,7 @@ class LongTest extends FunSuite with Matchers { } test("Long INC/DEC") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( """ | long output0 @$c000 | long output1 @$c004 @@ -234,7 +234,7 @@ class LongTest extends FunSuite with Matchers { } test("Returning long") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( """ | long output @$c000 | void main () { @@ -249,7 +249,7 @@ class LongTest extends FunSuite with Matchers { } test("Various combinations involving promotions") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( """ | long output0 @$c000 | long output1 @$c004 @@ -311,7 +311,7 @@ class LongTest extends FunSuite with Matchers { } test("Larger than long") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( """ | int64 output0 @$c000 | int64 output1 @$c008 diff --git a/src/test/scala/millfork/test/MacroSuite.scala b/src/test/scala/millfork/test/MacroSuite.scala index 7f780c2a..3b42580c 100644 --- a/src/test/scala/millfork/test/MacroSuite.scala +++ b/src/test/scala/millfork/test/MacroSuite.scala @@ -10,7 +10,7 @@ import org.scalatest.{FunSuite, Matchers} class MacroSuite extends FunSuite with Matchers { test("Most basic test") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8086)( """ | macro void run(byte x) { | output = x diff --git a/src/test/scala/millfork/test/MemsetSuite.scala b/src/test/scala/millfork/test/MemsetSuite.scala index 0033cf4c..e35f0aca 100644 --- a/src/test/scala/millfork/test/MemsetSuite.scala +++ b/src/test/scala/millfork/test/MemsetSuite.scala @@ -29,7 +29,7 @@ class MemsetSuite extends FunSuite with Matchers with AppendedClues { } def memsetCase(size: Int): Unit = { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Intel8080, Cpu.Z80)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Intel8080, Cpu.Z80, Cpu.Intel8086)( "const word SIZE = " + size + """ | array output [SIZE] @$c000 | void main () { diff --git a/src/test/scala/millfork/test/NodeOptimizationSuite.scala b/src/test/scala/millfork/test/NodeOptimizationSuite.scala index e20f3991..249629c7 100644 --- a/src/test/scala/millfork/test/NodeOptimizationSuite.scala +++ b/src/test/scala/millfork/test/NodeOptimizationSuite.scala @@ -32,7 +32,7 @@ class NodeOptimizationSuite extends FunSuite with Matchers { } test("Returning one variable") { - EmuUnoptimizedCrossPlatformRun(Cpu.Mos, Cpu.Z80)( + EmuUnoptimizedCrossPlatformRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8086)( """ | int64 output @$c000 | void main () { diff --git a/src/test/scala/millfork/test/NonetSuite.scala b/src/test/scala/millfork/test/NonetSuite.scala index 23b4cc12..bcd3ca1b 100644 --- a/src/test/scala/millfork/test/NonetSuite.scala +++ b/src/test/scala/millfork/test/NonetSuite.scala @@ -10,7 +10,7 @@ import org.scalatest.{FunSuite, Matchers} class NonetSuite extends FunSuite with Matchers { test("Nonet operations") { - EmuUnoptimizedCrossPlatformRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)( + EmuUnoptimizedCrossPlatformRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( """ | array output [5] @$c000 | void main () { @@ -30,7 +30,7 @@ class NonetSuite extends FunSuite with Matchers { } test("Nonet operations on bytes") { - EmuUnoptimizedCrossPlatformRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)( + EmuUnoptimizedCrossPlatformRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( """ | byte output @$c000 | @@ -45,7 +45,7 @@ class NonetSuite extends FunSuite with Matchers { } test("Nonet left shift") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( """ | word output0 @$c000 | word output1 @$c002 @@ -119,7 +119,7 @@ class NonetSuite extends FunSuite with Matchers { } test("Nonet shift right") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8086)( """ | byte output0 @$c000 | byte output1 @$c002 @@ -141,7 +141,7 @@ class NonetSuite extends FunSuite with Matchers { } test("Nonet shift right 2") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8086)( """ | byte output0 @$c000 | byte output1 @$c002 diff --git a/src/test/scala/millfork/test/PointerSuite.scala b/src/test/scala/millfork/test/PointerSuite.scala index 16f97a88..f1e9190f 100644 --- a/src/test/scala/millfork/test/PointerSuite.scala +++ b/src/test/scala/millfork/test/PointerSuite.scala @@ -10,7 +10,7 @@ import org.scalatest.{AppendedClues, FunSuite, Matchers} class PointerSuite extends FunSuite with Matchers with AppendedClues { test("Pointers outside zeropage") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Sixteen, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Sixteen, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( """ | pointer p @$c004 | array output[2] @$c000 @@ -25,7 +25,7 @@ class PointerSuite extends FunSuite with Matchers with AppendedClues { } test("Pointers on stack") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Sixteen, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Sixteen, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( """ | array output[2] @$c000 | void main() { @@ -40,7 +40,7 @@ class PointerSuite extends FunSuite with Matchers with AppendedClues { } test("Typed byte-targeting pointers") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Sixteen, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Sixteen, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( """ | enum e {} | array(e) output [3] @$c000 @@ -57,7 +57,7 @@ class PointerSuite extends FunSuite with Matchers with AppendedClues { } test("Typed word-targeting pointers") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Sixteen, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Sixteen, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( """ | word output @$c000 | void main() { @@ -73,7 +73,7 @@ class PointerSuite extends FunSuite with Matchers with AppendedClues { } test("Struct pointers") { - EmuUnoptimizedCrossPlatformRun(Cpu.Mos, Cpu.Z80)( + EmuUnoptimizedCrossPlatformRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8086)( """ | struct point { word x, word y } | struct pointlist { point head, pointer.pointlist tail } @@ -130,7 +130,7 @@ class PointerSuite extends FunSuite with Matchers with AppendedClues { } test("Pointer optimization") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8086)( """ | struct s { word a, byte b } | @@ -154,7 +154,7 @@ class PointerSuite extends FunSuite with Matchers with AppendedClues { } test("nullptr") { - EmuUnoptimizedCrossPlatformRun(Cpu.Mos, Cpu.Z80)( + EmuUnoptimizedCrossPlatformRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8086)( """ | void main() { | pointer.word pw @@ -171,7 +171,7 @@ class PointerSuite extends FunSuite with Matchers with AppendedClues { test("Complex pointers") { // TODO: optimize it when inlined - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8086)( """ | array output[3] @$c000 | struct s { @@ -193,7 +193,7 @@ class PointerSuite extends FunSuite with Matchers with AppendedClues { } test("Indexing returned pointers") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8086)( """ | array output[10] @$c000 | pointer get() = output.addr diff --git a/src/test/scala/millfork/test/ReturnDispatchSuite.scala b/src/test/scala/millfork/test/ReturnDispatchSuite.scala index d40b93d9..3bd8e175 100644 --- a/src/test/scala/millfork/test/ReturnDispatchSuite.scala +++ b/src/test/scala/millfork/test/ReturnDispatchSuite.scala @@ -10,7 +10,7 @@ import org.scalatest.{FunSuite, Matchers} class ReturnDispatchSuite extends FunSuite with Matchers { test("Trivial test") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Cmos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Cmos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( """ | byte output @$c000 | void main () { @@ -28,7 +28,7 @@ class ReturnDispatchSuite extends FunSuite with Matchers { } } test("Parameter test") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Cmos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Cmos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( """ | array output [200] @$c000 | sbyte param @@ -74,7 +74,7 @@ class ReturnDispatchSuite extends FunSuite with Matchers { } test("Enum test") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Cmos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Cmos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( """ | byte output @$c000 | enum ugly { diff --git a/src/test/scala/millfork/test/SecondAssemblyOptimizationSuite.scala b/src/test/scala/millfork/test/SecondAssemblyOptimizationSuite.scala index dfbe9e98..ebc9b046 100644 --- a/src/test/scala/millfork/test/SecondAssemblyOptimizationSuite.scala +++ b/src/test/scala/millfork/test/SecondAssemblyOptimizationSuite.scala @@ -10,7 +10,7 @@ import org.scalatest.{FunSuite, Matchers} class SecondAssemblyOptimizationSuite extends FunSuite with Matchers { test("Add-shift-add") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Cmos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Cmos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( """ | byte output @$c000 | void main () { @@ -23,7 +23,7 @@ class SecondAssemblyOptimizationSuite extends FunSuite with Matchers { } test("And-shift-and") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Cmos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Cmos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( """ | byte output @$c000 | void main () { @@ -36,7 +36,7 @@ class SecondAssemblyOptimizationSuite extends FunSuite with Matchers { } test("Add with limit") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Cmos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Cmos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( """ | byte output @$c000 | const byte start = 5 @@ -105,7 +105,7 @@ class SecondAssemblyOptimizationSuite extends FunSuite with Matchers { } test("Conditional variable initialization") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8086)( """ | array output [16] @$c000 | void main () { diff --git a/src/test/scala/millfork/test/SeparateBytesSuite.scala b/src/test/scala/millfork/test/SeparateBytesSuite.scala index 2ed77b1f..260c760f 100644 --- a/src/test/scala/millfork/test/SeparateBytesSuite.scala +++ b/src/test/scala/millfork/test/SeparateBytesSuite.scala @@ -10,7 +10,7 @@ import org.scalatest.{FunSuite, Matchers} class SeparateBytesSuite extends FunSuite with Matchers { test("Separate assignment 1") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Cmos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)(""" + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Cmos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)(""" | word output @$c000 | void main () { | output = 2:3 @@ -19,7 +19,7 @@ class SeparateBytesSuite extends FunSuite with Matchers { } test("Separate assignment 2") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Cmos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)(""" + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Cmos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)(""" | byte output @$c000 | byte ignore @$c001 | void main () { @@ -31,7 +31,7 @@ class SeparateBytesSuite extends FunSuite with Matchers { } test("Separate assignment 3") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Cmos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)(""" + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Cmos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)(""" | byte output @$c000 | byte ignore @$c001 | void main () { @@ -44,7 +44,7 @@ class SeparateBytesSuite extends FunSuite with Matchers { } test("Separate assignment 4") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Cmos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)(""" + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Cmos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)(""" | array output [5] @$c000 | byte ignore @$c001 | void main () { @@ -59,7 +59,7 @@ class SeparateBytesSuite extends FunSuite with Matchers { } test("Separate assignment 5") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Cmos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)(""" + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Cmos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)(""" | array output [5] @$c000 | byte ignore @$c001 | void main () { @@ -74,7 +74,7 @@ class SeparateBytesSuite extends FunSuite with Matchers { } test("Magic split array") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Cmos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)(""" + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Cmos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)(""" | array high [16] @$c000 | array low [16] @$c010 | void main () { @@ -107,7 +107,7 @@ class SeparateBytesSuite extends FunSuite with Matchers { } test("Separate addition") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Cmos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)(""" + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Cmos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)(""" | word output @$c000 | void main () { | byte h @@ -121,7 +121,7 @@ class SeparateBytesSuite extends FunSuite with Matchers { } test("Separate increase") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Cmos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)(""" + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Cmos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)(""" | word output @$c000 | void main () { | byte h diff --git a/src/test/scala/millfork/test/ShiftSuite.scala b/src/test/scala/millfork/test/ShiftSuite.scala index e9cb670d..2454c1e5 100644 --- a/src/test/scala/millfork/test/ShiftSuite.scala +++ b/src/test/scala/millfork/test/ShiftSuite.scala @@ -9,7 +9,7 @@ import org.scalatest.{FunSuite, Matchers} class ShiftSuite extends FunSuite with Matchers { test("In-place shifting") { - EmuUnoptimizedCrossPlatformRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)(""" + EmuUnoptimizedCrossPlatformRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)(""" | array output [3] @$c000 | void main () { | output[0] = 1 @@ -20,7 +20,7 @@ class ShiftSuite extends FunSuite with Matchers { } test("Byte shifting") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)(""" + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)(""" | byte output @$c000 | void main () { | byte a @@ -31,7 +31,7 @@ class ShiftSuite extends FunSuite with Matchers { } test("Word shifting") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)(""" + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)(""" | word output @$c000 | void main () { | byte a @@ -50,7 +50,7 @@ class ShiftSuite extends FunSuite with Matchers { | output <<= 2 | } """.stripMargin)(_.readLong(0xc000) should equal(0x4040C04)) - EmuCrossPlatformBenchmarkRun(Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)(""" + EmuCrossPlatformBenchmarkRun(Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)(""" | long output @$c000 | void main () { | output = $1010301 @@ -60,7 +60,7 @@ class ShiftSuite extends FunSuite with Matchers { } test("Long shifting right") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)(""" + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)(""" | long output @$c000 | void main () { | output = $4040C04 @@ -70,7 +70,7 @@ class ShiftSuite extends FunSuite with Matchers { } test("Word shifting via pseudoregister") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)(""" + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)(""" | word output @$c000 | void main () { | output = identity(three() << 7) @@ -81,7 +81,7 @@ class ShiftSuite extends FunSuite with Matchers { } test("Variable shifting") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)(""" + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)(""" | word output0 @$c000 | word output2 @$c002 | byte output4 @$c004 @@ -104,7 +104,7 @@ class ShiftSuite extends FunSuite with Matchers { } test("Zero shifting") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)(""" + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)(""" | byte output0 @$c000 | byte output1 @$c001 | noinline byte sl(byte input, byte amount) { diff --git a/src/test/scala/millfork/test/SignExtensionSuite.scala b/src/test/scala/millfork/test/SignExtensionSuite.scala index 32c5161b..35ef261f 100644 --- a/src/test/scala/millfork/test/SignExtensionSuite.scala +++ b/src/test/scala/millfork/test/SignExtensionSuite.scala @@ -10,7 +10,7 @@ import org.scalatest.{FunSuite, Matchers} class SignExtensionSuite extends FunSuite with Matchers { test("Sbyte to Word") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)(""" + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)(""" | word output @$c000 | void main () { | sbyte b @@ -22,7 +22,7 @@ class SignExtensionSuite extends FunSuite with Matchers { } } test("Sbyte to Word 2") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)(""" + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)(""" | word output @$c000 | void main () { | output = b() @@ -33,7 +33,7 @@ class SignExtensionSuite extends FunSuite with Matchers { """.stripMargin){m => m.readWord(0xc000) should equal(0xffff)} } test("Sbyte to Long") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)(""" + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)(""" | long output @$c000 | void main () { | output = 421 @@ -46,7 +46,7 @@ class SignExtensionSuite extends FunSuite with Matchers { } test("Optimize pointless sign extension") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)(""" + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)(""" | array output [10] @$c000 | word w | void main () { diff --git a/src/test/scala/millfork/test/StackVarSuite.scala b/src/test/scala/millfork/test/StackVarSuite.scala index 420d14ba..2f81a211 100644 --- a/src/test/scala/millfork/test/StackVarSuite.scala +++ b/src/test/scala/millfork/test/StackVarSuite.scala @@ -10,7 +10,7 @@ import org.scalatest.{FunSuite, Matchers} class StackVarSuite extends FunSuite with Matchers { test("Basic stack assignment") { - EmuCrossPlatformBenchmarkRun(Cpu.StrictMos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)(""" + EmuCrossPlatformBenchmarkRun(Cpu.StrictMos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)(""" | byte output @$c000 | void main () { | stack byte a @@ -24,7 +24,7 @@ class StackVarSuite extends FunSuite with Matchers { } test("Stack byte addition") { - EmuCrossPlatformBenchmarkRun(Cpu.StrictMos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)(""" + EmuCrossPlatformBenchmarkRun(Cpu.StrictMos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)(""" | byte output @$c000 | void main () { | stack byte a @@ -56,7 +56,7 @@ class StackVarSuite extends FunSuite with Matchers { } test("Complex expressions involving stack variables (Z80)") { - EmuCrossPlatformBenchmarkRun(Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)(""" + EmuCrossPlatformBenchmarkRun(Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)(""" | byte output @$c000 | void main () { | stack byte a @@ -70,7 +70,7 @@ class StackVarSuite extends FunSuite with Matchers { } test("Stack byte subtraction") { - EmuUnoptimizedCrossPlatformRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080)( + EmuUnoptimizedCrossPlatformRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Intel8086)( """ | byte output @$c000 | void main () { @@ -91,7 +91,7 @@ class StackVarSuite extends FunSuite with Matchers { } test("Stack word addition") { - EmuCrossPlatformBenchmarkRun(Cpu.StrictMos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)(""" + EmuCrossPlatformBenchmarkRun(Cpu.StrictMos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)(""" | word output @$c000 | void main () { | stack word a @@ -109,7 +109,7 @@ class StackVarSuite extends FunSuite with Matchers { } test("Recursion") { - EmuCrossPlatformBenchmarkRun(Cpu.StrictMos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)(""" + EmuCrossPlatformBenchmarkRun(Cpu.StrictMos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)(""" | array output [6] @$c000 | byte fails @$c010 | void main () { @@ -145,7 +145,7 @@ class StackVarSuite extends FunSuite with Matchers { } test("Recursion 2") { - EmuCrossPlatformBenchmarkRun(Cpu.StrictMos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)(""" + EmuCrossPlatformBenchmarkRun(Cpu.StrictMos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)(""" | array output [6] @$c000 | byte fails @$c010 | void main () { @@ -177,7 +177,7 @@ class StackVarSuite extends FunSuite with Matchers { } test("Complex stack-related stuff") { - EmuCrossPlatformBenchmarkRun(Cpu.StrictMos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)(""" + EmuCrossPlatformBenchmarkRun(Cpu.StrictMos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)(""" | byte output @$c000 | array id = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] | void main() { @@ -195,7 +195,7 @@ class StackVarSuite extends FunSuite with Matchers { test("Indexing") { - EmuCrossPlatformBenchmarkRun(Cpu.StrictMos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)(""" + EmuCrossPlatformBenchmarkRun(Cpu.StrictMos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)(""" | array output [200] @$c000 | void main () { | stack byte a @@ -208,7 +208,7 @@ class StackVarSuite extends FunSuite with Matchers { } test("Double array with stack variables") { - EmuCrossPlatformBenchmarkRun(Cpu.StrictMos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)( + EmuCrossPlatformBenchmarkRun(Cpu.StrictMos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( """ | array output[5]@$c001 | array input = [0,1,4,9,16,25,36,49] @@ -226,7 +226,7 @@ class StackVarSuite extends FunSuite with Matchers { } test("Complex large stacks") { - EmuCrossPlatformBenchmarkRun(Cpu.StrictMos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)( + EmuCrossPlatformBenchmarkRun(Cpu.StrictMos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( // val m = EmuUnoptimizedZ80Run( """ | array output[5]@$c000 @@ -255,7 +255,7 @@ class StackVarSuite extends FunSuite with Matchers { } test("Large stack storage") { - EmuUnoptimizedCrossPlatformRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)( + EmuUnoptimizedCrossPlatformRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( """ | int32 output @$c000 | void main () { @@ -272,7 +272,7 @@ class StackVarSuite extends FunSuite with Matchers { } test("Large stack-to-stack transfer") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( """ | int32 output @$c000 | void main () { diff --git a/src/test/scala/millfork/test/StatementOptimizationSuite.scala b/src/test/scala/millfork/test/StatementOptimizationSuite.scala index 97ad7bf3..df08fb2c 100644 --- a/src/test/scala/millfork/test/StatementOptimizationSuite.scala +++ b/src/test/scala/millfork/test/StatementOptimizationSuite.scala @@ -10,7 +10,7 @@ import org.scalatest.{FunSuite, Matchers} class StatementOptimizationSuite extends FunSuite with Matchers { test("Statement optimization 1") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Intel8080, Cpu.Sharp)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( """ | array output[10] @$c000 | void main() { @@ -58,7 +58,7 @@ class StatementOptimizationSuite extends FunSuite with Matchers { test("Stdlib optimization 1") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Intel8080, Cpu.Sharp)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)( """ | import stdio | byte output @$c000 diff --git a/src/test/scala/millfork/test/StructSuite.scala b/src/test/scala/millfork/test/StructSuite.scala index a48dbad7..9b434c4f 100644 --- a/src/test/scala/millfork/test/StructSuite.scala +++ b/src/test/scala/millfork/test/StructSuite.scala @@ -10,7 +10,7 @@ import org.scalatest.{FunSuite, Matchers} class StructSuite extends FunSuite with Matchers { test("Basic struct support") { - EmuUnoptimizedCrossPlatformRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080)(""" + EmuUnoptimizedCrossPlatformRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Intel8086)(""" | struct point { | byte x | byte y @@ -40,7 +40,7 @@ class StructSuite extends FunSuite with Matchers { } test("Nested structs") { - EmuUnoptimizedCrossPlatformRun(Cpu.Mos, Cpu.Intel8080)(""" + EmuUnoptimizedCrossPlatformRun(Cpu.Mos, Cpu.Intel8080, Cpu.Intel8086)(""" | struct inner { word x, word y } | struct s { | word w @@ -69,7 +69,7 @@ class StructSuite extends FunSuite with Matchers { } test("Basic union support") { - EmuUnoptimizedCrossPlatformRun(Cpu.Mos, Cpu.Intel8080)(""" + EmuUnoptimizedCrossPlatformRun(Cpu.Mos, Cpu.Intel8080, Cpu.Intel8086)(""" | struct point { byte x, byte y } | union point_or_word { point p, word w } | word output @$c000 @@ -85,7 +85,7 @@ class StructSuite extends FunSuite with Matchers { } test("Optimize struct modifications") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80)(""" + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8086)(""" | struct point { byte x, byte y } | enum direction { none, right } | direction last_direction @$c400 diff --git a/src/test/scala/millfork/test/TypeSuite.scala b/src/test/scala/millfork/test/TypeSuite.scala index cbd9b913..caa57e93 100644 --- a/src/test/scala/millfork/test/TypeSuite.scala +++ b/src/test/scala/millfork/test/TypeSuite.scala @@ -10,7 +10,7 @@ import org.scalatest.{FunSuite, Matchers} class TypeSuite extends FunSuite with Matchers { test("Word to word") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)(""" + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)(""" | word output @$c000 | void main () { | output = word(0x203) diff --git a/src/test/scala/millfork/test/TypeWideningSuite.scala b/src/test/scala/millfork/test/TypeWideningSuite.scala index 32d7aad0..dfdc1d2a 100644 --- a/src/test/scala/millfork/test/TypeWideningSuite.scala +++ b/src/test/scala/millfork/test/TypeWideningSuite.scala @@ -10,7 +10,7 @@ import org.scalatest.{FunSuite, Matchers} class TypeWideningSuite extends FunSuite with Matchers { test("Word after simple ops") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)(""" + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)(""" | word output @$c000 | void main () { | output = random() diff --git a/src/test/scala/millfork/test/VolatileSuite.scala b/src/test/scala/millfork/test/VolatileSuite.scala index 2bef73b3..8df06b36 100644 --- a/src/test/scala/millfork/test/VolatileSuite.scala +++ b/src/test/scala/millfork/test/VolatileSuite.scala @@ -10,7 +10,7 @@ import org.scalatest.{FunSuite, Matchers} class VolatileSuite extends FunSuite with Matchers { test("Basic volatile test") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8086)( """ | word addr @$c000 | volatile byte output @$c0ea diff --git a/src/test/scala/millfork/test/WordMathSuite.scala b/src/test/scala/millfork/test/WordMathSuite.scala index 82187230..78b4c71a 100644 --- a/src/test/scala/millfork/test/WordMathSuite.scala +++ b/src/test/scala/millfork/test/WordMathSuite.scala @@ -9,7 +9,7 @@ import org.scalatest.{AppendedClues, FunSuite, Matchers} class WordMathSuite extends FunSuite with Matchers with AppendedClues { test("Word addition") { - EmuCrossPlatformBenchmarkRun(Cpu.Sixteen, Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)(""" + EmuCrossPlatformBenchmarkRun(Cpu.Sixteen, Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)(""" | word output @$c000 | word a | void main () { @@ -21,7 +21,7 @@ class WordMathSuite extends FunSuite with Matchers with AppendedClues { } test("Cast word addition") { - EmuCrossPlatformBenchmarkRun(Cpu.Sixteen, Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)(""" + EmuCrossPlatformBenchmarkRun(Cpu.Sixteen, Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)(""" | byte output @$c000 | word a | void main () { @@ -34,7 +34,7 @@ class WordMathSuite extends FunSuite with Matchers with AppendedClues { } test("Word subtraction") { - EmuCrossPlatformBenchmarkRun(Cpu.Sixteen, Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)(""" + EmuCrossPlatformBenchmarkRun(Cpu.Sixteen, Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)(""" | word output @$c000 | word a | void main () { @@ -46,7 +46,7 @@ class WordMathSuite extends FunSuite with Matchers with AppendedClues { } test("Word subtraction 2") { - EmuCrossPlatformBenchmarkRun(Cpu.Sixteen, Cpu.Cmos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)(""" + EmuCrossPlatformBenchmarkRun(Cpu.Sixteen, Cpu.Cmos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)(""" | word output @$c000 | word a | void main () { @@ -58,7 +58,7 @@ class WordMathSuite extends FunSuite with Matchers with AppendedClues { } test("Word subtraction 3") { - EmuCrossPlatformBenchmarkRun(Cpu.Sixteen, Cpu.Cmos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)(""" + EmuCrossPlatformBenchmarkRun(Cpu.Sixteen, Cpu.Cmos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)(""" | word output @$c000 | word a | void main () { @@ -73,7 +73,7 @@ class WordMathSuite extends FunSuite with Matchers with AppendedClues { } test("Byte-to-word addition") { - EmuCrossPlatformBenchmarkRun(Cpu.Sixteen, Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)(""" + EmuCrossPlatformBenchmarkRun(Cpu.Sixteen, Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)(""" | word output @$c000 | word pair | void main () { @@ -86,7 +86,7 @@ class WordMathSuite extends FunSuite with Matchers with AppendedClues { } test("Literal addition") { - EmuCrossPlatformBenchmarkRun(Cpu.Sixteen, Cpu.Sixteen, Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)(""" + EmuCrossPlatformBenchmarkRun(Cpu.Sixteen, Cpu.Sixteen, Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)(""" | word output @$c000 | void main () { | output = 640 @@ -96,7 +96,7 @@ class WordMathSuite extends FunSuite with Matchers with AppendedClues { } test("Array element addition") { - EmuCrossPlatformBenchmarkRun(Cpu.Sixteen, Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)(""" + EmuCrossPlatformBenchmarkRun(Cpu.Sixteen, Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)(""" | word output @$c000 | word pair | array b[2] @@ -113,7 +113,7 @@ class WordMathSuite extends FunSuite with Matchers with AppendedClues { } test("nesdev.com example") { - EmuCrossPlatformBenchmarkRun(Cpu.Sixteen, Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)(""" + EmuCrossPlatformBenchmarkRun(Cpu.Sixteen, Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)(""" | byte output @$c000 | byte tile @$C3A6 | array map [256] @$c300 @@ -135,7 +135,7 @@ class WordMathSuite extends FunSuite with Matchers with AppendedClues { } test("nesdev.com example 2") { - EmuCrossPlatformBenchmarkRun(Cpu.Sixteen, Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)(""" + EmuCrossPlatformBenchmarkRun(Cpu.Sixteen, Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)(""" | byte output @$c000 | byte tile @$C3A6 | array map [256] @$c300 @@ -153,7 +153,7 @@ class WordMathSuite extends FunSuite with Matchers with AppendedClues { } test("hi()/lo()") { - EmuCrossPlatformBenchmarkRun(Cpu.Sixteen, Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)(""" + EmuCrossPlatformBenchmarkRun(Cpu.Sixteen, Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)(""" | array output [7] @$c000 | void main () { | output[0] = lo(33) @@ -185,7 +185,7 @@ class WordMathSuite extends FunSuite with Matchers with AppendedClues { } test("Word addition 2") { - EmuCrossPlatformBenchmarkRun(Cpu.Sixteen, Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)(""" + EmuCrossPlatformBenchmarkRun(Cpu.Sixteen, Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)(""" | word output @$c000 | void main () { | word v @@ -201,7 +201,7 @@ class WordMathSuite extends FunSuite with Matchers with AppendedClues { } test("Word addition 3") { - EmuCrossPlatformBenchmarkRun(Cpu.Sixteen, Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)(""" + EmuCrossPlatformBenchmarkRun(Cpu.Sixteen, Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)(""" | word output @$c000 | void main () { | byte c @@ -217,7 +217,7 @@ class WordMathSuite extends FunSuite with Matchers with AppendedClues { } test("Word addition 4") { - EmuCrossPlatformBenchmarkRun(Cpu.Sixteen, Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)(""" + EmuCrossPlatformBenchmarkRun(Cpu.Sixteen, Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)(""" | word output @$c000 | void main () { | word v @@ -237,7 +237,7 @@ class WordMathSuite extends FunSuite with Matchers with AppendedClues { } test("Word bit ops 2") { - EmuCrossPlatformBenchmarkRun(Cpu.Sixteen, Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)(""" + EmuCrossPlatformBenchmarkRun(Cpu.Sixteen, Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)(""" | word output @$c000 | void main () { | word v @@ -253,7 +253,7 @@ class WordMathSuite extends FunSuite with Matchers with AppendedClues { } test("Word shift") { - EmuCrossPlatformBenchmarkRun(Cpu.Sixteen, Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)(""" + EmuCrossPlatformBenchmarkRun(Cpu.Sixteen, Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)(""" | word output @$c000 | void main () { | word v @@ -271,7 +271,7 @@ class WordMathSuite extends FunSuite with Matchers with AppendedClues { } test("Word shift 2") { - EmuCrossPlatformBenchmarkRun(Cpu.Sixteen, Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)(""" + EmuCrossPlatformBenchmarkRun(Cpu.Sixteen, Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)(""" | word output @$c000 | void main () { | output = five() @@ -286,7 +286,7 @@ class WordMathSuite extends FunSuite with Matchers with AppendedClues { } test("Word shift 3") { - EmuCrossPlatformBenchmarkRun(Cpu.Sixteen, Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)(""" + EmuCrossPlatformBenchmarkRun(Cpu.Sixteen, Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)(""" | word output @$c000 | void main () { | output = five() @@ -301,7 +301,7 @@ class WordMathSuite extends FunSuite with Matchers with AppendedClues { } test("Word shift 4") { - EmuCrossPlatformBenchmarkRun(Cpu.Sixteen, Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)(""" + EmuCrossPlatformBenchmarkRun(Cpu.Sixteen, Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)(""" | word output @$c000 | void main () { | output = five() @@ -316,7 +316,7 @@ class WordMathSuite extends FunSuite with Matchers with AppendedClues { } test("Word shift 5") { - EmuCrossPlatformBenchmarkRun(Cpu.Sixteen, Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)(""" + EmuCrossPlatformBenchmarkRun(Cpu.Sixteen, Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)(""" | word output @$c000 | void main () { | output = five() @@ -332,7 +332,7 @@ class WordMathSuite extends FunSuite with Matchers with AppendedClues { } test("Word multiplication 5") { - EmuCrossPlatformBenchmarkRun(Cpu.Sixteen, Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp)(""" + EmuCrossPlatformBenchmarkRun(Cpu.Sixteen, Cpu.Mos, Cpu.Z80, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)(""" | word output @$c000 | void main () { | output = alot() @@ -351,7 +351,7 @@ class WordMathSuite extends FunSuite with Matchers with AppendedClues { } test("Word multiplication optimization") { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Intel8080, Cpu.Sharp)(""" + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Intel8080, Cpu.Sharp, Cpu.Intel8086)(""" | word output @$c000 | void main () { | output = alot() @@ -392,7 +392,7 @@ class WordMathSuite extends FunSuite with Matchers with AppendedClues { } private def multiplyCase1(x: Int, y: Int): Unit = { - EmuCrossPlatformBenchmarkRun(Cpu.Sixteen, Cpu.Mos, Cpu.Z80)( + EmuCrossPlatformBenchmarkRun(Cpu.Sixteen, Cpu.Mos, Cpu.Z80, Cpu.Intel8086)( s""" | import zp_reg | word output @$$c000 @@ -427,7 +427,7 @@ class WordMathSuite extends FunSuite with Matchers with AppendedClues { } private def multiplyCase2(x: Int, y: Int): Unit = { - EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80)( + EmuCrossPlatformBenchmarkRun(Cpu.Mos, Cpu.Z80, Cpu.Intel8086)( s""" | import zp_reg | word output1 @$$c000 diff --git a/src/test/scala/millfork/test/Z80AssemblySuite.scala b/src/test/scala/millfork/test/Z80AssemblySuite.scala index ef5c7737..71b81414 100644 --- a/src/test/scala/millfork/test/Z80AssemblySuite.scala +++ b/src/test/scala/millfork/test/Z80AssemblySuite.scala @@ -1,6 +1,7 @@ package millfork.test -import millfork.test.emu.{EmuUnoptimizedIntel8080Run, EmuUnoptimizedSharpRun, EmuUnoptimizedZ80Run} +import millfork.Cpu +import millfork.test.emu.{EmuUnoptimizedCrossPlatformRun, EmuUnoptimizedIntel8080Run, EmuUnoptimizedSharpRun, EmuUnoptimizedZ80Run} import org.scalatest.{FunSuite, Matchers} /** @@ -274,8 +275,8 @@ class Z80AssemblySuite extends FunSuite with Matchers { | } """.stripMargin) } - test("Common I80 instructions (Intel syntax)") { - EmuUnoptimizedIntel8080Run( + test("Common I80 instructions (without RST, Intel syntax)") { + EmuUnoptimizedCrossPlatformRun(Cpu.Intel8080, Cpu.Intel8086)( """ | #pragma intel_syntax | asm void main () { @@ -491,7 +492,6 @@ class Z80AssemblySuite extends FunSuite with Matchers { | cnz main | push b | adi 1 - | rst 0 | | rz | ret @@ -499,7 +499,6 @@ class Z80AssemblySuite extends FunSuite with Matchers { | cz main | call main | aci 1 - | rst 1 | | rnc | pop d @@ -507,38 +506,32 @@ class Z80AssemblySuite extends FunSuite with Matchers { | cnc main | push d | sui 1 - | rst 2 | | rc | jc main | cc main | sbi 1 - | rst 3 | | pop h | xthl | push h | ani 1 - | rst 4 | | pchl | xri 1 - | rst 5 | | pop psw | di | push psw | ori 1 - | rst 6 | | sphl | ei | cpi 1 - | rst 7 | | ret | } - """.stripMargin) + """.stripMargin){ m => } } test("Intel 8080 instructions (Zilog syntax)") { @@ -571,7 +564,7 @@ class Z80AssemblySuite extends FunSuite with Matchers { } test("Intel 8080 instructions (Intel syntax)") { - EmuUnoptimizedIntel8080Run( + EmuUnoptimizedCrossPlatformRun(Cpu.Intel8080, Cpu.Intel8086)( """ | #pragma intel_syntax | asm void main () { @@ -596,6 +589,26 @@ class Z80AssemblySuite extends FunSuite with Matchers { | | ret | } + """.stripMargin){ m => } + } + + test("Intel 8080 RST instructions (Intel syntax)") { + EmuUnoptimizedIntel8080Run( + """ + | #pragma intel_syntax + | asm void main () { + | ret + | rst 0 + | rst 1 + | rst 2 + | rst 3 + | rst 4 + | rst 5 + | rst 6 + | rst 7 + | + | ret + | } """.stripMargin) } diff --git a/src/test/scala/millfork/test/emu/EmuBenchmarkRun.scala b/src/test/scala/millfork/test/emu/EmuBenchmarkRun.scala index 6e7244e2..b9abf7f1 100644 --- a/src/test/scala/millfork/test/emu/EmuBenchmarkRun.scala +++ b/src/test/scala/millfork/test/emu/EmuBenchmarkRun.scala @@ -106,6 +106,25 @@ object EmuSharpBenchmarkRun { } } +object EmuIntel8086BenchmarkRun { + def apply(source: String)(verifier: MemoryBank => Unit): Unit = { + val (Timings(t0, _), m0) = EmuUnoptimizedIntel8086Run.apply2(source) + val (Timings(t1, _), m1) = EmuOptimizedIntel8086Run.apply2(source) + val (Timings(t2, _), m2) = EmuOptimizedInlinedIntel8086Run.apply2(source) + println(f"Before optimization: $t0%7d") + println(f"After optimization: $t1%7d") + println(f"After inlining: $t2%7d") + println(f"Gain: ${(100L * (t0 - t1) / t0.toDouble).round}%7d%%") + println(f"Gain with inlining: ${(100L * (t0 - t2) / t0.toDouble).round}%7d%%") + println(f"Running 8086 unoptimized") + verifier(m0) + println(f"Running 8086 optimized") + verifier(m1) + println(f"Running 8086 optimized inlined") + verifier(m2) + } +} + object EmuCrossPlatformBenchmarkRun { def apply(platforms: millfork.Cpu.Value*)(source: String)(verifier: MemoryBank => Unit): Unit = { if (platforms.isEmpty) { @@ -123,7 +142,7 @@ object EmuCrossPlatformBenchmarkRun { if (platforms.contains(millfork.Cpu.Cmos)) { EmuCmosBenchmarkRun.apply(source)(verifier) } - if (platforms.contains(millfork.Cpu.Sixteen)) { + if (Settings.enableWdc85816Tests && platforms.contains(millfork.Cpu.Sixteen)) { EmuNative65816BenchmarkRun.apply(source)(verifier) } if (platforms.contains(millfork.Cpu.Z80)) { @@ -135,5 +154,8 @@ object EmuCrossPlatformBenchmarkRun { if (platforms.contains(millfork.Cpu.Sharp)) { EmuSharpBenchmarkRun.apply(source)(verifier) } + if (Settings.enableIntel8086Tests && platforms.contains(millfork.Cpu.Intel8086)) { + EmuIntel8086BenchmarkRun.apply(source)(verifier) + } } } diff --git a/src/test/scala/millfork/test/emu/EmuI86Run.scala b/src/test/scala/millfork/test/emu/EmuI86Run.scala new file mode 100644 index 00000000..b950265e --- /dev/null +++ b/src/test/scala/millfork/test/emu/EmuI86Run.scala @@ -0,0 +1,213 @@ +package millfork.test.emu + +import java.nio.charset.StandardCharsets +import java.nio.file.{Files, Paths} + +import com.codingrodent.microprocessor.Z80.Z80Core +import fastparse.core.Parsed.{Failure, Success} +import fr.neatmonster.ibmpc.{IBMCGA, Intel8086} +import javax.swing.SwingUtilities +import millfork._ +import millfork.assembly.AssemblyOptimization +import millfork.assembly.z80.ZLine +import millfork.compiler.z80.Z80Compiler +import millfork.compiler.{CompilationContext, LabelGenerator} +import millfork.env.{Environment, InitializedArray, InitializedMemoryVariable, NormalFunction} +import millfork.node.opt.NodeOptimization +import millfork.node.{Program, StandardCallGraph} +import millfork.output.{MemoryBank, Z80ToX86Crossassembler} +import millfork.parser.{PreprocessingResult, Preprocessor, Z80Parser} +import org.scalatest.Matchers + +import scala.collection.JavaConverters._ +import scala.collection.mutable + +/** + * @author Karol Stasiak + */ +object EmuI86Run { + + private def preload(filename: String): Option[Program] = { + TestErrorReporting.log.info(s"Loading $filename for Intel8086") + val source = Files.readAllLines(Paths.get(filename), StandardCharsets.US_ASCII).asScala.mkString("\n") + val options = CompilationOptions(EmuPlatform.get(millfork.Cpu.Intel8086), Map( + CompilationFlag.LenientTextEncoding -> true + ), None, 0, Map(), JobContext(TestErrorReporting.log, new LabelGenerator)) + val PreprocessingResult(preprocessedSource, features, _) = Preprocessor.preprocessForTest(options, source) + TestErrorReporting.log.debug(s"Features: $features") + TestErrorReporting.log.info(s"Parsing $filename") + val parser = Z80Parser(filename, preprocessedSource, "", options, features, useIntelSyntax = false) + parser.toAst match { + case Success(x, _) => Some(x) + case f: Failure[_, _] => + TestErrorReporting.log.error(f.toString) + TestErrorReporting.log.error(f.extra.toString) + TestErrorReporting.log.error(f.lastParser.toString) + TestErrorReporting.log.error("Syntax error", Some(parser.lastPosition)) + TestErrorReporting.log.error("Parsing error") + ??? + } + } + + private lazy val cache: mutable.Map[String, Option[Program]] = mutable.Map[String, Option[Program]]() + private def get(path: String): Program = + synchronized { cache.getOrElseUpdate(path, preload(path)).getOrElse(throw new IllegalStateException()) } + + def cachedMath(): Program = get("include/i80_math.mfk") // TODO + def cachedStdio(): Program = get("src/test/resources/include/dummy_stdio.mfk") +} + +class EmuI86Run(nodeOptimizations: List[NodeOptimization], assemblyOptimizations: List[AssemblyOptimization[ZLine]]) extends Matchers { + def inline: Boolean = false + + def optimizeForSize: Boolean = false + + private val TooManyCycles: Long = 1500000 + + def apply(source: String): MemoryBank = { + apply2(source)._2 + } + + def apply2(source: String): (Timings, MemoryBank) = { + if (!Settings.enableIntel8086Tests) return Timings(-1, -1) -> new MemoryBank() + Console.out.flush() + Console.err.flush() + val log = TestErrorReporting.log + println(source) + val platform = EmuPlatform.get(millfork.Cpu.Intel8086) + val extraFlags = Map( + CompilationFlag.EnableInternalTestSyntax -> true, + CompilationFlag.InlineFunctions -> this.inline, + CompilationFlag.OptimizeStdlib -> this.inline, + CompilationFlag.OptimizeForSize -> this.optimizeForSize, + CompilationFlag.SubroutineExtraction -> optimizeForSize, + CompilationFlag.LenientTextEncoding -> true) + val options = CompilationOptions(platform, millfork.Cpu.defaultFlags(millfork.Cpu.Intel8086).map(_ -> true).toMap ++ extraFlags, None, 0, Map(), JobContext(log, new LabelGenerator)) + log.hasErrors = false + log.verbosity = 999 + var effectiveSource = source + if (!source.contains("_panic")) effectiveSource += "\n void _panic(){while(true){}}" + log.setSource(Some(effectiveSource.lines.toIndexedSeq)) + val PreprocessingResult(preprocessedSource, features, pragmas) = Preprocessor.preprocessForTest(options, effectiveSource) + // tests use Intel syntax only when forced to: + val parserF = Z80Parser("", preprocessedSource, "", options, features, pragmas.contains("intel_syntax")) + parserF.toAst match { + case Success(unoptimized, _) => + log.assertNoErrors("Parse failed") + + + // prepare + val withLibraries = { + var tmp = unoptimized + tmp += EmuI86Run.cachedMath() + if (source.contains("import stdio")) { + tmp += EmuI86Run.cachedStdio() + } + tmp + } + val program = nodeOptimizations.foldLeft(withLibraries.applyImportantAliases)((p, opt) => p.applyNodeOptimization(opt, options)) + val callGraph = new StandardCallGraph(program, log) + val env = new Environment(None, "", CpuFamily.I80, options) + env.collectDeclarations(program, options) + + val hasOptimizations = assemblyOptimizations.nonEmpty + var unoptimizedSize = 0L + // print unoptimized asm + env.allPreallocatables.foreach { + case f: NormalFunction => + val unoptimized = Z80Compiler.compile(CompilationContext(f.environment, f, 0, options, Set())) + unoptimizedSize += unoptimized.map(_.sizeInBytes).sum + case d: InitializedArray => + unoptimizedSize += d.contents.length + case d: InitializedMemoryVariable => + unoptimizedSize += d.typ.size + } + + log.assertNoErrors("Compile failed") + + + // compile + val env2 = new Environment(None, "", CpuFamily.I80, options) + env2.collectDeclarations(program, options) + val assembler = new Z80ToX86Crossassembler(program, env2, platform) + val output = assembler.assemble(callGraph, assemblyOptimizations, options) + println(";;; compiled: -----------------") + output.asm.takeWhile(s => !(s.startsWith(".") && s.contains("= $"))).filterNot(_.contains("////; DISCARD_")).foreach(println) + println(";;; ---------------------------") + assembler.labelMap.foreach { case (l, addr) => println(f"$l%-15s $$$addr%04x") } + + val optimizedSize = assembler.mem.banks("default").initialized.count(identity).toLong + if (unoptimizedSize == optimizedSize) { + println(f"Size: $unoptimizedSize%5d B") + } else { + println(f"Unoptimized size: $unoptimizedSize%5d B") + println(f"Optimized size: $optimizedSize%5d B") + println(f"Gain: ${(100L * (unoptimizedSize - optimizedSize) / unoptimizedSize.toDouble).round}%5d%%") + } + + if (log.hasErrors) { + fail("Code generation failed") + } + + val memoryBank = assembler.mem.banks("default") + (0xff00 to 0xffff).foreach{i => + memoryBank.readable(i) = true + memoryBank.writeable(i) = true + } + + (0x100 until 0x2000).takeWhile(memoryBank.occupied(_)).map(memoryBank.output).grouped(16).map(_.map(i => f"$i%02x").mkString(" ")).foreach(log.debug(_)) + val resetN = source.contains("-'") && !options.flag(CompilationFlag.EmitExtended80Opcodes) + val resetNMethod = { + val clazz = classOf[Z80Core] + val method = clazz.getDeclaredMethod("resetN") + method.setAccessible(true) + method + } + val timings = { + val cpu = new Intel8086() + cpu.reset() + val memory = sniffField[Array[Int]](cpu, "memory") + 0x100.until(1<<16).foreach(i => memory(i) = memoryBank.output(i) & 0xff) + // far jmp 0:0 + "ea:0000:0000".filter(Character.isJavaIdentifierPart).grouped(2).zipWithIndex.foreach{case (c, ix) => memory(0xFFFF0+ix) = Integer.parseInt(c, 16)} + // xor ax,ax / mov ds,ax / mov ss,ax / mov sp,0xfffe / near call 0x0100 / hlt + "31c0/8ed8/8ed0/bc:feff/e8:f400/f4".filter(Character.isJavaIdentifierPart).grouped(2).zipWithIndex.foreach{case (c, ix) => memory(ix) = Integer.parseInt(c, 16)} + var clocks = 0L + do { +// print(f"CS:IP=${sniffField[Int](cpu, "cs")}%04x:${sniffField[Int](cpu, "ip")}%04x") +// print(f" AX=${sniffField[Int](cpu, "ah")}%02x${sniffField[Int](cpu, "al")}%02x") +// print(f" BX=${sniffField[Int](cpu, "bh")}%02x${sniffField[Int](cpu, "bl")}%02x") +// print(f" CX=${sniffField[Int](cpu, "ch")}%02x${sniffField[Int](cpu, "cl")}%02x") +// print(f" DX=${sniffField[Int](cpu, "dh")}%02x${sniffField[Int](cpu, "dl")}%02x") +// println() + clocks = sniffField[Long](cpu, "clocks") + } while(clocks < 100000 && sniffMethod[Boolean](cpu, "tick")) + SwingUtilities.getWindowAncestor(sniffField[IBMCGA](cpu, "cga")).setVisible(false) + if (clocks >= 100000) throw new RuntimeException("Timeout") + 0x100.until(1<<16).foreach(i => memoryBank.output(i) = memory(i).toByte) + Timings(-1, -1) -> memoryBank + } + log.clearErrors() + timings + case f: Failure[_, _] => + println(f) + println(f.extra.toString) + println(f.lastParser.toString) + log.error("Syntax error", Some(parserF.lastPosition)) + fail("Parsing error") + } + } + + def sniffField[T](intel8086: Intel8086, fieldName: String): T = { + val f = intel8086.getClass.getDeclaredField(fieldName) + f.setAccessible(true) + f.get(intel8086).asInstanceOf[T] + } + + def sniffMethod[T](intel8086: Intel8086, fieldName: String): T = { + val m = intel8086.getClass.getDeclaredMethod(fieldName) + m.setAccessible(true) + m.invoke(intel8086).asInstanceOf[T] + } + +} diff --git a/src/test/scala/millfork/test/emu/EmuOptimizedInlinedRun.scala b/src/test/scala/millfork/test/emu/EmuOptimizedInlinedRun.scala index 308fb10b..130b1747 100644 --- a/src/test/scala/millfork/test/emu/EmuOptimizedInlinedRun.scala +++ b/src/test/scala/millfork/test/emu/EmuOptimizedInlinedRun.scala @@ -41,6 +41,10 @@ object EmuOptimizedInlinedIntel8080Run extends EmuZ80Run(Cpu.Intel8080, Optimiza override def inline: Boolean = true } +object EmuOptimizedInlinedIntel8086Run extends EmuI86Run(OptimizationPresets.NodeOpt, Z80OptimizationPresets.GoodForIntel8080) { + override def inline: Boolean = true +} + object EmuOptimizedInlinedSharpRun extends EmuZ80Run(Cpu.Sharp, OptimizationPresets.NodeOpt, Z80OptimizationPresets.GoodForSharp) { override def inline: Boolean = true } diff --git a/src/test/scala/millfork/test/emu/EmuOptimizedRun.scala b/src/test/scala/millfork/test/emu/EmuOptimizedRun.scala index 54ef5867..b05dfe05 100644 --- a/src/test/scala/millfork/test/emu/EmuOptimizedRun.scala +++ b/src/test/scala/millfork/test/emu/EmuOptimizedRun.scala @@ -71,6 +71,8 @@ object EmuSizeOptimizedZ80Run extends EmuZ80Run(Cpu.Z80, OptimizationPresets.Nod object EmuOptimizedIntel8080Run extends EmuZ80Run(Cpu.Intel8080, OptimizationPresets.NodeOpt, Z80OptimizationPresets.GoodForIntel8080) +object EmuOptimizedIntel8086Run extends EmuI86Run(OptimizationPresets.NodeOpt, Z80OptimizationPresets.GoodForIntel8080) + object EmuSizeOptimizedIntel8080Run extends EmuZ80Run(Cpu.Intel8080, OptimizationPresets.NodeOpt, Z80OptimizationPresets.GoodForIntel8080) { override def optimizeForSize = true } diff --git a/src/test/scala/millfork/test/emu/EmuPlatform.scala b/src/test/scala/millfork/test/emu/EmuPlatform.scala index 7708056e..925b6211 100644 --- a/src/test/scala/millfork/test/emu/EmuPlatform.scala +++ b/src/test/scala/millfork/test/emu/EmuPlatform.scala @@ -18,7 +18,7 @@ object EmuPlatform { TextCodec.Ascii, Platform.builtInCpuFeatures(cpu), CurrentBankFragmentOutput(0, 0xffff), - Map("default" -> new UpwardByteAllocator(0x200, 0xb000)), + Map("default" -> (if (cpu == Cpu.Intel8086) new UpwardByteAllocator(0x100, 0xb000) else new UpwardByteAllocator(0x200, 0xb000))), Map("default" -> new VariableAllocator( if (CpuFamily.forType(cpu) == CpuFamily.M6502) pointers else Nil, new AfterCodeByteAllocator(0xff00))), diff --git a/src/test/scala/millfork/test/emu/EmuUnoptimizedCrossPlatformRun.scala b/src/test/scala/millfork/test/emu/EmuUnoptimizedCrossPlatformRun.scala index f989f8cd..fed21909 100644 --- a/src/test/scala/millfork/test/emu/EmuUnoptimizedCrossPlatformRun.scala +++ b/src/test/scala/millfork/test/emu/EmuUnoptimizedCrossPlatformRun.scala @@ -14,6 +14,7 @@ object EmuUnoptimizedCrossPlatformRun { val (_, mz) = if (platforms.contains(Cpu.Z80)) EmuUnoptimizedZ80Run.apply2(source) else Timings(-1, -1) -> null val (_, mi) = if (platforms.contains(Cpu.Intel8080)) EmuUnoptimizedIntel8080Run.apply2(source) else Timings(-1, -1) -> null val (_, ms) = if (platforms.contains(Cpu.Sharp)) EmuUnoptimizedSharpRun.apply2(source) else Timings(-1, -1) -> null + val (_, mx) = if (Settings.enableIntel8086Tests && platforms.contains(Cpu.Intel8086)) EmuUnoptimizedIntel8086Run.apply2(source) else Timings(-1, -1) -> null if (platforms.contains(Cpu.Mos)) { println(f"Running 6502") verifier(mm) @@ -38,5 +39,9 @@ object EmuUnoptimizedCrossPlatformRun { println(f"Running LR35902") verifier(ms) } + if (Settings.enableIntel8086Tests && platforms.contains(Cpu.Intel8086)) { + println(f"Running 8086") + verifier(mx) + } } } diff --git a/src/test/scala/millfork/test/emu/EmuUnoptimizedRun.scala b/src/test/scala/millfork/test/emu/EmuUnoptimizedRun.scala index 20b5e7d4..778307da 100644 --- a/src/test/scala/millfork/test/emu/EmuUnoptimizedRun.scala +++ b/src/test/scala/millfork/test/emu/EmuUnoptimizedRun.scala @@ -20,4 +20,6 @@ object EmuUnoptimizedZ80Run extends EmuZ80Run(Cpu.Z80, Nil, Nil) object EmuUnoptimizedIntel8080Run extends EmuZ80Run(Cpu.Intel8080, Nil, Nil) +object EmuUnoptimizedIntel8086Run extends EmuI86Run(Nil, Nil) + object EmuUnoptimizedSharpRun extends EmuZ80Run(Cpu.Sharp, Nil, Nil) diff --git a/src/test/scala/millfork/test/emu/Settings.scala b/src/test/scala/millfork/test/emu/Settings.scala new file mode 100644 index 00000000..532f70ba --- /dev/null +++ b/src/test/scala/millfork/test/emu/Settings.scala @@ -0,0 +1,30 @@ +package millfork.test.emu + +/** + * @author Karol Stasiak + */ +object Settings { + + /** + * Should the Intel 8086 tests be enabled? + * Intel 8086 tests: + * - are slow + * - don't work on headless JRE's + * – open annoying windows on graphical JRE's + * – test only the 8080-to-8086 translation + * – are of low priority + * so they are disabled by default + */ + val enableIntel8086Tests: Boolean = false + + /** + * Should the WDC65816 tests be enabled? + * WDC65816 tests: + * - are slow + * - require Nashorn + * – are of low priority + * so they are disabled by default + */ + val enableWdc85816Tests: Boolean = false + +}