Commit Graph

68 Commits

Author SHA1 Message Date
Wu ChenXu
fe63ddb108 Merge pull request #1927 from ysat0/superh 2023-01-27 14:58:24 +08:00
Carlo Marcelo Arenas Belón
f5b668b2c5 cstool: avoid misaligned instructions in compressed riscv
When a compressed opcode is printed, make sure there is enough
extra space at the end of it for the instructions to align.
2022-12-18 01:26:24 -08:00
Xinyu Li
f40c8ba327 cstool: support riscv compressed instruction disassemble (#1940)
Signed-off-by: Xinyu Li <lixinyu@loongson.cn>

Signed-off-by: Xinyu Li <lixinyu@loongson.cn>
Co-authored-by: Xinyu Li <lixinyu@loongson.cn>
2022-12-03 09:57:40 +08:00
Yoshinori Sato
5b6846c2c8 SH: Add superh support for common part.
Signed-off-by: Yoshinori Sato <ysato@users.sourceforge.jp>
2022-10-12 20:11:05 +09:00
Richard Patel
f1a2281f03 Fix PPC insn names and psq displacement 2022-07-23 16:44:12 +02:00
Carlo Marcelo Arenas Belón
74282e18a2 systemz: pad instruction width up to 6 bytes (#1679)
instructions could be 2, 4 or 6 bytes so pad accordingly as it
was done on the other CISC architecture.
2020-09-16 17:03:34 +08:00
ksherlock
41e5f629ce updated 6502 support. (#1498)
* updated 6502 support. some improvements to the base 6502 support but also adds support for 65c02, w65c02, and 65816.

* add CS_OPT_SYNTAX_MOTOROLA.

This will use "$" as a hex prefix instead of "0x"

* remove excess blank lines
2019-06-03 23:20:51 +08:00
Nguyen Anh Quynh
d07228e856 cstool: add PPC32 mode 2019-05-08 18:17:00 +08:00
Nguyen Anh Quynh
b543c345ca ppc: sync with llvm 7.0.1 2019-04-30 13:50:42 +08:00
Nguyen Anh Quynh
25302d7e6e cstool: print instruction ID & name 2019-04-11 09:07:26 +08:00
Nguyen Anh Quynh
3b3f40fec5 cstool: add armv8be & thumbv8be modes 2019-03-15 20:16:45 +08:00
Nguyen Anh Quynh
9a8b23892a cstool: arm v8, thumb v8 2019-03-15 13:01:04 +08:00
Nguyen Anh Quynh
5ab5ed249a cstool: add armv8 & thumbv8 to usage instruction 2019-03-15 12:57:31 +08:00
z
b8fcf27b22 RISCV support ISRV32/ISRV64 (#1401)
* Added RISCV dir to contain the RISCV architecture engine code. Adding the TableGen files generated from llvm-tblgen. Add Disassembler.h

* Started working on RISCVDisassembler.c - RISCV_init(), RISCVDisassembler_getInstruction, and RISCV_getInstruction

* Added all functions to RISCVDisassembler.c and needed modifications to RISCVGenDisassemblerTables.inc. Add and modified RISCVGenSubtargetInfo.inc. Start creation of RISCVInstPrinter.h

* Finished RISCVGenAsmWriter.inc. Finished RISCVGenRegisterInfo.inc. Minor fixes to RISCVDisassembler.c. Working on RISCVInstPrinter

* Finished RISCVInstPrinter, RISCVMapping, RISCVBaseInfo, RISCVGenInstrInfo.inc, RISCVModule.c. Working on riscv.h

* Backport it from: 0db412ce3b

* All RISCV files added. Compiled correctly and initial test for ADD, ADDI, AND works properly.

* Add refactored cs.c for RISCV

* Testing all I instructions in test_riscv.c

* Modify the orignal backport for RISCVGenRegisterInfo.inc, capstone.h and test_iter to work w/ the current code strcuture

* Fix issue with RISCVGenRegisterInfo.inc - RISCVRegDesc[] (Excess elements in struct initializer). Added RISCV tests to test_iter.c

* fixed bug related to incorrect initialization of memory after malloc

* fix compile bug

* Fix compile errors.

* move riscv.h to include/capstone

* fix indentation issues

* fix coding style issues

* Fix indentation issues

* fix coding style

* Move variable declaration to the top of the block

* Fix coding indentation

* Move some stuff into RISCVMappingInsn.inc

* Fix code sytle

* remove cs_mode support for RISCV

* update asmwriter-inc to LLVM upstream

* update the .inc files to riscv upstream

* update riscv disassembler function for suport 16bit instructions

* update printer & tablegen inc files which have fixed arguments mismatch

* update headers and mapping source

* add riscv architecture specific test code

* fix all RISCV tons of compiler errors

* pass final tests

* add riscv tablegen patchs

* merge with upstream/next

* fix cstool missing riscv file

* fix root Makefile

* add new TableGen patchs for riscv

* fix cmakefile.txt of missing one riscv file

* fix declaration conflict

* fix incompatible declaration type

* change riscvc from arch to mode

* fix test_riscv warnning

* fix code style and add riscv part of test_basic

* add RISCV64 mode

* add suite for riscv

* crack fuzz test

* fix getfeaturebits test add riscvc

* fix test missing const qualifier warnning

* fix testcase type mismatch

* fix return value missing

* change getfeaturebits test

* add test cs files

* using a winder type contain the decode string

* fix a copy typo

* remove useless mode for riscv

* change cs file blank type

* add repo for update_riscv & fix cstool missing riscv mode

* fix typo

* add riscv for cstool useage

* add TableGen patch for riscv asmwriter

* clean ctags file

* remove black comment line

* fix fuzz related something

* fix missing RISCV string of fuzz

* update readme, etc..

* add riscv *.s.cs file

* add riscv *.s.cs file & clear ctags

* clear useless array declarations at capstone_test

* update to 5e4069f

* update readme change name more formal

* change position of riscv after bpf and modify copyright more uniform

* clear useless ctags file

* change blank with tab in riscv.h

* add riscv python bindings

* add riscv in __init__.py

* fix riscv define value for python binding

* fix test_riscv.py typo

* add missing riscvc in __init__.py of python bindings

* fix alias-insn printer bug, remove useless newline

* change inst print delimter from tab to bankspace for travis

* add riscv tablegen patch

* fix inst output more consistency

* add TableGen patch which fix inst output formal

* crack the effective address output for detail and change register print function

* fix not detail crash bug

* change item declaration position at cs_riscv

* update riscv.py

* change function name more meaningfull

* update python binding makefile

* fix register enum sequence according to riscvgenreginfo.inc

* test function name

* add enum s0/fp in riscv.h & update riscv_const.py

* add register name enum
2019-03-09 08:41:12 +08:00
Philippe Antoine
e3bcb06681 Make travis print the fuzzed input to be used with cstool
Adds architectures and modes to cstool as well
2019-02-28 00:59:33 +08:00
Nguyen Anh Quynh
a442e9d1f7 bpf: print setup config in cstool -v 2019-02-18 20:06:11 +08:00
david942j
9b3ead3ab8 fix conflicts 2019-02-18 20:04:30 +08:00
david942j
b227acc29c New architecture: BPF (#1388)
* Basic changes of new arch - BPF

* Define some constants

* defined some API methods

* Able to print MISC instruction

* Follow Linux coding style

* Ability to show ALU insn names

* decode return

* Add suite/MC/BPF

* decode jump

* decode store

* decode load

* print instruction done

* try to implement BPF_reg_access

* Implements explicit accessed registers and fix some tiny bugs

* Fix unhandled ja case

* Added BPF_REG_OFF do fix wrong display in jump class

* Great I'm able to decode cBPF with eyes

* Fix: misunderstood the 16-byte instruction's imm

* Add ldxdw

* Add extended-all.cs

* Implements cstest/bpf_getdetail.c

* Fix memory leak

* Add BPF to fuzz

* Implemented regs_read and regs_write

* Fix missing write-access on ALU's dst

* Updated cstool/, test_basic.c, test_detail.c, and test_iter.c

* Updated docs

* Fix type of cs_bpf#operands

* Implements python bindings

* Fix some bugs found by self code review

* Remove dummy tests

* remove typeof

* Address comments

* Fix MSVC's warnings and add test_bpf.py to bindings/python/Makefile

* Fix: call is not offset
2019-02-18 17:39:51 +08:00
Nguyen Anh Quynh
a7f12d96b0 cstool: print extra options in alphabet order 2019-02-18 10:45:52 +08:00
Nguyen Anh Quynh
19351b5b76 cstool: indent Wasm usage 2019-02-18 10:44:12 +08:00
Nguyen Anh Quynh
1104bf8bd2 cstool: set prototype for function 'print_string_hex', to silence compiler warning 2019-02-03 14:46:54 +08:00
Nguyen Anh Quynh
b6c253e22b cstool: sort flags in alphabet order 2019-02-02 07:44:44 +08:00
Spike
55f242d498 Add webassembly arch (#1359)
* add wasm arch

* fix bug

* delete todo & add wasm into readme
2019-02-01 23:03:47 +08:00
Nguyen Anh Quynh
48ba21041b cstool: cleanup usage instructions 2019-01-23 14:39:01 +08:00
Nguyen Anh Quynh
120fe0425a cstool: add MOS65XX to output of -v option 2019-01-09 18:32:33 +08:00
Nguyen Anh Quynh
2ff3baa138 cstool -v print out the core build setup 2019-01-09 18:32:33 +08:00
Nguyen Anh Quynh
8a6c520e8f Merge branch 'master' into next 2019-01-04 17:24:16 +08:00
Nguyen Anh Quynh
82c77d663d cstool: add -s option to turn on skipdata mode on disassembling 2019-01-04 17:23:15 +08:00
Sebastian Macke
82cd4c0747 Add support for the MOS65XX family such as the MOS 6502.
Signed-off-by: Sebastian Macke <sebastian@macke.de>
2018-12-06 22:53:33 +01:00
Riccardo Schirone
60616a6175 cstool: fix memleak to prevent ASAN from complaining (#1222) 2018-07-24 10:19:07 +08:00
Nguyen Anh Quynh
cdf269e020 fix warnings on const char * discards qualifiers 2018-07-24 01:41:59 +08:00
Nguyen Anh Quynh
9c7a094b58 add Ethereum VM architecture 2018-03-31 17:29:22 +08:00
Priit Laes
cc4ace75cc cstool: Add cortexm support (#1100) 2018-03-20 08:52:33 +08:00
Nguyen Anh Quynh
94134fd045 cstool: align assembly output 2017-10-25 01:03:24 +08:00
Wolfgang Schwotzer
e8d1f1d4d2 M680X: Target ready for pull request (#1034)
* Added new M680X target. Supports M6800/1/2/3/9, HD6301

* M680X: Reformat for coding guide lines. Set alphabetical order in HACK.TXT

* M680X: Prepare for python binding. Move cs_m680x, m680x_insn to m680x_info. Chec
> k cpu type, no default.

* M680X: Add python bindings. Added python tests.

* M680X: Added cpu types to usage message.

* cstool: Avoid segfault for invalid <arch+mode>.

* Make test_m680x.c/test_m680x.py output comparable (diff params: -bu). Keep xprint.py untouched.

* M680X: Update CMake/make for m680x support. Update .gitignore.

* M680X: Reduce compiler warnings.

* M680X: Reduce compiler warnings.

* M680X: Reduce compiler warnings.

* M680X: Make test_m680x.c/test_m680x.py output comparable (diff params: -bu).

* M680X: Add ocaml bindings and tests.

* M680X: Add java bindings and tests.

* M680X: Added tests for all indexed addressing modes. C/Python/Ocaml

* M680X: Naming, use page1 for PAGE1 instructions (without prefix).

* M680X: Naming, use page1 for PAGE1 instructions (without prefix).

* M680X: Used M680X_FIRST_OP_IN_MNEM in tests C/python/java/ocaml.

* M680X: Added access property to cs_m680x_op.

* M680X: Added operand size.

* M680X: Remove compiler warnings.

* M680X: Added READ/WRITE access property per operator.

* M680X: Make reg_inherent_hdlr independent of CPU type.

* M680X: Add HD6309 support + bug fixes

* M680X: Remove errors and warning.

* M680X: Add Bcc/LBcc to group BRAREL (relative branch).

* M680X: Add group JUMP to BVS/BVC/LBVS/LBVC. Remove BRAREL from BRN/LBRN.

* M680X: Remove LBRN from group BRAREL.

* M680X: Refactored cpu_type initialization for better readability.

* M680X: Add two operands for insn having two reg. in mnemonic. e.g. ABX.

* M680X: Remove typo in cstool.c

* M680X: Some format improvements in changed_regs.

* M680X: Remove insn id string list from tests (C/python/java/ocaml).

* M680X: SEXW, set access of reg. D to WRITE.

* M680X: Sort changed_regs in increasing m680x_insn order.

* M680X: Add M68HC11 support + Reduced from two to one INDEXED operand.

* M680X: cstool, also write '(in mnemonic)' for second reg. operand.

* M680X: Add BRN/LBRN to group JUMP and BRAREL.

* M680X: For Bcc/LBcc/BRSET/BRCLR set reg. CC to read access.

* M680X: Correctly print negative immediate values with option CS_OPT_UNSIGNED.

* M680X: Rename some instruction handlers.

* M680X: Add M68HC05 support.

* M680X: Dont print prefix '<' for direct addr. mode.

* M680X: Add M68HC08 support + resorted tables + bug fixes.

* M680X: Add Freescale HCS08 support.

* M680X: Changed group names, avoid spaces.

* M680X: Refactoring, rename addessing mode handlers.

* M680X: indexed addr. mode, changed pre/post inc-/decrement representation.

* M680X: Rename some M6809/HD6309 specific functions.

* M680X: Add CPU12 (68HC12/HCS12) support.

* M680X: Correctly display illegal instruction as FCB .

* M680X: bugfix: BRA/BRN/BSR/LBRA/LBRN/LBSR does not read CC reg.

* M680X: bugfix: Correctly check for sufficient code size for M6809 indexed addressing.

* M680X: Better support for changing insn id within handler for addessing mode.

* M680X: Remove warnings.

* M680X: In set_changed_regs_read_write_counts use own access_mode.

* M680X: Split cpu specific tables into separate *.inc files.

* M680X: Remove warnings.

* M680X: Removed address_mode. Addressing mode is available in operand.type

* M680X: Bugfix: BSET/BCLR/BRSET/BRCLR correct read/modify CC reg.

* M680X: Remove register TMP1. It is first visible in CPU12X.

* M680X: Performance improvement + bug fixes.

* M680X: Performance improvement, make cpu_tables const static.

* M680X: Simplify operand decoding by using two handlers.

* M680X: Replace M680X_OP_INDEX by M680X_OP_CONSTANT + bugfix in java/python/ocaml bindings.

* M680X: Format with astyle.

* M680X: Update documentation.

* M680X: Corrected author for m680x specific files.

* M680X: Make max. number of architectures single source.
2017-10-21 21:44:36 +08:00
Ruslan Kabatsayev
41f765f1f5 cstool: Separate instruction bytes by spaces (#1009) 2017-09-06 20:35:19 +07:00
Nguyen Anh Quynh
819dd2231e cstool: fix #975 2017-07-26 23:22:46 +08:00
Nguyen Anh Quynh
589585ecc1 cstool: some cleanup 2017-07-04 16:04:53 +08:00
Sergi Àlvarez i Capilla
8561f15d66 Refactor cstool to use getopt -100LOC (#953)
* Refactor cstool to use getopt -100LOC

* Add getopt.h for portability

* Do not use os-specific separators in include paths
2017-07-04 15:55:46 +08:00
radare
7a4567612c Honor CS_OPT_UNSIGNED on x86 and add cstool -u (#945) 2017-06-16 02:13:28 +08:00
Nguyen Anh Quynh
c768fa919f cstool: support arm64be 2017-04-25 21:33:26 +08:00
Fotis Loukos
e963a1e17c Added cstool support for tms320c64x 2017-04-17 11:58:29 +03:00
Nguyen Anh Quynh
bd20ee1f75 cstool: fix mips64 mode 2017-04-11 09:45:55 +08:00
Nguyen Anh Quynh
bb6e792f03 cstool: support armbe mode 2017-03-10 20:30:55 +08:00
Ben Cheney
19b89432eb Fix build under VS2012 (i.e. MSC_VER = 1700)
cstool.c currently imports inttypes.h, which breaks
building on older Visual Studio versions (I've been
testing 2012). This commit removes the explicit include
of inttypes.h, which is already handled in platform.h
(which is included by capstone.h). A define for the
function strtoull (used by cstool) has also been added
to platform.h for the case where MSC_VER <= 1700.

I don't know what effect this will have on OS X builds
as I'm unable to test on that platform.

Also, cstool.c doesn't need to include stdio.h
because it's already included by capstone.h.
2016-12-21 11:00:25 +08:00
Nguyen Anh Quynh
c9a2148b05 cstool: print out insn groups 2016-11-05 00:47:14 +08:00
Nguyen Anh Quynh
008a840a56 cstool: use switch 2016-11-05 00:43:22 +08:00
Nguyen Anh Quynh
bdf1b97a51 cstool: remove its version 2016-11-04 23:57:52 +08:00
Nguyen Anh Quynh
835042587f cleanup 2016-10-28 16:12:05 +08:00
Nguyen Anh Quynh
0a6b074929 Merge branch 'next' of https://github.com/echotyh/capstone into echotyh-next 2016-10-28 16:04:52 +08:00