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)); }
public static MaskedOpCode AsSigned(this MaskedOpCode opCode) { var code = (ushort)opCode; code |= 0x8000; return(new MaskedOpCode(code)); }
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)); }
public static MaskedOpCode SetSource(this MaskedOpCode opCode, OpCodeFlag sourceFlag) { var code = (ushort)opCode; code &= 0xf3ff; var result = code | ((ushort)sourceFlag << 10); return((MaskedOpCode)result); }
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]")); }
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); }
public void EncodeOpCodeAsString() { var op = new MaskedOpCode(OpCode.Add); Assert.That(op.ToString(), Is.EqualTo("Add")); }
public void EncodeOpCodeAsSigned() { var op = new MaskedOpCode(OpCode.Add).AsSigned(); Assert.That(op.OpCode, Is.EqualTo(OpCode.Add)); Assert.That(op.Signed, Is.True); }
public void EncodeOpCode() { var op = new MaskedOpCode(OpCode.Add); Assert.That(op.OpCode, Is.EqualTo(OpCode.Add)); Assert.That(op.Signed, Is.False); }
public Instruction(OpCode opCode, string commment = null) : this() { MaskedOpCode = new MaskedOpCode(opCode); Comment = commment; }