Beispiel #1
0
 public void EncodeOpCodeWithSource()
 {
     var op = new MaskedOpCode(OpCode.Add).SetSource(OpCodeFlag.Constant);
     Assert.That(op.OpCode, Is.EqualTo(OpCode.Add));
     Assert.That(op.Signed, Is.False);
     Assert.That(op.Source, Is.EqualTo(OpCodeFlag.Constant));
     Assert.That(op.Destination, Is.EqualTo(OpCodeFlag.None));
 }
Beispiel #2
0
        public static MaskedOpCode AsSigned(this MaskedOpCode opCode)
        {
            var code = (ushort)opCode;

            code |= 0x8000;

            return(new MaskedOpCode(code));
        }
Beispiel #3
0
        public void EncodeOpCodeWithDestination()
        {
            var op = new MaskedOpCode(OpCode.Add).SetDest(OpCodeFlag.MemoryAddress);
            Assert.That(op.OpCode, Is.EqualTo(OpCode.Add));
            Assert.That(op.Signed, Is.False);

            Assert.That(op.Destination, Is.EqualTo(OpCodeFlag.MemoryAddress));
        }
Beispiel #4
0
        public static MaskedOpCode SetSource(this MaskedOpCode opCode, OpCodeFlag sourceFlag)
        {
            var code = (ushort)opCode;

            code &= 0xf3ff;
            var result = code | ((ushort)sourceFlag << 10);

            return((MaskedOpCode)result);
        }
Beispiel #5
0
        public void EncodeOpCodeWithSourceAsString()
        {
            var op = new MaskedOpCode(OpCode.Add).SetDest(OpCodeFlag.MemoryAddress).SetSource(OpCodeFlag.Constant);
            Assert.That(op.ToString(), Is.EqualTo("Add [rX] 0x0"));

            op = op.SetSource(OpCodeFlag.Register);
            Assert.That(op.ToString(), Is.EqualTo("Add [rX] rX"));

            op = op.SetSource(OpCodeFlag.MemoryAddress);
            Assert.That(op.ToString(), Is.EqualTo("Add [rX] [rX]"));
        }
Beispiel #6
0
        public static MaskedOpCode SetDest(this MaskedOpCode opCode, OpCodeFlag destFlag)
        {
            if (destFlag == OpCodeFlag.Constant)
            {
                throw new InvalidOperationException("Cannot set constant as destination vector");
            }

            var code = (ushort)opCode;

            code &= 0xfcff;
            var result = code | ((ushort)destFlag << 8);

            return((MaskedOpCode )result);
        }
Beispiel #7
0
 public void EncodeOpCodeAsString()
 {
     var op = new MaskedOpCode(OpCode.Add);
     Assert.That(op.ToString(), Is.EqualTo("Add"));
 }
Beispiel #8
0
 public void EncodeOpCodeAsSigned()
 {
     var op = new MaskedOpCode(OpCode.Add).AsSigned();
     Assert.That(op.OpCode, Is.EqualTo(OpCode.Add));
     Assert.That(op.Signed, Is.True);
 }
Beispiel #9
0
 public void EncodeOpCode()
 {
     var op = new MaskedOpCode(OpCode.Add);
     Assert.That(op.OpCode, Is.EqualTo(OpCode.Add));
     Assert.That(op.Signed, Is.False);
 }
Beispiel #10
0
 public Instruction(OpCode opCode, string commment = null)
     : this()
 {
     MaskedOpCode = new MaskedOpCode(opCode);
     Comment = commment;
 }
Beispiel #11
0
 public Instruction(OpCode opCode, string commment = null) : this()
 {
     MaskedOpCode = new MaskedOpCode(opCode);
     Comment      = commment;
 }