Commit Graph

88 Commits

Author SHA1 Message Date
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
Erik Hemming
44ce36d1ad Fix a couple of corner-cases with rarely used m68k instructions. (#1344)
* Bump the "cs_insn.bytes[]" size to 24 (from 16) to support M680x0 instructions with full EA (maximum 11 words)
Added a test for this in test_m68k.s

* Bump the "cs_detail.regs_read[]" size to 16 (from 12) to support M680x0 instructions with full REG_BITS (Dn+An = 16)

* m68k: use immediate mode syntax (#$0) for movem/fmovem instructions with empty register list

* update bindings to match changes to cs_insn and cs_detail
2019-01-21 17:42:01 +08:00
Riccardo Schirone
b512f388cf arch/M68k: do not return reg_name if beyond limits (#1219)
* arch/M68k: do not return reg_name if beyond limits

(patch coming from radare2)

* arch: checks index when returning reg names
2018-07-24 13:40: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
Travis Finkenauer
292116bd0d Declare global arch arrays with contents (next branch) (#1186)
* Declare global arch arrays with contents (#1171)

This eliminates the need for archs_enable() and eliminates the racey
initialization.

This makes the architecture-specific init and option functions
non-static so that they may be called from a different file.

Cherry-picked 853a2870

* Add cs_arch_disallowed_mode_mask global

Cherry-pick 94bce437:
mips: CS_MODE_MIPS32R6 implies CS_MODE_32

Cherry-pick 8998a3a1:
ppc: fix endian check (#1029)
Fixes bug where endianness could not be set for ppc.

Remove `big_endian` field of `cs_struct`.
Added a helper macro `MODE_IS_BIG_ENDIAN()` to check if
`CS_MODE_BIG_ENDIAN` is set.

Refactored `cs_open()` check for valid mode out of arch-specific code
into arch-independent code. Also added a valid mode check to
`cs_option()`.  The checks use a new global array
`cs_arch_disallowed_mode_mask[]`.

* Make global arrays static

Make all_arch uint32_t to guarantee a certain number of bits (with
adequate room for growth).
2018-06-24 21:05:04 +08:00
Catena cyber
6c796d996b We can read more registers from M68K (#1151) 2018-06-02 01:08:54 +08: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
Alberto Garcia Illera
3c8e828b14 prefix cs_ to global variables to avoid link problems (#1108)
* prefix cs_ to global variables to avoid link problems

* force Capstone to be build using MT

* fix identation
2018-03-29 22:17:37 +08:00
Nguyen Anh Quynh
1b166ebdf4 m68k: update bindings after #1068 2018-01-06 20:16:58 +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
Daniel Collin
3b43ddb92c [M68K] Fixed invalid base reg (#1028)
This is one of those “how did this ever work?” changes. Problem was that as m68k_op was aliased with the imm value so when changing that to something big it would trash the values in the mem struct which would make things go really bad.

Now m68k_op_mem has been moved out of the union so this will not happen again. Also fixed instruction printing bug related to this (just happend to “work” due to the old union layout)
2017-10-13 09:06:01 +08:00
Alfredo Beaumont
5fc444c073 Add name to relative branch group in supported architectures. (#982) 2017-08-01 16:49:43 +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
Satoshi Tanda
c6592d5c7e suppress MSVC code analysis (PREfast) warnings for m68k
Signed-off-by: Satoshi Tanda <tanda.sat@gmail.com>
2016-09-28 07:59:25 -07: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
tandasat
7b2f93068d port #684 to the next branch 2016-05-16 20:32:36 -07:00
tandasat
6e79b1ac32 Merge remote-tracking branch 'upstream/next' into next 2016-05-13 07:38:42 -07: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
c7dae68dec Adjusted operand printing 2016-05-09 21:47:10 +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
Nguyen Anh Quynh
d5277c10f0 Merge branch 'next' of https://github.com/koutheir/capstone into koutheir-next 2016-04-12 23:05:37 +07: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
Koutheir Attouchi
9f2070748c Added support for building binaries for Windows CE 7 on ARMv7 (a.k.a., Windows Embedded Compact 7) and for Windows CE 8 on ARMv7 (a.k.a., Windows Embedded Compact 2013).
Added support for building binaries for Windows CE 7 on ARMv7 (a.k.a., Windows Embedded Compact 7) and for Windows CE 8 on ARMv7 (a.k.a., Windows Embedded Compact 2013).

Added support for building binaries for Windows CE 7 on ARMv7 (a.k.a., Windows Embedded Compact 7) and for Windows CE 8 on ARMv7 (a.k.a., Windows Embedded Compact 2013).

Replaced header inclusions of "stdint.h" and "intrin.h" by selective inclusions to support platforms that do not provide those headers. The header "platform.h" handles the platform test.
Updated the build script for Windows CE 7 on ARMv7.
2016-04-07 17:05:00 +02:00
Nguyen Anh Quynh
a95ee1da44 Merge pull request #617 from jmechnich/next-m68k-am-pci-index-8-bit-disp-size-missing-fix
M68KInstPrinter.c: print size after register in M68K_AM_PCI_INDEX_8_B…
2016-04-05 12:39:32 +07:00
jmechnich
1f38441efd M68KInstPrinter.c: removed space between register name and size indicator 2016-04-03 20:37:17 +02:00
jmechnich
14df65f933 M68KInstPrinter.c: print size after register in M68K_AM_PCI_INDEX_8_BIT_DISP 2016-04-03 19:36:46 +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