Skip to content

arm64 python binding, insn.cc is wrong #2751

@poisonflood

Description

@poisonflood

Work environment

Questions Answers
System Capstone runs on OS/arch/bits Linux gentoo 6.15.3-x64v3 #1 SMP PREEMPT_DYNAMIC Tue Jul 8 01:48:29 JST 2025 x86_64 Intel(R) Xeon(R) CPU E5-2696 v4 @ 2.20GHz GenuineIntel GNU/Linux
Capstone module affected x86_64
Source of Capstone pip
Version/git commit v5.0.6

Steps to get the wrong result

with Python

CODE = b'\x90\x90\x90\x90'

md = Cs(CS_ARCH_ARM64, CS_MODE_ARM)
md.detail = True
  
CODE = b'\x00\x98\x03\x54'  # b.eq #0x45264
for insn in md.disasm(CODE, 0):
      print(f"Instruction: {insn.mnemonic} {insn.op_str}")
      print(f"Condition Code: {insn.cc}")

Expected results

It should be:

Instruction: b.eq #0x7300
Condition Code: 0

Wrong(real) results

Instruction: b.eq #0x7300
Condition Code: 1

the cc code should be 0 , when eq. as list below:
AArch64CC_EQ = 0x0
AArch64CC_NE = 0x1
AArch64CC_HS = 0x2
AArch64CC_LO = 0x3
AArch64CC_MI = 0x4
AArch64CC_PL = 0x5
AArch64CC_VS = 0x6
AArch64CC_VC = 0x7
AArch64CC_HI = 0x8
AArch64CC_LS = 0x9
AArch64CC_GE = 0xa
AArch64CC_LT = 0xb
AArch64CC_GT = 0xc
AArch64CC_LE = 0xd
AArch64CC_AL = 0xe
AArch64CC_NV = 0xf
AArch64CC_Invalid = 16

[a2 13 00 54] "b.hs #0x3e408" -> cs_insn.cc: 3 ; should be 2
[01 96 00 54] "b.ne #0x3fe0c" -> cs_insn.cc: 2 ; should be 1
[8a 00 00 54] "b.ge #0x41c9c" -> cs_insn.cc: 11; should be 10

Additional Logs, screenshots, source code, configuration dump, ...

Drag and drop zip archives containing the Additional info here, don't use external services or link.
Screenshots can be directly dropped here.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions