Back to index

cell-binutils  2.17cvs20070401
Defines | Functions | Variables
tic80-opc.c File Reference
#include <stdio.h>
#include "sysdep.h"
#include "opcode/tic80.h"

Go to the source code of this file.

Defines

#define UNUSED   (0)
#define SSI   (UNUSED + 1)
#define SUI   (SSI + 1)
#define SUBF   (SUI + 1)
#define LSI   (SUBF + 1)
#define LUI   (LSI + 1)
#define LUBF   (LUI + 1)
#define SPFI   (LUBF + 1)
#define REG_0   (SPFI + 1)
#define REG_0_E   (REG_0 + 1)
#define REG_22   (REG_0_E + 1)
#define REG_22_E   (REG_22 + 1)
#define REG_DEST   (REG_22_E + 1)
#define REG_DEST_E   (REG_DEST + 1)
#define REG_FPA   (REG_DEST_E + 1)
#define OFF_SS_PC   (REG_FPA + 1)
#define OFF_SL_PC   (OFF_SS_PC + 1)
#define OFF_SS_BR   (OFF_SL_PC + 1)
#define OFF_SL_BR   (OFF_SS_BR + 1)
#define OFF_SL_BR_SCALED   (OFF_SL_BR + 1)
#define BITNUM   (OFF_SL_BR_SCALED + 1)
#define CC   (BITNUM + 1)
#define CR_SI   (CC + 1)
#define CR_LI   (CR_SI + 1)
#define REG_BASE   (CR_LI + 1)
#define REG_BASE_M_SI   (REG_BASE + 1)
#define REG_BASE_M_LI   (REG_BASE_M_SI + 1)
#define REG_SCALED   (REG_BASE_M_LI + 1)
#define ROTATE   (REG_SCALED + 1)
#define ENDMASK   (ROTATE + 1)
#define FIXME   0
#define OP_SI(x)   (((x) & 0x7F) << 15)
#define MASK_SI   OP_SI(0x7F)
#define OP_LI(x)   (((x) & 0x3FF) << 12)
#define MASK_LI   OP_LI(0x3FF)
#define OP_REG(x)   OP_LI(x) /* For readability */
#define MASK_REG   MASK_LI /* For readability */
#define n(x)   ((x) << 10)
#define i(x)   ((x) << 11)
#define F(x)   ((x) << 27)
#define E(x)   ((x) << 27)
#define M_REG(x)   ((x) << 15)
#define M_LI(x)   ((x) << 15)
#define M_SI(x)   ((x) << 17)
#define SZ_REG(x)   ((x) << 13)
#define SZ_LI(x)   ((x) << 13)
#define SZ_SI(x)   ((x) << 15)
#define D(x)   ((x) << 10)
#define S(x)   ((x) << 11)
#define PD(x)   ((x) << 9)
#define P2(x)   ((x) << 7)
#define P1(x)   ((x) << 5)
#define V_a1(x)   ((x) << 16)
#define V_a0(x)   ((x) << 11)
#define V_m(x)   ((x) << 10)
#define V_S(x)   ((x) << 9)
#define V_Z(x)   ((x) << 8)
#define V_p(x)   ((x) << 6)
#define OP_V(x)   ((x) << 17)
#define MASK_V   OP_V(0x1F)

Functions

int tic80_symbol_to_value (char *name, int class)
const char * tic80_value_to_symbol (int val, int class)
struct predefined_symboltic80_next_predefined_symbol (struct predefined_symbol *pdsp) const

Variables

const int tic80_num_predefined_symbols = sizeof (tic80_predefined_symbols) / sizeof (struct predefined_symbol)
const int tic80_num_operands = sizeof (tic80_operands)/sizeof(*tic80_operands)
const int tic80_num_opcodes = sizeof (tic80_opcodes) / sizeof (tic80_opcodes[0])

Define Documentation

#define BITNUM   (OFF_SL_BR_SCALED + 1)
#define CC   (BITNUM + 1)
#define CR_LI   (CR_SI + 1)
#define CR_SI   (CC + 1)
#define D (   x)    ((x) << 10)

Definition at line 551 of file tic80-opc.c.

#define E (   x)    ((x) << 27)

Definition at line 533 of file tic80-opc.c.

#define ENDMASK   (ROTATE + 1)
#define F (   x)    ((x) << 27)

Definition at line 530 of file tic80-opc.c.

#define FIXME   0

Definition at line 509 of file tic80-opc.c.

#define i (   x)    ((x) << 11)

Definition at line 527 of file tic80-opc.c.

#define LSI   (SUBF + 1)
#define LUBF   (LUI + 1)
#define LUI   (LSI + 1)
#define M_LI (   x)    ((x) << 15)

Definition at line 537 of file tic80-opc.c.

#define M_REG (   x)    ((x) << 15)

Definition at line 536 of file tic80-opc.c.

#define M_SI (   x)    ((x) << 17)

Definition at line 540 of file tic80-opc.c.

#define MASK_LI   OP_LI(0x3FF)

Definition at line 517 of file tic80-opc.c.

#define MASK_REG   MASK_LI /* For readability */

Definition at line 521 of file tic80-opc.c.

#define MASK_SI   OP_SI(0x7F)

Definition at line 513 of file tic80-opc.c.

#define MASK_V   OP_V(0x1F)

Definition at line 586 of file tic80-opc.c.

#define n (   x)    ((x) << 10)

Definition at line 524 of file tic80-opc.c.

