diff options
author | Sean Keys <skeys@ipdatasys.com> | 2013-10-11 04:55:42 +0000 |
---|---|---|
committer | Sean Keys <skeys@ipdatasys.com> | 2013-10-11 04:55:42 +0000 |
commit | 0e1c2434015db29e87a515288dafff24b8844efc (patch) | |
tree | 22696a6167073fc6e7ecb67c78e52448a08a471f /opcodes/xgate-dis.c | |
parent | bd80dc1a7cdcbf8113f69b1f05b0bc7f03152a03 (diff) | |
download | gdb-0e1c2434015db29e87a515288dafff24b8844efc.zip gdb-0e1c2434015db29e87a515288dafff24b8844efc.tar.gz gdb-0e1c2434015db29e87a515288dafff24b8844efc.tar.bz2 |
* Removed short_hand field from opcode table and
refactored assembler/disassember accordingly.
Testsuite checkout OK.
Diffstat (limited to 'opcodes/xgate-dis.c')
-rw-r--r-- | opcodes/xgate-dis.c | 228 |
1 files changed, 102 insertions, 126 deletions
diff --git a/opcodes/xgate-dis.c b/opcodes/xgate-dis.c index 31f44d6..61dfbe1 100644 --- a/opcodes/xgate-dis.c +++ b/opcodes/xgate-dis.c @@ -124,83 +124,69 @@ print_insn (bfd_vma memaddr, struct disassemble_info* info) (*info->fprintf_func)(info->stream, "%s", decodePTR->opcodePTR->name); /* First we compare the shorthand format of the constraints. If we - still are unable to pinpoint the operands - we analyze the opcodes constraint string. */ - switch (decodePTR->opcodePTR->sh_format) - { - case XG_R_C: - (*info->fprintf_func)(info->stream, " R%x, CCR", - (raw_code >> 8) & 0x7); - break; - case XG_C_R: - (*info->fprintf_func)(info->stream, " CCR, R%x", - (raw_code >> 8) & 0x7); - break; - case XG_R_P: - (*info->fprintf_func)(info->stream, " R%x, PC", - (raw_code >> 8) & 0x7); - break; - case XG_INH: - break; - case XG_R_R_R: - if (!strcmp (decodePTR->opcodePTR->constraints, XGATE_OP_TRI)) - { - (*info->fprintf_func)(info->stream, " R%x, R%x, R%x", - (raw_code >> 8) & 0x7, (raw_code >> 5) & 0x7, - (raw_code >> 2) & 0x7); - } - else if (!strcmp (decodePTR->opcodePTR->constraints, XGATE_OP_IDR)) - { - if (raw_code & 0x01) - { - (*info->fprintf_func)(info->stream, " R%x, (R%x, R%x+)", - (raw_code >> 8) & 0x7, (raw_code >> 5) & 0x7, - (raw_code >> 2) & 0x7); - } - else if (raw_code & 0x02) - { - (*info->fprintf_func)(info->stream, " R%x, (R%x, -R%x)", - (raw_code >> 8) & 0x7, (raw_code >> 5) & 0x7, - (raw_code >> 2) & 0x7); - } - else - { - (*info->fprintf_func)(info->stream, " R%x, (R%x, R%x)", - (raw_code >> 8) & 0x7, (raw_code >> 5) & 0x7, - (raw_code >> 2) & 0x7); - } - } - else - { - (*info->fprintf_func)(info->stream, " unhandled mode %s", - decodePTR->opcodePTR->constraints); - } - break; - case XG_R_R: - if (!strcmp (decodePTR->opcodePTR->constraints, XGATE_OP_DYA)) - { - operandOne = ripBits (&operMaskReg, 3, opcodePTR, raw_code); - operandTwo = ripBits (&operMaskReg, 3, opcodePTR, raw_code); - (*info->fprintf_func)(info->stream, " R%x, R%x", operandOne, - operandTwo); - } - else - { - (*info->fprintf_func)(info->stream, " unhandled mode %s", - opcodePTR->constraints); - } - break; - case XG_R_R_I: - (*info->fprintf_func)(info->stream, " R%x, (R%x, #0x%x)", - (raw_code >> 8) & 0x7, (raw_code >> 5) & 0x7, raw_code & 0x1f); - break; - case XG_R: - operandOne = ripBits (&operMaskReg, 3, decodePTR->opcodePTR, - raw_code); - (*info->fprintf_func)(info->stream, " R%x", operandOne); - break; - case XG_I | XG_PCREL: - if (!strcmp (decodePTR->opcodePTR->constraints, XGATE_OP_REL9)) + still are unable to pinpoint the operands + we analyze the opcodes constraint string. */ + if (!strcmp (decodePTR->opcodePTR->constraints, XGATE_OP_MON_R_C)) + { + (*info->fprintf_func)(info->stream, " R%x, CCR", + (raw_code >> 8) & 0x7); + } + else if (!strcmp (decodePTR->opcodePTR->constraints, XGATE_OP_MON_C_R)) + { + (*info->fprintf_func)(info->stream, " CCR, R%x", + (raw_code >> 8) & 0x7); + } + else if (!strcmp (decodePTR->opcodePTR->constraints, XGATE_OP_MON_R_P)) + { + (*info->fprintf_func)(info->stream, " R%x, PC", + (raw_code >> 8) & 0x7); + } + else if (!strcmp (decodePTR->opcodePTR->constraints, XGATE_OP_TRI)) + { + (*info->fprintf_func)(info->stream, " R%x, R%x, R%x", + (raw_code >> 8) & 0x7, (raw_code >> 5) & 0x7, + (raw_code >> 2) & 0x7); + } + else if (!strcmp (decodePTR->opcodePTR->constraints, XGATE_OP_IDR)) + { + if (raw_code & 0x01) + { + (*info->fprintf_func)(info->stream, " R%x, (R%x, R%x+)", + (raw_code >> 8) & 0x7, (raw_code >> 5) & 0x7, + (raw_code >> 2) & 0x7); + } + else if (raw_code & 0x02) + { + (*info->fprintf_func)(info->stream, " R%x, (R%x, -R%x)", + (raw_code >> 8) & 0x7, (raw_code >> 5) & 0x7, + (raw_code >> 2) & 0x7); + } + else + { + (*info->fprintf_func)(info->stream, " R%x, (R%x, R%x)", + (raw_code >> 8) & 0x7, (raw_code >> 5) & 0x7, + (raw_code >> 2) & 0x7); + } + } + else if (!strcmp (decodePTR->opcodePTR->constraints, XGATE_OP_DYA)) + { + operandOne = ripBits (&operMaskReg, 3, opcodePTR, raw_code); + operandTwo = ripBits (&operMaskReg, 3, opcodePTR, raw_code); + ( *info->fprintf_func)(info->stream, " R%x, R%x", operandOne, + operandTwo); + } + else if (!strcmp (decodePTR->opcodePTR->constraints, XGATE_OP_IDO5)) + { + (*info->fprintf_func)(info->stream, " R%x, (R%x, #0x%x)", + (raw_code >> 8) & 0x7, (raw_code >> 5) & 0x7, raw_code & 0x1f); + } + else if (!strcmp (decodePTR->opcodePTR->constraints, XGATE_OP_MON)) + { + operandOne = ripBits (&operMaskReg, 3, decodePTR->opcodePTR, + raw_code); + (*info->fprintf_func)(info->stream, " R%x", operandOne); + } + else if (!strcmp (decodePTR->opcodePTR->constraints, XGATE_OP_REL9)) { /* If address is negative handle it accordingly. */ if (raw_code & XGATE_NINE_SIGNBIT) @@ -215,10 +201,10 @@ print_insn (bfd_vma memaddr, struct disassemble_info* info) relAddr = raw_code & 0xff; relAddr = (relAddr << 1) + 2; } - (*info->fprintf_func)(info->stream, " *%d", relAddr); - (*info->fprintf_func)(info->stream, " Abs* 0x"); - (*info->print_address_func)(memaddr + relAddr, info); - } + (*info->fprintf_func)(info->stream, " *%d", relAddr); + (*info->fprintf_func)(info->stream, " Abs* 0x"); + (*info->print_address_func)(memaddr + relAddr, info); + } else if (!strcmp (decodePTR->opcodePTR->constraints, XGATE_OP_REL10)) { /* If address is negative handle it accordingly. */ @@ -238,54 +224,44 @@ print_insn (bfd_vma memaddr, struct disassemble_info* info) (*info->fprintf_func)(info->stream, " Abs* 0x"); (*info->print_address_func)(memaddr + relAddr, info); } + else if (!strcmp (decodePTR->opcodePTR->constraints, XGATE_OP_IMM4)) + { + (*info->fprintf_func)(info->stream, " R%x, #0x%02x", + (raw_code >> 8) & 0x7, (raw_code >> 4) & 0xF); + } + else if (!strcmp (decodePTR->opcodePTR->constraints, XGATE_OP_IMM8)) + { + if (macro_search (decodePTR->opcodePTR->name, previousOpName) && + previousOpName[0]) + { + absAddress = (0xFF & raw_code) << 8; + absAddress |= perviousBin & 0xFF; + (*info->fprintf_func)(info->stream, " R%x, #0x%02x Abs* 0x", + (raw_code >> 8) & 0x7, raw_code & 0xff); + (*info->print_address_func)(absAddress, info); + previousOpName[0] = 0; + } + else + { + strcpy (previousOpName, decodePTR->opcodePTR->name); + (*info->fprintf_func)(info->stream, " R%x, #0x%02x", + (raw_code >> 8) & 0x7, raw_code & 0xff); + } + } + else if (!strcmp (decodePTR->opcodePTR->constraints, XGATE_OP_IMM3)) + { + (*info->fprintf_func)(info->stream, " #0x%x", + (raw_code >> 8) & 0x7); + } + else if (!strcmp (decodePTR->opcodePTR->constraints, XGATE_OP_INH)) + { + // + } else { - (*info->fprintf_func)(info->stream, - " Can't disassemble for mode) %s", - decodePTR->opcodePTR->constraints); + (*info->fprintf_func)(info->stream, " unhandled mode %s", + opcodePTR->constraints); } - break; - case XG_R_I: - if (!strcmp (decodePTR->opcodePTR->constraints, XGATE_OP_IMM4)) - { - (*info->fprintf_func)(info->stream, " R%x, #0x%02x", - (raw_code >> 8) & 0x7, (raw_code >> 4) & 0xF); - } - else if (!strcmp (decodePTR->opcodePTR->constraints, XGATE_OP_IMM8)) - { - if (macro_search (decodePTR->opcodePTR->name, previousOpName) && - previousOpName[0]) - { - absAddress = (0xFF & raw_code) << 8; - absAddress |= perviousBin & 0xFF; - (*info->fprintf_func)(info->stream, " R%x, #0x%02x Abs* 0x", - (raw_code >> 8) & 0x7, raw_code & 0xff); - (*info->print_address_func)(absAddress, info); - previousOpName[0] = 0; - } - else - { - strcpy (previousOpName, decodePTR->opcodePTR->name); - (*info->fprintf_func)(info->stream, " R%x, #0x%02x", - (raw_code >> 8) & 0x7, raw_code & 0xff); - } - } - else - { - (*info->fprintf_func)(info->stream, - " Can't disassemble for mode %s", - decodePTR->opcodePTR->constraints); - } - break; - case XG_I: - (*info->fprintf_func)(info->stream, " #0x%x", - (raw_code >> 8) & 0x7); - break; - default: - (*info->fprintf_func)(info->stream, "address mode not found\t %x", - opcodePTR->bin_opcode); - break; - } perviousBin = raw_code; } else |