Skip to content

Commit

Permalink
arm: add new mode CS_MODE_MCLASS for Cortex-M series. updated Python …
Browse files Browse the repository at this point in the history
…& Java bindings accordingly
  • Loading branch information
aquynh committed Aug 13, 2014
1 parent b52f11f commit 7c089fd
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 4 deletions.
5 changes: 3 additions & 2 deletions arch/ARM/ARMDisassembler.c
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ static DecodeStatus DecodeMRRC2(MCInst *Inst, unsigned Val,
uint64_t Address, const void *Decoder);

// Hacky: enable all features for disassembler
uint64_t ARM_getFeatureBits(int mode)
uint64_t ARM_getFeatureBits(unsigned int mode)
{
uint64_t Bits = (uint64_t)-1; // everything by default

Expand All @@ -377,7 +377,8 @@ uint64_t ARM_getFeatureBits(int mode)
//Bits &= ~ARM_HasV8Ops;
//Bits &= ~ARM_HasV6Ops;

Bits &= (~ARM_FeatureMClass);
if ((mode & CS_MODE_MCLASS) == 0)
Bits &= (~ARM_FeatureMClass);

// some features are mutually exclusive
if (mode & CS_MODE_THUMB) {
Expand Down
2 changes: 1 addition & 1 deletion arch/ARM/ARMDisassembler.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ bool ARM_getInstruction(csh handle, const uint8_t *code, size_t code_len, MCInst

bool Thumb_getInstruction(csh handle, const uint8_t *code, size_t code_len, MCInst *instr, uint16_t *size, uint64_t address, void *info);

uint64_t ARM_getFeatureBits(int mode);
uint64_t ARM_getFeatureBits(unsigned int mode);

#endif
2 changes: 1 addition & 1 deletion arch/ARM/ARMModule.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ static cs_err init(cs_struct *ud)

// verify if requested mode is valid
if (ud->mode & ~(CS_MODE_LITTLE_ENDIAN | CS_MODE_ARM |
CS_MODE_THUMB | CS_MODE_BIG_ENDIAN))
CS_MODE_MCLASS | CS_MODE_THUMB | CS_MODE_BIG_ENDIAN))
return CS_ERR_MODE;

mri = cs_mem_malloc(sizeof(*mri));
Expand Down
1 change: 1 addition & 0 deletions bindings/java/capstone/Capstone.java
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,7 @@ public NativeLong cs_disasm_ex(NativeLong handle, byte[] code, NativeLong code_l
public static final int CS_MODE_32 = 1 << 2;
public static final int CS_MODE_64 = 1 << 3;
public static final int CS_MODE_THUMB = 1 << 4; // ARM's Thumb mode, including Thumb-2
public static final int CS_MODE_MCLASS = 1 << 5; // ARM's Cortex-M series
public static final int CS_MODE_MICRO = 1 << 4; // MicroMips mode (Mips arch)
public static final int CS_MODE_N64 = 1 << 5; // Nintendo-64 mode (Mips arch)
public static final int CS_MODE_BIG_ENDIAN = 1 << 31;
Expand Down
2 changes: 2 additions & 0 deletions bindings/python/capstone/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
'CS_MODE_64',
'CS_MODE_ARM',
'CS_MODE_THUMB',
'CS_MODE_MCLASS',
'CS_MODE_MICRO',
'CS_MODE_N64',
'CS_MODE_V9',
Expand Down Expand Up @@ -96,6 +97,7 @@
CS_MODE_32 = (1 << 2) # 32-bit mode (for X86, Mips)
CS_MODE_64 = (1 << 3) # 64-bit mode (for X86, Mips)
CS_MODE_THUMB = (1 << 4) # ARM's Thumb mode, including Thumb-2
CS_MODE_MCLASS = (1 << 5) # ARM's Cortex-M series
CS_MODE_MICRO = (1 << 4) # MicroMips mode (MIPS architecture)
CS_MODE_N64 = (1 << 5) # Nintendo-64 mode (MIPS architecture)
CS_MODE_V9 = (1 << 4) # Nintendo-64 mode (MIPS architecture)
Expand Down
1 change: 1 addition & 0 deletions include/capstone.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ typedef enum cs_mode {
CS_MODE_32 = 1 << 2, // 32-bit mode
CS_MODE_64 = 1 << 3, // 64-bit mode
CS_MODE_THUMB = 1 << 4, // ARM's Thumb mode, including Thumb-2
CS_MODE_MCLASS = 1 << 5, // ARM's Cortex-M series
CS_MODE_MICRO = 1 << 4, // MicroMips mode (MIPS architecture)
CS_MODE_N64 = 1 << 5, // Nintendo-64 mode (MIPS architecture)
CS_MODE_V9 = 1 << 4, // SparcV9 mode (Sparc architecture)
Expand Down

0 comments on commit 7c089fd

Please sign in to comment.