/* tc-xgate.c -- Assembler code for Freescale XGATE
- Copyright 2010, 2011, 2012
- Free Software Foundation, Inc.
+ Copyright (C) 2010-2016 Free Software Foundation, Inc.
Contributed by Sean Keys <skeys@ipdatasys.com>
This file is part of GAS, the GNU Assembler.
const char EXP_CHARS[] = "eE";
const char FLT_CHARS[] = "dD";
+/* Max opcodes per opcode handle. */
+#define MAX_OPCODES 0x05
+
#define SIXTEENTH_BIT 0x8000
#define N_BITS_IN_WORD 16
#define MAX_NUM_OPERANDS 3
static void get_default_target (void);
static char *extract_word (char *, char *, int);
static struct xgate_opcode *xgate_find_match (struct xgate_opcode_handle *,
- int, unsigned int);
+ int, s_operand [], unsigned int);
static int cmp_opcode (struct xgate_opcode *, struct xgate_opcode *);
static void xgate_print_table (void);
static unsigned int xgate_get_operands (char *, s_operand []);
struct xgate_opcode *xgate_opcode_ptr = NULL;
struct xgate_opcode *xgate_op_table = NULL;
struct xgate_opcode_handle *op_handles = 0;
- char *prev_op_name = 0;
+ const char *prev_op_name = 0;
int handle_enum = 0;
int number_of_op_handles = 0;
int i, j = 0;
if (flag_print_opcodes)
{
- print_opcode_list ();
+ xgate_print_table ();
exit (EXIT_SUCCESS);
}
}
md_section_align (asection * seg, valueT addr)
{
int align = bfd_get_section_alignment (stdoutput, seg);
- return ((addr + (1 << align) - 1) & (-1 << align));
+ return ((addr + (1 << align) - 1) & -(1 << align));
}
void
/* Caller expects it to be returned as it was passed. */
char *saved_input_line = input_line;
char op_name[9] = { 0 };
- unsigned int sh_format = 0;
+ unsigned int operandCount = 0;
char *p = 0;
s_operand new_operands[MAX_NUM_OPERANDS];
{
/* Parse operands so we can find the proper opcode bin. */
- sh_format = xgate_get_operands(input_line, new_operands);
+ operandCount = xgate_get_operands (input_line, new_operands);
opcode = xgate_find_match (opcode_handle, opcode_handle->number_of_modes,
- sh_format);
+ new_operands, operandCount);
if (!opcode)
{
}
else
{
- sh_format = xgate_get_operands(input_line, new_operands);
- macro_opcode
- = xgate_find_match (opcode_handle,
- opcode_handle->number_of_modes,
- sh_format);
+ operandCount = xgate_get_operands(input_line, new_operands);
+ macro_opcode = xgate_find_match (opcode_handle,
+ opcode_handle->number_of_modes, new_operands,
+ operandCount);
xgate_scan_operands (macro_opcode, new_operands);
-
}
}
}
static struct xgate_opcode *
xgate_find_match (struct xgate_opcode_handle *opcode_handle,
- int numberOfModes,
- unsigned int sh_format)
+ int numberOfModes, s_operand oprs[], unsigned int operandCount)
{
int i;
return opcode_handle->opc0[0];
for (i = 0; i <= numberOfModes; i++)
- if (opcode_handle->opc0[i]->sh_format & sh_format)
- return opcode_handle->opc0[i];
-
- return NULL;
+ {
+ switch (operandCount)
+ {
+ case 0:
+ if (!strcmp(opcode_handle->opc0[i]->constraints, XGATE_OP_INH))
+ return opcode_handle->opc0[i];
+ break;
+ case 1:
+ if (oprs[0].reg >= REG_R0 && oprs[0].reg <= REG_R7)
+ if (!strcmp(opcode_handle->opc0[i]->constraints, XGATE_OP_MON))
+ return opcode_handle->opc0[i];
+ if (!strcmp(opcode_handle->opc0[i]->constraints, XGATE_OP_DYA_MON))
+ return opcode_handle->opc0[i];
+ if (oprs[0].reg == REG_NONE)
+ if (!strcmp(opcode_handle->opc0[i]->constraints, XGATE_OP_IMM3))
+ return opcode_handle->opc0[i];
+ break;
+ case 2:
+ if (oprs[0].reg >= REG_R0 && oprs[0].reg <= REG_R7)
+ {
+ if (oprs[1].reg >= REG_R0 && oprs[1].reg <= REG_R7)
+ if (!strcmp(opcode_handle->opc0[i]->constraints, XGATE_OP_DYA))
+ return opcode_handle->opc0[i];
+ if (oprs[1].reg == REG_CCR)
+ if (!strcmp(opcode_handle->opc0[i]->constraints,
+ XGATE_OP_MON_R_C))
+ return opcode_handle->opc0[i];
+ if (oprs[1].reg == REG_PC)
+ if (!strcmp(opcode_handle->opc0[i]->constraints,
+ XGATE_OP_MON_R_P))
+ return opcode_handle->opc0[i];
+ if (oprs[1].reg == REG_NONE)
+ if (!strcmp(opcode_handle->opc0[i]->constraints, XGATE_OP_IMM16)
+ || !strcmp(opcode_handle->opc0[i]->constraints, XGATE_OP_IMM8)
+ || !strcmp(opcode_handle->opc0[i]->constraints, XGATE_OP_IMM4)
+ || !strcmp(opcode_handle->opc0[i]->constraints,
+ XGATE_OP_IMM16mADD)
+ || !strcmp(opcode_handle->opc0[i]->constraints,
+ XGATE_OP_IMM16mAND)
+ || !strcmp(opcode_handle->opc0[i]->constraints,
+ XGATE_OP_IMM16mCPC)
+ || !strcmp(opcode_handle->opc0[i]->constraints,
+ XGATE_OP_IMM16mSUB)
+ || !strcmp(opcode_handle->opc0[i]->constraints,
+ XGATE_OP_IMM16mLDW))
+ return opcode_handle->opc0[i];
+ }
+ if (oprs[0].reg == REG_CCR)
+ if (!strcmp(opcode_handle->opc0[i]->constraints, XGATE_OP_MON_C_R))
+ return opcode_handle->opc0[i];
+ break;
+ case 3:
+ if (oprs[0].reg >= REG_R0 && oprs[0].reg <= REG_R7)
+ {
+ if (oprs[1].reg >= REG_R0 && oprs[1].reg <= REG_R7)
+ {
+ if (oprs[2].reg >= REG_R0 && oprs[2].reg <= REG_R7)
+ {
+ if (!strcmp(opcode_handle->opc0[i]->constraints,
+ XGATE_OP_IDR)
+ || !strcmp(opcode_handle->opc0[i]->constraints,
+ XGATE_OP_TRI))
+ return opcode_handle->opc0[i];
+ }
+
+ if (oprs[2].reg == REG_NONE)
+ if (!strcmp(opcode_handle->opc0[i]->constraints,
+ XGATE_OP_IDO5))
+ return opcode_handle->opc0[i];
+ }
+ }
+ break;
+ default:
+ as_bad(_("unknown operand count"));
+ break;
+ }
+ }
+ return NULL ;
}
/* Because we are dealing with two different core that view the system
/* If there are no operands, then it must be inherent. */
if (*line == 0 || *line == '\n' || *line == '\r')
- return XG_INH;
+ return 0;
for (num_operands = 0; strlen (line) && (num_operands < MAX_NUM_OPERANDS);
num_operands++)
line++;
}
}
-
if (num_operands > MAX_NUM_OPERANDS)
return 0;
-
- switch (num_operands)
- {
- case 1:
- if (oprs[0].reg >= REG_R0 && oprs[0].reg <= REG_R7)
- return XG_R;
- if (oprs[0].reg == REG_NONE)
- return XG_I;
- break;
- case 2:
- if (oprs[0].reg >= REG_R0 && oprs[0].reg <= REG_R7)
- {
- if (oprs[1].reg >= REG_R0 && oprs[1].reg <= REG_R7)
- return XG_R_R;
- if (oprs[1].reg == REG_CCR)
- return XG_R_C;
- if (oprs[1].reg == REG_PC)
- return XG_R_P;
- if (oprs[1].reg == REG_NONE)
- return XG_R_I;
- }
- if (oprs[0].reg == REG_CCR)
- return XG_C_R;
- break;
- case 3:
- if (oprs[0].reg >= REG_R0 && oprs[0].reg <= REG_R7)
- {
- if (oprs[1].reg >= REG_R0 && oprs[1].reg <= REG_R7)
- {
- if (oprs[2].reg >= REG_R0 && oprs[2].reg <= REG_R7)
- return XG_R_R_R;
- if (oprs[2].reg >= REG_NONE)
- return XG_R_R_I;
- }
- }
- break;
- default:
- as_bad (_("unknown operand format"));
- break;
- }
-
- return 0;
+ return num_operands;
}
/* reg_name_search() finds the register number given its name.
{
bfd_putl16 (bin, frag);
}
- else if ((opcode->sh_format & XG_PCREL))
+ else if ( !strcmp (opcode->constraints, XGATE_OP_REL9)
+ || !strcmp (opcode->constraints, XGATE_OP_REL10))
{
/* Write our data to a frag for further processing. */
bfd_putl16 (opcode->bin_opcode, frag);