about summary refs log tree commit diff stats
path: root/example/expression/get_read_write.py
blob: d98b461a8124ac21ce3be726d78f6b13def3859c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
from miasm2.arch.x86.arch import mn_x86
from miasm2.expression.expression import get_rw
from miasm2.arch.x86.ira import ir_a_x86_32
print """
Simple expression manipulation demo.
Get read/written registers for a given instruction
"""

arch = mn_x86
ir_arch = ir_a_x86_32()

l = arch.fromstring('LODSB', 32)
l.offset, l.l = 0, 15
ir_arch.add_instr(l)

print '*' * 80
for lbl, b in ir_arch.blocs.items():
    print b
    for irs in b.irs:
        o_r, o_w = get_rw(irs)
        print 'read:   ', [str(x) for x in o_r]
        print 'written:', [str(x) for x in o_w]
        print

open('graph_instr.dot', 'w').write(ir_arch.graph.dot())