Esempio n. 1
0
            internal override void WriteTo(BinaryWriter writer, IAssemblingContext context)
            {
                uint value = 0;

                foreach (ImageSection section in m_sections)
                {
                    if (Match(section))
                    {
                        value = value == 0
                                      ? context.GetRelativeMemoryAddress(section)
                                      : Math.Min(value, context.GetRelativeMemoryAddress(section));
                    }
                }

                writer.Write(value);
            }
            internal override void WriteTo(BinaryWriter writer, IAssemblingContext context)
            {
                UInt32 jmpAddress = context.GetRelativeMemoryAddress(this);
                UInt32 refAddress = context.GetRelativeMemoryAddress(m_offsetElement);

                int diff = (int)(refAddress - jmpAddress) + m_offsetValue;

                if (diff >= -126 && diff <= 129)
                {
                    writer.Write(m_opcode);
                    writer.Write((SByte)(diff - 2));
                }
                else
                {
                    throw new Exception("Invalid loop range");
                }
            }
            internal override void WriteTo(BinaryWriter writer, IAssemblingContext context)
            {
                UInt32 jmpAddress = context.GetRelativeMemoryAddress(this);
                UInt32 refAddress = context.GetRelativeMemoryAddress(m_offsetElement);

                int diff = (int)(refAddress - jmpAddress) + m_offsetValue;

                if (diff >= -126 && diff <= 129)
                {
                    writer.Write((Byte)0xeb);
                    writer.Write((SByte)(diff - 2));
                }
                else
                {
                    writer.Write((Byte)0xe9);
                    writer.Write((Int32)(diff - 5));
                }
            }
 internal override void WriteTo(BinaryWriter writer, IAssemblingContext context)
 {
     if (m_target != null)
     {
         writer.Write(context.GetRelativeMemoryAddress(m_target));
     }
     else
     {
         writer.Write((UInt32)0);
     }
 }
 internal override void WriteTo(BinaryWriter writer, IAssemblingContext context)
 {
     if (m_target != null)
     {
         context.GetPointerSize().WriteTo(writer, context.GetRelativeMemoryAddress(m_target));
     }
     else
     {
         context.GetPointerSize().WriteTo(writer, 0);
     }
 }
            internal override uint ComputeSize(IAssemblingContext context)
            {
                if (!context.IsPositioned(this) || !context.IsPositioned(m_offsetElement))
                {
                    return(5);
                }

                UInt32 jmpAddress = context.GetRelativeMemoryAddress(this);
                UInt32 refAddress = context.GetRelativeMemoryAddress(m_offsetElement);

                int diff = (int)(refAddress - jmpAddress) + m_offsetValue;

                if (diff >= -126 && diff <= 129)
                {
                    return(2);
                }
                else
                {
                    return(5);
                }
            }
Esempio n. 7
0
        internal override uint ComputeMemorySize(IAssemblingContext context)
        {
            uint modulo = context.GetRelativeMemoryAddress(this) % m_memoryAlignment;

            return(modulo == 0 ? 0 : m_memoryAlignment - modulo);
        }