Adjustments in TriCore and add more instructions into tests/test_tricore.c

This commit is contained in:
Sidney Pontes Filho 2016-10-08 14:05:39 +02:00 committed by billow
parent 651aa5a1f1
commit 72cdfdab80
4 changed files with 7 additions and 14 deletions

View File

@ -41,12 +41,6 @@ void TriCore_post_printer(csh ud, cs_insn *insn, char *insn_asm, MCInst *mci)
*/
}
static void printRegName(SStream *OS, unsigned RegNo)
{
SStream_concat0(OS, "%");
SStream_concat0(OS, getRegisterName(RegNo));
}
#define GET_INSTRINFO_ENUM
#include "TriCoreGenInstrInfo.inc"
@ -63,7 +57,7 @@ static void printOperand(MCInst *MI, int OpNum, SStream *O)
if (MCOperand_isReg(Op)) {
unsigned int reg = MCOperand_getReg(Op);
printRegName(O, reg);
SStream_concat(O, "%%%s", getRegisterName(reg));
reg = TriCore_map_register(reg);
if (MI->csh->detail) {
@ -157,7 +151,7 @@ static void printAddrModeMemSrc(MCInst *MI, int OpNum, SStream *O) {
uint64_t Disp = (uint64_t)MCOperand_getImm(MCInst_getOperand(MI, OpNum + 1));
SStream_concat(O, "[");
printRegName(O, Base);
SStream_concat(O, "%%%s", getRegisterName(Base));
SStream_concat(O, "]");
if (Disp > HEX_THRESHOLD)

View File

@ -32,6 +32,9 @@ static cs_err init(cs_struct *ud)
static cs_err option(cs_struct *handle, cs_opt_type type, size_t value)
{
if (type == CS_OPT_SYNTAX)
handle->syntax = (int) value;
return CS_ERR_OK;
}

View File

@ -30,7 +30,6 @@ typedef enum tricore_op_type {
// This is associated with TRICORE_OP_MEM operand type above
typedef struct tricore_op_mem {
uint8_t base; // base register
uint8_t index; // index register
int32_t disp; // displacement/offset value
} tricore_op_mem;

View File

@ -47,7 +47,7 @@ static void print_insn_detail(cs_insn *ins)
default:
break;
case TRICORE_OP_REG:
printf("\t\toperands[%u].type: REG = %s, %d\n", i, cs_reg_name(handle, op->reg), op->reg);
printf("\t\toperands[%u].type: REG = %s\n", i, cs_reg_name(handle, op->reg));
break;
case TRICORE_OP_IMM:
printf("\t\toperands[%u].type: IMM = 0x%x\n", i, op->imm);
@ -57,9 +57,6 @@ static void print_insn_detail(cs_insn *ins)
if (op->mem.base != TRICORE_REG_INVALID)
printf("\t\t\toperands[%u].mem.base: REG = %s\n",
i, cs_reg_name(handle, op->mem.base));
if (op->mem.index != TRICORE_REG_INVALID)
printf("\t\t\toperands[%u].mem.index: REG = %s\n",
i, cs_reg_name(handle, op->mem.index));
if (op->mem.disp != 0)
printf("\t\t\toperands[%u].mem.disp: 0x%x\n", i, op->mem.disp);
@ -72,7 +69,7 @@ static void print_insn_detail(cs_insn *ins)
static void test()
{
#define TRICORE_CODE "\x16\x01\x20\x01\x1d\x00\x02\x00\x8f\x70\x00\x11\x40\xae\x89\xee\x04\x09\x42\xf2\xe2\xf2"
#define TRICORE_CODE "\x16\x01\x20\x01\x1d\x00\x02\x00\x8f\x70\x00\x11\x40\xae\x89\xee\x04\x09\x42\xf2\xe2\xf2\xc2\x11\x19\xff\xc0\x70\x19\xff\x20\x10"
struct platform platforms[] = {
{