summaryrefslogtreecommitdiff
path: root/Q1.tests/Core/InstructionEncodingTests.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Q1.tests/Core/InstructionEncodingTests.cs')
-rw-r--r--Q1.tests/Core/InstructionEncodingTests.cs28
1 files changed, 28 insertions, 0 deletions
diff --git a/Q1.tests/Core/InstructionEncodingTests.cs b/Q1.tests/Core/InstructionEncodingTests.cs
new file mode 100644
index 0000000..7bb653f
--- /dev/null
+++ b/Q1.tests/Core/InstructionEncodingTests.cs
@@ -0,0 +1,28 @@
+namespace Q1.tests.Core;
+
+using core.Arch;
+
+[TestFixture]
+public class InstructionEncodingTests
+{
+ [Test]
+ public void EncodeDecode_ShouldRoundTrip()
+ {
+ u8 opcode = 0x01;
+ u8 m1 = 0x5;
+ u8 m2 = 0xC;
+ bool word = true;
+
+ u16 instruction = InstructionEncoding.Encode(opcode, m1, m2, word);
+
+ InstructionEncoding.Decode(instruction, out var op2, out var m1_2, out var m2_2, out var word2);
+
+ Assert.Multiple(() =>
+ {
+ Assert.That(op2, Is.EqualTo(opcode));
+ Assert.That(m1_2, Is.EqualTo(m1));
+ Assert.That(m2_2, Is.EqualTo(m2));
+ Assert.That(word2, Is.EqualTo(word));
+ });
+ }
+} \ No newline at end of file