Merge branch 'next' of github.com:aquynh/capstone into next

This commit is contained in:
Nguyen Anh Quynh 2019-05-09 22:20:48 +08:00
commit 8623090df7
4 changed files with 28 additions and 9 deletions

View File

@ -791,6 +791,11 @@ static void printOperand(MCInst *MI, unsigned OpNo, SStream *O)
#ifndef CAPSTONE_DIET #ifndef CAPSTONE_DIET
const char *RegName = getRegisterName(reg); 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. // The linux and AIX assembler does not take register prefixes.
if (MI->csh->syntax == CS_OPT_SYNTAX_NOREGNAME) if (MI->csh->syntax == CS_OPT_SYNTAX_NOREGNAME)
RegName = stripRegisterPrefix(RegName); RegName = stripRegisterPrefix(RegName);

View File

@ -13,7 +13,6 @@
#define GET_INSTRINFO_ENUM #define GET_INSTRINFO_ENUM
#include "PPCGenInstrInfo.inc" #include "PPCGenInstrInfo.inc"
#ifndef CAPSTONE_DIET
// NOTE: this reg_name_maps[] reflects the order of registers in ppc_reg // NOTE: this reg_name_maps[] reflects the order of registers in ppc_reg
static const name_map reg_name_maps[] = { static const name_map reg_name_maps[] = {
{ PPC_REG_INVALID, NULL }, { PPC_REG_INVALID, NULL },
@ -263,7 +262,6 @@ static const name_map reg_name_maps[] = {
{ PPC_REG_CR6UN, "cr6un" }, { PPC_REG_CR6UN, "cr6un" },
{ PPC_REG_CR7UN, "cr7un" }, { PPC_REG_CR7UN, "cr7un" },
}; };
#endif
const char *PPC_reg_name(csh handle, unsigned int reg) 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; 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[] = { static const insn_map insns[] = {
// dummy item // dummy item
{ {

View File

@ -9,6 +9,9 @@
// return name of regiser in friendly string // return name of regiser in friendly string
const char *PPC_reg_name(csh handle, unsigned int reg); 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 // given internal insn id, return public instruction info
void PPC_get_insn_id(cs_struct *h, cs_insn *insn, unsigned int id); void PPC_get_insn_id(cs_struct *h, cs_insn *insn, unsigned int id);

View File

@ -1474,7 +1474,7 @@
}, },
{ {
PPC_CMPD, PPC_INS_CMP, PPC_CMPD, PPC_INS_CMPD,
#ifndef CAPSTONE_DIET #ifndef CAPSTONE_DIET
{ 0 }, { 0 }, { 0 }, 0, 0 { 0 }, { 0 }, { 0 }, 0, 0
#endif #endif
@ -1516,7 +1516,7 @@
}, },
{ {
PPC_CMPLWI, PPC_INS_CMPLI, PPC_CMPLWI, PPC_INS_CMPLWI,
#ifndef CAPSTONE_DIET #ifndef CAPSTONE_DIET
{ 0 }, { 0 }, { 0 }, 0, 0 { 0 }, { 0 }, { 0 }, 0, 0
#endif #endif
@ -1537,7 +1537,7 @@
}, },
{ {
PPC_CMPWI, PPC_INS_CMPI, PPC_CMPWI, PPC_INS_CMPWI,
#ifndef CAPSTONE_DIET #ifndef CAPSTONE_DIET
{ 0 }, { 0 }, { 0 }, 0, 0 { 0 }, { 0 }, { 0 }, 0, 0
#endif #endif
@ -1691,7 +1691,7 @@
}, },
{ {
PPC_CROR, PPC_INS_CRMOVE, PPC_CROR, PPC_INS_CROR,
#ifndef CAPSTONE_DIET #ifndef CAPSTONE_DIET
{ 0 }, { 0 }, { 0 }, 0, 0 { 0 }, { 0 }, { 0 }, 0, 0
#endif #endif
@ -1705,7 +1705,7 @@
}, },
{ {
PPC_CRSET, PPC_INS_CREQV, PPC_CRSET, PPC_INS_CRSET,
#ifndef CAPSTONE_DIET #ifndef CAPSTONE_DIET
{ 0 }, { 0 }, { 0 }, 0, 0 { 0 }, { 0 }, { 0 }, 0, 0
#endif #endif
@ -10217,7 +10217,7 @@
}, },
{ {
PPC_VOR, PPC_INS_VMR, PPC_VOR, PPC_INS_VOR,
#ifndef CAPSTONE_DIET #ifndef CAPSTONE_DIET
{ 0 }, { 0 }, { PPC_GRP_ALTIVEC, 0 }, 0, 0 { 0 }, { 0 }, { PPC_GRP_ALTIVEC, 0 }, 0, 0
#endif #endif
@ -11015,7 +11015,7 @@
}, },
{ {
PPC_XORI, PPC_INS_XNOP, PPC_XORI, PPC_INS_XORI,
#ifndef CAPSTONE_DIET #ifndef CAPSTONE_DIET
{ 0 }, { 0 }, { 0 }, 0, 0 { 0 }, { 0 }, { 0 }, 0, 0
#endif #endif