Esempio n. 1
0
        /// <summary>
        /// Emits the specified platform instruction.
        /// </summary>
        /// <param name="node">The node.</param>
        /// <param name="emitter">The emitter.</param>
        /// <exception cref="System.InvalidOperationException">@unable to emit opcode for segment register</exception>
        internal override void EmitLegacy(InstructionNode node, X86CodeEmitter emitter)
        {
            if (node.Result.IsCPURegister)
            {
                if (node.Result.Register is SegmentRegister)
                {
                    switch ((node.Result.Register as SegmentRegister).Segment)
                    {
                    case SegmentRegister.SegmentType.DS: emitter.Emit(POP_DS); return;

                    case SegmentRegister.SegmentType.ES: emitter.Emit(POP_ES); return;

                    case SegmentRegister.SegmentType.FS: emitter.Emit(POP_FS); return;

                    case SegmentRegister.SegmentType.GS: emitter.Emit(POP_GS); return;

                    case SegmentRegister.SegmentType.SS: emitter.Emit(POP_SS); return;

                    default: throw new InvalidOperationException(@"unable to emit opcode for segment register");
                    }
                }
                else
                {
                    emitter.WriteByte((byte)(0x58 + node.Result.Register.RegisterCode));
                }
            }
            else
            {
                emitter.Emit(POP, node.Result);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Emits the specified platform instruction.
        /// </summary>
        /// <param name="node">The node.</param>
        /// <param name="emitter">The emitter.</param>
        internal override void EmitLegacy(InstructionNode node, X86CodeEmitter emitter)
        {
            if (node.OperandCount == 0)
            {
                emitter.EmitRelativeBranch(CALL, node.BranchTargets[0].Label);
                return;
            }

            if (node.Operand1.IsSymbol)
            {
                emitter.WriteByte(0xE8);
                emitter.EmitCallSite(node.Operand1);
            }
            else
            {
                emitter.Emit(RegCall, node.Operand1);
            }
        }
Esempio n. 3
0
 /// <summary>
 /// Emits the specified platform instruction.
 /// </summary>
 /// <param name="node">The node.</param>
 /// <param name="emitter">The emitter.</param>
 internal override void EmitLegacy(InstructionNode node, X86CodeEmitter emitter)
 {
     if (node.Operand1 == null)
     {
         emitter.EmitRelativeBranch(JMP, node.BranchTargets[0].Label);
     }
     else
     {
         if (node.Operand1.IsSymbol)
         {
             emitter.WriteByte(0xE9);
             emitter.EmitCallSite(node.Operand1);
         }
         else if (node.Operand1.IsCPURegister)
         {
             emitter.Emit(JMP_R, node.Operand1);
         }
     }
 }
Esempio n. 4
0
 /// <summary>
 /// Emits the specified platform instruction.
 /// </summary>
 /// <param name="ctx">The context.</param>
 /// <param name="emitter">The emitter.</param>
 internal override void EmitLegacy(InstructionNode node, X86CodeEmitter emitter)
 {
     emitter.WriteByte(0xF0);
 }
Esempio n. 5
0
 /// <summary>
 /// Emits the specified platform instruction.
 /// </summary>
 /// <param name="node">The node.</param>
 /// <param name="emitter">The emitter.</param>
 internal override void EmitLegacy(InstructionNode node, X86CodeEmitter emitter)
 {
     emitter.WriteByte(0xCD);
     emitter.WriteByte((byte)node.Operand1.ConstantUnsignedInteger);
 }