Ejemplo n.º 1
0
        public void DtbArrayAccess2()
        {
            ProcedureBuilder m = new ProcedureBuilder();
            Identifier ds = m.Local(PrimitiveType.SegmentSelector, "ds");
            Identifier bx = m.Local16("bx");
            Expression e = m.Array(PrimitiveType.Word32, m.Seq(ds, m.Word16(0x300)), m.IMul(bx, 8));
            e.Accept(eqb);

            TraitCollector coll = new TraitCollector(factory, store, dtb, program);
            e.Accept(coll);
            Verify("Typing/DtbArrayAccess2.txt");
        }
        public void CEB_SegmentedArray()
        {
            var m   = new Reko.UnitTests.Mocks.ProcedureBuilder("CEB_SegmentedArray");
            var aw  = new ArrayType(PrimitiveType.Int16, 0);
            var ds  = m.Temp(PrimitiveType.SegmentSelector, "ds");
            var bx  = m.Temp(PrimitiveType.Word16, "bx");
            var acc =
                m.Array(
                    PrimitiveType.Word16,
                    m.Seq(
                        ds,
                        m.Word16(0x5388)),
                    m.IMul(bx, 2));

            CreateTv(globals, Ptr32(factory.CreateStructureType()), Ptr32(factory.CreateStructureType()));
            CreateTv(ds, Ptr16(factory.CreateStructureType()), Ptr16(factory.CreateStructureType()));
        }
Ejemplo n.º 3
0
        public void CEB_SegmentedArray()
        {
            var m = new Reko.UnitTests.Mocks.ProcedureBuilder("CEB_SegmentedArray");
            var aw = new ArrayType(PrimitiveType.Int16, 0);
            var ds = m.Temp(PrimitiveType.SegmentSelector, "ds");
            var bx = m.Temp(PrimitiveType.Word16, "bx");
            var acc =
                m.Array(
                    PrimitiveType.Word16,
                    m.Seq(
                        ds,
                        m.Word16(0x5388)),
                    m.IMul(bx, 2));

            CreateTv(globals, Ptr32(factory.CreateStructureType()), Ptr32(factory.CreateStructureType()));
            CreateTv(ds, Ptr16(factory.CreateStructureType()), Ptr16(factory.CreateStructureType()));
        }
Ejemplo n.º 4
0
 public void TrcoArrayAccess()
 {
     ProcedureBuilder m = new ProcedureBuilder();
     Identifier ds = m.Local(PrimitiveType.SegmentSelector, "ds");
     Identifier bx = m.Local16("bx");
     Expression e = m.Array(PrimitiveType.Word32, m.Seq(ds, m.Word16(0x300)), m.IMul(bx, 8));
     coll = CreateCollector();
     e.Accept(eqb);
     e.Accept(coll);
     StringWriter sb = new StringWriter();
     handler.Traits.Write(sb);
     string sExp =
         "T_1 (in ds : selector)" + nl +
         "\ttrait_primitive(selector)" + nl +
         "\ttrait_mem_array(300, 8, 0, T_7)" + nl + 
         "T_2 (in 0x0300 : word16)" + nl +
         "	trait_primitive(word16)" + nl +
         "T_3 (in SEQ(ds, 0x0300) : ptr32)" + nl +
         "	trait_primitive(ptr32)" + nl +
         "T_4 (in bx : word16)" + nl +
         "	trait_primitive(word16)" + nl +
         "	trait_primitive(ui16)" + nl +
         "T_5 (in 0x0008 : word16)" + nl +
         "	trait_primitive(word16)" + nl +
         "	trait_primitive(ui16)" + nl +
         "T_6 (in bx * 0x0008 : word16)" + nl +
         "	trait_primitive(ui16)" + nl +
         "T_7 (in SEQ(ds, 0x0300)[bx * 0x0008] : word32)" + nl +
         "	trait_primitive(word32)" + nl;
     Assert.AreEqual(sExp, sb.ToString());
 }
