Mosa.Compiler.Framework.InstructionNode.GetOperand C# (CSharp) Method

GetOperand() public method

Gets the operand by index.
public GetOperand ( int opIndex ) : Operand
opIndex int The index.
return Operand
        public Operand GetOperand(int opIndex)
        {
            switch (opIndex)
            {
                case 0: return Operand1;
                case 1: return Operand2;
                case 2: return Operand3;
                default: return GetAdditionalOperand(opIndex);
            }
        }

Usage Example

Esempio n. 1
0
        private static void CmpXchg(InstructionNode node, MachineCodeEmitter emitter)
        {
            Debug.Assert(node.Result.IsRegister);
            Debug.Assert(node.Operand1.IsRegister);
            Debug.Assert(node.Operand2.IsRegister);
            Debug.Assert(node.GetOperand(3).IsRegister);
            Debug.Assert(node.Result.Register == GeneralPurposeRegister.EAX);
            Debug.Assert(node.Operand1.Register == GeneralPurposeRegister.EAX);
            Debug.Assert(node.ResultCount == 1);

            var linkreference = node.Operand2.IsLabel || node.Operand2.IsField || node.Operand2.IsSymbol;

            // Compare EAX with r/m32. If equal, ZF is set and r32 is loaded into r/m32.
            // Else, clear ZF and load r/m32 into EAX.

            // memory, register 0000 1111 : 1011 000w : mod reg r/m
            var opcode = new OpcodeEncoder()
                .AppendConditionalPrefix(0x66, node.Size == InstructionSize.Size16)  // 8:prefix: 16bit
                .AppendNibble(Bits.b0000)                                       // 4:opcode
                .AppendNibble(Bits.b1111)                                       // 4:opcode
                .AppendNibble(Bits.b1011)                                       // 4:opcode
                .Append3Bits(Bits.b000)                                         // 3:opcode
                .AppendWidthBit(node.Size != InstructionSize.Size8)             // 1:width
                .ModRegRMSIBDisplacement(node.GetOperand(3), node.Operand2, node.Operand3) // Mod-Reg-RM-?SIB-?Displacement
                .AppendConditionalIntegerValue(0, linkreference);               // 32:memory

            if (linkreference)
                emitter.Emit(opcode, node.Operand1, (opcode.Size - 32) / 8);
            else
                emitter.Emit(opcode);
        }
All Usage Examples Of Mosa.Compiler.Framework.InstructionNode::GetOperand