public void EnSegAccessMemPointer() { Identifier bx = m.Local16("bx"); Identifier ds = m.Local16("ds"); Expression e = m.SegMem(PrimitiveType.Byte, ds, bx); e = e.Accept(aen); Assert.AreEqual("Mem0[ds:bx + 0x0000:byte]", e.ToString()); }
public void AtrcoSegPtr() { Identifier ds = m.Local16("ds"); Identifier bx = m.Local16("bx"); MemoryAccess mem = m.SegMem(PrimitiveType.Word16, ds, bx); mem.Accept(eqb); atrco.Collect(program.Globals, 2, mem, mem.EffectiveAddress); Verify(null, "Typing/AtrcoSegPtr.txt"); }
public void TrcoSegmentedAccess() { ProcedureBuilder m = new ProcedureBuilder(); Identifier ds = m.Local16("ds"); Identifier bx = m.Local16("bx"); Expression e = m.SegMem(PrimitiveType.Word16, ds, m.IAdd(bx, 4)); coll = CreateCollector(); e = e.Accept(en); e.Accept(eqb); e.Accept(coll); Verify(null, "Typing/TrcoSegmentedAccess.txt"); }
public void TrcoMemberPointer() { ProcedureBuilder m = new ProcedureBuilder(); Identifier ds = m.Local16("ds"); Identifier bx = m.Local16("bx"); MemberPointerSelector mps = m.MembPtrW(ds, m.IAdd(bx, 4)); Expression e = m.Mem(PrimitiveType.Byte, mps); coll = CreateCollector(); e = e.Accept(en); e.Accept(eqb); e.Accept(coll); Verify(null, "Typing/TrcoMemberPointer.txt"); }
public void CpaConstantMemberPointer() { ProgramBuilder program = new ProgramBuilder(); ProcedureBuilder m = new ProcedureBuilder(); Identifier ds = m.Local16("ds"); ds.DataType = PrimitiveType.SegmentSelector; Identifier bx = m.Local16("bx"); m.Assign(bx, 0x1234); m.Store(m.SegMem16(ds, bx), m.Word16(0x0042)); program.Add(m); RunTest(program.BuildProgram(), "Typing/CpaConstantMemberPointer.txt"); }
public void TrcoMemberPointer() { ProcedureBuilder m = new ProcedureBuilder(); Identifier ds = m.Local16("ds"); Identifier bx = m.Local16("bx"); MemberPointerSelector mps = m.MembPtrW(ds, m.IAdd(bx, 4)); Expression e = m.Mem(PrimitiveType.Byte, mps); coll = CreateCollector(); e = e.Accept(en); e.Accept(eqb); e.Accept(coll); Assert.IsNotNull(mps.BasePointer.TypeVariable, "Base pointer should have type variable"); Verify(null, "Typing/TrcoMemberPointer.txt"); }
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()); }
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(cupos16)" + nl + "T_2 (in 0x0800 : word16)" + nl + "\ttrait_primitive(word16)" + nl + "\ttrait_primitive(cupos16)" + nl + "T_3 (in ds >=u 0x0800 : bool)" + nl + "\ttrait_primitive(bool)" + nl; Assert.AreEqual(exp, sb.ToString()); }
public void TrcoSegMem() { ProcedureBuilder m = new ProcedureBuilder(); Identifier ds = m.Local16("ds"); Expression e = m.SegMem16(ds, m.Word16(0xC002U)); coll = CreateCollector(); e.Accept(eqb); e.Accept(coll); Verify(null, "Typing/TrcoSegMem.txt"); }
public void DtbSignedCompare() { ProcedureBuilder m = new ProcedureBuilder(); 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.SegMem16(ds, m.Word16(0x5404)), m.Word16(20))); m.Store(m.SegMem16(ds2, m.Word16(0x5404)), m.Word16(0)); ProgramBuilder program = new ProgramBuilder(); program.Add(m); RunTest(program.BuildProgram(), "Typing/DtbSignedCompare.txt"); }
public void DtbSegmentedAccess() { ProcedureBuilder m = new ProcedureBuilder(); Identifier ds = m.Local16("ds"); Identifier bx = m.Local16("bx"); Expression e = m.SegMem(bx.DataType, ds, m.IAdd(bx, 4)); var arch = new Reko.Arch.X86.X86ArchitectureReal(); Program prog = new Program { Architecture = arch, Platform = new DefaultPlatform(null, arch), }; TraitCollector trco = new TraitCollector(factory, store, dtb, prog); e = e.Accept(aen); e.Accept(eqb); e.Accept(trco); dtb.BuildEquivalenceClassDataTypes(); Verify("Typing/DtbSegmentedAccess.txt"); }
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"); }
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 TrcoSegmentedDirectAddress() { Program program = CreateProgram(); program.TypeStore.EnsureExpressionTypeVariable(program.TypeFactory, program.Globals); ProcedureBuilder m = new ProcedureBuilder(); Identifier ds = m.Local16("ds"); Expression e = m.SegMem(PrimitiveType.Byte, ds, m.Word16(0x0200)); coll = CreateCollector(program); e = e.Accept(en); e.Accept(eqb); e.Accept(coll); Verify(null, "Typing/TrcoSegmentedDirectAddress.txt"); }
public void DtbSegmentedDirectAddress() { ProcedureBuilder m = new ProcedureBuilder(); var arch = new Reko.Arch.X86.X86ArchitectureReal(); var prog = new Program { Architecture = arch, Platform = new DefaultPlatform(null, arch) }; store.EnsureExpressionTypeVariable(factory, prog.Globals); Identifier ds = m.Local16("ds"); Expression e = m.SegMem(PrimitiveType.Byte, ds, m.Int16(0x0200)); TraitCollector coll = new TraitCollector(factory, store, dtb, prog); e = e.Accept(aen); e.Accept(eqb); e.Accept(coll); dtb.BuildEquivalenceClassDataTypes(); Verify("Typing/DtbSegmentedDirectAddress.txt"); }
public void DtbSegmentedDirectAddress() { ProcedureBuilder m = new ProcedureBuilder(); var sc = new ServiceContainer(); var arch = new Reko.Arch.X86.X86ArchitectureReal(sc, "x86-real-16", new Dictionary <string, object>()); var program = new Program { Architecture = arch, Platform = new DefaultPlatform(sc, arch) }; store.EnsureExpressionTypeVariable(factory, 0, program.Globals); Identifier ds = m.Local16("ds"); Expression e = m.SegMem(PrimitiveType.Byte, ds, m.Word16(0x0200)); TraitCollector coll = new TraitCollector(factory, store, dtb, program); e = e.Accept(aen); e.Accept(eqb); e.Accept(coll); dtb.BuildEquivalenceClassDataTypes(); Verify("Typing/DtbSegmentedDirectAddress.txt"); }