Skip to content

arm thumb invalid instruction: lda r0, [r0] #1783

@enoorez

Description

@enoorez

Bytecode \xd0\xE8\xAF\x0f should be disassembled into 'LDA R0, [R0]' in thumb mode, but capstone cannot decompile, And the result obtained through cs_errno() is CS_ OK

The following is the test code and the output of the code:

int main()
{
	cs_mode mode[] = { CS_MODE_ARM,CS_MODE_THUMB ,CS_MODE_V8 };
	const char* strmode[] = { "CS_MODE_ARM","CS_MODE_THUMB ","CS_MODE_V8"};
	csh ud;
	for (int i = 0; i < _countof(mode); ++i) {
		cs_open(CS_ARCH_ARM, mode[i], &ud);
		cs_insn* insn;
		cs_disasm(ud, (uint8_t*)"\xD0\xE8\xAF\x0F", 4, 0, 1, &insn);
		if (insn == nullptr) {
			printf("%s fail : %s\n", strmode[i], cs_strerror(cs_errno(ud)));
		}
		else {
			printf("%s success : %s %s\n", strmode[i], insn->mnemonic, insn->op_str);
			cs_free(insn, 1);
		}
		cs_close(&ud);
	}
	return 0;
}

----------------------------------------- the output --------------------------------------------

CS_MODE_ARM success : svceq #0xafe8d0
CS_MODE_THUMB  fail : OK (CS_ERR_OK)
CS_MODE_V8 success : svceq #0xafe8d0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions