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

'subtracted' flag is set incorrectly #695

Closed
vnd opened this issue Jun 7, 2016 · 5 comments
Closed

'subtracted' flag is set incorrectly #695

vnd opened this issue Jun 7, 2016 · 5 comments

Comments

@vnd
Copy link

vnd commented Jun 7, 2016

0xe1f200b2 (ldrh r0, [r2, #2]! in ARMv7) is decoded as:

Insn {
    address: 1614951176,
    size: 4,
    mnemonic: Some(
        "ldrh"
    ),
    op_str: Some(
        "r0, [r2, #2]!"
    )
}
ARMDetail {
    usermode: false,
    vector_size: 0,
    vector_data: 0,
    cps_mode: ARM_CPSMODE_INVALID,
    cps_flag: ARM_CPSFLAG_INVALID,
    cc: ARM_CC_AL,
    update_flags: false,
    writeback: true,
    mem_barrier: 0,
    op_count: 2,
    operands: [
        ARMOp {
            vector_index: -1,
            shift_type: 0,
            shift_value: 0,
            ty: ARM_OP_REG,
            data: [
                66,
                0
            ],
            subtracted: false
        },
        ARMOp {
            vector_index: -1,
            shift_type: 0,
            shift_value: 0,
            ty: ARM_OP_MEM,
            data: [
                68,
                8589934593
            ],
            **subtracted: true**
        }
    ]
}

Data of the second operand is:

Mem(
    ARMOpMem {
        base: 68,
        index: 0,
        scale: 1,
        disp: 2
    }
)

(the above is an output from Rust wrapper around capstone but I've checked it via plain C program as well)

'subtracted' for the second operands seems to be set incorrectly.

@vnd
Copy link
Author

vnd commented Jun 8, 2016

Also happens for strh (0xe1e530b2).

@aquynh
Copy link
Collaborator

aquynh commented Jun 18, 2016

your code is not properly formatted. you can either put them inside triple "`" (without quote), or paste them to gist.github.com, and put a link to it here.

for the record, can you post your C program reproducing this as well?

@vnd
Copy link
Author

vnd commented Jun 18, 2016

Fixed formatting, here's also a code of C program https://gist.github.com/vnd/76ba4d470c49fb6ed8b962bf54300e3c and it's output:

$ ./decode 0xe1e530b2
e1e530b2
0x0:    strh            r3, [r5, #2]!   209
subtracted for op 0: 0
subtracted for op 1: 1
subtracted for op 2: 0
        This instruction belongs to groups: 147 
$ ./decode 0xe1f200b2
e1f200b2
0x0:    ldrh            r0, [r2, #2]!   66
subtracted for op 0: 0
subtracted for op 1: 1
subtracted for op 2: 0
        This instruction belongs to groups: 147 

@offlinemark
Copy link

+1

@kabeor
Copy link
Member

kabeor commented Dec 7, 2021

Close this issue for now because of legacy, we are preparing to release Capstone 5.0, plz feel free to open a new issue if that still has this issue.
thx :)

@kabeor kabeor closed this as completed Dec 7, 2021
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

No branches or pull requests

4 participants