#define OFF_SL_BR   (OFF_SS_BR + 1)
#define OFF_SL_BR_SCALED   (OFF_SL_BR + 1)
#define OFF_SL_PC   (OFF_SS_PC + 1)
#define OFF_SS_BR   (OFF_SL_PC + 1)
#define OFF_SS_PC   (REG_FPA + 1)
#define OP_LI (   x)    (((x) & 0x3FF) << 12)

Definition at line 516 of file tic80-opc.c.

#define OP_REG (   x)    OP_LI(x) /* For readability */

Definition at line 520 of file tic80-opc.c.

#define OP_SI (   x)    (((x) & 0x7F) << 15)

Definition at line 512 of file tic80-opc.c.

#define OP_V (   x)    ((x) << 17)

Definition at line 585 of file tic80-opc.c.

#define P1 (   x)    ((x) << 5)

Definition at line 564 of file tic80-opc.c.

#define P2 (   x)    ((x) << 7)

Definition at line 561 of file tic80-opc.c.

#define PD (   x)    ((x) << 9)

Definition at line 558 of file tic80-opc.c.

#define REG_0   (SPFI + 1)
#define REG_0_E   (REG_0 + 1)
#define REG_22   (REG_0_E + 1)
#define REG_22_E   (REG_22 + 1)
#define REG_BASE   (CR_LI + 1)
#define REG_BASE_M_LI   (REG_BASE_M_SI + 1)
#define REG_BASE_M_SI   (REG_BASE + 1)
#define REG_DEST   (REG_22_E + 1)
#define REG_DEST_E   (REG_DEST + 1)
#define REG_FPA   (REG_DEST_E + 1)
#define REG_SCALED   (REG_BASE_M_LI + 1)
#define ROTATE   (REG_SCALED + 1)
#define S (   x)    ((x) << 11)

Definition at line 555 of file tic80-opc.c.

#define SPFI   (LUBF + 1)
#define SSI   (UNUSED + 1)
#define SUBF   (SUI + 1)
#define SUI   (SSI + 1)
#define SZ_LI (   x)    ((x) << 13)

Definition at line 544 of file tic80-opc.c.

#define SZ_REG (   x)    ((x) << 13)

Definition at line 543 of file tic80-opc.c.

#define SZ_SI (   x)    ((x) << 15)

Definition at line 547 of file tic80-opc.c.

#define UNUSED   (0)
#define V_a0 (   x)    ((x) << 11)

Definition at line 570 of file tic80-opc.c.

#define V_a1 (   x)    ((x) << 16)

Definition at line 567 of file tic80-opc.c.

#define V_m (   x)    ((x) << 10)

Definition at line 573 of file tic80-opc.c.

#define V_p (   x)    ((x) << 6)

Definition at line 582 of file tic80-opc.c.

#define V_S (   x)    ((x) << 9)

Definition at line 576 of file tic80-opc.c.

#define V_Z (   x)    ((x) << 8)

Definition at line 579 of file tic80-opc.c.


Function Documentation

Definition at line 313 of file tic80-opc.c.

{
  if (pdsp == NULL)
    {
      pdsp = tic80_predefined_symbols;
    }
  else if (pdsp >= tic80_predefined_symbols &&
          pdsp < tic80_predefined_symbols + tic80_num_predefined_symbols - 1)
    {
      pdsp++;
    }
  else
    {
      pdsp = NULL;
    }
  return (pdsp);
}
int tic80_symbol_to_value ( char *  name,
int  class 
)

Definition at line 236 of file tic80-opc.c.

{
  const struct predefined_symbol *pdsp;
  int low = 0;
  int middle;
  int high = tic80_num_predefined_symbols - 1;
  int cmp;
  int rtnval = -1;

  while (low <= high)
    {
      middle = (low + high) / 2;
      cmp = strcasecmp (name, tic80_predefined_symbols[middle].name);
      if (cmp < 0)
       {
         high = middle - 1;
       }
      else if (cmp > 0)
       {
         low = middle + 1;
       }
      else 
       {
         pdsp = &tic80_predefined_symbols[middle];
         if ((class == 0) || (class & PDS_VALUE (pdsp)))
           {
             rtnval = PDS_VALUE (pdsp);
           }
         /* For now we assume that there are no duplicate names */
         break;
       }
    }
  return (rtnval);
}

Here is the call graph for this function:

const char* tic80_value_to_symbol ( int  val,
int  class 
)

Definition at line 278 of file tic80-opc.c.

{
  const struct predefined_symbol *pdsp;
  int ival;
  char *name;

  name = NULL;
  for (pdsp = tic80_predefined_symbols;
       pdsp < tic80_predefined_symbols + tic80_num_predefined_symbols;
       pdsp++)
    {
      ival = PDS_VALUE (pdsp) & ~TIC80_OPERAND_MASK;
      if (ival == val)
       {
         if ((class == 0) || (class & PDS_VALUE (pdsp)))
           {
             /* Found the desired match */
             name = PDS_NAME (pdsp);
             break;
           }
       }
    }
  return (name);
}

Here is the caller graph for this function:


Variable Documentation

const int tic80_num_opcodes = sizeof (tic80_opcodes) / sizeof (tic80_opcodes[0])

Definition at line 1216 of file tic80-opc.c.

const int tic80_num_operands = sizeof (tic80_operands)/sizeof(*tic80_operands)

Definition at line 504 of file tic80-opc.c.

const int tic80_num_predefined_symbols = sizeof (tic80_predefined_symbols) / sizeof (struct predefined_symbol)

Definition at line 216 of file tic80-opc.c.