This class represents an x86 32-bit register
상속: Register
예제 #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Memory"/> class.
        /// </summary>
        /// <param name="segment">The segment.</param>
        /// <param name="_base">The _base.</param>
        /// <param name="index">The index.</param>
        /// <param name="scale">The scale.</param>
        public Memory(SegType segment, R32Type _base, R32Type index, byte scale)
        {
            this.segment = segment;
            this._base   = _base;
            this.index   = index;
            this.scale   = scale;

            Check32Values();
        }
예제 #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Memory"/> class.
        /// </summary>
        /// <param name="segment">The segment.</param>
        /// <param name="_base">The _base.</param>
        /// <param name="index">The index.</param>
        /// <param name="scale">The scale.</param>
        /// <param name="displacement">The displacement.</param>
        public Memory(SegType segment, R32Type _base, R32Type index, byte scale, Int32 displacement)
        {
            this.segment      = segment;
            this._base        = _base;
            this.index        = index;
            this.scale        = scale;
            this.Displacement = displacement;

            Check32Values();
        }
예제 #3
0
파일: IR.cs 프로젝트: sharpos/SharpOS
		/// <summary>
		/// Utility used to implement null reference checking for the 'ldfld' family of instructions
		/// as well as for the implementation of 'call' for non-static methods. The method will
		/// encode a call to the runtime's null reference handler (marked with
		/// SharpOS.AOT.Attributes.NullReferenceHandlerAttribute), which is executed if the value
		/// in the 32-bit x86 register <paramref name="reg" /> is zero (null).
		/// </summary>
		private void NullCheck (R32Type reg)
		{
			string okLabel = this.assembly.GetCMPLabel;

			this.assembly.CMP (reg, 0);
			this.assembly.JNE (okLabel);
			this.assembly.CALL (this.assembly.Engine.NullReferenceHandler.AssemblyLabel);

			this.assembly.LABEL (okLabel);
		}
예제 #4
0
파일: Asm.cs 프로젝트: sharpos/SharpOS
		/// <summary>
		/// SUB mem32,reg32
		/// </summary>
		public static void SUB (DWordMemory target, R32Type source)
		{
		}
예제 #5
0
파일: Asm.cs 프로젝트: sharpos/SharpOS
		/// <summary>
		/// SHRD rmreg32,reg32,CL
		/// </summary>
		public static void SHRD___CL (R32Type target, R32Type source)
		{
		}
예제 #6
0
파일: Asm.cs 프로젝트: sharpos/SharpOS
		/// <summary>
		/// SHRD mem32,reg32,CL
		/// </summary>
		public unsafe static void SHRD___CL (UInt32* target, R32Type source)
		{
		}
예제 #7
0
파일: Asm.cs 프로젝트: sharpos/SharpOS
		/// <summary>
		/// SHRD mem32,reg32,imm8
		/// </summary>
		public unsafe static void SHRD (UInt32* target, R32Type source, Byte value)
		{
		}
예제 #8
0
파일: Asm.cs 프로젝트: sharpos/SharpOS
		/// <summary>
		/// MOVZX reg32,mem16
		/// </summary>
		public unsafe static void MOVZX (R32Type target, UInt16* source)
		{
		}
예제 #9
0
파일: Asm.cs 프로젝트: sharpos/SharpOS
		/// <summary>
		/// BOUND reg32,mem
		/// </summary>
		public static void BOUND (R32Type target, Memory source)
		{
		}
예제 #10
0
파일: Asm.cs 프로젝트: sharpos/SharpOS
		/// <summary>
		/// POP reg32
		/// </summary>
		public static void POP (R32Type target)
		{
		}
예제 #11
0
파일: Asm.cs 프로젝트: sharpos/SharpOS
		/// <summary>
		/// NOT rmreg32
		/// </summary>
		public static void NOT (R32Type target)
		{
		}
예제 #12
0
파일: Asm.cs 프로젝트: sharpos/SharpOS
		/// <summary>
		/// NEG rmreg32
		/// </summary>
		public static void NEG (R32Type target)
		{
		}
예제 #13
0
파일: Asm.cs 프로젝트: sharpos/SharpOS
		/// <summary>
		/// MUL rmreg32
		/// </summary>
		public static void MUL (R32Type target)
		{
		}
예제 #14
0
파일: Asm.cs 프로젝트: sharpos/SharpOS
		/// <summary>
		/// MOVZX reg32,rmreg16
		/// </summary>
		public static void MOVZX (R32Type target, R16Type source)
		{
		}
예제 #15
0
 /// <summary>
 /// Initializes a new instance of the <see cref="QWordMemory"/> class.
 /// </summary>
 /// <param name="segment">The segment.</param>
 /// <param name="_base">The _base.</param>
 /// <param name="index">The index.</param>
 /// <param name="scale">The scale.</param>
 /// <param name="displacement">The displacement.</param>
 public QWordMemory(SegType segment, R32Type _base, R32Type index, byte scale, Int32 displacement)
     : base(segment, _base, index, scale, displacement)
 {
 }
