mirror of
https://github.com/capstone-engine/capstone.git
synced 2025-02-17 12:58:06 +00:00
ppc: proper map internal register ID to public register ID
This commit is contained in:
parent
63c07ba724
commit
37dda9d4b7
@ -791,6 +791,11 @@ static void printOperand(MCInst *MI, unsigned OpNo, SStream *O)
|
||||
#ifndef CAPSTONE_DIET
|
||||
const char *RegName = getRegisterName(reg);
|
||||
|
||||
// printf("reg = %u (%s)\n", reg, RegName);
|
||||
|
||||
// convert internal register ID to public register ID
|
||||
reg = PPC_name_reg(RegName);
|
||||
|
||||
// The linux and AIX assembler does not take register prefixes.
|
||||
if (MI->csh->syntax == CS_OPT_SYNTAX_NOREGNAME)
|
||||
RegName = stripRegisterPrefix(RegName);
|
||||
|
@ -13,7 +13,6 @@
|
||||
#define GET_INSTRINFO_ENUM
|
||||
#include "PPCGenInstrInfo.inc"
|
||||
|
||||
#ifndef CAPSTONE_DIET
|
||||
// NOTE: this reg_name_maps[] reflects the order of registers in ppc_reg
|
||||
static const name_map reg_name_maps[] = {
|
||||
{ PPC_REG_INVALID, NULL },
|
||||
@ -263,7 +262,6 @@ static const name_map reg_name_maps[] = {
|
||||
{ PPC_REG_CR6UN, "cr6un" },
|
||||
{ PPC_REG_CR7UN, "cr7un" },
|
||||
};
|
||||
#endif
|
||||
|
||||
const char *PPC_reg_name(csh handle, unsigned int reg)
|
||||
{
|
||||
@ -295,6 +293,19 @@ const char *PPC_reg_name(csh handle, unsigned int reg)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ppc_reg PPC_name_reg(const char *name)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
for(i = 1; i < ARR_SIZE(reg_name_maps); i++) {
|
||||
if (!strcmp(name, reg_name_maps[i].name))
|
||||
return reg_name_maps[i].id;
|
||||
}
|
||||
|
||||
// not found
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const insn_map insns[] = {
|
||||
// dummy item
|
||||
{
|
||||
|
@ -9,6 +9,9 @@
|
||||
// return name of regiser in friendly string
|
||||
const char *PPC_reg_name(csh handle, unsigned int reg);
|
||||
|
||||
// return register id, given register name
|
||||
ppc_reg PPC_name_reg(const char *name);
|
||||
|
||||
// given internal insn id, return public instruction info
|
||||
void PPC_get_insn_id(cs_struct *h, cs_insn *insn, unsigned int id);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user