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.IsMemoryAddress && context.Operand1.IsRegister)
            {
                Operand destination = context.Result;

                if (IsBetween(destination.Offset.ToInt32(), 0, 60))
                {
                    emitter.EmitTwoRegistersWithK4((byte)destination.Base.RegisterCode, (byte)context.Operand1.Register.RegisterCode, (sbyte)destination.Offset.ToInt32());
                }
                else if (IsBetween(destination.Offset.ToInt32(), -32768, 32767))
                {
                    emitter.EmitTwoRegistersAndK16(0x14, (byte)destination.Base.RegisterCode, (byte)context.Operand1.Register.RegisterCode, (short)destination.Offset.ToInt32());
                }
                else
                    throw new OverflowException();
            }
            else
                throw new Exception("Not supported combination of operands");
        }