Ejemplo n.º 5
0
		public void TrcoUnsignedCompare()
		{
			ProcedureBuilder m = new ProcedureBuilder();
			Identifier ds = m.Local16("ds");
			Expression e = m.Uge(ds, m.Word16(0x0800));

            coll = CreateCollector();
			e.Accept(eqb);
			e.Accept(coll);
			StringWriter sb = new StringWriter();
			handler.Traits.Write(sb);
			string exp = 
				"T_1 (in ds : word16)" + nl +
				"\ttrait_primitive(word16)" + nl +
				"\ttrait_equal(T_2)" + nl +
				"\ttrait_primitive(cups16)" + nl +
				"T_2 (in 0x0800 : word16)" + nl +
				"\ttrait_primitive(word16)" + nl +
				"\ttrait_primitive(cups16)" + nl +
				"T_3 (in ds >=u 0x0800 : bool)" + nl +
				"\ttrait_primitive(bool)" + nl;
			Assert.AreEqual(exp, sb.ToString());
		}
Ejemplo n.º 6
0
		public void TrcoSegMem()
		{
			ProcedureBuilder m = new ProcedureBuilder();
			Identifier ds = m.Local16("ds");
			Expression e = m.SegMemW(ds, m.Word16(0xC002U));

            coll = CreateCollector();
			e.Accept(eqb);
			e.Accept(coll);
			Verify(null, "Typing/TrcoSegMem.txt");
		}
Ejemplo n.º 7
0
        public void DtbSequenceWithSegment()
        {
            ProcedureBuilder m = new ProcedureBuilder();
            Identifier ds = m.Local16("ds");
            ds.DataType = PrimitiveType.SegmentSelector;
            m.SegStore(ds, m.Word16(0x0100), m.Seq(ds, m.Word16(0x1234)));

            ProgramBuilder prog = new ProgramBuilder();
            prog.Add(m);
            RunTest(prog.BuildProgram(), "Typing/DtbSequenceWithSegment.txt");
        }
Ejemplo n.º 8
0
        public void DtbSignedCompare()
        {
            ProcedureBuilder m = new ProcedureBuilder();
            Identifier p = m.Local32("p");
            Identifier ds = m.Local16("ds");
            ds.DataType = PrimitiveType.SegmentSelector;
            Identifier ds2 = m.Local16("ds2");
            ds.DataType = PrimitiveType.SegmentSelector;
            m.Assign(ds2, ds);
            m.Store(
                m.SegMem(PrimitiveType.Bool, ds, m.Word16(0x5400)),
                m.Lt(m.SegMemW(ds, m.Word16(0x5404)), m.Word16(20)));
            m.Store(m.SegMemW(ds2, m.Word16(0x5404)), m.Word16(0));

            ProgramBuilder prog = new ProgramBuilder();
            prog.Add(m);
            RunTest(prog.BuildProgram(), "Typing/DtbSignedCompare.txt");
        }
Ejemplo n.º 9
0
        public void Pdg_InfiniteLoop()
        {
            ProcedureBuilder m = new ProcedureBuilder();
            m.Label("Infinity");
            m.BranchIf(m.Eq(m.LoadW(m.Word16(0x1234)), 0), "hop");
            m.SideEffect(m.Fn("foo"));
            m.Label("hop");
            m.BranchIf(m.Eq(m.LoadW(m.Word16(0x5123)), 1), "Infinity");
            m.SideEffect(m.Fn("bar"));
            m.Jump("Infinity");
            m.Return();

            FindPostDominators(m);
            string sExp = 
                "hop (4): idom ProcedureBuilder_exit (6)" + nl +
                "Infinity (2): idom hop (4)" + nl +
                "l1 (3): idom hop (4)" + nl +
                "l2 (5): idom ProcedureBuilder_exit (6)" + nl +
                "ProcedureBuilder_entry (1): idom Infinity (2)" + nl +
                "ProcedureBuilder_exit (6): idom " + nl;
            Assert.AreEqual(sExp, sw.ToString());
        }