aboutsummaryrefslogtreecommitdiffstats
path: root/capstone/bindings/python/test_evm.py
blob: 81f646423836e3a4b5117383abfda5f104c6fa19 (plain)
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
26
27
28
29
#!/usr/bin/env python

# Capstone Python bindings, by Nguyen Anh Quynnh <aquynh@gmail.com>

from __future__ import print_function
from capstone import *
from xprint import to_hex

CODE = "\x60\x61\x50"
cs = Cs(CS_ARCH_EVM, 0)
cs.detail = True

print("Platform: EVM")
print("Code: %s" %to_hex(CODE))
print("Disasm:")

for i in cs.disasm(CODE, 0x80001000):
    print("0x%x:\t%s\t%s" %(i.address, i.mnemonic, i.op_str))
    if i.pop > 0:
        print("\tPop:     %u" %i.pop)
    if i.push > 0:
        print("\tPush:    %u" %i.push)
    if i.fee > 0:
        print("\tGas fee: %u" %i.fee)
    if len(i.groups) > 0:
        print("\tGroups: ", end=''),
        for m in i.groups:
            print("%s " % i.group_name(m), end=''),
        print()