本文整理汇总了C#中Reko.UnitTests.Mocks.ProcedureBuilder.Store方法的典型用法代码示例。如果您正苦于以下问题:C# ProcedureBuilder.Store方法的具体用法?C# ProcedureBuilder.Store怎么用?C# ProcedureBuilder.Store使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Reko.UnitTests.Mocks.ProcedureBuilder
的用法示例。
在下文中一共展示了ProcedureBuilder.Store方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PprMemberVars
public void PprMemberVars()
{
ProgramBuilder mock = new ProgramBuilder();
ProcedureBuilder p = new ProcedureBuilder();
Identifier cs = p.Frame.EnsureRegister(Registers.cs);
p.Store(p.SegMemW(cs, p.Word32(0x0001)), Constant.Create(PrimitiveType.SegmentSelector, 0x0800));
mock.Add(p);
RunTest(mock.BuildProgram(), "Typing/PprMemberVars.txt");
}
示例2: DpaConstantPointer
public void DpaConstantPointer()
{
ProgramBuilder prog = new ProgramBuilder();
ProcedureBuilder m = new ProcedureBuilder();
Identifier r1 = m.Register(1);
m.Assign(r1, 0x123130);
m.Store(r1, m.Int32(0x42));
prog.Add(m);
RunTest(prog.BuildProgram(), "Typing/DpaConstantPointer.txt");
}
示例3: DpaConstantMemberPointer
public void DpaConstantMemberPointer()
{
ProgramBuilder prog = 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.SegMemW(ds, bx), m.Int16(0x0042));
prog.Add(m);
RunTest(prog.BuildProgram(), "Typing/DpaConstantMemberPointer.txt");
}
示例4: BlockDoesntTerminate
public void BlockDoesntTerminate()
{
var m = new ProcedureBuilder();
m.Store(m.Word32(0x1231), m.Byte(0));
var b = m.Block;
m.Return();
var a = new TerminationAnalysis(flow);
program = new Program
{
Architecture = new FakeArchitecture()
};
flow[b] = CreateBlockFlow(b, m.Frame);
a.Analyze(b);
Assert.IsFalse(flow[b].TerminatesProcess);
}
示例5: BuildSimpleLoop
private Procedure BuildSimpleLoop()
{
ProcedureBuilder m = new ProcedureBuilder();
Identifier p = m.Local32("p");
m.Assign(p, 0);
m.Label("loop");
m.BranchIf(m.Eq(p, 0x4000), "done");
m.Store(m.IAdd(p, 0x3000), m.Int32(0));
m.Assign(p, m.IAdd(p, 4));
m.Goto("loop");
m.Label("done");
m.Return();
return m.Procedure;
}
示例6: VpCastCast
public void VpCastCast()
{
var m = new ProcedureBuilder();
m.Store(
m.Word32(0x1234000),
m.Cast(
PrimitiveType.Real32,
m.Cast(
PrimitiveType.Real64,
m.Load(PrimitiveType.Real32, m.Word32(0x123400)))));
m.Return();
mr.ReplayAll();
RunFileTest(m, "Analysis/VpCastCast.txt");
}
示例7: VpIndirectCall
public void VpIndirectCall()
{
var callee = CreateExternalProcedure("foo", RegArg(1, "r1"), StackArg(4), StackArg(8));
var pc = new ProcedureConstant(PrimitiveType.Pointer32, callee);
var m = new ProcedureBuilder();
var r1 = m.Reg32("r1", 1);
var sp = m.Frame.EnsureRegister(m.Architecture.StackRegister);
m.Assign(r1, pc);
m.Assign(sp, m.ISub(sp, 4));
m.Store(sp, 3);
m.Assign(sp, m.ISub(sp, 4));
m.Store(sp, m.LoadW(m.Word32(0x1231230)));
m.Call(r1, 4);
m.Return();
arch.Stub(a => a.CreateStackAccess(null, 0, null))
.IgnoreArguments()
.Do(new Func<Frame, int, DataType, Expression>((f, off, dt) => m.Load(dt, m.IAdd(sp, off))));
mr.ReplayAll();
var ssa = RunTest(m);
var sExp =
#region Expected
@"r1_0: orig: r1
def: r1_0 = foo
r63:r63
def: def r63
uses: r63_2 = r63 - 0x00000004
Mem3[r63 - 0x00000004:word32] = 0x00000003
r63_4 = r63 - 0x00000008
Mem5[r63 - 0x00000008:word16] = Mem3[0x01231230:word16]
r1_6 = foo(Mem8[r63 - 0x00000008:word32], Mem9[r63 - 0x00000004:word32])
r1_6 = foo(Mem8[r63 - 0x00000008:word32], Mem9[r63 - 0x00000004:word32])
r63_2: orig: r63
def: r63_2 = r63 - 0x00000004
Mem3: orig: Mem0
def: Mem3[r63 - 0x00000004:word32] = 0x00000003
uses: Mem5[r63 - 0x00000008:word16] = Mem3[0x01231230:word16]
r63_4: orig: r63
def: r63_4 = r63 - 0x00000008
Mem5: orig: Mem0
def: Mem5[r63 - 0x00000008:word16] = Mem3[0x01231230:word16]
r1_6: orig: r1
def: r1_6 = foo(Mem8[r63 - 0x00000008:word32], Mem9[r63 - 0x00000004:word32])
r63_7: orig: r63
Mem8: orig: Mem0
uses: r1_6 = foo(Mem8[r63 - 0x00000008:word32], Mem9[r63 - 0x00000004:word32])
Mem9: orig: Mem0
uses: r1_6 = foo(Mem8[r63 - 0x00000008:word32], Mem9[r63 - 0x00000004:word32])
// ProcedureBuilder
// Return size: 0
void ProcedureBuilder()
ProcedureBuilder_entry:
def r63
// succ: l1
l1:
r1_0 = foo
r63_2 = r63 - 0x00000004
Mem3[r63 - 0x00000004:word32] = 0x00000003
r63_4 = r63 - 0x00000008
Mem5[r63 - 0x00000008:word16] = Mem3[0x01231230:word16]
r1_6 = foo(Mem8[r63 - 0x00000008:word32], Mem9[r63 - 0x00000004:word32])
return
// succ: ProcedureBuilder_exit
ProcedureBuilder_exit:
";
#endregion
AssertStringsEqual(sExp, ssa);
}
示例8: VpLoadDpbSmallerCast
public void VpLoadDpbSmallerCast()
{
var m = new ProcedureBuilder();
var a2 = m.Reg32("a2", 10);
var d3 = m.Reg32("d3", 3);
var tmp = m.Temp(PrimitiveType.Word16, "tmp");
m.Assign(tmp, m.LoadW(a2));
m.Assign(d3, m.Dpb(d3, tmp, 0));
m.Store(m.IAdd(a2, 4), m.Cast(PrimitiveType.Byte, d3));
SsaState ssa = RunTest(m);
var sExp =
#region Expected
@"a2:a2
def: def a2
uses: tmp_2 = Mem0[a2:word16]
Mem5[a2 + 0x00000004:byte] = (byte) tmp_2
Mem0:Global memory
def: def Mem0
uses: tmp_2 = Mem0[a2:word16]
tmp_2: orig: tmp
def: tmp_2 = Mem0[a2:word16]
uses: d3_4 = DPB(d3, tmp_2, 0)
Mem5[a2 + 0x00000004:byte] = (byte) tmp_2
d3:d3
def: def d3
uses: d3_4 = DPB(d3, tmp_2, 0)
d3_4: orig: d3
def: d3_4 = DPB(d3, tmp_2, 0)
Mem5: orig: Mem0
def: Mem5[a2 + 0x00000004:byte] = (byte) tmp_2
// ProcedureBuilder
// Return size: 0
void ProcedureBuilder()
ProcedureBuilder_entry:
def a2
def Mem0
def d3
// succ: l1
l1:
tmp_2 = Mem0[a2:word16]
d3_4 = DPB(d3, tmp_2, 0)
Mem5[a2 + 0x00000004:byte] = (byte) tmp_2
ProcedureBuilder_exit:
";
#endregion
AssertStringsEqual(sExp, ssa);
}
示例9: Usb_ParseFunctionDeclaration_WithRegisterArgs
public void Usb_ParseFunctionDeclaration_WithRegisterArgs()
{
var arch = new FakeArchitecture();
var m = new ProcedureBuilder(arch, "test");
var r1 = m.Reg32("r1", 1);
var r2 = m.Reg32("r2", 2);
m.Store(m.Word32(0x123400), m.Cast(PrimitiveType.Byte, r1));
m.Store(m.Word32(0x123404), m.Cast(PrimitiveType.Real32, r2));
m.Return();
var usb = new UserSignatureBuilder(program);
usb.ApplySignatureToProcedure(
Address.Create(PrimitiveType.Pointer32, 0x1000),
new ProcedureSignature(
null,
new Identifier("r2", PrimitiveType.Char, r1.Storage), // perverse but legal.
new Identifier("r1", PrimitiveType.Real32, r2.Storage)),
m.Procedure);
var sExp = @"// test
// Return size: 0
void test(char r2, real32 r1)
test_entry:
// succ: l1
l1:
r1 = r2
r2 = r1
Mem0[0x00123400:byte] = (byte) r1
Mem0[0x00123404:real32] = (real32) r2
return
// succ: test_exit
test_exit:
";
var sb = new StringWriter();
m.Procedure.Write(false, sb);
Assert.AreEqual(sExp, sb.ToString());
}
示例10: SsaPushAndPop
public void SsaPushAndPop()
{
// Mirrors the pattern of stack accesses used by x86 compilers.
var m = new ProcedureBuilder("SsaPushAndPop");
var esp = EnsureRegister32(m, "esp");
var ebp = EnsureRegister32(m, "ebp");
var eax = EnsureRegister32(m, "eax");
m.Assign(esp, m.ISub(esp, 4));
m.Store(esp, ebp);
m.Assign(ebp, esp);
m.Assign(eax, m.LoadDw(m.IAdd(ebp, 8))); // dwArg04
m.Assign(ebp, m.LoadDw(esp));
m.Assign(esp, m.IAdd(esp,4));
m.Return();
RunUnitTest(m, "Analysis/SsaPushAndPop.txt");
}
示例11: SsaOutParamters
public void SsaOutParamters()
{
ProcedureBuilder m = new ProcedureBuilder("foo");
Identifier r4 = m.Register(4);
m.Store(m.Int32(0x400), m.Fn("foo", m.Out(PrimitiveType.Pointer32, r4)));
m.Return();
RunFileTest(m, "Analysis/SsaOutParameters.txt");
}
示例12: DtbSignedCompare
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");
}
示例13: Pdg_PostdominateLoop
public void Pdg_PostdominateLoop()
{
ProcedureBuilder m = new ProcedureBuilder();
m.Jump("test");
m.Label("test");
m.BranchIf(m.LocalBool("f"), "done");
m.Label("body");
m.Store(m.Int32(30), m.Int32(0));
m.Jump("test");
m.Label("done");
m.Return();
FindPostDominators(m);
string sExp =
"body (4): idom test (3)" + nl +
"done (5): idom ProcedureBuilder_exit (6)" + nl +
"l1 (2): idom test (3)" + nl +
"ProcedureBuilder_entry (1): idom l1 (2)" + nl +
"ProcedureBuilder_exit (6): idom " + nl +
"test (3): idom done (5)" + nl;
Console.WriteLine(sw.ToString());
Assert.AreEqual(sExp, sw.ToString());
}
示例14: DfaUnsignedDiv
public void DfaUnsignedDiv()
{
var m = new ProcedureBuilder();
var r1 = m.Register(1);
var r2 = m.Register(2);
var r2_r1 = m.Frame.EnsureSequence(r2.Storage, r1.Storage, PrimitiveType.Word64);
var tmp = m.Frame.CreateTemporary(r2_r1.DataType);
m.Assign(r1, m.LoadDw(m.Word32(0x123400)));
m.Assign(r2_r1, m.Seq(m.Word32(0), r1));
m.Assign(tmp, r2_r1);
m.Assign(r1, m.UDiv(tmp, m.Word32(42)));
m.Store(m.Word32(0x123404), r1);
m.Return();
RunFileTest(m, "Analysis/DfaUnsignedDiv.txt");
}
示例15: MemStore
public static void MemStore(ProcedureBuilder m)
{
m.Store(m.Word32(0x3120), 0);
m.Store(m.Word32(0x3120), m.IAdd(m.LoadDw(m.Word32(0x3120)), 1));
m.Return();
}