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] Return first the system register name then the banked one #2116

Merged
merged 1 commit into from
Jul 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions arch/ARM/ARMMapping.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,18 @@ const char *ARM_reg_name(csh handle, unsigned int reg)
return alias;

if (reg == ARM_REG_INVALID || reg >= ARM_REG_ENDING) {
// This might be a system register encoding.
const ARMBankedReg_BankedReg *banked_reg =
ARMBankedReg_lookupBankedRegByEncoding(reg);
if (banked_reg)
return banked_reg->Name;
// This might be a system register or banked register encoding.
// Note: The system and banked register encodings can overlap.
// So this might return a system register name although a
// banked register name is expected.
const ARMSysReg_MClassSysReg *sys_reg =
ARMSysReg_lookupMClassSysRegByEncoding(reg);
if (sys_reg)
return sys_reg->Name;
const ARMBankedReg_BankedReg *banked_reg =
ARMBankedReg_lookupBankedRegByEncoding(reg);
if (banked_reg)
return banked_reg->Name;
}

if (syntax_opt & CS_OPT_SYNTAX_NOREGNAME) {
Expand Down
2 changes: 1 addition & 1 deletion cstool/cstool_arm.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ void print_insn_detail_arm(csh handle, cs_insn *ins)
printf("\t\toperands[%u].type: SETEND = %s\n", i, op->setend == ARM_SETEND_BE? "be" : "le");
break;
case ARM_OP_SYSREG:
printf("\t\toperands[%u].type: SYSREG = %u\n", i, op->reg);
printf("\t\toperands[%u].type: SYSREG = %s\n", i, cs_reg_name(handle, op->reg));
break;
}

Expand Down