58 Commits

Author SHA1 Message Date
Richard Henderson
936dca0e2d Constify backends (#1549)
* Constify registerinfo.py output

Remove two conditionals separating identical bits of code.
Add "const" markup to MCRegisterDesc and MCRegisterClass.

Signed-off-by: Richard Henderson <rth@twiddle.net>

* Constify instrinfo-arch.py output

In this case, do not actively strip const.

Signed-off-by: Richard Henderson <rth@twiddle.net>

* Constify the AArch64 backend

Signed-off-by: Richard Henderson <rth@twiddle.net>

* Constify the EVM backend

Signed-off-by: Richard Henderson <rth@twiddle.net>

* Constify M680X backend

Signed-off-by: Richard Henderson <rth@twiddle.net>

* Constify M68K backend

Signed-off-by: Richard Henderson <rth@twiddle.net>

* Constify the Mips backend

The Mips backend has not been regenerated from LLVM recently,
and there are more fixups required than I'd like.  Just apply
the fixes to the tables by hand for now.

Signed-off-by: Richard Henderson <rth@twiddle.net>

* Constify the Sparc backend

Signed-off-by: Richard Henderson <rth@twiddle.net>

* Constify the TMS320C64x backend

Signed-off-by: Richard Henderson <rth@twiddle.net>

* Constify the X86 backend

Signed-off-by: Richard Henderson <rth@twiddle.net>

* Constify the XCore backend

Signed-off-by: Richard Henderson <rth@twiddle.net>

* Constify systemregister.py output

Signed-off-by: Richard Henderson <rth@twiddle.net>

* Constify the ARM backend

Signed-off-by: Richard Henderson <rth@twiddle.net>

* Constify the PowerPC backend

Signed-off-by: Richard Henderson <rth@twiddle.net>

* Constify the MOS65XX backend

Signed-off-by: Richard Henderson <rth@twiddle.net>

* Constify the SystemZ backend

The mapping of system register to indexes is easy to
generate read-only.  Since we know the indexes are
between 0 and 31, use uint8_t instead of unsigned.

Signed-off-by: Richard Henderson <rth@twiddle.net>

* Constify the WASM backend

Signed-off-by: Richard Henderson <rth@twiddle.net>

* Constify cs.c

Signed-off-by: Richard Henderson <rth@twiddle.net>

* Constify the BPF backend

Signed-off-by: Richard Henderson <rth@twiddle.net>
2019-12-23 20:30:57 +08:00
Travis Finkenauer
31d0de4552 [M68K] store correct register value in op.reg_pair (#1411)
* m68k: store correct m68k_reg value in op.reg_pair

Originally, value - M68K_REG_D0 was stored and the print logic added
M68K_REG_D0.

* m68k: fix license typo
2019-03-02 17:40:29 +08:00
Daniel Collin
9f53e3b0d4 Made instruction table static (#1408) 2019-03-02 10:53:30 +08:00
david942j
a512e2668f Fixed m68k has wrong type of read_imm_64 (#1369) 2019-02-06 00:07:54 +08:00
Marius Melzer
7d20c40060 Fix missing-prototypes warnings (#1348) 2019-01-22 08:43:02 +08:00
clslgrnc
91601ac1fd Init cs_detail (#1205)
* Update init of cs_detail for AArch64

as @aquynh requested in #1125

* Update init of cs_detail for ARM

as @aquynh requested in #1125

* Update init of cs_detail for EVM

as @aquynh requested in #1125

* Update init of cs_detail for M680X

as @aquynh requested in #1125

* Update init of cs_detail for M68K

as @aquynh requested in #1125

* Update init of cs_detail for Mips

as @aquynh requested in #1125

* Update init of cs_detail for PowerPC

as @aquynh requested in #1125

* Update init of cs_detail for Sparc

as @aquynh requested in #1125

* Update init of cs_detail for SystemZ

as @aquynh requested in #1125

* Update init of cs_detail for TMS320C64x

as @aquynh requested in #1125

* Update init of cs_detail for XCore

as @aquynh requested in #1125

* Comment on init of cs_detail

* wrap long lines
2018-07-12 11:01:34 +07:00
Catena cyber
f1f5fca1b5 M68K increment index after having written register (#1147) 2018-06-01 20:53:01 +08:00
Catena cyber
d937c94cac Fix buffer overflow in M68K (#1146) 2018-06-01 20:52:37 +08:00
Daniel Collin
d3080c4d0c Fixed incorrect size of code check (#1130)
Also added a sanity check that the code is at least 2 bytes before trying to disassemble.

Also removed some unused code while at it
2018-05-10 15:06:46 +08:00
Kalmalyzer
9944bfde76 M68K: Branch targets are a separate addressing mode; PC relative displacements printed as target addresses (#1068)
* Branch targets are a separate addressing mode

Branch targets are relative displacements that identify code locations. These are neither .w nor .l nor immediates. This change removes the immediate #s before branch target addresses in disassembly, and represents the actual branch instructions more accurately in the cs_m68k_op datastructure.

M68K Python bindings have also been updated.

* m68k_inst.pc handles better; print target for PC relative offsets

Previous changes to branch operations relied on m68k_inst.pc pointing to (start of instruction + 2). This was not the case - it pointed to the end of the current instruction. This change makes it so that m68k_inst.pc points to (start of instruction), which is simple to work with.

It also changes printing of PC relative offsets to print the absolute target address, which is consistent with how most 68000 assemblers & disassemblers behave.
2018-01-06 20:13:41 +08:00
Alfredo Beaumont
f82395b959 Relative branch group (#964)
* Add a new group for relative branching instructions

* x86: Add relative branch group to appropiate instructions

* Rename RELATIVE_BRANCH to BRANCH_RELATIVE

* aarch64: Add relative branch group to appropiate instructions

* arm: Add relative branch group to appropiate instructions

* m68k: Add relative branch group to appropiate instructions

* mips: Add relative branch group to appropiate instructions
2017-07-30 19:05:03 +08:00
Daniel Collin
1510c4f26f Fixed incorrect 8-bit displacement
8-bit displacement was treated as unsigned while it should actually be signed.
2017-01-23 20:11:53 +01:00
BartmanAbyss
6830660783 (M68k) make displacements signed (#836)
* (M68k) make displacements signed

* (M68k) revert group changes

* (m68k) signed displacement in python bindings
2017-01-01 01:11:48 +08:00
Nguyen Anh Quynh
a4634b45dc Merge pull request #696 from emoon/m68k-reg-read-write
[M68K] Implemented regs read/write lists
2016-08-11 11:22:48 +08:00
Daniel Collin
147083be67 [M68K] Implemented regs read/write lists 2016-08-09 17:29:36 +02:00
Niels Boehm
06cc17d41c Fix typo in m68k constant for immediate operand. 2016-06-15 08:25:59 +02:00
pancake
1614338ead Append LL for all > 32bit numeric immediates 2016-06-06 17:38:09 +02:00
Nguyen Anh Quynh
e3f94ac4ab fix merging conflict 2016-05-22 08:58:33 +08:00
tandasat
e36384e224 Merge remote-tracking branch 'upstream/next' into next 2016-05-11 22:52:34 -07:00
tandasat
d4ef430b33 port Windows driver support 2016-05-11 21:48:32 -07:00
Inokentiy Babushkin
bd139c663a Added enum tag setting to FPU handling code for m68k 2016-05-09 23:09:27 +02:00
Inokentiy Babushkin
46e10afb24 Changed register pair handling in M68K header
* instead of using bit operations, we now leverage the size of the
  enclosing union to avoid running code and provide a more convenient
  interface to the library user.
2016-05-08 23:19:47 +02:00
jmechnich
4906bf1de9 m68k: fixed d68000_move_to_sr
* instruction is available for all processors, not 68010+ (see e.g.
   https://www.nxp.com/files/archives/doc/ref_manual/M68000PRM.pdf, p. 6-19)
 * operand size is WORD not BYTE
2016-04-16 23:07:00 +02:00
Daniel Collin
0bcb2e546c Various fixes
* Fixed a break indentation
* Fixed incorrect enum value for M68K_GRP_IRET
* Fixed so groups_count is set to 0 at init
* Added group_count printing in python example
2016-04-10 16:16:28 +02:00
Daniel Collin
d994c74b02 [M68K] Added basic groups
Added support for basic groups in the M68K backend. Also did some minor cleanups/whitespace fixes while at it.

Relates to this issue https://github.com/aquynh/capstone/issues/494
2016-04-10 10:55:21 +02:00
jmechnich
29ad5e671d M68KDisassembler.c: fixed typo in d68000_roxr_ea 2016-04-03 13:50:28 +02:00
Nguyen Anh Quynh
92807007ac m68k: indentation 2016-03-30 09:39:24 +08:00
jmechnich
1f9d2ace95 bugfix: use proper order for operands in M68K movem 2016-03-25 22:04:04 +01:00
Nguyen Anh Quynh
017267e0ea fix some MSVC warnings 2016-03-08 11:08:20 +08:00
Nguyen Anh Quynh
15768eafb0 fix some compilation warnings reported by MSVC 2016-03-08 00:49:15 +08:00
Nicolas PLANEL
626510c5e5 [M68K] avoid mixed declarations and code
Avoid mixed declarations and code reported by the gcc warning flag :
-Wdeclaration-after-statement.
Introduce new m68k_read_safe_16/32/64() method.
2015-10-12 21:31:16 +11:00
Nicolas PLANEL
97aca80830 [M68K] add const helper
Add some const aim to help inlining.

Signed-off-by: Nicolas PLANEL <nplanel@gmail.com>
2015-10-10 22:47:48 +11:00
Nicolas PLANEL
91f3cdb475 [M68K] move peek/read macros to real functions
Some compilers don't like statements in macro.
Anyway modern compiler should optimized (read inline)
2015-10-10 19:53:50 +11:00
Daniel Collin
997112d3d2 Removed a big chunk of unused stuff
* Cleaned up M68KDisassembler.h with legacy stuff from Musashi which isn't used at all.
* Removed M68KConf.h which isn't needed anymore.
* Made some functions static as they are now only local to the current file.
2015-10-10 19:30:04 +11:00
Nicolas PLANEL
5f9257cfaa [M68K] use M68K line A for memory data poisoning
In case of out of bound access return a poison value to force to point to
d68000_invalid() opcode. This will force instruction_is_valid() to return
false and capstone will do skipdata.
Line A are more M68K standard invalid lines than 0x0808.
2015-10-08 22:27:59 +11:00
Nicolas PLANEL
af1d39d336 cleanup peek/read macros
Remove unused m68k_read_disassembler_8(), rework peek/read macros.

Signed-off-by: Nicolas PLANEL <nplanel@gmail.com>
2015-10-08 22:22:39 +11:00
Nicolas PLANEL
8daac3a164 Add boundary checker
Avoid reading bytes outside of the code section.
Trick by returning bad data (illegal instruction) to force capstone to skip data.

Signed-off-by: Nicolas PLANEL <nplanel@gmail.com>
2015-10-08 16:41:03 +11:00
Nicolas PLANEL
d1b5c3f384 cleanup : move the initialization of m68k_info
Simplify the code by moving the initialization of printer_info (m68k_info)
at the right place, in the module.init() function.

Signed-off-by: Nicolas PLANEL <nplanel@gmail.com>
2015-10-08 16:40:56 +11:00
Nicolas PLANEL
b9f66d63c9 [M68K] fixup increment pc only if the instruction_is_valid()
m68k_disassemble() should return the number of decoded bytes, aim to help
M68K_getInstruction() to return if it was a good instruction or not.

Signed-off-by: Nicolas PLANEL <nplanel@gmail.com>
2015-10-08 16:39:02 +11:00
Nicolas PLANEL
ee33bcf967 [M68K] fixup read/peak() address_line_mask
The correct implementation : addr = (address - base) & address_line_mask
2015-10-08 15:21:24 +11:00
Nicolas PLANEL
e661bd0cfc [M68K] Coverity fixup : remove old/dead code.
if(info) should be removed as it's an old part of the code that has been forgotten before merging.

Didn't cause any Bug as info is always true.
Related to issue #494

Signed-off-by: Nicolas PLANEL <nplanel@gmail.com>
2015-10-07 18:10:43 +11:00
Daniel Collin
25d2ea6ac6 Fixed MSVC warnings 2015-10-05 16:31:06 +02:00
Nguyen Anh Quynh
9331ffc517 Merge branch 'print_info' of https://github.com/nplanel/capstone into nplanel-print_info 2015-10-05 21:50:54 +08:00
Nicolas PLANEL
e996c4a3bb [M68K] we don't need anymore cleaning printer_info is case of error
Will not change the behavior, cs_close() we cleanup printer_info for us.
2015-10-05 22:19:28 +11:00
Nicolas PLANEL
78b0722b1d [M68K] handle->printer_info need to be check
handle->printer_info need to be check, not instruction_info.
2015-10-05 22:03:20 +11:00
Nicolas PLANEL
44cc3d0c1e [M68K] printer_info need to be allocated only once
printer_info need to be allocated only once. cs_close() will cleanup for us.

Signed-off-by: Nicolas PLANEL <nplanel@gmail.com>
2015-10-05 21:57:01 +11:00
Nicolas PLANEL
d529ea0db7 [M68K] Use printer_info to share private info between disassembler and printer
Implementation is done by adding cs_m68k extension field in m68k_info.
The private m68k_info structure is allocated in M68K_getInstruction() (disassembly)
and free (if no error) by M68K_printInst() (printer).

Signed-off-by: Nicolas PLANEL <nplanel@gmail.com>
2015-10-05 20:19:45 +11:00
Nicolas PLANEL
ee75626661 [M68K] remove global dependency aim to have reentrant code
Remove the last global bytes :
static uint8_t* s_disassemblyBuffer;
static uint32_t s_baseAddress;

Introduce private struct m68k_info on the heap for future use.

Signed-off-by: Nicolas PLANEL <nplanel@gmail.com>
2015-10-05 19:26:37 +11:00
Nguyen Anh Quynh
58fe7cd068 m68k: more coding style 2015-10-05 16:05:17 +08:00
Nguyen Anh Quynh
7d5badd641 m68k: more cleanup & fix code style 2015-10-04 21:45:50 +08:00