about summary refs log tree commit diff stats
path: root/example/asm_msp430_sc.py
diff options
context:
space:
mode:
authorCamille Mougey <camille.mougey@cea.fr>2015-01-18 18:36:23 +0100
committerCamille Mougey <camille.mougey@cea.fr>2015-01-23 17:24:43 +0100
commit663b49b712b4309d44e2ae77e37f26861c4906b7 (patch)
treefb853170d0183a2b15925057ef76bef2ea59eda4 /example/asm_msp430_sc.py
parent488cb99d4d61a0b3b176f7e3c53431872fc234ef (diff)
downloadmiasm-663b49b712b4309d44e2ae77e37f26861c4906b7.tar.gz
miasm-663b49b712b4309d44e2ae77e37f26861c4906b7.zip
Example: Move asm's examples to a `asm` directory
Diffstat (limited to 'example/asm_msp430_sc.py')
-rw-r--r--example/asm_msp430_sc.py52
1 files changed, 0 insertions, 52 deletions
diff --git a/example/asm_msp430_sc.py b/example/asm_msp430_sc.py
deleted file mode 100644
index de488803..00000000
--- a/example/asm_msp430_sc.py
+++ /dev/null
@@ -1,52 +0,0 @@
-#! /usr/bin/env python
-from pdb import pm
-
-from elfesteem.strpatchwork import StrPatchwork
-
-from miasm2.core import asmbloc
-from miasm2.core.cpu import parse_ast
-from miasm2.arch.msp430.arch import mn_msp430, base_expr
-from miasm2.core import parse_asm
-import miasm2.expression.expression as m2_expr
-
-reg_and_id = dict(mn_msp430.regs.all_regs_ids_byname)
-
-
-def my_ast_int2expr(a):
-    return m2_expr.ExprInt32(a)
-
-
-def my_ast_id2expr(t):
-    return reg_and_id.get(t, m2_expr.ExprId(t, size=32))
-
-my_var_parser = parse_ast(my_ast_id2expr, my_ast_int2expr)
-base_expr.setParseAction(my_var_parser)
-
-
-st = StrPatchwork()
-
-blocs, symbol_pool = parse_asm.parse_txt(mn_msp430, None, '''
-main:
-    mov.w      0x10, R10
-    mov.w      0x0, R11
-loop:
-    add.w      1, R11
-    sub.w      1, R10
-    jnz        loop
-    mov.w      @SP+, PC
-''')
-
-# fix shellcode addr
-symbol_pool.set_offset(symbol_pool.getby_name("main"), 0)
-
-for b in blocs[0]:
-    print b
-
-resolved_b, patches = asmbloc.asm_resolve_final(
-    mn_msp430, blocs[0], symbol_pool)
-print patches
-
-for offset, raw in patches.items():
-    st[offset] = raw
-
-open('msp430_sc.bin', 'wb').write(str(st))