Exemplo n.º 1
0
        public void ParseRegisterOperand()
        {
            OperandParser opp = Create16BitParser("eax");
            ParsedOperand po  = opp.ParseOperand();

            Assert.AreEqual("RegisterOperand", po.Operand.GetType().Name);
            Assert.AreEqual("eax", po.Operand.ToString());
        }
Exemplo n.º 2
0
        public void ParseMemoryAccess_IntelSyntax_NegativeOffset()
        {
            OperandParser opp = Create16BitParser("[ebp-70h]");
            ParsedOperand po  = opp.ParseOperand();
            var           mop = (MemoryOperand)po.Operand;

            Assert.AreEqual("[ebp-70]", mop.ToString(MachineInstructionRendererOptions.Default));
        }
Exemplo n.º 3
0
        public void ParseImmediate_IntelSyntax()
        {
            OperandParser    opp = Create16BitParser("21Eh");
            ParsedOperand    po  = opp.ParseOperand();
            ImmediateOperand mop = (ImmediateOperand)po.Operand;

            Assert.AreEqual("021E", mop.ToString(MachineInstructionRendererOptions.Default));
        }
Exemplo n.º 4
0
        public void ParseMemoryOperandWithSpecifiedWidth()
        {
            OperandParser opp = Create16BitParser("byte ptr [bx]");
            ParsedOperand po  = opp.ParseOperand();
            MemoryOperand mop = (MemoryOperand)po.Operand;

            Assert.AreSame(PrimitiveType.Byte, mop.Width);
            Assert.AreSame(Registers.bx, mop.Base);
        }
Exemplo n.º 5
0
        public void ParseMemoryOperandWithUnspecifiedWidth()
        {
            OperandParser opp = Create16BitParser("[bx]");
            ParsedOperand po  = opp.ParseOperand();
            MemoryOperand mop = (MemoryOperand)po.Operand;

            Assert.IsNull(po.Operand.Width, "Operand width should have been null, was " + po.Operand.Width);
            Assert.AreSame(Registers.bx, mop.Base);
        }
Exemplo n.º 6
0
        public void ParseSibMemoryOperand()
        {
            OperandParser opp = Create16BitParser("[eax+eax*4]");
            ParsedOperand po  = opp.ParseOperand();
            MemoryOperand mop = (MemoryOperand)po.Operand;

            Assert.IsNull(mop.Width, "Width should be undefined, but is " + mop.Width);
            Assert.IsNull(mop.Offset, "Offset should be null, but is " + mop.Offset);
            Assert.AreEqual("[eax+eax*4]", mop.ToString(MachineInstructionWriterOptions.None));
        }
Exemplo n.º 7
0
        public void ParseNumericMemoryOperand()
        {
            OperandParser opp = Create16BitParser("[0x21E]");
            ParsedOperand po  = opp.ParseOperand();
            MemoryOperand mop = (MemoryOperand)po.Operand;

            Assert.IsNull(mop.Width, "Width should be undefined, but is " + mop.Width);
            Assert.AreSame(PrimitiveType.Word16, mop.Offset.DataType);
            Assert.AreEqual("[021E]", mop.ToString(MachineInstructionWriterOptions.None));
        }
Exemplo n.º 8
0
        public void ParseMemorySymbol()
        {
            OperandParser opp = Create16BitParser("[foo]");
            ParsedOperand po  = opp.ParseOperand();
            MemoryOperand mop = (MemoryOperand)po.Operand;

            Assert.IsNull(mop.Width, "Width should be undefined, but is " + mop.Width);
            Assert.IsNotNull(po.Symbol, "Should have defined symbol foo");
            Assert.AreEqual("[0000]", mop.ToString(MachineInstructionWriterOptions.None));
        }