Ejemplo n.º 1
0
        /// <summary>
        /// Emits the specified platform instruction.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <param name="emitter">The emitter.</param>
        protected override void Emit(Context context, MachineCodeEmitter emitter)
        {
            if (context.Result.IsRegister && context.Operand1.IsMemoryAddress)
            {
                int displacement = context.Operand1.Offset.ToInt32();

                if (IsBetween(displacement, 0, 124))
                {
                    emitter.EmitDisplacementLoadWithK5Immediate((byte)context.Result.Register.RegisterCode, (sbyte)displacement, (byte)context.Operand1.Base.RegisterCode);
                }
                else
                    if (IsBetween(displacement, -32768, 32767))
                    {
                        emitter.EmitTwoRegistersAndK16(0x0F, (byte)context.Operand1.Base.RegisterCode, (byte)context.Result.Register.RegisterCode, (short)displacement);
                    }
                    else
                        throw new OverflowException();
            }
            else
                throw new Exception("Not supported combination of operands");
        }