示例#1
0
def test_neg():
    block_size = (rsize, csize) = 32,32

    # test program
    def test_code(code, block_size, args):
         yield Neg(code.r(0), code.r(0))

    code = Code()
    code.set_generator(test_code, block_size)
    print str(code)

    image = zeros(rsize, csize)
    pe = PE(None, image, (rsize, csize))
    # warning: this makes certain assumptions on internals of PE
    pe.regs[regname_to_id('r0')] = 42

    for c in code.plain_instr():
        pe.step1(c)
        pe.step2(c)

    assert pe.get_reg_by_name('r0') == -42.
示例#2
0
def test_register_value_fetch():
    block_size = (rsize, csize) = 64,64
    image = zeros(rsize, csize)

    # test code
    def test_code(code, block_size, args):
         yield Imm(code.r(0), 3)

    code = Code()
    code.set_generator(test_code, block_size)
    print str(code)

    # PE
    pe = PE(None, image, (rsize, csize)) 

    # execute program
    for c in code.plain_instr():
        pe.step1(c)
        pe.step2(c)

    assert pe.get_reg_by_name('r0') == 3