def test(): prog = Program( push(ebp), mov(ebp, esp), mov(eax, ebp.addr + 8), inc(eax), pop(ebp), ret(), ) fun = prog.compile(c_int, [c_int]) assert fun(1234) == 1235
def test(): label = Label('foo') prog = Program( mov(eax, 0), label, inc(eax), cmp(eax, 100), jl(label), ret(), ) fun = prog.compile(c_int) assert fun() == 100
def test(): prog = Program(push(ebp), mov(ebp, esp), mov(eax, ebp.addr + 8), inc(eax), pop(ebp), ret()) fun = prog.compile(c_int, [c_int]) assert fun(1234) == 1235
# -*- coding: utf-8 -*- """ inc ~~~ :copyright: 2008 by Henri Tuhola <*****@*****.**> :license: GNU AGPL v3 or later, see LICENSE for more details. """ from ctypes import c_long from pyasm import Program from pyasm.instructions import mov, inc, ret from pyasm.registers import rax, eax, rdi if __name__ == '__main__': prog = Program( mov(rax, rdi), inc(rax), ret() ) fun = prog.compile(c_long, [c_long]) assert fun(1234) == 1235