diff options
| author | Fabrice Desclaux <fabrice.desclaux@cea.fr> | 2014-09-19 15:27:13 +0200 |
|---|---|---|
| committer | Fabrice Desclaux <fabrice.desclaux@cea.fr> | 2014-09-19 15:27:13 +0200 |
| commit | 308e7127ab1f67d62d02496aa73385533f8a3e7a (patch) | |
| tree | ad1b5eab8133ef9cc3d188e63f482ac680bcfa9a /example/expression/get_read_write.py | |
| parent | 032263e8f58573c5cbb61928b9edcc62855c989d (diff) | |
| parent | 602f73846b316b7d6ba14f74355fb0da72571fb6 (diff) | |
| download | miasm-308e7127ab1f67d62d02496aa73385533f8a3e7a.tar.gz miasm-308e7127ab1f67d62d02496aa73385533f8a3e7a.zip | |
merge
Diffstat (limited to 'example/expression/get_read_write.py')
| -rw-r--r-- | example/expression/get_read_write.py | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/example/expression/get_read_write.py b/example/expression/get_read_write.py new file mode 100644 index 00000000..faa3f9df --- /dev/null +++ b/example/expression/get_read_write.py @@ -0,0 +1,26 @@ +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 +ir_arch.gen_graph() +g = ir_arch.graph() +open('graph_instr.txt', 'w').write(g) |