1Code structure
2--------------
3
4Capstone source is organized as followings.
5
6.                   <- core engine + README + COMPILE.TXT etc
7├── arch            <- code handling disasm engine for each arch
8│   ├── AArch64     <- ARM64 (aka ARMv8) engine
9│   ├── ARM         <- ARM engine
10│   ├── EVM         <- Ethereum engine
11│   ├── M680X       <- M680X engine
12│   ├── M68K        <- M68K engine
13│   ├── Mips        <- Mips engine
14│   ├── MOS65XX     <- MOS65XX engine
15│   ├── PowerPC     <- PowerPC engine
16│   ├── Sparc       <- Sparc engine
17│   ├── SystemZ     <- SystemZ engine
18│   ├── TMS320C64x  <- TMS320C64x engine
19│   ├── X86         <- X86 engine
20│   └── XCore       <- XCore engine
21├── bindings        <- all bindings are under this dir
22│   ├── java        <- Java bindings + test code
23│   ├── ocaml       <- Ocaml bindings + test code
24│   └── python      <- Python bindings + test code
25├── contrib         <- Code contributed by community to help Capstone integration
26├── cstool          <- Cstool
27├── docs            <- Documentation
28├── include         <- API headers in C language (*.h)
29├── msvc            <- Microsoft Visual Studio support (for Windows compile)
30├── packages        <- Packages for Linux/OSX/BSD.
31├── windows         <- Windows support (for Windows kernel driver compile)
32├── suite           <- Development test tools - for Capstone developers only
33├── tests           <- Test code (in C language)
34└── xcode           <- Xcode support (for MacOSX compile)
35
36
37Follow instructions in COMPILE.TXT for how to compile and run test code.
38
39Note: if you find some strange bugs, it is recommended to firstly clean
40the code and try to recompile/reinstall again. This can be done with:
41
42	$ ./make.sh
43	$ sudo ./make.sh install
44
45Then test Capstone with cstool, for example:
46
47	$ cstool x32 "90 91"
48
49At the same time, for Java/Ocaml/Python bindings, be sure to always use
50the bindings coming with the core to avoid potential incompatibility issue
51with older versions.
52See bindings/<language>/README for detail instructions on how to compile &
53install the bindings.
54
55
56Coding style
57------------
58- C code follows Linux kernel coding style, using tabs for indentation.
59- Python code uses 4 spaces for indentation.
60
61
62Adding an architecture
63----------------------
64
65Obviously, you first need to write all the logic and put it in a new directory arch/newarch
66Then, you have to modify other files.
67(You can look for one architecture such as EVM in these files to get what you need to do)
68
69Integrate:
70- cs.c
71- cstool/cstool.c
72- cstool/cstool_newarch.c: print the architecture specific details
73- include/capstone/capstone.h
74- include/capstone/newarch.h: create this file to export all specifics about the new architecture
75
76Compile:
77- CMakeLists.txt
78- Makefile
79- config.mk
80
81Tests:
82- tests/Makefile
83- tests/test_basic.c
84- tests/test_detail.c
85- tests/test_iter.c
86- tests/test_newarch.c
87- suite/fuzz/fuzz_disasm.c: add the architecture and its modes to the list of fuzzed platforms
88
89Bindings:
90- bindings/Makefile
91- bindings/const_generator.py: add the header file and the architecture
92- bindings/python/Makefile
93- bindings/python/capstone/__init__.py
94- bindings/python/capstone/newarch.py: define the python structures
95- bindings/python/capstone/newarch_const.py: generate this file
96- bindings/python/test_newarch.py: create a basic decoding test
97- bindings/python/test_all.py
98
99Docs:
100- README.md
101- HACK.txt
102- CREDITS.txt: add your name
103