예제 #16
0
		/// <summary>
		/// Initializes a new instance of the <see cref="QWordMemory"/> class.
		/// </summary>
		/// <param name="segment">The segment.</param>
		/// <param name="_base">The _base.</param>
		/// <param name="index">The index.</param>
		/// <param name="scale">The scale.</param>
		/// <param name="displacement">The displacement.</param>
		public QWordMemory (SegType segment, R32Type _base, R32Type index, byte scale, Int32 displacement)
			: base (segment, _base, index, scale, displacement)
		{
		}
예제 #17
0
파일: Asm.cs 프로젝트: sharpos/SharpOS
		/// <summary>
		/// BOUND reg32,mem
		/// </summary>
		public unsafe static void BOUND (R32Type target, byte* source)
		{
		}
예제 #18
0
파일: Asm.cs 프로젝트: sharpos/SharpOS
		/// <summary>
		/// SHRD mem32,reg32,imm8
		/// </summary>
		public static void SHRD (DWordMemory target, R32Type source, Byte value)
		{
		}
예제 #19
0
파일: Asm.cs 프로젝트: sharpos/SharpOS
		/// <summary>
		/// PUSH reg32
		/// </summary>
		public static void PUSH (R32Type target)
		{
		}
예제 #20
0
파일: Asm.cs 프로젝트: sharpos/SharpOS
		/// <summary>
		/// SHRD mem32,reg32,CL
		/// </summary>
		public static void SHRD___CL (DWordMemory target, R32Type source)
		{
		}
예제 #21
0
파일: Asm.cs 프로젝트: sharpos/SharpOS
		/// <summary>
		/// ROL rmreg32,CL
		/// </summary>
		public static void ROL__CL (R32Type target)
		{
		}
예제 #22
0
파일: Asm.cs 프로젝트: sharpos/SharpOS
		/// <summary>
		/// SHRD rmreg32,reg32,imm8
		/// </summary>
		public static void SHRD (R32Type target, R32Type source, Byte value)
		{
		}
예제 #23
0
파일: Asm.cs 프로젝트: sharpos/SharpOS
		/// <summary>
		/// BSWAP reg32
		/// </summary>
		public static void BSWAP (R32Type target)
		{
		}
예제 #24
0
파일: Asm.cs 프로젝트: sharpos/SharpOS
		/// <summary>
		/// BTC rmreg32,reg32
		/// </summary>
		public static void BTC (R32Type target, R32Type source)
		{
		}
예제 #25
0
파일: Asm.cs 프로젝트: sharpos/SharpOS
		/// <summary>
		/// SBB reg32,mem32
		/// </summary>
		public static void SBB (R32Type target, DWordMemory source)
		{
		}
예제 #26
0
파일: Asm.cs 프로젝트: sharpos/SharpOS
		/// <summary>
		/// SUB mem32,reg32
		/// </summary>
		public unsafe static void SUB (UInt32* target, R32Type source)
		{
		}
예제 #27
0
파일: Asm.cs 프로젝트: sharpos/SharpOS
		/// <summary>
		/// SBB reg32,mem32
		/// </summary>
		public unsafe static void SBB (R32Type target, UInt32* source)
		{
		}
예제 #28
0
파일: Asm.cs 프로젝트: sharpos/SharpOS
		/// <summary>
		/// SBB rmreg32,reg32
		/// </summary>
		public static void SBB (R32Type target, R32Type source)
		{
		}
예제 #29
0
파일: Asm.cs 프로젝트: sharpos/SharpOS
		/// <summary>
		/// SBB rmreg32,imm32
		/// </summary>
		public static void SBB (R32Type target, UInt32 source)
		{
		}
예제 #30
0
        /// <summary>
        /// Encodes the specified bits32.
        /// </summary>
        /// <param name="bits32">if set to <c>true</c> [bits32].</param>
        /// <param name="spareRegister">The spare register.</param>
        /// <param name="binaryWriter">The binary writer.</param>
        /// <returns></returns>
        public bool Encode(bool bits32, byte spareRegister, BinaryWriter binaryWriter)
        {
            byte value = (byte)(spareRegister * 8);

            if (bits32 != this.bits32Address && (this._base != null || this.index != null))
            {
                throw new EngineException("Wrong kind of address. (16bit/32bit mix not allowed)");
            }

            if (bits32)
            {
                R32Type _base = (R32Type)this._base, index = (R32Type)this.index;
                Int32   displacement    = this.displacement;
                bool    displacementSet = this.displacementSet;
                byte    scale           = this.scale;

                if ((this._base == null && this.index != null && this.scale == 0) ||
                    this.index == R32.ESP)
                {
                    _base = (R32Type)this.index;
                    index = (R32Type)this._base;
                }

                if (_base == null && index != null && scale == 1)
                {
                    _base = index;
                    scale = 0;
                }

                bool fixEBP = false;

                if (!displacementSet && _base == R32.EBP)                 // && index == null) || (_base == null && index == R32.EBP)))
                {
                    fixEBP          = true;
                    displacementSet = true;
                    displacement    = 0;
                }

                bool shortDisplacement = false;

                if (displacementSet != false)
                {
                    if (_base == null && index == null)
                    {
                        value += 5;

                        binaryWriter.Write(value);

                        binaryWriter.Write((UInt32)displacement);

                        return(true);
                    }
                    else if (_base != null)
                    {
                        if (fixEBP || (displacement >= -0x80 && displacement <= 0x7f))
                        {
                            shortDisplacement = true;
                            value            += 1 * 64;                  // 8bit
                        }
                        else
                        {
                            value += 2 * 64;                             // 32bit
                        }
                    }
                }

                if (_base != R32.ESP && index == null)
                {
                    value += _base.Index;
                }
                else
                {
                    value += 0x04;
                }

                binaryWriter.Write(value);

                if (_base == R32.ESP || index != null)
                {
                    value = (byte)(scale * 64);

                    if (index != null)
                    {
                        value += (byte)(index.Index * 8);
                    }
                    else
                    {
                        value += 0x20;
                    }

                    if (_base != null)
                    {
                        value += _base.Index;
                    }
                    else
                    {
                        value += 0x05;
                    }

                    binaryWriter.Write(value);

                    if (!this.displacementSet && _base == null)
                    {
                        binaryWriter.Write((UInt32)0);
                    }
                }

                if (displacementSet)
                {
                    if (fixEBP || shortDisplacement)                     //(displacement >= -0x80 && displacement <= 0x7f))
                    {
                        binaryWriter.Write((byte)displacement);
                    }

                    else
                    {
                        binaryWriter.Write((UInt32)displacement);
                    }
                }
            }
            else
            {
                byte  rm;
                Int16 displacement = (Int16)this.displacement;

                if (this._base == R16.BX && this.index == R16.SI)
                {
                    rm = 0;
                }
                else if (this._base == R16.BX && this.index == R16.DI)
                {
                    rm = 1;
                }
                else if (this._base == R16.BP && this.index == R16.SI)
                {
                    rm = 2;
                }
                else if (this._base == R16.BP && this.index == R16.DI)
                {
                    rm = 3;
                }
                else if (this._base == R16.SI && this.index == null)
                {
                    rm = 4;
                }
                else if (this._base == R16.DI && this.index == null)
                {
                    rm = 5;
                }
                else if (this._base == R16.BP && this.index == null)
                {
                    rm = 6;

                    if (!displacementSet)
                    {
                        value += 0x46;
                        binaryWriter.Write(value);
                        binaryWriter.Write((byte)0);
                        return(true);
                    }
                }
                else if (this._base == R16.BX && this.index == null)
                {
                    rm = 7;
                }
                else
                {
                    rm = 6;
                }

                value += rm;

                if (this._base != null || this.index != null)
                {
                    if (displacementSet != false)
                    {
                        if (displacement >= -0x80 && displacement <= 0x7f)
                        {
                            value += 0x40;                             // 8Bit
                        }
                        else
                        {
                            value += 0x80;                             // 16Bit
                        }
                    }
                }

                binaryWriter.Write(value);

                if (displacementSet != false)
                {
                    if (displacement >= -0x80 && displacement <= 0x7f)
                    {
                        binaryWriter.Write((byte)displacement);
                    }
                    else
                    {
                        binaryWriter.Write((UInt16)displacement);
                    }
                }
            }

            return(true);
        }
예제 #31
0
파일: Asm.cs 프로젝트: sharpos/SharpOS
		/// <summary>
		/// SHR rmreg32,CL
		/// </summary>
		public static void SHR__CL (R32Type target)
		{
		}
예제 #32
0
 /// <summary>
 /// Initializes a new instance of the <see cref="QWordMemory"/> class.
 /// </summary>
 /// <param name="segment">The segment.</param>
 /// <param name="_base">The _base.</param>
 /// <param name="index">The index.</param>
 /// <param name="scale">The scale.</param>
 public QWordMemory(SegType segment, R32Type _base, R32Type index, byte scale)
     : base(segment, _base, index, scale)
 {
 }
예제 #33
0
파일: Asm.cs 프로젝트: sharpos/SharpOS
		/// <summary>
		/// SHR rmreg32,imm8
		/// </summary>
		public static void SHR (R32Type target, Byte source)
		{
		}
예제 #34
0
		/// <summary>
		/// Initializes a new instance of the <see cref="QWordMemory"/> class.
		/// </summary>
		/// <param name="segment">The segment.</param>
		/// <param name="_base">The _base.</param>
		/// <param name="index">The index.</param>
		/// <param name="scale">The scale.</param>
		public QWordMemory (SegType segment, R32Type _base, R32Type index, byte scale)
			: base (segment, _base, index, scale)
		{
		}
예제 #35
0
파일: Asm.cs 프로젝트: sharpos/SharpOS
		/// <summary>
		/// MOVZX reg32,mem16
		/// </summary>
		public static void MOVZX (R32Type target, WordMemory source)
		{
		}