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

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

Closed
enoorez opened this issue Sep 18, 2021 · 0 comments · Fixed by #1949
Closed

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

enoorez opened this issue Sep 18, 2021 · 0 comments · Fixed by #1949

Comments

@enoorez
Copy link

enoorez commented Sep 18, 2021

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

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.

1 participant