Пример #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Call"/> class.
 /// </summary>
 /// <param name="target">The target <see cref="FarPointer"/>.</param>
 public Call(FarPointer target)
     : this((Operand)target)
 {
     #region Contract
     Contract.Requires <ArgumentNullException>(target != null);
     #endregion
 }
Пример #2
0
        /// <summary>
        /// Writes a far pointer operand.
        /// </summary>
        /// <returns>The number of characters written.</returns>
        private int WriteOperand(FarPointer operand, bool writeSize)
        {
            #region Contract
            if (operand == null)
            {
                return(0);
            }
            #endregion
            int length = 0;

            if (writeSize)
            {
                switch (operand.RequestedSize)
                {
                case DataSize.Bit8:
                    Writer.Write("byte ");
                    length += 5;
                    break;

                case DataSize.Bit16:
                    Writer.Write("word ");
                    length += 5;
                    break;

                case DataSize.Bit32:
                    Writer.Write("dword ");
                    length += 6;
                    break;

                case DataSize.Bit64:
                    Writer.Write("qword ");
                    length += 6;
                    break;

                case DataSize.None:
                    break;

                default:
                    throw new LanguageException(ExceptionStrings.UnknownRequestedSize);
                }
            }

            length += WriteExpression(operand.Selector);
            Writer.Write(":");
            length += 1;
            length += WriteExpression(operand.Offset);

            return(length);
        }
        public void file_source(DebuggerCore debugger, FarPointer address)
        {
            // Get the selector
            var sel = _machine.GlobalHeap.GetSelector(address.Segment);

            if (sel == null || sel.allocation == null || sel.allocation.filename == null)
            {
                debugger.WriteLine("No associated source file");
                return;
            }

            uint offset = (uint)(((address.Segment >> 3) - sel.selectorIndex) << 16 | address.Offset);

            if (offset > sel.allocation.buffer.Length)
            {
                debugger.WriteLine("Address is past end of allocation");
                return;
            }

            debugger.WriteLine("VM address 0x{0:X4}:{1:X4} => {2}:{3:X8}",
                               address.Segment, address.Offset,
                               System.IO.Path.GetFileName(sel.allocation.filename), sel.allocation.fileoffset + offset);
        }
 /// <summary>
 /// Creates a new CALL FAR (Far Procedure Call) instruction.
 /// </summary>
 /// <param name="target">A far pointer.</param>
 /// <returns>The created instruction.</returns>
 public static X86Instruction CallFar(FarPointer target)
 {
     return(X86Opcode.CallFar.CreateInstruction(target));
 }
 /// <summary>
 /// Creates a new CALL FAR (Far Procedure Call) instruction.
 /// </summary>
 /// <param name="target">A far pointer.</param>
 /// <returns>The created instruction.</returns>
 public static X86Instruction CallFar(FarPointer target)
 {
     return X86Opcode.CallFar.CreateInstruction(target);
 }
Пример #6
0
        /// <summary>
        /// Writes a far pointer operand.
        /// </summary>
        /// <returns>The number of characters written.</returns>
        private int WriteOperand(FarPointer operand, bool writeSize)
        {
            #region Contract
            if (operand == null) return 0;
            #endregion
            int length = 0;

            if (writeSize)
            {
                switch (operand.RequestedSize)
                {
                    case DataSize.Bit8:
                        Writer.Write("byte ");
                        length += 5;
                        break;
                    case DataSize.Bit16:
                        Writer.Write("word ");
                        length += 5;
                        break;
                    case DataSize.Bit32:
                        Writer.Write("dword ");
                        length += 6;
                        break;
                    case DataSize.Bit64:
                        Writer.Write("qword ");
                        length += 6;
                        break;
                    case DataSize.None:
                        break;
                    default:
                        throw new LanguageException(ExceptionStrings.UnknownRequestedSize);
                }
            }

            length += WriteExpression(operand.Selector);
            Writer.Write(":");
            length += 1;
            length += WriteExpression(operand.Offset);

            return length;
        }
        public bool Match(Operand operand)
        {
            switch (operandType)
            {
            case OperandType.FixedRegister:
            {
                RegisterOperand castoperand = operand as RegisterOperand;
                if (castoperand != null)
                {
                    return(castoperand.Register == fixedRegister);
                }
                return(false);
            }

            case OperandType.Immediate:
            {
                Immediate castoperand = operand as Immediate;
                if (castoperand != null)
                {
                    return(castoperand.Size == DataSize.None || castoperand.Size == size);
                }
                return(false);
            }

            case OperandType.RegisterOperand:
            {
                RegisterOperand castoperand = operand as RegisterOperand;
                if (castoperand != null)
                {
                    return(/*castoperand.Size == size &&*/ registerType.HasFlag(castoperand.Register.GetRegisterType()));
                }
                return(false);
            }

            case OperandType.RegisterOrMemoryOperand:
            {
                RegisterOperand  castoperand1 = operand as RegisterOperand;
                EffectiveAddress castoperand2 = operand as EffectiveAddress;
                if (castoperand1 != null)
                {
                    return(/*castoperand1.Size == size &&*/ registerType.HasFlag(castoperand1.Register.GetRegisterType()));
                }
                if (castoperand2 != null)
                {
                    return(/*castoperand2.Size == size*/ registerType.HasFlag(castoperand2.Size));
                }
                return(false);
            }

            case OperandType.MemoryOperand:
            {
                EffectiveAddress castoperand = operand as EffectiveAddress;
                if (castoperand != null)
                {
                    return(castoperand.Size == size);
                }
                return(false);
            }

            case OperandType.MemoryOffset:
                // TODO: Implement!
                return(false);

            case OperandType.FarPointer:
            {
                FarPointer castoperand = operand as FarPointer;
                if (castoperand != null)
                {
                    return(castoperand.Size == size);
                }
                return(false);
            }

            case OperandType.RelativeOffset:
            {
                // A relative offset matches when the Size of the operand
                // equals DataSize.None. The Size will be set when the
                // operand has been preprocessed, after which it is tested
                // again.
                RelativeOffset castoperand = operand as RelativeOffset;
                if (castoperand != null)
                {
                    return(castoperand.Size == DataSize.None || castoperand.Size == size);
                }
                return(false);
            }

            case OperandType.None:
                return(operand == null);

            default:
                throw new NotSupportedException();
            }
        }