Last active
April 26, 2025 09:59
-
-
Save azolotko/ef32811f8154476067f751bbbd6d8f41 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package td4 | |
| import weaver.SimpleIOSuite | |
| import cats.syntax.applicative.* | |
| import cats.syntax.flatMap.* | |
| import td4.free.* | |
| import td4.Register.* | |
| object TD4Suite extends SimpleIOSuite: | |
| pureTest("compiler"): | |
| val program: Asm = | |
| mov(A, 15: Byte) >> | |
| block { loop => | |
| mov(B, A) >> | |
| out(B) >> | |
| add(A, nibble(-1)) >> | |
| jz(loop.exit) >> | |
| jmp(loop.entry) >> | |
| mov(A, 0: Byte).replicateA_(8) | |
| } >> | |
| mov(B, A) >> | |
| out(B) | |
| val compiled = compile(program) | |
| val expected = cats.data.Chain(63, 64, -112, 15, -18, -15, 48, 48, 48, 48, 48, 48, 48, 48, 64, -112) | |
| expect(compiled == expected) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment