AsmResolver.X86.X86Assembler.Write C# (CSharp) Метод

Write() публичный Метод

Writes an instruction to the output stream.
public Write ( X86Instruction instruction ) : void
instruction X86Instruction The instruction to write.
Результат void
        public void Write(X86Instruction instruction)
        {
            var opcode = instruction.OpCode;
            WriteOpCode(opcode);

            var mnemonicIndex = Array.IndexOf(opcode.Mnemonics, instruction.Mnemonic);
            if (mnemonicIndex == -1)
                throw new ArgumentException("Instruction's mnemonic is not supported by its opcode.");

            if (opcode.HasRegisterToken)
            {
                var token = (byte)(ComputeRegisterTokenPart(opcode.OperandTypes1[mnemonicIndex],
                                        opcode.OperandSizes1[mnemonicIndex], instruction.Operand1) |
                                   ComputeRegisterTokenPart(opcode.OperandTypes2[mnemonicIndex],
                                       opcode.OperandSizes2[mnemonicIndex], instruction.Operand2));

                if (opcode.HasOpCodeModifier)
                {
                    token |= (byte)(mnemonicIndex << 3);
                }

                _writer.WriteByte(token);
            }

            if (instruction.Operand1 != null)
            {
                WriteOperand(opcode.OperandTypes1[mnemonicIndex],
                    opcode.OperandSizes1[mnemonicIndex], instruction.Operand1);
                if (instruction.Operand2 != null)
                {
                    WriteOperand(opcode.OperandTypes2[mnemonicIndex],
                        opcode.OperandSizes2[mnemonicIndex], instruction.Operand2);
                }
            }
        }

Usage Example

Пример #1
0
        public override void Write(WritingContext context)
        {
            var assembler = new X86Assembler(context.Writer);

            foreach (var instruction in Instructions)
            {
                assembler.Write(instruction);
            }
        }
All Usage Examples Of AsmResolver.X86.X86Assembler::Write