diff options
| author | serpilliere <devnull@localhost> | 2012-02-27 10:46:29 +0100 |
|---|---|---|
| committer | serpilliere <devnull@localhost> | 2012-02-27 10:46:29 +0100 |
| commit | c12642d1d0ab242054a95db52d79f8e208f02355 (patch) | |
| tree | 3a91aea9c79bc85b086882e8fd97c804749c25db /example/expression/manip_expression2.py | |
| parent | 9ada5b417a2b92aa855791fb2d4c3e282c2dcb2e (diff) | |
| download | miasm-c12642d1d0ab242054a95db52d79f8e208f02355.tar.gz miasm-c12642d1d0ab242054a95db52d79f8e208f02355.zip | |
example: add expression manipulation demo
Diffstat (limited to 'example/expression/manip_expression2.py')
| -rw-r--r-- | example/expression/manip_expression2.py | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/example/expression/manip_expression2.py b/example/expression/manip_expression2.py new file mode 100644 index 00000000..cbdd8f9d --- /dev/null +++ b/example/expression/manip_expression2.py @@ -0,0 +1,27 @@ +from miasm.arch.ia32_sem import * + +print 'simple expression use demo: get read/written stuff for instruction:' +print 'add eax, [ebx]' +print + +def get_rw(exprs): + o_r = set() + o_w = set() + for e in exprs: + o_r.update(e.get_r(mem_read=True)) + for e in exprs: + o_w.update(e.get_w()) + return o_r, o_w + +a = ExprId('eax') +b = ExprMem(ExprId('ebx'), 32) + +exprs = add(('u32', 'u32'), a, b) +o_r, o_w = get_rw(exprs) +# read ID +print 'r:', [str(x) for x in o_r] +# ['eax', '@32[ebx]', 'ebx'] + +# written ID +print 'w:', [str(x) for x in o_w] +# ['eax', 'pf', 'af', 'of', 'zf', 'cf', 'nf'] |