Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"if-then" disassembled incorrectly for ARM Thumb #1195

Closed
lwerdna opened this issue Jul 3, 2018 · 4 comments · Fixed by #1949
Closed

"if-then" disassembled incorrectly for ARM Thumb #1195

lwerdna opened this issue Jul 3, 2018 · 4 comments · Fixed by #1949

Comments

@lwerdna
Copy link

lwerdna commented Jul 3, 2018

Instruction word 0xBFF6 should be "itet" but instead is "itte". Here is minimal code to reproduce:

#!/usr/bin/env python
from capstone import *
md = Cs(CS_ARCH_ARM, CS_MODE_BIG_ENDIAN|CS_MODE_THUMB)
for i in md.disasm("\xbf\xf6", 0):
	print("0x%x:\t%s\t%s" %(i.address, i.mnemonic, i.op_str))

Here are the bit fields:

+----+----+-----------+------+
|1011|1111|firstcond.4|mask.4|
+----+----+-----------+------+
|1011|1111|       1111|  0110|
+----+----+-----------+------+

Looking up '0110' in table A8-2 in doc DDI0406C gives the "et" correct answer. Also verified with online disassembler.

@lwerdna
Copy link
Author

lwerdna commented Jul 3, 2018

Another example: 0xbff5 has fields:

+----+----+-----------+------+
|1011|1111|firstcond.4|mask.4|
+----+----+-----------+------+
|1011|1111|       1111|  0101|
+----+----+-----------+------+

And should be itete but capstone gives the complement ittet. The https://onlinedisassembler.com corroborates itete.

@aquynh
Copy link
Collaborator

aquynh commented Jul 3, 2018

you can use cstool to avoid writing testcase.

on the "next" branch, we have:

$ cstool thumbbe bff6
 0  bf f6  itte al

$ cstool thumbbe bff5
 0  bf f5  ittet al

is this correct?

@lwerdna
Copy link
Author

lwerdna commented Jul 7, 2018

Thanks for the cstool recommendation.

No, those are the erroneous outputs I reported.

cstool thumbbe bff6 should return itet al or itet <und> (not itte al)
cstool thumbbe bff5 should return itete al or itete <und> (not ittet al)

@Rot127
Copy link
Collaborator

Rot127 commented May 6, 2023

llvm-objdump says otherwise:

000003fc <_start>:
     3fc: bff6         	itte	al

@kabeor Can be closed?

@kabeor kabeor closed this as completed May 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants