Debian Codegraph @

bindings/python/tests/test_evm.py

raw symbols SCIP
1 #!/usr/bin/env python
2
3 # Capstone Python bindings, by Nguyen Anh Quynnh <[email protected]>
4
5 from __future__ import print_function
6 from capstone import *
7 import sys
8
9
10 _python3 = sys.version_info.major == 3
11
12
13 EVM_CODE = b"\x60\x61\x50"
14
15 all_tests = (
16 (CS_ARCH_EVM, 0, EVM_CODE, "EVM"),
17 )
18
19
20 def test_class():
21 address = 0x80001000
22 for (arch, mode, code, comment) in all_tests:
23 print("Platform: %s" % comment)
24 print("Code: %s " % code.hex(' '))
25 print("Disasm:")
26
27 try:
28 md = Cs(arch, mode)
29 md.detail = True
30 for i in md.disasm(code, address):
31 print("0x%x:\t%s\t%s" %(i.address, i.mnemonic, i.op_str))
32 if i.pop > 0:
33 print("\tPop: %u" %i.pop)
34 if i.push > 0:
35 print("\tPush: %u" %i.push)
36 if i.fee > 0:
37 print("\tGas fee: %u" %i.fee)
38 if len(i.groups) > 0:
39 print("\tGroups: ", end=''),
40 for m in i.groups:
41 print("%s " % i.group_name(m), end=''),
42 print()
43
44 except CsError as e:
45 print("ERROR: %s" % e.__str__())
46
47
48 if __name__ == '__main__':
49 test_class()