OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [gdb-5.0/] [opcodes/] [or32-dis.c] - Diff between revs 372 and 603

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 372 Rev 603
Line 24... Line 24...
#include "dis-asm.h"
#include "dis-asm.h"
#include "opcode/or32.h"
#include "opcode/or32.h"
 
 
#include <ctype.h>
#include <ctype.h>
#include <string.h>
#include <string.h>
#include <stdlib.h>
 
 
 
#define EXTEND29(x) ((x) & 0x10000000 ? ((x) | 0xf0000000) : ((x)))
#define EXTEND29(x) ((x) & 0x10000000 ? ((x) | 0xf0000000) : ((x)))
 
 
/* Now find the four bytes of INSN_CH and put them in *INSN.  */
/* Now find the four bytes of INSN_CH and put them in *INSN.  */
static void
static void
Line 71... Line 70...
  int opc_pos = 0;
  int opc_pos = 0;
  int param_pos = 0;
  int param_pos = 0;
 
 
  for (enc = enc_initial; *enc != '\0'; enc++)
  for (enc = enc_initial; *enc != '\0'; enc++)
    if (*enc == param_ch)
    if (*enc == param_ch)
      {
 
        if (enc - 2 >= enc_initial && (*(enc - 2) == '0') && (*(enc - 1) == 'x'))
        if (enc - 2 >= enc_initial && (*(enc - 2) == '0') && (*(enc - 1) == 'x'))
          continue;
          continue;
        else
        else
          param_pos++;
          param_pos++;
      }
 
 
 
#if DEBUG
#if DEBUG
  printf("or32_extract: %c %x ", param_ch, param_pos);
  printf("or32_extract: %c %x ", param_ch, param_pos);
#endif
#endif
  opc_pos = 32;
  opc_pos = 32;
  for (enc = enc_initial; *enc != '\0'; )
  for (enc = enc_initial; *enc != '\0'; )
    if ((*enc == '0') && (*(enc+1) == 'x'))
                if ((*enc == '0') && (*(enc+1) == 'x')) {
      {
 
        opc_pos -= 4;
        opc_pos -= 4;
        if ((param_ch == '0') || (param_ch == '1'))
                  if ((param_ch == '0') || (param_ch == '1')) {
          {
 
            unsigned long tmp = strtol(enc, NULL, 16);
            unsigned long tmp = strtol(enc, NULL, 16);
#if DEBUG
#if DEBUG
            printf(" enc=%s, tmp=%x ", enc, tmp);
            printf(" enc=%s, tmp=%x ", enc, tmp);
#endif
#endif
            if (param_ch == '0')
            if (param_ch == '0')
              tmp = 15 - tmp;
              tmp = 15 - tmp;
            ret |= tmp << opc_pos;
            ret |= tmp << opc_pos;
          }
          }
        enc += 3;
        enc += 3;
      }
      }
    else if ((*enc == '0') || (*enc == '1'))
                else if ((*enc == '0') || (*enc == '1')) {
      {
 
        opc_pos--;
        opc_pos--;
        if (param_ch == *enc)
        if (param_ch == *enc)
          ret |= 1 << opc_pos;
          ret |= 1 << opc_pos;
        enc++;
        enc++;
      }
      }
    else if (*enc == param_ch)
                else if (*enc == param_ch) {
      {
 
        opc_pos--;
        opc_pos--;
        param_pos--;
        param_pos--;
#if DEBUG
#if DEBUG
        printf("\n  ret=%x opc_pos=%x, param_pos=%x\n", ret, opc_pos, param_pos);
        printf("\n  ret=%x opc_pos=%x, param_pos=%x\n", ret, opc_pos, param_pos);
#endif
#endif
        ret += ((insn >> opc_pos) & 0x1) << param_pos;
        ret += ((insn >> opc_pos) & 0x1) << param_pos;
        if (!param_pos && letter_signed(param_ch) && ret >> (letter_range(param_ch) - 1))
                        if (!param_pos && letter_signed(param_ch) && ret >> letter_range(param_ch) - 1) {
          {
 
#if DEBUG
#if DEBUG
            printf("\n  ret=%x opc_pos=%x, param_pos=%x\n", ret, opc_pos, param_pos);
            printf("\n  ret=%x opc_pos=%x, param_pos=%x\n", ret, opc_pos, param_pos);
#endif
#endif
            ret |= 0xffffffff << letter_range(param_ch);
            ret |= 0xffffffff << letter_range(param_ch);
#if DEBUG
#if DEBUG
            printf("\n  after conversion to signed: ret=%x\n", ret);
            printf("\n  after conversion to signed: ret=%x\n", ret);
#endif
#endif
         }
         }
       enc++;
       enc++;
     }
     }
   else if (isalpha(*enc))
                else if (isalpha(*enc)) {
     {
 
       opc_pos--;
       opc_pos--;
       enc++;
       enc++;
     }
     }
   else if (*enc == '-')
                else if (*enc == '-') {
     {
 
       opc_pos--;
       opc_pos--;
       enc++;
       enc++;
     }
     }
   else
   else
     enc++;
     enc++;
Line 144... Line 134...
  printf("ret=%x\n", ret);
  printf("ret=%x\n", ret);
#endif
#endif
  return ret;
  return ret;
}
}
 
 
int
static int
or32_opcode_match (insn, encoding)
or32_opcode_match (insn, encoding)
     unsigned long insn;
     unsigned long insn;
     char *encoding;
     char *encoding;
{
{
  unsigned long ones, zeros;
  unsigned long ones, zeros;
Line 200... Line 190...
#endif  
#endif  
  if (param_ch == 'A')
  if (param_ch == 'A')
    (*info->fprintf_func) (info->stream, "r%d", regnum);
    (*info->fprintf_func) (info->stream, "r%d", regnum);
  else if (param_ch == 'B')
  else if (param_ch == 'B')
                (*info->fprintf_func) (info->stream, "r%d", regnum);
                (*info->fprintf_func) (info->stream, "r%d", regnum);
  else if (param_ch == 'S')
  else if (param_ch == 'D')
                (*info->fprintf_func) (info->stream, "r%d", regnum);
                (*info->fprintf_func) (info->stream, "r%d", regnum);
        else if (regnum < 16)
        else if (regnum < 16)
                (*info->fprintf_func) (info->stream, "r%d", regnum);
                (*info->fprintf_func) (info->stream, "r%d", regnum);
        else if (regnum < 32)
        else if (regnum < 32)
                (*info->fprintf_func) (info->stream, "r%d", regnum-16);
                (*info->fprintf_func) (info->stream, "r%d", regnum-16);

powered by: WebSVN 2.1.0

© copyright 1999-2025 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.