예제 #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));
 }
예제 #2
0
        public static MaskedOpCode AsSigned(this MaskedOpCode opCode)
        {
            var code = (ushort)opCode;

            code |= 0x8000;

            return(new MaskedOpCode(code));
        }
예제 #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));
        }
예제 #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);
        }
예제 #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]"));
        }
예제 #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);
        }
예제 #7
0
 public void EncodeOpCodeAsString()
 {
     var op = new MaskedOpCode(OpCode.Add);
     Assert.That(op.ToString(), Is.EqualTo("Add"));
 }
예제 #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);
 }
예제 #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);
 }
예제 #10
0
 public Instruction(OpCode opCode, string commment = null)
     : this()
 {
     MaskedOpCode = new MaskedOpCode(opCode);
     Comment = commment;
 }
예제 #11
0
 public Instruction(OpCode opCode, string commment = null) : this()
 {
     MaskedOpCode = new MaskedOpCode(opCode);
     Comment      = commment;
 }