X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=opcodes%2Fxgate-dis.c;h=61eeb9971c6c94123a7af3ef4e4de076f47fe45c;hb=6c0946d0d28d787b166cae3c2ebc2cb309c4f5a2;hp=8c722f5d5c0eaa3b684b7dcd59daf99025baab51;hpb=df7b86aa4cb63ce86e60949b8160438bc0f9e389;p=deliverable%2Fbinutils-gdb.git diff --git a/opcodes/xgate-dis.c b/opcodes/xgate-dis.c index 8c722f5d5c..61eeb9971c 100644 --- a/opcodes/xgate-dis.c +++ b/opcodes/xgate-dis.c @@ -1,6 +1,5 @@ /* xgate-dis.c -- Freescale XGATE disassembly - Copyright 2009, 2010, 2011, 2012 - Free Software Foundation, Inc. + Copyright (C) 2009-2020 Free Software Foundation, Inc. Written by Sean Keys (skeys@ipdatasys.com) This file is part of the GNU opcodes library. @@ -22,7 +21,7 @@ #include "sysdep.h" #include -#include "dis-asm.h" +#include "disassemble.h" #include "opintl.h" #include "libiberty.h" #include "ansidecl.h" @@ -124,92 +123,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_MON)) - { - operandOne = ripBits (&operMaskReg, 3, decodePTR->opcodePTR, - raw_code); - operandTwo = ripBits (&operMaskReg, 3, decodePTR->opcodePTR, - raw_code); - (*info->fprintf_func)(info->stream, " R%x, R%x", operandOne, - operandTwo); - } - 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 - { - (*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, decodePTR->opcodePTR, raw_code); + operandTwo = ripBits (&operMaskReg, 3, decodePTR->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) @@ -217,17 +193,17 @@ print_insn (bfd_vma memaddr, struct disassemble_info* info) relAddr = XGATE_NINE_BITS >> 1; /* Clip sign bit. */ relAddr = ~relAddr; /* Make signed. */ relAddr |= (raw_code & 0xFF) + 1; /* Apply our value. */ - relAddr <<= 1; /* Multiply by two as per processor docs. */ + relAddr *= 2; /* Multiply by two as per processor docs. */ } else { relAddr = raw_code & 0xff; - relAddr = (relAddr << 1) + 2; + relAddr = relAddr * 2 + 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. */ @@ -236,65 +212,55 @@ print_insn (bfd_vma memaddr, struct disassemble_info* info) relAddr = XGATE_TEN_BITS >> 1; /* Clip sign bit. */ relAddr = ~relAddr; /* Make signed. */ relAddr |= (raw_code & 0x1FF) + 1; /* Apply our value. */ - relAddr <<= 1; /* Multiply by two as per processor docs. */ + relAddr *= 2; /* Multiply by two as per processor docs. */ } else { relAddr = raw_code & 0x1FF; - relAddr = (relAddr << 1) + 2; + relAddr = relAddr * 2 + 2; } (*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_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", + decodePTR->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 @@ -333,12 +299,12 @@ ripBits (unsigned int *operandBitsRemaining, unsigned int memory) { unsigned int currentBit; - int operand; + unsigned int operand = 0; int numBitsFound; - for (operand = 0, numBitsFound = 0, currentBit = 1 - << ((opcodePTR->size * 8) - 1); - (numBitsFound < numBitsRequested) && currentBit; currentBit >>= 1) + for (numBitsFound = 0, currentBit = 1u << ((opcodePTR->size * 8) - 1); + numBitsFound < numBitsRequested && currentBit != 0; + currentBit >>= 1) { if (currentBit & *operandBitsRemaining) {