Example #1
0
        public void Emit(OpCode opCode, IArgument a, IArgument b)
        {
            AssertNotFinished();
            if (!opCode.IsBasic)
                throw new ArgumentException("Non-basic OpCodes cannot have 2 arguments.", "opCode");

            ushort? aNextWord;
            ushort? bNextWord;

            int nextWordPosition = CurrentBytePosition + 2;
            ushort aValue = GetArgumentValue(a, nextWordPosition, out aNextWord);

            if (aNextWord != null)
                nextWordPosition += 2;

            ushort bValue = GetArgumentValue(b, nextWordPosition, out bNextWord);

            ushort instruction = (ushort)(opCode.Code | (aValue << 4) | (bValue << 10));
            WriteWord(stream, instruction);

            if (aNextWord != null)
                WriteWord(stream, aNextWord.Value);
            if (bNextWord != null)
                WriteWord(stream, bNextWord.Value);
        }
Example #2
0
 public bool Equals(OpCode opCode)
 {
     return this.code == opCode.code;
 }
Example #3
0
        public void Emit(OpCode opCode, IArgument a)
        {
            AssertNotFinished();
            if (opCode.IsBasic)
                throw new ArgumentException("Basic OpCodes cannot have only 1 argument.", "opCode");

            ushort? aNextWord;
            int nextWordPosition = CurrentBytePosition + 2;
            ushort aValue = GetArgumentValue(a, nextWordPosition, out aNextWord);

            ushort instruction = (ushort)(opCode.Code | aValue << 10);
            WriteWord(stream, instruction);

            if (aNextWord != null)
                WriteWord(stream, aNextWord.Value);
        }