2016-10-14 12:47:29 +00:00
|
|
|
/* Capstone Disassembler Engine */
|
|
|
|
/* By Nguyen Anh Quynh <aquynh@gmail.com>, 2013-2014 */
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
2016-10-21 09:03:27 +00:00
|
|
|
#include <capstone/capstone.h>
|
2023-05-09 12:46:10 +00:00
|
|
|
#include "cstool.h"
|
2016-10-14 12:47:29 +00:00
|
|
|
|
2024-09-14 08:57:54 +00:00
|
|
|
void print_insn_detail_systemz(csh handle, cs_insn *ins)
|
2016-10-14 12:47:29 +00:00
|
|
|
{
|
2024-09-14 08:57:54 +00:00
|
|
|
cs_systemz *systemz;
|
2016-10-21 08:42:47 +00:00
|
|
|
int i;
|
|
|
|
|
|
|
|
// detail can be NULL on "data" instruction if SKIPDATA option is turned ON
|
|
|
|
if (ins->detail == NULL)
|
|
|
|
return;
|
|
|
|
|
2024-09-14 08:57:54 +00:00
|
|
|
systemz = &(ins->detail->systemz);
|
|
|
|
if (systemz->op_count)
|
|
|
|
printf("\top_count: %u\n", systemz->op_count);
|
2016-10-21 08:42:47 +00:00
|
|
|
|
2024-09-14 08:57:54 +00:00
|
|
|
for (i = 0; i < systemz->op_count; i++) {
|
|
|
|
cs_systemz_op *op = &(systemz->operands[i]);
|
2016-10-21 08:42:47 +00:00
|
|
|
switch((int)op->type) {
|
|
|
|
default:
|
|
|
|
break;
|
2024-09-14 08:57:54 +00:00
|
|
|
case SYSTEMZ_OP_REG:
|
2016-10-21 08:42:47 +00:00
|
|
|
printf("\t\toperands[%u].type: REG = %s\n", i, cs_reg_name(handle, op->reg));
|
|
|
|
break;
|
2024-09-14 08:57:54 +00:00
|
|
|
case SYSTEMZ_OP_IMM:
|
2016-10-21 08:42:47 +00:00
|
|
|
printf("\t\toperands[%u].type: IMM = 0x%" PRIx64 "\n", i, op->imm);
|
|
|
|
break;
|
2024-09-14 08:57:54 +00:00
|
|
|
case SYSTEMZ_OP_MEM:
|
2016-10-21 08:42:47 +00:00
|
|
|
printf("\t\toperands[%u].type: MEM\n", i);
|
2024-09-14 08:57:54 +00:00
|
|
|
if (op->mem.base != SYSTEMZ_REG_INVALID)
|
2016-10-21 08:42:47 +00:00
|
|
|
printf("\t\t\toperands[%u].mem.base: REG = %s\n",
|
|
|
|
i, cs_reg_name(handle, op->mem.base));
|
2024-09-14 08:57:54 +00:00
|
|
|
if (op->mem.index != SYSTEMZ_REG_INVALID)
|
2016-10-21 08:42:47 +00:00
|
|
|
printf("\t\t\toperands[%u].mem.index: REG = %s\n",
|
|
|
|
i, cs_reg_name(handle, op->mem.index));
|
2024-09-14 08:57:54 +00:00
|
|
|
if (op->mem.length != 0) {
|
2024-09-18 13:19:42 +00:00
|
|
|
printf("\t\t\toperands[%u].mem.length: 0x%" PRIx64 "\n", i, op->mem.length);
|
2024-09-14 08:57:54 +00:00
|
|
|
}
|
|
|
|
printf("\t\t\toperands[%u].mem.disp: 0x%" PRIx64 "\n", i, op->mem.disp);
|
|
|
|
switch(op->mem.am) {
|
|
|
|
default:
|
|
|
|
printf("\t\t\toperands[%u].mem.am: UNHANDLED\n", i);
|
|
|
|
break;
|
|
|
|
case SYSTEMZ_AM_BD:
|
|
|
|
printf("\t\t\toperands[%u].mem.am: SYSTEMZ_AM_BD\n", i);
|
|
|
|
break;
|
|
|
|
case SYSTEMZ_AM_BDX:
|
|
|
|
printf("\t\t\toperands[%u].mem.am: SYSTEMZ_AM_BDX\n", i);
|
|
|
|
break;
|
|
|
|
case SYSTEMZ_AM_BDL:
|
|
|
|
printf("\t\t\toperands[%u].mem.am: SYSTEMZ_AM_BDL\n", i);
|
|
|
|
break;
|
|
|
|
case SYSTEMZ_AM_BDR:
|
|
|
|
printf("\t\t\toperands[%u].mem.am: SYSTEMZ_AM_BDR\n", i);
|
|
|
|
break;
|
|
|
|
case SYSTEMZ_AM_BDV:
|
|
|
|
printf("\t\t\toperands[%u].mem.am: SYSTEMZ_AM_BDV\n", i);
|
|
|
|
break;
|
|
|
|
}
|
2016-10-21 08:42:47 +00:00
|
|
|
break;
|
|
|
|
}
|
2024-09-14 08:57:54 +00:00
|
|
|
switch(op->access) {
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
case CS_AC_READ:
|
|
|
|
printf("\t\toperands[%u].access: READ\n", i);
|
|
|
|
break;
|
|
|
|
case CS_AC_WRITE:
|
|
|
|
printf("\t\toperands[%u].access: WRITE\n", i);
|
|
|
|
break;
|
|
|
|
case CS_AC_READ | CS_AC_WRITE:
|
|
|
|
printf("\t\toperands[%u].access: READ | WRITE\n", i);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2016-10-21 08:42:47 +00:00
|
|
|
}
|
|
|
|
|
2024-09-14 08:57:54 +00:00
|
|
|
if (systemz->cc != SYSTEMZ_CC_INVALID)
|
|
|
|
printf("\tCode condition: %u\n", systemz->cc);
|
2016-10-14 12:47:29 +00:00
|
|
|
}
|