summaryrefslogtreecommitdiffstats
path: root/contrib/binutils/gas/config
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/binutils/gas/config')
-rw-r--r--contrib/binutils/gas/config/tc-tic30.c1881
-rw-r--r--contrib/binutils/gas/config/tc-tic30.h55
-rw-r--r--contrib/binutils/gas/config/tc-v850.c2434
-rw-r--r--contrib/binutils/gas/config/tc-v850.h98
-rw-r--r--contrib/binutils/gas/config/tc-z8k.c1566
-rw-r--r--contrib/binutils/gas/config/tc-z8k.h53
6 files changed, 0 insertions, 6087 deletions
diff --git a/contrib/binutils/gas/config/tc-tic30.c b/contrib/binutils/gas/config/tc-tic30.c
deleted file mode 100644
index 1258b13..0000000
--- a/contrib/binutils/gas/config/tc-tic30.c
+++ /dev/null
@@ -1,1881 +0,0 @@
-/* tc-c30.c -- Assembly code for the Texas Instruments TMS320C30
- Copyright 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
- Contributed by Steven Haworth (steve@pm.cse.rmit.edu.au)
-
- This file is part of GAS, the GNU Assembler.
-
- GAS is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2, or (at your option)
- any later version.
-
- GAS is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with GAS; see the file COPYING. If not, write to the Free
- Software Foundation, 59 Temple Place - Suite 330, Boston, MA
- 02111-1307, USA. */
-
-/* Texas Instruments TMS320C30 machine specific gas.
- Written by Steven Haworth (steve@pm.cse.rmit.edu.au).
- Bugs & suggestions are completely welcome. This is free software.
- Please help us make it better. */
-
-#include "as.h"
-#include "safe-ctype.h"
-#include "opcode/tic30.h"
-
-/* Put here all non-digit non-letter charcters that may occur in an
- operand. */
-static char operand_special_chars[] = "%$-+(,)*._~/<>&^!:[@]";
-static char *ordinal_names[] = {
- "first", "second", "third", "fourth", "fifth"
-};
-
-const int md_reloc_size = 0;
-
-const char comment_chars[] = ";";
-const char line_comment_chars[] = "*";
-const char line_separator_chars[] = "";
-
-const char *md_shortopts = "";
-struct option md_longopts[] = {
- {NULL, no_argument, NULL, 0}
-};
-
-size_t md_longopts_size = sizeof (md_longopts);
-
-/* Chars that mean this number is a floating point constant. */
-/* As in 0f12.456 */
-/* or 0d1.2345e12 */
-const char FLT_CHARS[] = "fFdDxX";
-
-/* Chars that can be used to separate mant from exp in floating point
- nums. */
-const char EXP_CHARS[] = "eE";
-
-/* tables for lexical analysis */
-static char opcode_chars[256];
-static char register_chars[256];
-static char operand_chars[256];
-static char space_chars[256];
-static char identifier_chars[256];
-static char digit_chars[256];
-
-/* lexical macros */
-#define is_opcode_char(x) (opcode_chars[(unsigned char) x])
-#define is_operand_char(x) (operand_chars[(unsigned char) x])
-#define is_register_char(x) (register_chars[(unsigned char) x])
-#define is_space_char(x) (space_chars[(unsigned char) x])
-#define is_identifier_char(x) (identifier_chars[(unsigned char) x])
-#define is_digit_char(x) (digit_chars[(unsigned char) x])
-
-const pseudo_typeS md_pseudo_table[] = {
- {0, 0, 0}
-};
-
-#undef USE_STDOUT
-#define USE_STDOUT 1
-
-#ifdef USE_STDARG
-
-#include <stdarg.h>
-
-int
-debug (const char *string, ...)
-{
- if (flag_debug)
- {
- va_list argptr;
- char str[100];
-
- va_start (argptr, string);
- vsprintf (str, string, argptr);
- if (str[0] == '\0')
- return (0);
- va_end (argptr);
- fputs (str, USE_STDOUT ? stdout : stderr);
- return strlen (str);
- }
- else
- return 0;
-}
-#else
-int
-debug (string, va_alist)
- const char *string;
- va_dcl
-{
- if (flag_debug)
- {
- va_list argptr;
- char str[100];
- int cnt;
-
- va_start (argptr, string);
- cnt = vsprintf (str, string, argptr);
- if (str[0] == NULL)
- return (0);
- va_end (argptr);
- fputs (str, USE_STDOUT ? stdout : stderr);
- return (cnt);
- }
- else
- return 0;
-}
-#endif
-
-/* hash table for opcode lookup */
-static struct hash_control *op_hash;
-/* hash table for parallel opcode lookup */
-static struct hash_control *parop_hash;
-/* hash table for register lookup */
-static struct hash_control *reg_hash;
-/* hash table for indirect addressing lookup */
-static struct hash_control *ind_hash;
-
-void
-md_begin ()
-{
- const char *hash_err;
- debug ("In md_begin()\n");
- op_hash = hash_new ();
- {
- const template *current_optab = tic30_optab;
- for (; current_optab < tic30_optab_end; current_optab++)
- {
- hash_err = hash_insert (op_hash, current_optab->name, (char *) current_optab);
- if (hash_err)
- as_fatal ("Internal Error: Can't Hash %s: %s", current_optab->name, hash_err);
- }
- }
- parop_hash = hash_new ();
- {
- const partemplate *current_parop = tic30_paroptab;
- for (; current_parop < tic30_paroptab_end; current_parop++)
- {
- hash_err = hash_insert (parop_hash, current_parop->name, (char *) current_parop);
- if (hash_err)
- as_fatal ("Internal Error: Can't Hash %s: %s", current_parop->name, hash_err);
- }
- }
- reg_hash = hash_new ();
- {
- const reg *current_reg = tic30_regtab;
- for (; current_reg < tic30_regtab_end; current_reg++)
- {
- hash_err = hash_insert (reg_hash, current_reg->name, (char *) current_reg);
- if (hash_err)
- as_fatal ("Internal Error: Can't Hash %s: %s", current_reg->name, hash_err);
- }
- }
- ind_hash = hash_new ();
- {
- const ind_addr_type *current_ind = tic30_indaddr_tab;
- for (; current_ind < tic30_indaddrtab_end; current_ind++)
- {
- hash_err = hash_insert (ind_hash, current_ind->syntax, (char *) current_ind);
- if (hash_err)
- as_fatal ("Internal Error: Can't Hash %s: %s", current_ind->syntax, hash_err);
- }
- }
- /* fill in lexical tables: opcode_chars, operand_chars, space_chars */
- {
- register int c;
- register char *p;
-
- for (c = 0; c < 256; c++)
- {
- if (ISLOWER (c) || ISDIGIT (c))
- {
- opcode_chars[c] = c;
- register_chars[c] = c;
- }
- else if (ISUPPER (c))
- {
- opcode_chars[c] = TOLOWER (c);
- register_chars[c] = opcode_chars[c];
- }
- else if (c == ')' || c == '(')
- {
- register_chars[c] = c;
- }
- if (ISUPPER (c) || ISLOWER (c) || ISDIGIT (c))
- operand_chars[c] = c;
- if (ISDIGIT (c) || c == '-')
- digit_chars[c] = c;
- if (ISALPHA (c) || c == '_' || c == '.' || ISDIGIT (c))
- identifier_chars[c] = c;
- if (c == ' ' || c == '\t')
- space_chars[c] = c;
- if (c == '_')
- opcode_chars[c] = c;
- }
- for (p = operand_special_chars; *p != '\0'; p++)
- operand_chars[(unsigned char) *p] = *p;
- }
-}
-
-/* Address Mode OR values */
-#define AM_Register 0x00000000
-#define AM_Direct 0x00200000
-#define AM_Indirect 0x00400000
-#define AM_Immediate 0x00600000
-#define AM_NotReq 0xFFFFFFFF
-
-/* PC Relative OR values */
-#define PC_Register 0x00000000
-#define PC_Relative 0x02000000
-
-typedef struct {
- unsigned op_type;
- struct {
- int resolved;
- unsigned address;
- char *label;
- expressionS direct_expr;
- } direct;
- struct {
- unsigned mod;
- int ARnum;
- unsigned char disp;
- } indirect;
- struct {
- unsigned opcode;
- } reg;
- struct {
- int resolved;
- int decimal_found;
- float f_number;
- int s_number;
- unsigned int u_number;
- char *label;
- expressionS imm_expr;
- } immediate;
-} operand;
-
-int tic30_parallel_insn PARAMS ((char *));
-operand *tic30_operand PARAMS ((char *));
-char *tic30_find_parallel_insn PARAMS ((char *, char *));
-
-template *opcode;
-
-struct tic30_insn {
- template *tm; /* Template of current instruction */
- unsigned opcode; /* Final opcode */
- int operands; /* Number of given operands */
- /* Type of operand given in instruction */
- operand *operand_type[MAX_OPERANDS];
- unsigned addressing_mode; /* Final addressing mode of instruction */
-};
-
-struct tic30_insn insn;
-static int found_parallel_insn;
-
-void
-md_assemble (line)
- char *line;
-{
- template *opcode;
- char *current_posn;
- char *token_start;
- char save_char;
- int count;
-
- debug ("In md_assemble() with argument %s\n", line);
- memset (&insn, '\0', sizeof (insn));
- if (found_parallel_insn)
- {
- debug ("Line is second part of parallel instruction\n\n");
- found_parallel_insn = 0;
- return;
- }
- if ((current_posn = tic30_find_parallel_insn (line, input_line_pointer + 1)) == NULL)
- current_posn = line;
- else
- found_parallel_insn = 1;
- while (is_space_char (*current_posn))
- current_posn++;
- token_start = current_posn;
- if (!is_opcode_char (*current_posn))
- {
- as_bad ("Invalid character %s in opcode", output_invalid (*current_posn));
- return;
- }
- /* Check if instruction is a parallel instruction by seeing if the first
- character is a q. */
- if (*token_start == 'q')
- {
- if (tic30_parallel_insn (token_start))
- {
- if (found_parallel_insn)
- free (token_start);
- return;
- }
- }
- while (is_opcode_char (*current_posn))
- current_posn++;
- { /* Find instruction */
- save_char = *current_posn;
- *current_posn = '\0';
- opcode = (template *) hash_find (op_hash, token_start);
- if (opcode)
- {
- debug ("Found instruction %s\n", opcode->name);
- insn.tm = opcode;
- }
- else
- {
- debug ("Didn't find insn\n");
- as_bad ("Unknown TMS320C30 instruction: %s", token_start);
- return;
- }
- *current_posn = save_char;
- }
- if (*current_posn != END_OF_INSN)
- { /* Find operands */
- int paren_not_balanced;
- int expecting_operand = 0;
- int this_operand;
- do
- {
- /* skip optional white space before operand */
- while (!is_operand_char (*current_posn) && *current_posn != END_OF_INSN)
- {
- if (!is_space_char (*current_posn))
- {
- as_bad ("Invalid character %s before %s operand",
- output_invalid (*current_posn),
- ordinal_names[insn.operands]);
- return;
- }
- current_posn++;
- }
- token_start = current_posn; /* after white space */
- paren_not_balanced = 0;
- while (paren_not_balanced || *current_posn != ',')
- {
- if (*current_posn == END_OF_INSN)
- {
- if (paren_not_balanced)
- {
- as_bad ("Unbalanced parenthesis in %s operand.",
- ordinal_names[insn.operands]);
- return;
- }
- else
- break; /* we are done */
- }
- else if (!is_operand_char (*current_posn) && !is_space_char (*current_posn))
- {
- as_bad ("Invalid character %s in %s operand",
- output_invalid (*current_posn),
- ordinal_names[insn.operands]);
- return;
- }
- if (*current_posn == '(')
- ++paren_not_balanced;
- if (*current_posn == ')')
- --paren_not_balanced;
- current_posn++;
- }
- if (current_posn != token_start)
- { /* yes, we've read in another operand */
- this_operand = insn.operands++;
- if (insn.operands > MAX_OPERANDS)
- {
- as_bad ("Spurious operands; (%d operands/instruction max)",
- MAX_OPERANDS);
- return;
- }
- /* now parse operand adding info to 'insn' as we go along */
- save_char = *current_posn;
- *current_posn = '\0';
- insn.operand_type[this_operand] = tic30_operand (token_start);
- *current_posn = save_char;
- if (insn.operand_type[this_operand] == NULL)
- return;
- }
- else
- {
- if (expecting_operand)
- {
- as_bad ("Expecting operand after ','; got nothing");
- return;
- }
- if (*current_posn == ',')
- {
- as_bad ("Expecting operand before ','; got nothing");
- return;
- }
- }
- /* now *current_posn must be either ',' or END_OF_INSN */
- if (*current_posn == ',')
- {
- if (*++current_posn == END_OF_INSN)
- { /* just skip it, if it's \n complain */
- as_bad ("Expecting operand after ','; got nothing");
- return;
- }
- expecting_operand = 1;
- }
- }
- while (*current_posn != END_OF_INSN); /* until we get end of insn */
- }
- debug ("Number of operands found: %d\n", insn.operands);
- /* Check that number of operands is correct */
- if (insn.operands != insn.tm->operands)
- {
- int i;
- int numops = insn.tm->operands;
- /* If operands are not the same, then see if any of the operands are not
- required. Then recheck with number of given operands. If they are still not
- the same, then give an error, otherwise carry on. */
- for (i = 0; i < insn.tm->operands; i++)
- if (insn.tm->operand_types[i] & NotReq)
- numops--;
- if (insn.operands != numops)
- {
- as_bad ("Incorrect number of operands given");
- return;
- }
- }
- insn.addressing_mode = AM_NotReq;
- for (count = 0; count < insn.operands; count++)
- {
- if (insn.operand_type[count]->op_type & insn.tm->operand_types[count])
- {
- debug ("Operand %d matches\n", count + 1);
- /* If instruction has two operands and has an AddressMode modifier then set
- addressing mode type for instruction */
- if (insn.tm->opcode_modifier == AddressMode)
- {
- int addr_insn = 0;
- /* Store instruction uses the second operand for the address mode. */
- if ((insn.tm->operand_types[1] & (Indirect | Direct)) == (Indirect | Direct))
- addr_insn = 1;
- if (insn.operand_type[addr_insn]->op_type & (AllReg))
- insn.addressing_mode = AM_Register;
- else if (insn.operand_type[addr_insn]->op_type & Direct)
- insn.addressing_mode = AM_Direct;
- else if (insn.operand_type[addr_insn]->op_type & Indirect)
- insn.addressing_mode = AM_Indirect;
- else
- insn.addressing_mode = AM_Immediate;
- }
- }
- else
- {
- as_bad ("The %s operand doesn't match", ordinal_names[count]);
- return;
- }
- }
- /* Now set the addressing mode for 3 operand instructions. */
- if ((insn.tm->operand_types[0] & op3T1) && (insn.tm->operand_types[1] & op3T2))
- {
- /* Set the addressing mode to the values used for 2 operand instructions in the
- G addressing field of the opcode. */
- char *p;
- switch (insn.operand_type[0]->op_type)
- {
- case Rn:
- case ARn:
- case DPReg:
- case OtherReg:
- if (insn.operand_type[1]->op_type & (AllReg))
- insn.addressing_mode = AM_Register;
- else if (insn.operand_type[1]->op_type & Indirect)
- insn.addressing_mode = AM_Direct;
- else
- {
- /* Shouldn't make it to this stage */
- as_bad ("Incompatible first and second operands in instruction");
- return;
- }
- break;
- case Indirect:
- if (insn.operand_type[1]->op_type & (AllReg))
- insn.addressing_mode = AM_Indirect;
- else if (insn.operand_type[1]->op_type & Indirect)
- insn.addressing_mode = AM_Immediate;
- else
- {
- /* Shouldn't make it to this stage */
- as_bad ("Incompatible first and second operands in instruction");
- return;
- }
- break;
- }
- /* Now make up the opcode for the 3 operand instructions. As in parallel
- instructions, there will be no unresolved values, so they can be fully formed
- and added to the frag table. */
- insn.opcode = insn.tm->base_opcode;
- if (insn.operand_type[0]->op_type & Indirect)
- {
- insn.opcode |= (insn.operand_type[0]->indirect.ARnum);
- insn.opcode |= (insn.operand_type[0]->indirect.mod << 3);
- }
- else
- insn.opcode |= (insn.operand_type[0]->reg.opcode);
- if (insn.operand_type[1]->op_type & Indirect)
- {
- insn.opcode |= (insn.operand_type[1]->indirect.ARnum << 8);
- insn.opcode |= (insn.operand_type[1]->indirect.mod << 11);
- }
- else
- insn.opcode |= (insn.operand_type[1]->reg.opcode << 8);
- if (insn.operands == 3)
- insn.opcode |= (insn.operand_type[2]->reg.opcode << 16);
- insn.opcode |= insn.addressing_mode;
- p = frag_more (INSN_SIZE);
- md_number_to_chars (p, (valueT) insn.opcode, INSN_SIZE);
- }
- else
- { /* Not a three operand instruction */
- char *p;
- int am_insn = -1;
- insn.opcode = insn.tm->base_opcode;
- /* Create frag for instruction - all instructions are 4 bytes long. */
- p = frag_more (INSN_SIZE);
- if ((insn.operands > 0) && (insn.tm->opcode_modifier == AddressMode))
- {
- insn.opcode |= insn.addressing_mode;
- if (insn.addressing_mode == AM_Indirect)
- {
- /* Determine which operand gives the addressing mode */
- if (insn.operand_type[0]->op_type & Indirect)
- am_insn = 0;
- if ((insn.operands > 1) && (insn.operand_type[1]->op_type & Indirect))
- am_insn = 1;
- insn.opcode |= (insn.operand_type[am_insn]->indirect.disp);
- insn.opcode |= (insn.operand_type[am_insn]->indirect.ARnum << 8);
- insn.opcode |= (insn.operand_type[am_insn]->indirect.mod << 11);
- if (insn.operands > 1)
- insn.opcode |= (insn.operand_type[!am_insn]->reg.opcode << 16);
- md_number_to_chars (p, (valueT) insn.opcode, INSN_SIZE);
- }
- else if (insn.addressing_mode == AM_Register)
- {
- insn.opcode |= (insn.operand_type[0]->reg.opcode);
- if (insn.operands > 1)
- insn.opcode |= (insn.operand_type[1]->reg.opcode << 16);
- md_number_to_chars (p, (valueT) insn.opcode, INSN_SIZE);
- }
- else if (insn.addressing_mode == AM_Direct)
- {
- if (insn.operand_type[0]->op_type & Direct)
- am_insn = 0;
- if ((insn.operands > 1) && (insn.operand_type[1]->op_type & Direct))
- am_insn = 1;
- if (insn.operands > 1)
- insn.opcode |= (insn.operand_type[!am_insn]->reg.opcode << 16);
- if (insn.operand_type[am_insn]->direct.resolved == 1)
- {
- /* Resolved values can be placed straight into instruction word, and output */
- insn.opcode |= (insn.operand_type[am_insn]->direct.address & 0x0000FFFF);
- md_number_to_chars (p, (valueT) insn.opcode, INSN_SIZE);
- }
- else
- { /* Unresolved direct addressing mode instruction */
- md_number_to_chars (p, (valueT) insn.opcode, INSN_SIZE);
- fix_new_exp (frag_now, p + 2 - (frag_now->fr_literal), 2, &insn.operand_type[am_insn]->direct.direct_expr, 0, 0);
- }
- }
- else if (insn.addressing_mode == AM_Immediate)
- {
- if (insn.operand_type[0]->immediate.resolved == 1)
- {
- char *keeploc;
- int size;
- if (insn.operands > 1)
- insn.opcode |= (insn.operand_type[1]->reg.opcode << 16);
- switch (insn.tm->imm_arg_type)
- {
- case Imm_Float:
- debug ("Floating point first operand\n");
- md_number_to_chars (p, (valueT) insn.opcode, INSN_SIZE);
- keeploc = input_line_pointer;
- input_line_pointer = insn.operand_type[0]->immediate.label;
- if (md_atof ('f', p + 2, &size) != 0)
- {
- as_bad ("invalid short form floating point immediate operand");
- return;
- }
- input_line_pointer = keeploc;
- break;
- case Imm_UInt:
- debug ("Unsigned int first operand\n");
- if (insn.operand_type[0]->immediate.decimal_found)
- as_warn ("rounding down first operand float to unsigned int");
- if (insn.operand_type[0]->immediate.u_number > 0xFFFF)
- as_warn ("only lower 16-bits of first operand are used");
- insn.opcode |= (insn.operand_type[0]->immediate.u_number & 0x0000FFFFL);
- md_number_to_chars (p, (valueT) insn.opcode, INSN_SIZE);
- break;
- case Imm_SInt:
- debug ("Int first operand\n");
- if (insn.operand_type[0]->immediate.decimal_found)
- as_warn ("rounding down first operand float to signed int");
- if (insn.operand_type[0]->immediate.s_number < -32768 ||
- insn.operand_type[0]->immediate.s_number > 32767)
- {
- as_bad ("first operand is too large for 16-bit signed int");
- return;
- }
- insn.opcode |= (insn.operand_type[0]->immediate.s_number & 0x0000FFFFL);
- md_number_to_chars (p, (valueT) insn.opcode, INSN_SIZE);
- break;
- }
- }
- else
- { /* Unresolved immediate label */
- if (insn.operands > 1)
- insn.opcode |= (insn.operand_type[1]->reg.opcode << 16);
- md_number_to_chars (p, (valueT) insn.opcode, INSN_SIZE);
- fix_new_exp (frag_now, p + 2 - (frag_now->fr_literal), 2, &insn.operand_type[0]->immediate.imm_expr, 0, 0);
- }
- }
- }
- else if (insn.tm->opcode_modifier == PCRel)
- {
- /* Conditional Branch and Call instructions */
- if ((insn.tm->operand_types[0] & (AllReg | Disp)) == (AllReg | Disp))
- {
- if (insn.operand_type[0]->op_type & (AllReg))
- {
- insn.opcode |= (insn.operand_type[0]->reg.opcode);
- insn.opcode |= PC_Register;
- md_number_to_chars (p, (valueT) insn.opcode, INSN_SIZE);
- }
- else
- {
- insn.opcode |= PC_Relative;
- if (insn.operand_type[0]->immediate.resolved == 1)
- {
- insn.opcode |= (insn.operand_type[0]->immediate.s_number & 0x0000FFFF);
- md_number_to_chars (p, (valueT) insn.opcode, INSN_SIZE);
- }
- else
- {
- md_number_to_chars (p, (valueT) insn.opcode, INSN_SIZE);
- fix_new_exp (frag_now, p + 2 - (frag_now->fr_literal), 2, &insn.operand_type[0]->immediate.imm_expr, 1, 0);
- }
- }
- }
- else if ((insn.tm->operand_types[0] & ARn) == ARn)
- {
- /* Decrement and Branch instructions */
- insn.opcode |= ((insn.operand_type[0]->reg.opcode - 0x08) << 22);
- if (insn.operand_type[1]->op_type & (AllReg))
- {
- insn.opcode |= (insn.operand_type[1]->reg.opcode);
- insn.opcode |= PC_Register;
- md_number_to_chars (p, (valueT) insn.opcode, INSN_SIZE);
- }
- else if (insn.operand_type[1]->immediate.resolved == 1)
- {
- if (insn.operand_type[0]->immediate.decimal_found)
- {
- as_bad ("first operand is floating point");
- return;
- }
- if (insn.operand_type[0]->immediate.s_number < -32768 ||
- insn.operand_type[0]->immediate.s_number > 32767)
- {
- as_bad ("first operand is too large for 16-bit signed int");
- return;
- }
- insn.opcode |= (insn.operand_type[1]->immediate.s_number);
- insn.opcode |= PC_Relative;
- md_number_to_chars (p, (valueT) insn.opcode, INSN_SIZE);
- }
- else
- {
- insn.opcode |= PC_Relative;
- md_number_to_chars (p, (valueT) insn.opcode, INSN_SIZE);
- fix_new_exp (frag_now, p + 2 - frag_now->fr_literal, 2, &insn.operand_type[1]->immediate.imm_expr, 1, 0);
- }
- }
- }
- else if (insn.tm->operand_types[0] == IVector)
- {
- /* Trap instructions */
- if (insn.operand_type[0]->op_type & IVector)
- insn.opcode |= (insn.operand_type[0]->immediate.u_number);
- else
- { /* Shouldn't get here */
- as_bad ("interrupt vector for trap instruction out of range");
- return;
- }
- md_number_to_chars (p, (valueT) insn.opcode, INSN_SIZE);
- }
- else if (insn.tm->opcode_modifier == StackOp || insn.tm->opcode_modifier == Rotate)
- {
- /* Push, Pop and Rotate instructions */
- insn.opcode |= (insn.operand_type[0]->reg.opcode << 16);
- md_number_to_chars (p, (valueT) insn.opcode, INSN_SIZE);
- }
- else if ((insn.tm->operand_types[0] & (Abs24 | Direct)) == (Abs24 | Direct))
- {
- /* LDP Instruction needs to be tested for before the next section */
- if (insn.operand_type[0]->op_type & Direct)
- {
- if (insn.operand_type[0]->direct.resolved == 1)
- {
- /* Direct addressing uses lower 8 bits of direct address */
- insn.opcode |= (insn.operand_type[0]->direct.address & 0x00FF0000) >> 16;
- md_number_to_chars (p, (valueT) insn.opcode, INSN_SIZE);
- }
- else
- {
- fixS *fix;
- md_number_to_chars (p, (valueT) insn.opcode, INSN_SIZE);
- fix = fix_new_exp (frag_now, p + 3 - (frag_now->fr_literal), 1, &insn.operand_type[0]->direct.direct_expr, 0, 0);
- /* Ensure that the assembler doesn't complain about fitting a 24-bit
- address into 8 bits. */
- fix->fx_no_overflow = 1;
- }
- }
- else
- {
- if (insn.operand_type[0]->immediate.resolved == 1)
- {
- /* Immediate addressing uses upper 8 bits of address */
- if (insn.operand_type[0]->immediate.u_number > 0x00FFFFFF)
- {
- as_bad ("LDP instruction needs a 24-bit operand");
- return;
- }
- insn.opcode |= ((insn.operand_type[0]->immediate.u_number & 0x00FF0000) >> 16);
- md_number_to_chars (p, (valueT) insn.opcode, INSN_SIZE);
- }
- else
- {
- fixS *fix;
- md_number_to_chars (p, (valueT) insn.opcode, INSN_SIZE);
- fix = fix_new_exp (frag_now, p + 3 - (frag_now->fr_literal), 1, &insn.operand_type[0]->immediate.imm_expr, 0, 0);
- fix->fx_no_overflow = 1;
- }
- }
- }
- else if (insn.tm->operand_types[0] & (Imm24))
- {
- /* Unconditional Branch and Call instructions */
- if (insn.operand_type[0]->immediate.resolved == 1)
- {
- if (insn.operand_type[0]->immediate.u_number > 0x00FFFFFF)
- as_warn ("first operand is too large for a 24-bit displacement");
- insn.opcode |= (insn.operand_type[0]->immediate.u_number & 0x00FFFFFF);
- md_number_to_chars (p, (valueT) insn.opcode, INSN_SIZE);
- }
- else
- {
- md_number_to_chars (p, (valueT) insn.opcode, INSN_SIZE);
- fix_new_exp (frag_now, p + 1 - (frag_now->fr_literal), 3, &insn.operand_type[0]->immediate.imm_expr, 0, 0);
- }
- }
- else if (insn.tm->operand_types[0] & NotReq)
- {
- /* Check for NOP instruction without arguments. */
- md_number_to_chars (p, (valueT) insn.opcode, INSN_SIZE);
- }
- else if (insn.tm->operands == 0)
- {
- /* Check for instructions without operands. */
- md_number_to_chars (p, (valueT) insn.opcode, INSN_SIZE);
- }
- }
- debug ("Addressing mode: %08X\n", insn.addressing_mode);
- {
- int i;
- for (i = 0; i < insn.operands; i++)
- {
- if (insn.operand_type[i]->immediate.label)
- free (insn.operand_type[i]->immediate.label);
- free (insn.operand_type[i]);
- }
- }
- debug ("Final opcode: %08X\n", insn.opcode);
- debug ("\n");
-}
-
-struct tic30_par_insn {
- partemplate *tm; /* Template of current parallel instruction */
- int operands[2]; /* Number of given operands for each insn */
- /* Type of operand given in instruction */
- operand *operand_type[2][MAX_OPERANDS];
- int swap_operands; /* Whether to swap operands around. */
- unsigned p_field; /* Value of p field in multiply add/sub instructions */
- unsigned opcode; /* Final opcode */
-};
-
-struct tic30_par_insn p_insn;
-
-int
-tic30_parallel_insn (char *token)
-{
- static partemplate *p_opcode;
- char *current_posn = token;
- char *token_start;
- char save_char;
-
- debug ("In tic30_parallel_insn with %s\n", token);
- memset (&p_insn, '\0', sizeof (p_insn));
- while (is_opcode_char (*current_posn))
- current_posn++;
- { /* Find instruction */
- save_char = *current_posn;
- *current_posn = '\0';
- p_opcode = (partemplate *) hash_find (parop_hash, token);
- if (p_opcode)
- {
- debug ("Found instruction %s\n", p_opcode->name);
- p_insn.tm = p_opcode;
- }
- else
- {
- char first_opcode[6] =
- {0};
- char second_opcode[6] =
- {0};
- int i;
- int current_opcode = -1;
- int char_ptr = 0;
-
- for (i = 0; i < strlen (token); i++)
- {
- char ch = *(token + i);
- if (ch == '_' && current_opcode == -1)
- {
- current_opcode = 0;
- continue;
- }
- if (ch == '_' && current_opcode == 0)
- {
- current_opcode = 1;
- char_ptr = 0;
- continue;
- }
- switch (current_opcode)
- {
- case 0:
- first_opcode[char_ptr++] = ch;
- break;
- case 1:
- second_opcode[char_ptr++] = ch;
- break;
- }
- }
- debug ("first_opcode = %s\n", first_opcode);
- debug ("second_opcode = %s\n", second_opcode);
- sprintf (token, "q_%s_%s", second_opcode, first_opcode);
- p_opcode = (partemplate *) hash_find (parop_hash, token);
- if (p_opcode)
- {
- debug ("Found instruction %s\n", p_opcode->name);
- p_insn.tm = p_opcode;
- p_insn.swap_operands = 1;
- }
- else
- return 0;
- }
- *current_posn = save_char;
- }
- { /* Find operands */
- int paren_not_balanced;
- int expecting_operand = 0;
- int found_separator = 0;
- do
- {
- /* skip optional white space before operand */
- while (!is_operand_char (*current_posn) && *current_posn != END_OF_INSN)
- {
- if (!is_space_char (*current_posn) && *current_posn != PARALLEL_SEPARATOR)
- {
- as_bad ("Invalid character %s before %s operand",
- output_invalid (*current_posn),
- ordinal_names[insn.operands]);
- return 1;
- }
- if (*current_posn == PARALLEL_SEPARATOR)
- found_separator = 1;
- current_posn++;
- }
- token_start = current_posn; /* after white space */
- paren_not_balanced = 0;
- while (paren_not_balanced || *current_posn != ',')
- {
- if (*current_posn == END_OF_INSN)
- {
- if (paren_not_balanced)
- {
- as_bad ("Unbalanced parenthesis in %s operand.",
- ordinal_names[insn.operands]);
- return 1;
- }
- else
- break; /* we are done */
- }
- else if (*current_posn == PARALLEL_SEPARATOR)
- {
- while (is_space_char (*(current_posn - 1)))
- current_posn--;
- break;
- }
- else if (!is_operand_char (*current_posn) && !is_space_char (*current_posn))
- {
- as_bad ("Invalid character %s in %s operand",
- output_invalid (*current_posn),
- ordinal_names[insn.operands]);
- return 1;
- }
- if (*current_posn == '(')
- ++paren_not_balanced;
- if (*current_posn == ')')
- --paren_not_balanced;
- current_posn++;
- }
- if (current_posn != token_start)
- { /* yes, we've read in another operand */
- p_insn.operands[found_separator]++;
- if (p_insn.operands[found_separator] > MAX_OPERANDS)
- {
- as_bad ("Spurious operands; (%d operands/instruction max)",
- MAX_OPERANDS);
- return 1;
- }
- /* now parse operand adding info to 'insn' as we go along */
- save_char = *current_posn;
- *current_posn = '\0';
- p_insn.operand_type[found_separator][p_insn.operands[found_separator] - 1] =
- tic30_operand (token_start);
- *current_posn = save_char;
- if (!p_insn.operand_type[found_separator][p_insn.operands[found_separator] - 1])
- return 1;
- }
- else
- {
- if (expecting_operand)
- {
- as_bad ("Expecting operand after ','; got nothing");
- return 1;
- }
- if (*current_posn == ',')
- {
- as_bad ("Expecting operand before ','; got nothing");
- return 1;
- }
- }
- /* now *current_posn must be either ',' or END_OF_INSN */
- if (*current_posn == ',')
- {
- if (*++current_posn == END_OF_INSN)
- { /* just skip it, if it's \n complain */
- as_bad ("Expecting operand after ','; got nothing");
- return 1;
- }
- expecting_operand = 1;
- }
- }
- while (*current_posn != END_OF_INSN); /* until we get end of insn */
- }
- if (p_insn.swap_operands)
- {
- int temp_num, i;
- operand *temp_op;
-
- temp_num = p_insn.operands[0];
- p_insn.operands[0] = p_insn.operands[1];
- p_insn.operands[1] = temp_num;
- for (i = 0; i < MAX_OPERANDS; i++)
- {
- temp_op = p_insn.operand_type[0][i];
- p_insn.operand_type[0][i] = p_insn.operand_type[1][i];
- p_insn.operand_type[1][i] = temp_op;
- }
- }
- if (p_insn.operands[0] != p_insn.tm->operands_1)
- {
- as_bad ("incorrect number of operands given in the first instruction");
- return 1;
- }
- if (p_insn.operands[1] != p_insn.tm->operands_2)
- {
- as_bad ("incorrect number of operands given in the second instruction");
- return 1;
- }
- debug ("Number of operands in first insn: %d\n", p_insn.operands[0]);
- debug ("Number of operands in second insn: %d\n", p_insn.operands[1]);
- { /* Now check if operands are correct */
- int count;
- int num_rn = 0;
- int num_ind = 0;
- for (count = 0; count < 2; count++)
- {
- int i;
- for (i = 0; i < p_insn.operands[count]; i++)
- {
- if ((p_insn.operand_type[count][i]->op_type &
- p_insn.tm->operand_types[count][i]) == 0)
- {
- as_bad ("%s instruction, operand %d doesn't match", ordinal_names[count], i + 1);
- return 1;
- }
- /* Get number of R register and indirect reference contained within the first
- two operands of each instruction. This is required for the multiply
- parallel instructions which require two R registers and two indirect
- references, but not in any particular place. */
- if ((p_insn.operand_type[count][i]->op_type & Rn) && i < 2)
- num_rn++;
- else if ((p_insn.operand_type[count][i]->op_type & Indirect) && i < 2)
- num_ind++;
- }
- }
- if ((p_insn.tm->operand_types[0][0] & (Indirect | Rn)) == (Indirect | Rn))
- {
- /* Check for the multiply instructions */
- if (num_rn != 2)
- {
- as_bad ("incorrect format for multiply parallel instruction");
- return 1;
- }
- if (num_ind != 2)
- { /* Shouldn't get here */
- as_bad ("incorrect format for multiply parallel instruction");
- return 1;
- }
- if ((p_insn.operand_type[0][2]->reg.opcode != 0x00) &&
- (p_insn.operand_type[0][2]->reg.opcode != 0x01))
- {
- as_bad ("destination for multiply can only be R0 or R1");
- return 1;
- }
- if ((p_insn.operand_type[1][2]->reg.opcode != 0x02) &&
- (p_insn.operand_type[1][2]->reg.opcode != 0x03))
- {
- as_bad ("destination for add/subtract can only be R2 or R3");
- return 1;
- }
- /* Now determine the P field for the instruction */
- if (p_insn.operand_type[0][0]->op_type & Indirect)
- {
- if (p_insn.operand_type[0][1]->op_type & Indirect)
- p_insn.p_field = 0x00000000; /* Ind * Ind, Rn +/- Rn */
- else if (p_insn.operand_type[1][0]->op_type & Indirect)
- p_insn.p_field = 0x01000000; /* Ind * Rn, Ind +/- Rn */
- else
- p_insn.p_field = 0x03000000; /* Ind * Rn, Rn +/- Ind */
- }
- else
- {
- if (p_insn.operand_type[0][1]->op_type & Rn)
- p_insn.p_field = 0x02000000; /* Rn * Rn, Ind +/- Ind */
- else if (p_insn.operand_type[1][0]->op_type & Indirect)
- {
- operand *temp;
- p_insn.p_field = 0x01000000; /* Rn * Ind, Ind +/- Rn */
- /* Need to swap the two multiply operands around so that everything is in
- its place for the opcode makeup ie so Ind * Rn, Ind +/- Rn */
- temp = p_insn.operand_type[0][0];
- p_insn.operand_type[0][0] = p_insn.operand_type[0][1];
- p_insn.operand_type[0][1] = temp;
- }
- else
- {
- operand *temp;
- p_insn.p_field = 0x03000000; /* Rn * Ind, Rn +/- Ind */
- temp = p_insn.operand_type[0][0];
- p_insn.operand_type[0][0] = p_insn.operand_type[0][1];
- p_insn.operand_type[0][1] = temp;
- }
- }
- }
- }
- debug ("P field: %08X\n", p_insn.p_field);
- /* Finalise opcode. This is easier for parallel instructions as they have to be
- fully resolved, there are no memory addresses allowed, except through indirect
- addressing, so there are no labels to resolve. */
- {
- p_insn.opcode = p_insn.tm->base_opcode;
- switch (p_insn.tm->oporder)
- {
- case OO_4op1:
- p_insn.opcode |= (p_insn.operand_type[0][0]->indirect.ARnum);
- p_insn.opcode |= (p_insn.operand_type[0][0]->indirect.mod << 3);
- p_insn.opcode |= (p_insn.operand_type[1][1]->indirect.ARnum << 8);
- p_insn.opcode |= (p_insn.operand_type[1][1]->indirect.mod << 11);
- p_insn.opcode |= (p_insn.operand_type[1][0]->reg.opcode << 16);
- p_insn.opcode |= (p_insn.operand_type[0][1]->reg.opcode << 22);
- break;
- case OO_4op2:
- p_insn.opcode |= (p_insn.operand_type[0][0]->indirect.ARnum);
- p_insn.opcode |= (p_insn.operand_type[0][0]->indirect.mod << 3);
- p_insn.opcode |= (p_insn.operand_type[1][0]->indirect.ARnum << 8);
- p_insn.opcode |= (p_insn.operand_type[1][0]->indirect.mod << 11);
- p_insn.opcode |= (p_insn.operand_type[1][1]->reg.opcode << 19);
- p_insn.opcode |= (p_insn.operand_type[0][1]->reg.opcode << 22);
- if (p_insn.operand_type[1][1]->reg.opcode == p_insn.operand_type[0][1]->reg.opcode)
- as_warn ("loading the same register in parallel operation");
- break;
- case OO_4op3:
- p_insn.opcode |= (p_insn.operand_type[0][1]->indirect.ARnum);
- p_insn.opcode |= (p_insn.operand_type[0][1]->indirect.mod << 3);
- p_insn.opcode |= (p_insn.operand_type[1][1]->indirect.ARnum << 8);
- p_insn.opcode |= (p_insn.operand_type[1][1]->indirect.mod << 11);
- p_insn.opcode |= (p_insn.operand_type[1][0]->reg.opcode << 16);
- p_insn.opcode |= (p_insn.operand_type[0][0]->reg.opcode << 22);
- break;
- case OO_5op1:
- p_insn.opcode |= (p_insn.operand_type[0][0]->indirect.ARnum);
- p_insn.opcode |= (p_insn.operand_type[0][0]->indirect.mod << 3);
- p_insn.opcode |= (p_insn.operand_type[1][1]->indirect.ARnum << 8);
- p_insn.opcode |= (p_insn.operand_type[1][1]->indirect.mod << 11);
- p_insn.opcode |= (p_insn.operand_type[1][0]->reg.opcode << 16);
- p_insn.opcode |= (p_insn.operand_type[0][1]->reg.opcode << 19);
- p_insn.opcode |= (p_insn.operand_type[0][2]->reg.opcode << 22);
- break;
- case OO_5op2:
- p_insn.opcode |= (p_insn.operand_type[0][1]->indirect.ARnum);
- p_insn.opcode |= (p_insn.operand_type[0][1]->indirect.mod << 3);
- p_insn.opcode |= (p_insn.operand_type[1][1]->indirect.ARnum << 8);
- p_insn.opcode |= (p_insn.operand_type[1][1]->indirect.mod << 11);
- p_insn.opcode |= (p_insn.operand_type[1][0]->reg.opcode << 16);
- p_insn.opcode |= (p_insn.operand_type[0][0]->reg.opcode << 19);
- p_insn.opcode |= (p_insn.operand_type[0][2]->reg.opcode << 22);
- break;
- case OO_PField:
- p_insn.opcode |= p_insn.p_field;
- if (p_insn.operand_type[0][2]->reg.opcode == 0x01)
- p_insn.opcode |= 0x00800000;
- if (p_insn.operand_type[1][2]->reg.opcode == 0x03)
- p_insn.opcode |= 0x00400000;
- switch (p_insn.p_field)
- {
- case 0x00000000:
- p_insn.opcode |= (p_insn.operand_type[0][1]->indirect.ARnum);
- p_insn.opcode |= (p_insn.operand_type[0][1]->indirect.mod << 3);
- p_insn.opcode |= (p_insn.operand_type[0][0]->indirect.ARnum << 8);
- p_insn.opcode |= (p_insn.operand_type[0][0]->indirect.mod << 11);
- p_insn.opcode |= (p_insn.operand_type[1][1]->reg.opcode << 16);
- p_insn.opcode |= (p_insn.operand_type[1][0]->reg.opcode << 19);
- break;
- case 0x01000000:
- p_insn.opcode |= (p_insn.operand_type[1][0]->indirect.ARnum);
- p_insn.opcode |= (p_insn.operand_type[1][0]->indirect.mod << 3);
- p_insn.opcode |= (p_insn.operand_type[0][0]->indirect.ARnum << 8);
- p_insn.opcode |= (p_insn.operand_type[0][0]->indirect.mod << 11);
- p_insn.opcode |= (p_insn.operand_type[1][1]->reg.opcode << 16);
- p_insn.opcode |= (p_insn.operand_type[0][1]->reg.opcode << 19);
- break;
- case 0x02000000:
- p_insn.opcode |= (p_insn.operand_type[1][1]->indirect.ARnum);
- p_insn.opcode |= (p_insn.operand_type[1][1]->indirect.mod << 3);
- p_insn.opcode |= (p_insn.operand_type[1][0]->indirect.ARnum << 8);
- p_insn.opcode |= (p_insn.operand_type[1][0]->indirect.mod << 11);
- p_insn.opcode |= (p_insn.operand_type[0][1]->reg.opcode << 16);
- p_insn.opcode |= (p_insn.operand_type[0][0]->reg.opcode << 19);
- break;
- case 0x03000000:
- p_insn.opcode |= (p_insn.operand_type[1][1]->indirect.ARnum);
- p_insn.opcode |= (p_insn.operand_type[1][1]->indirect.mod << 3);
- p_insn.opcode |= (p_insn.operand_type[0][0]->indirect.ARnum << 8);
- p_insn.opcode |= (p_insn.operand_type[0][0]->indirect.mod << 11);
- p_insn.opcode |= (p_insn.operand_type[1][0]->reg.opcode << 16);
- p_insn.opcode |= (p_insn.operand_type[0][1]->reg.opcode << 19);
- break;
- }
- break;
- }
- } /* Opcode is finalised at this point for all parallel instructions. */
- { /* Output opcode */
- char *p;
- p = frag_more (INSN_SIZE);
- md_number_to_chars (p, (valueT) p_insn.opcode, INSN_SIZE);
- }
- {
- int i, j;
- for (i = 0; i < 2; i++)
- for (j = 0; j < p_insn.operands[i]; j++)
- free (p_insn.operand_type[i][j]);
- }
- debug ("Final opcode: %08X\n", p_insn.opcode);
- debug ("\n");
- return 1;
-}
-
-operand *
-tic30_operand (token)
- char *token;
-{
- int count;
- char ind_buffer[strlen (token)];
- operand *current_op;
-
- debug ("In tic30_operand with %s\n", token);
- current_op = (operand *) malloc (sizeof (operand));
- memset (current_op, '\0', sizeof (operand));
- if (*token == DIRECT_REFERENCE)
- {
- char *token_posn = token + 1;
- int direct_label = 0;
- debug ("Found direct reference\n");
- while (*token_posn)
- {
- if (!is_digit_char (*token_posn))
- direct_label = 1;
- token_posn++;
- }
- if (direct_label)
- {
- char *save_input_line_pointer;
- segT retval;
- debug ("Direct reference is a label\n");
- current_op->direct.label = token + 1;
- save_input_line_pointer = input_line_pointer;
- input_line_pointer = token + 1;
- debug ("Current input_line_pointer: %s\n", input_line_pointer);
- retval = expression (&current_op->direct.direct_expr);
- debug ("Expression type: %d\n", current_op->direct.direct_expr.X_op);
- debug ("Expression addnum: %d\n", current_op->direct.direct_expr.X_add_number);
- debug ("Segment: %d\n", retval);
- input_line_pointer = save_input_line_pointer;
- if (current_op->direct.direct_expr.X_op == O_constant)
- {
- current_op->direct.address = current_op->direct.direct_expr.X_add_number;
- current_op->direct.resolved = 1;
- }
- }
- else
- {
- debug ("Direct reference is a number\n");
- current_op->direct.address = atoi (token + 1);
- current_op->direct.resolved = 1;
- }
- current_op->op_type = Direct;
- }
- else if (*token == INDIRECT_REFERENCE)
- { /* Indirect reference operand */
- int found_ar = 0;
- int found_disp = 0;
- int ar_number = -1;
- int disp_number = 0;
- int buffer_posn = 1;
- ind_addr_type *ind_addr_op;
- debug ("Found indirect reference\n");
- ind_buffer[0] = *token;
- for (count = 1; count < strlen (token); count++)
- { /* Strip operand */
- ind_buffer[buffer_posn] = TOLOWER (*(token + count));
- if ((*(token + count - 1) == 'a' || *(token + count - 1) == 'A') &&
- (*(token + count) == 'r' || *(token + count) == 'R'))
- {
- /* AR reference is found, so get its number and remove it from the buffer
- so it can pass through hash_find() */
- if (found_ar)
- {
- as_bad ("More than one AR register found in indirect reference");
- return NULL;
- }
- if (*(token + count + 1) < '0' || *(token + count + 1) > '7')
- {
- as_bad ("Illegal AR register in indirect reference");
- return NULL;
- }
- ar_number = *(token + count + 1) - '0';
- found_ar = 1;
- count++;
- }
- if (*(token + count) == '(')
- {
- /* Parenthesis found, so check if a displacement value is inside. If so, get
- the value and remove it from the buffer. */
- if (is_digit_char (*(token + count + 1)))
- {
- char disp[10];
- int disp_posn = 0;
-
- if (found_disp)
- {
- as_bad ("More than one displacement found in indirect reference");
- return NULL;
- }
- count++;
- while (*(token + count) != ')')
- {
- if (!is_digit_char (*(token + count)))
- {
- as_bad ("Invalid displacement in indirect reference");
- return NULL;
- }
- disp[disp_posn++] = *(token + (count++));
- }
- disp[disp_posn] = '\0';
- disp_number = atoi (disp);
- count--;
- found_disp = 1;
- }
- }
- buffer_posn++;
- }
- ind_buffer[buffer_posn] = '\0';
- if (!found_ar)
- {
- as_bad ("AR register not found in indirect reference");
- return NULL;
- }
- ind_addr_op = (ind_addr_type *) hash_find (ind_hash, ind_buffer);
- if (ind_addr_op)
- {
- debug ("Found indirect reference: %s\n", ind_addr_op->syntax);
- if (ind_addr_op->displacement == IMPLIED_DISP)
- {
- found_disp = 1;
- disp_number = 1;
- }
- else if ((ind_addr_op->displacement == DISP_REQUIRED) && !found_disp)
- {
- /* Maybe an implied displacement of 1 again */
- as_bad ("required displacement wasn't given in indirect reference");
- return 0;
- }
- }
- else
- {
- as_bad ("illegal indirect reference");
- return NULL;
- }
- if (found_disp && (disp_number < 0 || disp_number > 255))
- {
- as_bad ("displacement must be an unsigned 8-bit number");
- return NULL;
- }
- current_op->indirect.mod = ind_addr_op->modfield;
- current_op->indirect.disp = disp_number;
- current_op->indirect.ARnum = ar_number;
- current_op->op_type = Indirect;
- }
- else
- {
- reg *regop = (reg *) hash_find (reg_hash, token);
- if (regop)
- {
- debug ("Found register operand: %s\n", regop->name);
- if (regop->regtype == REG_ARn)
- current_op->op_type = ARn;
- else if (regop->regtype == REG_Rn)
- current_op->op_type = Rn;
- else if (regop->regtype == REG_DP)
- current_op->op_type = DPReg;
- else
- current_op->op_type = OtherReg;
- current_op->reg.opcode = regop->opcode;
- }
- else
- {
- if (!is_digit_char (*token) || *(token + 1) == 'x' || strchr (token, 'h'))
- {
- char *save_input_line_pointer;
- segT retval;
- debug ("Probably a label: %s\n", token);
- current_op->immediate.label = (char *) malloc (strlen (token) + 1);
- strcpy (current_op->immediate.label, token);
- current_op->immediate.label[strlen (token)] = '\0';
- save_input_line_pointer = input_line_pointer;
- input_line_pointer = token;
- debug ("Current input_line_pointer: %s\n", input_line_pointer);
- retval = expression (&current_op->immediate.imm_expr);
- debug ("Expression type: %d\n", current_op->immediate.imm_expr.X_op);
- debug ("Expression addnum: %d\n", current_op->immediate.imm_expr.X_add_number);
- debug ("Segment: %d\n", retval);
- input_line_pointer = save_input_line_pointer;
- if (current_op->immediate.imm_expr.X_op == O_constant)
- {
- current_op->immediate.s_number = current_op->immediate.imm_expr.X_add_number;
- current_op->immediate.u_number = (unsigned int) current_op->immediate.imm_expr.X_add_number;
- current_op->immediate.resolved = 1;
- }
- }
- else
- {
- unsigned count;
- debug ("Found a number or displacement\n");
- for (count = 0; count < strlen (token); count++)
- if (*(token + count) == '.')
- current_op->immediate.decimal_found = 1;
- current_op->immediate.label = (char *) malloc (strlen (token) + 1);
- strcpy (current_op->immediate.label, token);
- current_op->immediate.label[strlen (token)] = '\0';
- current_op->immediate.f_number = (float) atof (token);
- current_op->immediate.s_number = (int) atoi (token);
- current_op->immediate.u_number = (unsigned int) atoi (token);
- current_op->immediate.resolved = 1;
- }
- current_op->op_type = Disp | Abs24 | Imm16 | Imm24;
- if (current_op->immediate.u_number >= 0 && current_op->immediate.u_number <= 31)
- current_op->op_type |= IVector;
- }
- }
- return current_op;
-}
-
-/* next_line points to the next line after the current instruction (current_line).
- Search for the parallel bars, and if found, merge two lines into internal syntax
- for a parallel instruction:
- q_[INSN1]_[INSN2] [OPERANDS1] | [OPERANDS2]
- By this stage, all comments are scrubbed, and only the bare lines are given.
- */
-
-#define NONE 0
-#define START_OPCODE 1
-#define END_OPCODE 2
-#define START_OPERANDS 3
-#define END_OPERANDS 4
-
-char *
-tic30_find_parallel_insn (current_line, next_line)
- char *current_line;
- char *next_line;
-{
- int found_parallel = 0;
- char first_opcode[256];
- char second_opcode[256];
- char first_operands[256];
- char second_operands[256];
- char *parallel_insn;
-
- debug ("In tic30_find_parallel_insn()\n");
- while (!is_end_of_line[(unsigned char) *next_line])
- {
- if (*next_line == PARALLEL_SEPARATOR && *(next_line + 1) == PARALLEL_SEPARATOR)
- {
- found_parallel = 1;
- next_line++;
- break;
- }
- next_line++;
- }
- if (!found_parallel)
- return NULL;
- debug ("Found a parallel instruction\n");
- {
- int i;
- char *opcode, *operands, *line;
-
- for (i = 0; i < 2; i++)
- {
- if (i == 0)
- {
- opcode = &first_opcode[0];
- operands = &first_operands[0];
- line = current_line;
- }
- else
- {
- opcode = &second_opcode[0];
- operands = &second_operands[0];
- line = next_line;
- }
- {
- int search_status = NONE;
- int char_ptr = 0;
- char c;
-
- while (!is_end_of_line[(unsigned char) (c = *line)])
- {
- if (is_opcode_char (c) && search_status == NONE)
- {
- opcode[char_ptr++] = TOLOWER (c);
- search_status = START_OPCODE;
- }
- else if (is_opcode_char (c) && search_status == START_OPCODE)
- {
- opcode[char_ptr++] = TOLOWER (c);
- }
- else if (!is_opcode_char (c) && search_status == START_OPCODE)
- {
- opcode[char_ptr] = '\0';
- char_ptr = 0;
- search_status = END_OPCODE;
- }
- else if (is_operand_char (c) && search_status == START_OPERANDS)
- {
- operands[char_ptr++] = c;
- }
- if (is_operand_char (c) && search_status == END_OPCODE)
- {
- operands[char_ptr++] = c;
- search_status = START_OPERANDS;
- }
- line++;
- }
- if (search_status != START_OPERANDS)
- return NULL;
- operands[char_ptr] = '\0';
- }
- }
- }
- parallel_insn = (char *) malloc (strlen (first_opcode) + strlen (first_operands) +
- strlen (second_opcode) + strlen (second_operands) + 8);
- sprintf (parallel_insn, "q_%s_%s %s | %s", first_opcode, second_opcode, first_operands, second_operands);
- debug ("parallel insn = %s\n", parallel_insn);
- return parallel_insn;
-}
-
-#undef NONE
-#undef START_OPCODE
-#undef END_OPCODE
-#undef START_OPERANDS
-#undef END_OPERANDS
-
-/* In order to get gas to ignore any | chars at the start of a line,
- this function returns true if a | is found in a line. */
-
-int
-tic30_unrecognized_line (c)
- int c;
-{
- debug ("In tc_unrecognized_line\n");
- return (c == PARALLEL_SEPARATOR);
-}
-
-int
-md_estimate_size_before_relax (fragP, segment)
- fragS *fragP;
- segT segment;
-{
- debug ("In md_estimate_size_before_relax()\n");
- return 0;
-}
-
-void
-md_convert_frag (abfd, sec, fragP)
- bfd *abfd;
- segT sec;
- register fragS *fragP;
-{
- debug ("In md_convert_frag()\n");
-}
-
-void
-md_apply_fix3 (fixP, valP, seg)
- fixS *fixP;
- valueT *valP;
- segT seg ATTRIBUTE_UNUSED;
-{
- valueT value = *valP;
-
- debug ("In md_apply_fix() with value = %ld\n", (long) value);
- debug ("Values in fixP\n");
- debug ("fx_size = %d\n", fixP->fx_size);
- debug ("fx_pcrel = %d\n", fixP->fx_pcrel);
- debug ("fx_where = %d\n", fixP->fx_where);
- debug ("fx_offset = %d\n", (int) fixP->fx_offset);
- {
- char *buf = fixP->fx_frag->fr_literal + fixP->fx_where;
-
- value /= INSN_SIZE;
- if (fixP->fx_size == 1)
- /* Special fix for LDP instruction. */
- value = (value & 0x00FF0000) >> 16;
-
- debug ("new value = %ld\n", (long) value);
- md_number_to_chars (buf, value, fixP->fx_size);
- }
-
- if (fixP->fx_addsy == NULL && fixP->fx_pcrel == 0)
- fixP->fx_done = 1;
-}
-
-int
-md_parse_option (c, arg)
- int c;
- char *arg;
-{
- int i;
-
- debug ("In md_parse_option()\n");
- for (i = 0; i < c; i++)
- {
- printf ("%c\n", arg[c]);
- }
- return 0;
-}
-
-void
-md_show_usage (stream)
- FILE *stream;
-{
- debug ("In md_show_usage()\n");
-}
-
-symbolS *
-md_undefined_symbol (name)
- char *name;
-{
- debug ("In md_undefined_symbol()\n");
- return (symbolS *) 0;
-}
-
-valueT
-md_section_align (segment, size)
- segT segment;
- valueT size;
-{
- debug ("In md_section_align() segment = %d and size = %d\n", segment, size);
- size = (size + 3) / 4;
- size *= 4;
- debug ("New size value = %d\n", size);
- return size;
-}
-
-long
-md_pcrel_from (fixP)
- fixS *fixP;
-{
- int offset;
-
- debug ("In md_pcrel_from()\n");
- debug ("fx_where = %d\n", fixP->fx_where);
- debug ("fx_size = %d\n", fixP->fx_size);
- /* Find the opcode that represents the current instruction in the fr_literal
- storage area, and check bit 21. Bit 21 contains whether the current instruction
- is a delayed one or not, and then set the offset value appropriately. */
- if (fixP->fx_frag->fr_literal[fixP->fx_where - fixP->fx_size + 1] & 0x20)
- offset = 3;
- else
- offset = 1;
- debug ("offset = %d\n", offset);
- /* PC Relative instructions have a format:
- displacement = Label - (PC + offset)
- This function returns PC + offset where:
- fx_where - fx_size = PC
- INSN_SIZE * offset = offset number of instructions
- */
- return fixP->fx_where - fixP->fx_size + (INSN_SIZE * offset);
-}
-
-char *
-md_atof (what_statement_type, literalP, sizeP)
- int what_statement_type;
- char *literalP;
- int *sizeP;
-{
- int prec;
- char *token;
- char keepval;
- unsigned long value;
- /* char *atof_ieee (); */
- float float_value;
- debug ("In md_atof()\n");
- debug ("precision = %c\n", what_statement_type);
- debug ("literal = %s\n", literalP);
- debug ("line = ");
- token = input_line_pointer;
- while (!is_end_of_line[(unsigned char) *input_line_pointer]
- && (*input_line_pointer != ','))
- {
- debug ("%c", *input_line_pointer);
- input_line_pointer++;
- }
- keepval = *input_line_pointer;
- *input_line_pointer = '\0';
- debug ("\n");
- float_value = (float) atof (token);
- *input_line_pointer = keepval;
- debug ("float_value = %f\n", float_value);
- switch (what_statement_type)
- {
- case 'f':
- case 'F':
- case 's':
- case 'S':
- prec = 2;
- break;
-
- case 'd':
- case 'D':
- case 'r':
- case 'R':
- prec = 4;
- break;
-
- default:
- *sizeP = 0;
- return "Bad call to MD_ATOF()";
- }
- if (float_value == 0.0)
- {
- value = (prec == 2) ? 0x00008000L : 0x80000000L;
- }
- else
- {
- unsigned long exp, sign, mant, tmsfloat;
- tmsfloat = *((long *) &float_value);
- sign = tmsfloat & 0x80000000;
- mant = tmsfloat & 0x007FFFFF;
- exp = tmsfloat & 0x7F800000;
- exp <<= 1;
- if (exp == 0xFF000000)
- {
- if (mant == 0)
- value = 0x7F7FFFFF;
- else if (sign == 0)
- value = 0x7F7FFFFF;
- else
- value = 0x7F800000;
- }
- else
- {
- exp -= 0x7F000000;
- if (sign)
- {
- mant = mant & 0x007FFFFF;
- mant = -mant;
- mant = mant & 0x00FFFFFF;
- if (mant == 0)
- {
- mant |= 0x00800000;
- exp = (long) exp - 0x01000000;
- }
- }
- tmsfloat = exp | mant;
- value = tmsfloat;
- }
- if (prec == 2)
- {
- long exp, mant;
-
- if (tmsfloat == 0x80000000)
- {
- value = 0x8000;
- }
- else
- {
- value = 0;
- exp = (tmsfloat & 0xFF000000);
- exp >>= 24;
- mant = tmsfloat & 0x007FFFFF;
- if (tmsfloat & 0x00800000)
- {
- mant |= 0xFF000000;
- mant += 0x00000800;
- mant >>= 12;
- mant |= 0x00000800;
- mant &= 0x0FFF;
- if (exp > 7)
- value = 0x7800;
- }
- else
- {
- mant |= 0x00800000;
- mant += 0x00000800;
- exp += (mant >> 24);
- mant >>= 12;
- mant &= 0x07FF;
- if (exp > 7)
- value = 0x77FF;
- }
- if (exp < -8)
- value = 0x8000;
- if (value == 0)
- {
- mant = (exp << 12) | mant;
- value = mant & 0xFFFF;
- }
- }
- }
- }
- md_number_to_chars (literalP, value, prec);
- *sizeP = prec;
- return 0;
-}
-
-void
-md_number_to_chars (buf, val, n)
- char *buf;
- valueT val;
- int n;
-{
- debug ("In md_number_to_chars()\n");
- number_to_chars_bigendian (buf, val, n);
- /* number_to_chars_littleendian(buf,val,n); */
-}
-
-#define F(SZ,PCREL) (((SZ) << 1) + (PCREL))
-#define MAP(SZ,PCREL,TYPE) case F(SZ,PCREL): code = (TYPE); break
-
-arelent *
-tc_gen_reloc (section, fixP)
- asection *section;
- fixS *fixP;
-{
- arelent *rel;
- bfd_reloc_code_real_type code = 0;
-
- debug ("In tc_gen_reloc()\n");
- debug ("fixP.size = %d\n", fixP->fx_size);
- debug ("fixP.pcrel = %d\n", fixP->fx_pcrel);
- debug ("addsy.name = %s\n", S_GET_NAME (fixP->fx_addsy));
- switch (F (fixP->fx_size, fixP->fx_pcrel))
- {
- MAP (1, 0, BFD_RELOC_TIC30_LDP);
- MAP (2, 0, BFD_RELOC_16);
- MAP (3, 0, BFD_RELOC_24);
- MAP (2, 1, BFD_RELOC_16_PCREL);
- MAP (4, 0, BFD_RELOC_32);
- default:
- as_bad ("Can not do %d byte %srelocation", fixP->fx_size,
- fixP->fx_pcrel ? "pc-relative " : "");
- }
-#undef MAP
-#undef F
-
- rel = (arelent *) xmalloc (sizeof (arelent));
- assert (rel != 0);
- rel->sym_ptr_ptr = (asymbol **) xmalloc (sizeof (asymbol *));
- *rel->sym_ptr_ptr = symbol_get_bfdsym (fixP->fx_addsy);
- rel->address = fixP->fx_frag->fr_address + fixP->fx_where;
- if (fixP->fx_pcrel)
- rel->addend = fixP->fx_addnumber;
- else
- rel->addend = 0;
- rel->howto = bfd_reloc_type_lookup (stdoutput, code);
- if (!rel->howto)
- {
- const char *name;
- name = S_GET_NAME (fixP->fx_addsy);
- if (name == NULL)
- name = "<unknown>";
- as_fatal ("Cannot generate relocation type for symbol %s, code %s", name, bfd_get_reloc_code_name (code));
- }
- return rel;
-}
-
-void
-tc_aout_pre_write_hook ()
-{
- debug ("In tc_aout_pre_write_hook()\n");
-}
-
-void
-md_operand (expressionP)
- expressionS *expressionP;
-{
- debug ("In md_operand()\n");
-}
-
-char output_invalid_buf[8];
-
-char *
-output_invalid (c)
- char c;
-{
- if (ISPRINT (c))
- sprintf (output_invalid_buf, "'%c'", c);
- else
- sprintf (output_invalid_buf, "(0x%x)", (unsigned) c);
- return output_invalid_buf;
-}
diff --git a/contrib/binutils/gas/config/tc-tic30.h b/contrib/binutils/gas/config/tc-tic30.h
deleted file mode 100644
index d55c870..0000000
--- a/contrib/binutils/gas/config/tc-tic30.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/* tc-tic30.h -- Header file for tc-tic30.c
- Copyright 1998, 2000 Free Software Foundation, Inc.
- Contributed by Steven Haworth (steve@pm.cse.rmit.edu.au)
-
- This file is part of GAS, the GNU Assembler.
-
- GAS is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2, or (at your option)
- any later version.
-
- GAS is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with GAS; see the file COPYING. If not, write to the Free
- Software Foundation, 59 Temple Place - Suite 330, Boston, MA
- 02111-1307, USA. */
-
-#ifndef _TC_TIC30_H_
-#define _TC_TIC30_H_
-
-#define TC_TIC30 1
-
-#ifdef OBJ_AOUT
-#define TARGET_FORMAT "a.out-tic30"
-#endif
-
-#define TARGET_ARCH bfd_arch_tic30
-#define TARGET_BYTES_BIG_ENDIAN 1
-
-#define WORKING_DOT_WORD
-
-char *output_invalid PARAMS ((int c));
-
-#define END_OF_INSN '\0'
-#define MAX_OPERANDS 6
-#define DIRECT_REFERENCE '@'
-#define INDIRECT_REFERENCE '*'
-#define PARALLEL_SEPARATOR '|'
-#define INSN_SIZE 4
-
-/* Define this to 1 if you want the debug output to be on stdout,
- otherwise stderr will be used. If stderr is used, there will be a
- better synchronisation with the as_bad outputs, but you can't
- capture the output. */
-#define USE_STDOUT 0
-
-#define tc_unrecognized_line tic30_unrecognized_line
-
-extern int tic30_unrecognized_line PARAMS ((int));
-
-#endif
diff --git a/contrib/binutils/gas/config/tc-v850.c b/contrib/binutils/gas/config/tc-v850.c
deleted file mode 100644
index e1e5475..0000000
--- a/contrib/binutils/gas/config/tc-v850.c
+++ /dev/null
@@ -1,2434 +0,0 @@
-/* tc-v850.c -- Assembler code for the NEC V850
- Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002
- Free Software Foundation, Inc.
-
- This file is part of GAS, the GNU Assembler.
-
- GAS is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2, or (at your option)
- any later version.
-
- GAS is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with GAS; see the file COPYING. If not, write to
- the Free Software Foundation, 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA. */
-
-#include <stdio.h>
-#include "as.h"
-#include "safe-ctype.h"
-#include "subsegs.h"
-#include "opcode/v850.h"
-#include "dwarf2dbg.h"
-
-/* Sign-extend a 16-bit number. */
-#define SEXT16(x) ((((x) & 0xffff) ^ (~0x7fff)) + 0x8000)
-
-/* Temporarily holds the reloc in a cons expression. */
-static bfd_reloc_code_real_type hold_cons_reloc = BFD_RELOC_UNUSED;
-
-/* Set to TRUE if we want to be pedantic about signed overflows. */
-static boolean warn_signed_overflows = FALSE;
-static boolean warn_unsigned_overflows = FALSE;
-
-/* Indicates the target BFD machine number. */
-static int machine = -1;
-
-/* Indicates the target processor(s) for the assemble. */
-static int processor_mask = -1;
-
-/* Structure to hold information about predefined registers. */
-struct reg_name {
- const char *name;
- int value;
-};
-
-/* Generic assembler global variables which must be defined by all
- targets. */
-
-/* Characters which always start a comment. */
-const char comment_chars[] = "#";
-
-/* Characters which start a comment at the beginning of a line. */
-const char line_comment_chars[] = ";#";
-
-/* Characters which may be used to separate multiple commands on a
- single line. */
-const char line_separator_chars[] = ";";
-
-/* Characters which are used to indicate an exponent in a floating
- point number. */
-const char EXP_CHARS[] = "eE";
-
-/* Characters which mean that a number is a floating point constant,
- as in 0d1.0. */
-const char FLT_CHARS[] = "dD";
-
-const relax_typeS md_relax_table[] = {
- /* Conditional branches. */
- {0xff, -0x100, 2, 1},
- {0x1fffff, -0x200000, 6, 0},
- /* Unconditional branches. */
- {0xff, -0x100, 2, 3},
- {0x1fffff, -0x200000, 4, 0},
-};
-
-/* Fixups. */
-#define MAX_INSN_FIXUPS (5)
-struct v850_fixup {
- expressionS exp;
- int opindex;
- bfd_reloc_code_real_type reloc;
-};
-
-struct v850_fixup fixups[MAX_INSN_FIXUPS];
-static int fc;
-
-struct v850_seg_entry
-{
- segT s;
- const char *name;
- flagword flags;
-};
-
-struct v850_seg_entry v850_seg_table[] =
-{
- { NULL, ".sdata",
- SEC_ALLOC | SEC_LOAD | SEC_RELOC | SEC_DATA | SEC_HAS_CONTENTS
- | SEC_SMALL_DATA },
- { NULL, ".tdata",
- SEC_ALLOC | SEC_LOAD | SEC_RELOC | SEC_DATA | SEC_HAS_CONTENTS },
- { NULL, ".zdata",
- SEC_ALLOC | SEC_LOAD | SEC_RELOC | SEC_DATA | SEC_HAS_CONTENTS },
- { NULL, ".sbss",
- SEC_ALLOC | SEC_SMALL_DATA },
- { NULL, ".tbss",
- SEC_ALLOC },
- { NULL, ".zbss",
- SEC_ALLOC},
- { NULL, ".rosdata",
- SEC_ALLOC | SEC_LOAD | SEC_RELOC | SEC_READONLY | SEC_DATA
- | SEC_HAS_CONTENTS | SEC_SMALL_DATA },
- { NULL, ".rozdata",
- SEC_ALLOC | SEC_LOAD | SEC_RELOC | SEC_READONLY | SEC_DATA
- | SEC_HAS_CONTENTS },
- { NULL, ".scommon",
- SEC_ALLOC | SEC_LOAD | SEC_RELOC | SEC_DATA | SEC_HAS_CONTENTS
- | SEC_SMALL_DATA | SEC_IS_COMMON },
- { NULL, ".tcommon",
- SEC_ALLOC | SEC_LOAD | SEC_RELOC | SEC_DATA | SEC_HAS_CONTENTS
- | SEC_IS_COMMON },
- { NULL, ".zcommon",
- SEC_ALLOC | SEC_LOAD | SEC_RELOC | SEC_DATA | SEC_HAS_CONTENTS
- | SEC_IS_COMMON },
- { NULL, ".call_table_data",
- SEC_ALLOC | SEC_LOAD | SEC_RELOC | SEC_DATA | SEC_HAS_CONTENTS },
- { NULL, ".call_table_text",
- SEC_ALLOC | SEC_LOAD | SEC_RELOC | SEC_READONLY | SEC_CODE
- | SEC_HAS_CONTENTS},
- { NULL, ".bss",
- SEC_ALLOC }
-};
-
-#define SDATA_SECTION 0
-#define TDATA_SECTION 1
-#define ZDATA_SECTION 2
-#define SBSS_SECTION 3
-#define TBSS_SECTION 4
-#define ZBSS_SECTION 5
-#define ROSDATA_SECTION 6
-#define ROZDATA_SECTION 7
-#define SCOMMON_SECTION 8
-#define TCOMMON_SECTION 9
-#define ZCOMMON_SECTION 10
-#define CALL_TABLE_DATA_SECTION 11
-#define CALL_TABLE_TEXT_SECTION 12
-#define BSS_SECTION 13
-
-static void do_v850_seg PARAMS ((int, subsegT));
-
-static void
-do_v850_seg (i, sub)
- int i;
- subsegT sub;
-{
- struct v850_seg_entry *seg = v850_seg_table + i;
-
- obj_elf_section_change_hook ();
- if (seg->s != NULL)
- {
- subseg_set (seg->s, sub);
- }
- else
- {
- seg->s = subseg_new (seg->name, sub);
- bfd_set_section_flags (stdoutput, seg->s, seg->flags);
- if ((seg->flags & SEC_LOAD) == 0)
- seg_info (seg->s)->bss = 1;
- }
-}
-
-static void v850_seg PARAMS ((int i));
-
-static void
-v850_seg (i)
- int i;
-{
- subsegT sub = get_absolute_expression ();
-
- do_v850_seg (i, sub);
- demand_empty_rest_of_line ();
-}
-
-static void v850_offset PARAMS ((int));
-
-static void
-v850_offset (ignore)
- int ignore ATTRIBUTE_UNUSED;
-{
- int temp = get_absolute_expression ();
-
- temp -= frag_now_fix ();
-
- if (temp > 0)
- (void) frag_more (temp);
-
- demand_empty_rest_of_line ();
-}
-
-/* Copied from obj_elf_common() in gas/config/obj-elf.c. */
-
-static void v850_comm PARAMS ((int));
-
-static void
-v850_comm (area)
- int area;
-{
- char *name;
- char c;
- char *p;
- int temp;
- unsigned int size;
- symbolS *symbolP;
- int have_align;
-
- name = input_line_pointer;
- c = get_symbol_end ();
-
- /* Just after name is now '\0'. */
- p = input_line_pointer;
- *p = c;
-
- SKIP_WHITESPACE ();
-
- if (*input_line_pointer != ',')
- {
- as_bad (_("Expected comma after symbol-name"));
- ignore_rest_of_line ();
- return;
- }
-
- /* Skip ','. */
- input_line_pointer++;
-
- if ((temp = get_absolute_expression ()) < 0)
- {
- /* xgettext:c-format */
- as_bad (_(".COMMon length (%d.) < 0! Ignored."), temp);
- ignore_rest_of_line ();
- return;
- }
-
- size = temp;
- *p = 0;
- symbolP = symbol_find_or_make (name);
- *p = c;
-
- if (S_IS_DEFINED (symbolP) && ! S_IS_COMMON (symbolP))
- {
- as_bad (_("Ignoring attempt to re-define symbol"));
- ignore_rest_of_line ();
- return;
- }
-
- if (S_GET_VALUE (symbolP) != 0)
- {
- if (S_GET_VALUE (symbolP) != size)
- {
- /* xgettext:c-format */
- as_warn (_("Length of .comm \"%s\" is already %ld. Not changed to %d."),
- S_GET_NAME (symbolP), (long) S_GET_VALUE (symbolP), size);
- }
- }
-
- know (symbol_get_frag (symbolP) == &zero_address_frag);
-
- if (*input_line_pointer != ',')
- have_align = 0;
- else
- {
- have_align = 1;
- input_line_pointer++;
- SKIP_WHITESPACE ();
- }
-
- if (! have_align || *input_line_pointer != '"')
- {
- if (! have_align)
- temp = 0;
- else
- {
- temp = get_absolute_expression ();
-
- if (temp < 0)
- {
- temp = 0;
- as_warn (_("Common alignment negative; 0 assumed"));
- }
- }
-
- if (symbol_get_obj (symbolP)->local)
- {
- segT old_sec;
- int old_subsec;
- char *pfrag;
- int align;
- flagword applicable;
-
- old_sec = now_seg;
- old_subsec = now_subseg;
-
- applicable = bfd_applicable_section_flags (stdoutput);
-
- applicable &= SEC_ALLOC;
-
- switch (area)
- {
- case SCOMMON_SECTION:
- do_v850_seg (SBSS_SECTION, 0);
- break;
-
- case ZCOMMON_SECTION:
- do_v850_seg (ZBSS_SECTION, 0);
- break;
-
- case TCOMMON_SECTION:
- do_v850_seg (TBSS_SECTION, 0);
- break;
- }
-
- if (temp)
- {
- /* Convert to a power of 2 alignment. */
- for (align = 0; (temp & 1) == 0; temp >>= 1, ++align)
- ;
-
- if (temp != 1)
- {
- as_bad (_("Common alignment not a power of 2"));
- ignore_rest_of_line ();
- return;
- }
- }
- else
- align = 0;
-
- record_alignment (now_seg, align);
-
- if (align)
- frag_align (align, 0, 0);
-
- switch (area)
- {
- case SCOMMON_SECTION:
- if (S_GET_SEGMENT (symbolP) == v850_seg_table[SBSS_SECTION].s)
- symbol_get_frag (symbolP)->fr_symbol = 0;
- break;
-
- case ZCOMMON_SECTION:
- if (S_GET_SEGMENT (symbolP) == v850_seg_table[ZBSS_SECTION].s)
- symbol_get_frag (symbolP)->fr_symbol = 0;
- break;
-
- case TCOMMON_SECTION:
- if (S_GET_SEGMENT (symbolP) == v850_seg_table[TBSS_SECTION].s)
- symbol_get_frag (symbolP)->fr_symbol = 0;
- break;
-
- default:
- abort ();
- }
-
- symbol_set_frag (symbolP, frag_now);
- pfrag = frag_var (rs_org, 1, 1, (relax_substateT) 0, symbolP,
- (offsetT) size, (char *) 0);
- *pfrag = 0;
- S_SET_SIZE (symbolP, size);
-
- switch (area)
- {
- case SCOMMON_SECTION:
- S_SET_SEGMENT (symbolP, v850_seg_table[SBSS_SECTION].s);
- break;
-
- case ZCOMMON_SECTION:
- S_SET_SEGMENT (symbolP, v850_seg_table[ZBSS_SECTION].s);
- break;
-
- case TCOMMON_SECTION:
- S_SET_SEGMENT (symbolP, v850_seg_table[TBSS_SECTION].s);
- break;
-
- default:
- abort ();
- }
-
- S_CLEAR_EXTERNAL (symbolP);
- obj_elf_section_change_hook ();
- subseg_set (old_sec, old_subsec);
- }
- else
- {
- allocate_common:
- S_SET_VALUE (symbolP, (valueT) size);
- S_SET_ALIGN (symbolP, temp);
- S_SET_EXTERNAL (symbolP);
-
- switch (area)
- {
- case SCOMMON_SECTION:
- case ZCOMMON_SECTION:
- case TCOMMON_SECTION:
- do_v850_seg (area, 0);
- S_SET_SEGMENT (symbolP, v850_seg_table[area].s);
- break;
-
- default:
- abort ();
- }
- }
- }
- else
- {
- input_line_pointer++;
-
- /* @@ Some use the dot, some don't. Can we get some consistency?? */
- if (*input_line_pointer == '.')
- input_line_pointer++;
-
- /* @@ Some say data, some say bss. */
- if (strncmp (input_line_pointer, "bss\"", 4)
- && strncmp (input_line_pointer, "data\"", 5))
- {
- while (*--input_line_pointer != '"')
- ;
- input_line_pointer--;
- goto bad_common_segment;
- }
- while (*input_line_pointer++ != '"')
- ;
- goto allocate_common;
- }
-
- symbol_get_bfdsym (symbolP)->flags |= BSF_OBJECT;
-
- demand_empty_rest_of_line ();
- return;
-
- {
- bad_common_segment:
- p = input_line_pointer;
- while (*p && *p != '\n')
- p++;
- c = *p;
- *p = '\0';
- as_bad (_("bad .common segment %s"), input_line_pointer + 1);
- *p = c;
- input_line_pointer = p;
- ignore_rest_of_line ();
- return;
- }
-}
-
-static void set_machine PARAMS ((int));
-
-static void
-set_machine (number)
- int number;
-{
- machine = number;
- bfd_set_arch_mach (stdoutput, TARGET_ARCH, machine);
-
- switch (machine)
- {
- case 0: processor_mask = PROCESSOR_V850; break;
- case bfd_mach_v850e: processor_mask = PROCESSOR_V850E; break;
- case bfd_mach_v850ea: processor_mask = PROCESSOR_V850EA; break;
- }
-}
-
-/* The target specific pseudo-ops which we support. */
-const pseudo_typeS md_pseudo_table[] = {
- { "sdata", v850_seg, SDATA_SECTION },
- { "tdata", v850_seg, TDATA_SECTION },
- { "zdata", v850_seg, ZDATA_SECTION },
- { "sbss", v850_seg, SBSS_SECTION },
- { "tbss", v850_seg, TBSS_SECTION },
- { "zbss", v850_seg, ZBSS_SECTION },
- { "rosdata", v850_seg, ROSDATA_SECTION },
- { "rozdata", v850_seg, ROZDATA_SECTION },
- { "bss", v850_seg, BSS_SECTION },
- { "offset", v850_offset, 0 },
- { "word", cons, 4 },
- { "zcomm", v850_comm, ZCOMMON_SECTION },
- { "scomm", v850_comm, SCOMMON_SECTION },
- { "tcomm", v850_comm, TCOMMON_SECTION },
- { "v850", set_machine, 0 },
- { "call_table_data", v850_seg, CALL_TABLE_DATA_SECTION },
- { "call_table_text", v850_seg, CALL_TABLE_TEXT_SECTION },
- { "v850e", set_machine, bfd_mach_v850e },
- { "v850ea", set_machine, bfd_mach_v850ea },
- { "file", dwarf2_directive_file, 0 },
- { "loc", dwarf2_directive_loc, 0 },
- { NULL, NULL, 0 }
-};
-
-/* Opcode hash table. */
-static struct hash_control *v850_hash;
-
-/* This table is sorted. Suitable for searching by a binary search. */
-static const struct reg_name pre_defined_registers[] = {
- { "ep", 30 }, /* ep - element ptr */
- { "gp", 4 }, /* gp - global ptr */
- { "hp", 2 }, /* hp - handler stack ptr */
- { "lp", 31 }, /* lp - link ptr */
- { "r0", 0 },
- { "r1", 1 },
- { "r10", 10 },
- { "r11", 11 },
- { "r12", 12 },
- { "r13", 13 },
- { "r14", 14 },
- { "r15", 15 },
- { "r16", 16 },
- { "r17", 17 },
- { "r18", 18 },
- { "r19", 19 },
- { "r2", 2 },
- { "r20", 20 },
- { "r21", 21 },
- { "r22", 22 },
- { "r23", 23 },
- { "r24", 24 },
- { "r25", 25 },
- { "r26", 26 },
- { "r27", 27 },
- { "r28", 28 },
- { "r29", 29 },
- { "r3", 3 },
- { "r30", 30 },
- { "r31", 31 },
- { "r4", 4 },
- { "r5", 5 },
- { "r6", 6 },
- { "r7", 7 },
- { "r8", 8 },
- { "r9", 9 },
- { "sp", 3 }, /* sp - stack ptr */
- { "tp", 5 }, /* tp - text ptr */
- { "zero", 0 },
-};
-
-#define REG_NAME_CNT \
- (sizeof (pre_defined_registers) / sizeof (struct reg_name))
-
-static const struct reg_name system_registers[] = {
- { "ctbp", 20 },
- { "ctpc", 16 },
- { "ctpsw", 17 },
- { "dbpc", 18 },
- { "dbpsw", 19 },
- { "ecr", 4 },
- { "eipc", 0 },
- { "eipsw", 1 },
- { "fepc", 2 },
- { "fepsw", 3 },
- { "psw", 5 },
-};
-
-#define SYSREG_NAME_CNT \
- (sizeof (system_registers) / sizeof (struct reg_name))
-
-static const struct reg_name system_list_registers[] = {
- {"PS", 5 },
- {"SR", 0 + 1}
-};
-
-#define SYSREGLIST_NAME_CNT \
- (sizeof (system_list_registers) / sizeof (struct reg_name))
-
-static const struct reg_name cc_names[] = {
- { "c", 0x1 },
- { "e", 0x2 },
- { "ge", 0xe },
- { "gt", 0xf },
- { "h", 0xb },
- { "l", 0x1 },
- { "le", 0x7 },
- { "lt", 0x6 },
- { "n", 0x4 },
- { "nc", 0x9 },
- { "ne", 0xa },
- { "nh", 0x3 },
- { "nl", 0x9 },
- { "ns", 0xc },
- { "nv", 0x8 },
- { "nz", 0xa },
- { "p", 0xc },
- { "s", 0x4 },
- { "sa", 0xd },
- { "t", 0x5 },
- { "v", 0x0 },
- { "z", 0x2 },
-};
-
-#define CC_NAME_CNT \
- (sizeof (cc_names) / sizeof (struct reg_name))
-
-/* Do a binary search of the given register table to see if NAME is a
- valid regiter name. Return the register number from the array on
- success, or -1 on failure. */
-
-static int reg_name_search
- PARAMS ((const struct reg_name *, int, const char *, boolean));
-
-static int
-reg_name_search (regs, regcount, name, accept_numbers)
- const struct reg_name *regs;
- int regcount;
- const char *name;
- boolean accept_numbers;
-{
- int middle, low, high;
- int cmp;
- symbolS *symbolP;
-
- /* If the register name is a symbol, then evaluate it. */
- if ((symbolP = symbol_find (name)) != NULL)
- {
- /* If the symbol is an alias for another name then use that.
- If the symbol is an alias for a number, then return the number. */
- if (symbol_equated_p (symbolP))
- {
- name
- = S_GET_NAME (symbol_get_value_expression (symbolP)->X_add_symbol);
- }
- else if (accept_numbers)
- {
- int reg = S_GET_VALUE (symbolP);
-
- if (reg >= 0 && reg <= 31)
- return reg;
- }
-
- /* Otherwise drop through and try parsing name normally. */
- }
-
- low = 0;
- high = regcount - 1;
-
- do
- {
- middle = (low + high) / 2;
- cmp = strcasecmp (name, regs[middle].name);
- if (cmp < 0)
- high = middle - 1;
- else if (cmp > 0)
- low = middle + 1;
- else
- return regs[middle].value;
- }
- while (low <= high);
- return -1;
-}
-
-/* Summary of register_name().
- *
- * in: Input_line_pointer points to 1st char of operand.
- *
- * out: An expressionS.
- * The operand may have been a register: in this case, X_op == O_register,
- * X_add_number is set to the register number, and truth is returned.
- * Input_line_pointer->(next non-blank) char after operand, or is in
- * its original state. */
-
-static boolean register_name PARAMS ((expressionS *));
-
-static boolean
-register_name (expressionP)
- expressionS *expressionP;
-{
- int reg_number;
- char *name;
- char *start;
- char c;
-
- /* Find the spelling of the operand. */
- start = name = input_line_pointer;
-
- c = get_symbol_end ();
-
- reg_number = reg_name_search (pre_defined_registers, REG_NAME_CNT,
- name, FALSE);
-
- /* Put back the delimiting char. */
- *input_line_pointer = c;
-
- /* Look to see if it's in the register table. */
- if (reg_number >= 0)
- {
- expressionP->X_op = O_register;
- expressionP->X_add_number = reg_number;
-
- /* Make the rest nice. */
- expressionP->X_add_symbol = NULL;
- expressionP->X_op_symbol = NULL;
-
- return true;
- }
- else
- {
- /* Reset the line as if we had not done anything. */
- input_line_pointer = start;
-
- return false;
- }
-}
-
-/* Summary of system_register_name().
- *
- * in: INPUT_LINE_POINTER points to 1st char of operand.
- * EXPRESSIONP points to an expression structure to be filled in.
- * ACCEPT_NUMBERS is true iff numerical register names may be used.
- * ACCEPT_LIST_NAMES is true iff the special names PS and SR may be
- * accepted.
- *
- * out: An expressionS structure in expressionP.
- * The operand may have been a register: in this case, X_op == O_register,
- * X_add_number is set to the register number, and truth is returned.
- * Input_line_pointer->(next non-blank) char after operand, or is in
- * its original state. */
-
-static boolean system_register_name PARAMS ((expressionS *, boolean, boolean));
-
-static boolean
-system_register_name (expressionP, accept_numbers, accept_list_names)
- expressionS *expressionP;
- boolean accept_numbers;
- boolean accept_list_names;
-{
- int reg_number;
- char *name;
- char *start;
- char c;
-
- /* Find the spelling of the operand. */
- start = name = input_line_pointer;
-
- c = get_symbol_end ();
- reg_number = reg_name_search (system_registers, SYSREG_NAME_CNT, name,
- accept_numbers);
-
- /* Put back the delimiting char. */
- *input_line_pointer = c;
-
- if (reg_number < 0
- && accept_numbers)
- {
- /* Reset input_line pointer. */
- input_line_pointer = start;
-
- if (ISDIGIT (*input_line_pointer))
- {
- reg_number = strtol (input_line_pointer, &input_line_pointer, 10);
-
- /* Make sure that the register number is allowable. */
- if (reg_number < 0
- || (reg_number > 5 && reg_number < 16)
- || reg_number > 20)
- {
- reg_number = -1;
- }
- }
- else if (accept_list_names)
- {
- c = get_symbol_end ();
- reg_number = reg_name_search (system_list_registers,
- SYSREGLIST_NAME_CNT, name, FALSE);
-
- /* Put back the delimiting char. */
- *input_line_pointer = c;
- }
- }
-
- /* Look to see if it's in the register table. */
- if (reg_number >= 0)
- {
- expressionP->X_op = O_register;
- expressionP->X_add_number = reg_number;
-
- /* Make the rest nice. */
- expressionP->X_add_symbol = NULL;
- expressionP->X_op_symbol = NULL;
-
- return true;
- }
- else
- {
- /* Reset the line as if we had not done anything. */
- input_line_pointer = start;
-
- return false;
- }
-}
-
-/* Summary of cc_name().
- *
- * in: INPUT_LINE_POINTER points to 1st char of operand.
- *
- * out: An expressionS.
- * The operand may have been a register: in this case, X_op == O_register,
- * X_add_number is set to the register number, and truth is returned.
- * Input_line_pointer->(next non-blank) char after operand, or is in
- * its original state. */
-
-static boolean cc_name PARAMS ((expressionS *));
-
-static boolean
-cc_name (expressionP)
- expressionS *expressionP;
-{
- int reg_number;
- char *name;
- char *start;
- char c;
-
- /* Find the spelling of the operand. */
- start = name = input_line_pointer;
-
- c = get_symbol_end ();
- reg_number = reg_name_search (cc_names, CC_NAME_CNT, name, FALSE);
-
- /* Put back the delimiting char. */
- *input_line_pointer = c;
-
- /* Look to see if it's in the register table. */
- if (reg_number >= 0)
- {
- expressionP->X_op = O_constant;
- expressionP->X_add_number = reg_number;
-
- /* Make the rest nice. */
- expressionP->X_add_symbol = NULL;
- expressionP->X_op_symbol = NULL;
-
- return true;
- }
- else
- {
- /* Reset the line as if we had not done anything. */
- input_line_pointer = start;
-
- return false;
- }
-}
-
-static void skip_white_space PARAMS ((void));
-
-static void
-skip_white_space ()
-{
- while (*input_line_pointer == ' '
- || *input_line_pointer == '\t')
- ++input_line_pointer;
-}
-
-/* Summary of parse_register_list ().
- *
- * in: INPUT_LINE_POINTER points to 1st char of a list of registers.
- * INSN is the partially constructed instruction.
- * OPERAND is the operand being inserted.
- *
- * out: NULL if the parse completed successfully, otherwise a
- * pointer to an error message is returned. If the parse
- * completes the correct bit fields in the instruction
- * will be filled in.
- *
- * Parses register lists with the syntax:
- *
- * { rX }
- * { rX, rY }
- * { rX - rY }
- * { rX - rY, rZ }
- * etc
- *
- * and also parses constant epxressions whoes bits indicate the
- * registers in the lists. The LSB in the expression refers to
- * the lowest numbered permissable register in the register list,
- * and so on upwards. System registers are considered to be very
- * high numbers. */
-
-static char *parse_register_list
- PARAMS ((unsigned long *, const struct v850_operand *));
-
-static char *
-parse_register_list (insn, operand)
- unsigned long *insn;
- const struct v850_operand *operand;
-{
- static int type1_regs[32] = {
- 30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 31, 29, 28, 23, 22, 21, 20, 27, 26, 25, 24
- };
- static int type2_regs[32] = {
- 19, 18, 17, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 30, 31, 29, 28, 23, 22, 21, 20, 27, 26, 25, 24
- };
- static int type3_regs[32] = {
- 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 14, 15, 13, 12, 7, 6, 5, 4, 11, 10, 9, 8
- };
- int *regs;
- expressionS exp;
-
- /* Select a register array to parse. */
- switch (operand->shift)
- {
- case 0xffe00001: regs = type1_regs; break;
- case 0xfff8000f: regs = type2_regs; break;
- case 0xfff8001f: regs = type3_regs; break;
- default:
- as_bad (_("unknown operand shift: %x\n"), operand->shift);
- return _("internal failure in parse_register_list");
- }
-
- skip_white_space ();
-
- /* If the expression starts with a curly brace it is a register list.
- Otherwise it is a constant expression, whoes bits indicate which
- registers are to be included in the list. */
-
- if (*input_line_pointer != '{')
- {
- int reg;
- int i;
-
- expression (&exp);
-
- if (exp.X_op != O_constant)
- return _("constant expression or register list expected");
-
- if (regs == type1_regs)
- {
- if (exp.X_add_number & 0xFFFFF000)
- return _("high bits set in register list expression");
-
- for (reg = 20; reg < 32; reg++)
- if (exp.X_add_number & (1 << (reg - 20)))
- {
- for (i = 0; i < 32; i++)
- if (regs[i] == reg)
- *insn |= (1 << i);
- }
- }
- else if (regs == type2_regs)
- {
- if (exp.X_add_number & 0xFFFE0000)
- return _("high bits set in register list expression");
-
- for (reg = 1; reg < 16; reg++)
- if (exp.X_add_number & (1 << (reg - 1)))
- {
- for (i = 0; i < 32; i++)
- if (regs[i] == reg)
- *insn |= (1 << i);
- }
-
- if (exp.X_add_number & (1 << 15))
- *insn |= (1 << 3);
-
- if (exp.X_add_number & (1 << 16))
- *insn |= (1 << 19);
- }
- else /* regs == type3_regs */
- {
- if (exp.X_add_number & 0xFFFE0000)
- return _("high bits set in register list expression");
-
- for (reg = 16; reg < 32; reg++)
- if (exp.X_add_number & (1 << (reg - 16)))
- {
- for (i = 0; i < 32; i++)
- if (regs[i] == reg)
- *insn |= (1 << i);
- }
-
- if (exp.X_add_number & (1 << 16))
- *insn |= (1 << 19);
- }
-
- return NULL;
- }
-
- input_line_pointer++;
-
- /* Parse the register list until a terminator (closing curly brace or
- new-line) is found. */
- for (;;)
- {
- if (register_name (&exp))
- {
- int i;
-
- /* Locate the given register in the list, and if it is there,
- insert the corresponding bit into the instruction. */
- for (i = 0; i < 32; i++)
- {
- if (regs[i] == exp.X_add_number)
- {
- *insn |= (1 << i);
- break;
- }
- }
-
- if (i == 32)
- {
- return _("illegal register included in list");
- }
- }
- else if (system_register_name (&exp, true, true))
- {
- if (regs == type1_regs)
- {
- return _("system registers cannot be included in list");
- }
- else if (exp.X_add_number == 5)
- {
- if (regs == type2_regs)
- return _("PSW cannot be included in list");
- else
- *insn |= 0x8;
- }
- else if (exp.X_add_number < 4)
- *insn |= 0x80000;
- else
- return _("High value system registers cannot be included in list");
- }
- else if (*input_line_pointer == '}')
- {
- input_line_pointer++;
- break;
- }
- else if (*input_line_pointer == ',')
- {
- input_line_pointer++;
- continue;
- }
- else if (*input_line_pointer == '-')
- {
- /* We have encountered a range of registers: rX - rY. */
- int j;
- expressionS exp2;
-
- /* Skip the dash. */
- ++input_line_pointer;
-
- /* Get the second register in the range. */
- if (! register_name (&exp2))
- {
- return _("second register should follow dash in register list");
- exp2.X_add_number = exp.X_add_number;
- }
-
- /* Add the rest of the registers in the range. */
- for (j = exp.X_add_number + 1; j <= exp2.X_add_number; j++)
- {
- int i;
-
- /* Locate the given register in the list, and if it is there,
- insert the corresponding bit into the instruction. */
- for (i = 0; i < 32; i++)
- {
- if (regs[i] == j)
- {
- *insn |= (1 << i);
- break;
- }
- }
-
- if (i == 32)
- return _("illegal register included in list");
- }
- }
- else
- {
- break;
- }
-
- skip_white_space ();
- }
-
- return NULL;
-}
-
-const char *md_shortopts = "m:";
-
-struct option md_longopts[] = {
- {NULL, no_argument, NULL, 0}
-};
-
-size_t md_longopts_size = sizeof (md_longopts);
-
-void
-md_show_usage (stream)
- FILE *stream;
-{
- fprintf (stream, _(" V850 options:\n"));
- fprintf (stream, _(" -mwarn-signed-overflow Warn if signed immediate values overflow\n"));
- fprintf (stream, _(" -mwarn-unsigned-overflow Warn if unsigned immediate values overflow\n"));
- fprintf (stream, _(" -mv850 The code is targeted at the v850\n"));
- fprintf (stream, _(" -mv850e The code is targeted at the v850e\n"));
- fprintf (stream, _(" -mv850ea The code is targeted at the v850ea\n"));
- fprintf (stream, _(" -mv850any The code is generic, despite any processor specific instructions\n"));
-}
-
-int
-md_parse_option (c, arg)
- int c;
- char *arg;
-{
- if (c != 'm')
- {
- if (c != 'a')
- /* xgettext:c-format */
- fprintf (stderr, _("unknown command line option: -%c%s\n"), c, arg);
- return 0;
- }
-
- if (strcmp (arg, "warn-signed-overflow") == 0)
- {
- warn_signed_overflows = TRUE;
- }
- else if (strcmp (arg, "warn-unsigned-overflow") == 0)
- {
- warn_unsigned_overflows = TRUE;
- }
- else if (strcmp (arg, "v850") == 0)
- {
- machine = 0;
- processor_mask = PROCESSOR_V850;
- }
- else if (strcmp (arg, "v850e") == 0)
- {
- machine = bfd_mach_v850e;
- processor_mask = PROCESSOR_V850E;
- }
- else if (strcmp (arg, "v850ea") == 0)
- {
- machine = bfd_mach_v850ea;
- processor_mask = PROCESSOR_V850EA;
- }
- else if (strcmp (arg, "v850any") == 0)
- {
- /* Tell the world that this is for any v850 chip. */
- machine = 0;
-
- /* But support instructions for the extended versions. */
- processor_mask = PROCESSOR_V850EA;
- }
- else
- {
- /* xgettext:c-format */
- fprintf (stderr, _("unknown command line option: -%c%s\n"), c, arg);
- return 0;
- }
-
- return 1;
-}
-
-symbolS *
-md_undefined_symbol (name)
- char *name ATTRIBUTE_UNUSED;
-{
- return 0;
-}
-
-char *
-md_atof (type, litp, sizep)
- int type;
- char *litp;
- int *sizep;
-{
- int prec;
- LITTLENUM_TYPE words[4];
- char *t;
- int i;
-
- switch (type)
- {
- case 'f':
- prec = 2;
- break;
-
- case 'd':
- prec = 4;
- break;
-
- default:
- *sizep = 0;
- return _("bad call to md_atof");
- }
-
- t = atof_ieee (input_line_pointer, type, words);
- if (t)
- input_line_pointer = t;
-
- *sizep = prec * 2;
-
- for (i = prec - 1; i >= 0; i--)
- {
- md_number_to_chars (litp, (valueT) words[i], 2);
- litp += 2;
- }
-
- return NULL;
-}
-
-/* Very gross. */
-
-void
-md_convert_frag (abfd, sec, fragP)
- bfd *abfd ATTRIBUTE_UNUSED;
- asection *sec;
- fragS *fragP;
-{
- subseg_change (sec, 0);
-
- /* In range conditional or unconditional branch. */
- if (fragP->fr_subtype == 0 || fragP->fr_subtype == 2)
- {
- fix_new (fragP, fragP->fr_fix, 2, fragP->fr_symbol,
- fragP->fr_offset, 1, BFD_RELOC_UNUSED + (int)fragP->fr_opcode);
- fragP->fr_fix += 2;
- }
- /* Out of range conditional branch. Emit a branch around a jump. */
- else if (fragP->fr_subtype == 1)
- {
- unsigned char *buffer =
- (unsigned char *) (fragP->fr_fix + fragP->fr_literal);
-
- /* Reverse the condition of the first branch. */
- buffer[0] ^= 0x08;
- /* Mask off all the displacement bits. */
- buffer[0] &= 0x8f;
- buffer[1] &= 0x07;
- /* Now set the displacement bits so that we branch
- around the unconditional branch. */
- buffer[0] |= 0x30;
-
- /* Now create the unconditional branch + fixup to the final
- target. */
- md_number_to_chars (buffer + 2, 0x00000780, 4);
- fix_new (fragP, fragP->fr_fix + 2, 4, fragP->fr_symbol,
- fragP->fr_offset, 1, BFD_RELOC_UNUSED +
- (int) fragP->fr_opcode + 1);
- fragP->fr_fix += 6;
- }
- /* Out of range unconditional branch. Emit a jump. */
- else if (fragP->fr_subtype == 3)
- {
- md_number_to_chars (fragP->fr_fix + fragP->fr_literal, 0x00000780, 4);
- fix_new (fragP, fragP->fr_fix, 4, fragP->fr_symbol,
- fragP->fr_offset, 1, BFD_RELOC_UNUSED +
- (int) fragP->fr_opcode + 1);
- fragP->fr_fix += 4;
- }
- else
- abort ();
-}
-
-valueT
-md_section_align (seg, addr)
- asection *seg;
- valueT addr;
-{
- int align = bfd_get_section_alignment (stdoutput, seg);
- return ((addr + (1 << align) - 1) & (-1 << align));
-}
-
-void
-md_begin ()
-{
- char *prev_name = "";
- register const struct v850_opcode *op;
-
- if (strncmp (TARGET_CPU, "v850ea", 6) == 0)
- {
- if (machine == -1)
- machine = bfd_mach_v850ea;
-
- if (processor_mask == -1)
- processor_mask = PROCESSOR_V850EA;
- }
- else if (strncmp (TARGET_CPU, "v850e", 5) == 0)
- {
- if (machine == -1)
- machine = bfd_mach_v850e;
-
- if (processor_mask == -1)
- processor_mask = PROCESSOR_V850E;
- }
- else if (strncmp (TARGET_CPU, "v850", 4) == 0)
- {
- if (machine == -1)
- machine = 0;
-
- if (processor_mask == -1)
- processor_mask = PROCESSOR_V850;
- }
- else
- /* xgettext:c-format */
- as_bad (_("Unable to determine default target processor from string: %s"),
- TARGET_CPU);
-
- v850_hash = hash_new ();
-
- /* Insert unique names into hash table. The V850 instruction set
- has many identical opcode names that have different opcodes based
- on the operands. This hash table then provides a quick index to
- the first opcode with a particular name in the opcode table. */
-
- op = v850_opcodes;
- while (op->name)
- {
- if (strcmp (prev_name, op->name))
- {
- prev_name = (char *) op->name;
- hash_insert (v850_hash, op->name, (char *) op);
- }
- op++;
- }
-
- v850_seg_table[BSS_SECTION].s = bss_section;
- bfd_set_arch_mach (stdoutput, TARGET_ARCH, machine);
-}
-
-static bfd_reloc_code_real_type handle_ctoff
- PARAMS ((const struct v850_operand *));
-
-static bfd_reloc_code_real_type
-handle_ctoff (operand)
- const struct v850_operand *operand;
-{
- if (operand == NULL)
- return BFD_RELOC_V850_CALLT_16_16_OFFSET;
-
- if (operand->bits != 6
- || operand->shift != 0)
- {
- as_bad (_("ctoff() relocation used on an instruction which does not support it"));
- return BFD_RELOC_64; /* Used to indicate an error condition. */
- }
-
- return BFD_RELOC_V850_CALLT_6_7_OFFSET;
-}
-
-static bfd_reloc_code_real_type handle_sdaoff
- PARAMS ((const struct v850_operand *));
-
-static bfd_reloc_code_real_type
-handle_sdaoff (operand)
- const struct v850_operand *operand;
-{
- if (operand == NULL)
- return BFD_RELOC_V850_SDA_16_16_OFFSET;
-
- if (operand->bits == 15 && operand->shift == 17)
- return BFD_RELOC_V850_SDA_15_16_OFFSET;
-
- if (operand->bits == -1)
- return BFD_RELOC_V850_SDA_16_16_SPLIT_OFFSET;
-
- if (operand->bits != 16
- || operand->shift != 16)
- {
- as_bad (_("sdaoff() relocation used on an instruction which does not support it"));
- return BFD_RELOC_64; /* Used to indicate an error condition. */
- }
-
- return BFD_RELOC_V850_SDA_16_16_OFFSET;
-}
-
-static bfd_reloc_code_real_type handle_zdaoff
- PARAMS ((const struct v850_operand *));
-
-static bfd_reloc_code_real_type
-handle_zdaoff (operand)
- const struct v850_operand *operand;
-{
- if (operand == NULL)
- return BFD_RELOC_V850_ZDA_16_16_OFFSET;
-
- if (operand->bits == 15 && operand->shift == 17)
- return BFD_RELOC_V850_ZDA_15_16_OFFSET;
-
- if (operand->bits == -1)
- return BFD_RELOC_V850_ZDA_16_16_SPLIT_OFFSET;
-
- if (operand->bits != 16
- || operand->shift != 16)
- {
- as_bad (_("zdaoff() relocation used on an instruction which does not support it"));
- /* Used to indicate an error condition. */
- return BFD_RELOC_64;
- }
-
- return BFD_RELOC_V850_ZDA_16_16_OFFSET;
-}
-
-static bfd_reloc_code_real_type handle_tdaoff
- PARAMS ((const struct v850_operand *));
-
-static bfd_reloc_code_real_type
-handle_tdaoff (operand)
- const struct v850_operand *operand;
-{
- if (operand == NULL)
- /* Data item, not an instruction. */
- return BFD_RELOC_V850_TDA_7_7_OFFSET;
-
- if (operand->bits == 6 && operand->shift == 1)
- /* sld.w/sst.w, operand: D8_6 */
- return BFD_RELOC_V850_TDA_6_8_OFFSET;
-
- if (operand->bits == 4 && operand->insert != NULL)
- /* sld.hu, operand: D5-4 */
- return BFD_RELOC_V850_TDA_4_5_OFFSET;
-
- if (operand->bits == 4 && operand->insert == NULL)
- /* sld.bu, operand: D4 */
- return BFD_RELOC_V850_TDA_4_4_OFFSET;
-
- if (operand->bits == 16 && operand->shift == 16)
- /* set1 & chums, operands: D16 */
- return BFD_RELOC_V850_TDA_16_16_OFFSET;
-
- if (operand->bits != 7)
- {
- as_bad (_("tdaoff() relocation used on an instruction which does not support it"));
- /* Used to indicate an error condition. */
- return BFD_RELOC_64;
- }
-
- return operand->insert != NULL
- ? BFD_RELOC_V850_TDA_7_8_OFFSET /* sld.h/sst.h, operand: D8_7 */
- : BFD_RELOC_V850_TDA_7_7_OFFSET; /* sld.b/sst.b, opreand: D7 */
-}
-
-/* Warning: The code in this function relies upon the definitions
- in the v850_operands[] array (defined in opcodes/v850-opc.c)
- matching the hard coded values contained herein. */
-
-static bfd_reloc_code_real_type v850_reloc_prefix
- PARAMS ((const struct v850_operand *));
-
-static bfd_reloc_code_real_type
-v850_reloc_prefix (operand)
- const struct v850_operand *operand;
-{
- boolean paren_skipped = false;
-
- /* Skip leading opening parenthesis. */
- if (*input_line_pointer == '(')
- {
- ++input_line_pointer;
- paren_skipped = true;
- }
-
-#define CHECK_(name, reloc) \
- if (strncmp (input_line_pointer, name "(", strlen (name) + 1) == 0) \
- { \
- input_line_pointer += strlen (name); \
- return reloc; \
- }
-
- CHECK_ ("hi0", BFD_RELOC_HI16 );
- CHECK_ ("hi", BFD_RELOC_HI16_S );
- CHECK_ ("lo", BFD_RELOC_LO16 );
- CHECK_ ("sdaoff", handle_sdaoff (operand));
- CHECK_ ("zdaoff", handle_zdaoff (operand));
- CHECK_ ("tdaoff", handle_tdaoff (operand));
- CHECK_ ("hilo", BFD_RELOC_32 );
- CHECK_ ("ctoff", handle_ctoff (operand) );
-
- /* Restore skipped parenthesis. */
- if (paren_skipped)
- --input_line_pointer;
-
- return BFD_RELOC_UNUSED;
-}
-
-/* Insert an operand value into an instruction. */
-
-static unsigned long v850_insert_operand
- PARAMS ((unsigned long, const struct v850_operand *, offsetT, char *,
- unsigned int, char *));
-
-static unsigned long
-v850_insert_operand (insn, operand, val, file, line, str)
- unsigned long insn;
- const struct v850_operand *operand;
- offsetT val;
- char *file;
- unsigned int line;
- char *str;
-{
- if (operand->insert)
- {
- const char *message = NULL;
-
- insn = operand->insert (insn, val, &message);
- if (message != NULL)
- {
- if ((operand->flags & V850_OPERAND_SIGNED)
- && ! warn_signed_overflows
- && strstr (message, "out of range") != NULL)
- {
- /* Skip warning... */
- }
- else if ((operand->flags & V850_OPERAND_SIGNED) == 0
- && ! warn_unsigned_overflows
- && strstr (message, "out of range") != NULL)
- {
- /* Skip warning... */
- }
- else if (str)
- {
- if (file == (char *) NULL)
- as_warn ("%s: %s", str, message);
- else
- as_warn_where (file, line, "%s: %s", str, message);
- }
- else
- {
- if (file == (char *) NULL)
- as_warn (message);
- else
- as_warn_where (file, line, message);
- }
- }
- }
- else
- {
- if (operand->bits != 32)
- {
- long min, max;
-
- if ((operand->flags & V850_OPERAND_SIGNED) != 0)
- {
- if (! warn_signed_overflows)
- max = (1 << operand->bits) - 1;
- else
- max = (1 << (operand->bits - 1)) - 1;
-
- min = -(1 << (operand->bits - 1));
- }
- else
- {
- max = (1 << operand->bits) - 1;
-
- if (! warn_unsigned_overflows)
- min = -(1 << (operand->bits - 1));
- else
- min = 0;
- }
-
- if (val < (offsetT) min || val > (offsetT) max)
- {
- /* xgettext:c-format */
- const char *err =
- _("operand out of range (%s not between %ld and %ld)");
- char buf[100];
-
- /* Restore min and mix to expected values for decimal ranges. */
- if ((operand->flags & V850_OPERAND_SIGNED)
- && ! warn_signed_overflows)
- max = (1 << (operand->bits - 1)) - 1;
-
- if (! (operand->flags & V850_OPERAND_SIGNED)
- && ! warn_unsigned_overflows)
- min = 0;
-
- if (str)
- {
- sprintf (buf, "%s: ", str);
-
- sprint_value (buf + strlen (buf), val);
- }
- else
- sprint_value (buf, val);
-
- if (file == (char *) NULL)
- as_warn (err, buf, min, max);
- else
- as_warn_where (file, line, err, buf, min, max);
- }
- }
-
- insn |= (((long) val & ((1 << operand->bits) - 1)) << operand->shift);
- }
-
- return insn;
-}
-
-static char copy_of_instruction[128];
-
-void
-md_assemble (str)
- char *str;
-{
- char *s;
- char *start_of_operands;
- struct v850_opcode *opcode;
- struct v850_opcode *next_opcode;
- const unsigned char *opindex_ptr;
- int next_opindex;
- int relaxable = 0;
- unsigned long insn;
- unsigned long insn_size;
- char *f;
- int i;
- int match;
- boolean extra_data_after_insn = false;
- unsigned extra_data_len = 0;
- unsigned long extra_data = 0;
- char *saved_input_line_pointer;
-
- strncpy (copy_of_instruction, str, sizeof (copy_of_instruction) - 1);
-
- /* Get the opcode. */
- for (s = str; *s != '\0' && ! ISSPACE (*s); s++)
- continue;
-
- if (*s != '\0')
- *s++ = '\0';
-
- /* Find the first opcode with the proper name. */
- opcode = (struct v850_opcode *) hash_find (v850_hash, str);
- if (opcode == NULL)
- {
- /* xgettext:c-format */
- as_bad (_("Unrecognized opcode: `%s'"), str);
- ignore_rest_of_line ();
- return;
- }
-
- str = s;
- while (ISSPACE (*str))
- ++str;
-
- start_of_operands = str;
-
- saved_input_line_pointer = input_line_pointer;
-
- for (;;)
- {
- const char *errmsg = NULL;
-
- match = 0;
-
- if ((opcode->processors & processor_mask) == 0)
- {
- errmsg = _("Target processor does not support this instruction.");
- goto error;
- }
-
- relaxable = 0;
- fc = 0;
- next_opindex = 0;
- insn = opcode->opcode;
- extra_data_after_insn = false;
-
- input_line_pointer = str = start_of_operands;
-
- for (opindex_ptr = opcode->operands; *opindex_ptr != 0; opindex_ptr++)
- {
- const struct v850_operand *operand;
- char *hold;
- expressionS ex;
- bfd_reloc_code_real_type reloc;
-
- if (next_opindex == 0)
- {
- operand = &v850_operands[*opindex_ptr];
- }
- else
- {
- operand = &v850_operands[next_opindex];
- next_opindex = 0;
- }
-
- errmsg = NULL;
-
- while (*str == ' ' || *str == ',' || *str == '[' || *str == ']')
- ++str;
-
- if (operand->flags & V850_OPERAND_RELAX)
- relaxable = 1;
-
- /* Gather the operand. */
- hold = input_line_pointer;
- input_line_pointer = str;
-
- /* lo(), hi(), hi0(), etc... */
- if ((reloc = v850_reloc_prefix (operand)) != BFD_RELOC_UNUSED)
- {
- /* This is a fake reloc, used to indicate an error condition. */
- if (reloc == BFD_RELOC_64)
- {
- match = 1;
- goto error;
- }
-
- expression (&ex);
-
- if (ex.X_op == O_constant)
- {
- switch (reloc)
- {
- case BFD_RELOC_V850_ZDA_16_16_OFFSET:
- /* To cope with "not1 7, zdaoff(0xfffff006)[r0]"
- and the like. */
- /* Fall through. */
-
- case BFD_RELOC_LO16:
- {
- /* Truncate, then sign extend the value. */
- ex.X_add_number = SEXT16 (ex.X_add_number);
- break;
- }
-
- case BFD_RELOC_HI16:
- {
- /* Truncate, then sign extend the value. */
- ex.X_add_number = SEXT16 (ex.X_add_number >> 16);
- break;
- }
-
- case BFD_RELOC_HI16_S:
- {
- /* Truncate, then sign extend the value. */
- int temp = (ex.X_add_number >> 16) & 0xffff;
-
- temp += (ex.X_add_number >> 15) & 1;
-
- ex.X_add_number = SEXT16 (temp);
- break;
- }
-
- case BFD_RELOC_32:
- if ((operand->flags & V850E_IMMEDIATE32) == 0)
- {
- errmsg = _("immediate operand is too large");
- goto error;
- }
-
- extra_data_after_insn = true;
- extra_data_len = 4;
- extra_data = ex.X_add_number;
- ex.X_add_number = 0;
- break;
-
- default:
- fprintf (stderr, "reloc: %d\n", reloc);
- as_bad (_("AAARG -> unhandled constant reloc"));
- break;
- }
-
- if (fc > MAX_INSN_FIXUPS)
- as_fatal (_("too many fixups"));
-
- fixups[fc].exp = ex;
- fixups[fc].opindex = *opindex_ptr;
- fixups[fc].reloc = reloc;
- fc++;
- }
- else
- {
- if (reloc == BFD_RELOC_32)
- {
- if ((operand->flags & V850E_IMMEDIATE32) == 0)
- {
- errmsg = _("immediate operand is too large");
- goto error;
- }
-
- extra_data_after_insn = true;
- extra_data_len = 4;
- extra_data = ex.X_add_number;
- }
-
- if (fc > MAX_INSN_FIXUPS)
- as_fatal (_("too many fixups"));
-
- fixups[fc].exp = ex;
- fixups[fc].opindex = *opindex_ptr;
- fixups[fc].reloc = reloc;
- fc++;
- }
- }
- else
- {
- errmsg = NULL;
-
- if ((operand->flags & V850_OPERAND_REG) != 0)
- {
- if (!register_name (&ex))
- {
- errmsg = _("invalid register name");
- }
- else if ((operand->flags & V850_NOT_R0)
- && ex.X_add_number == 0)
- {
- errmsg = _("register r0 cannot be used here");
-
- /* Force an error message to be generated by
- skipping over any following potential matches
- for this opcode. */
- opcode += 3;
- }
- }
- else if ((operand->flags & V850_OPERAND_SRG) != 0)
- {
- if (!system_register_name (&ex, true, false))
- {
- errmsg = _("invalid system register name");
- }
- }
- else if ((operand->flags & V850_OPERAND_EP) != 0)
- {
- char *start = input_line_pointer;
- char c = get_symbol_end ();
-
- if (strcmp (start, "ep") != 0 && strcmp (start, "r30") != 0)
- {
- /* Put things back the way we found them. */
- *input_line_pointer = c;
- input_line_pointer = start;
- errmsg = _("expected EP register");
- goto error;
- }
-
- *input_line_pointer = c;
- str = input_line_pointer;
- input_line_pointer = hold;
-
- while (*str == ' ' || *str == ','
- || *str == '[' || *str == ']')
- ++str;
- continue;
- }
- else if ((operand->flags & V850_OPERAND_CC) != 0)
- {
- if (!cc_name (&ex))
- {
- errmsg = _("invalid condition code name");
- }
- }
- else if (operand->flags & V850E_PUSH_POP)
- {
- errmsg = parse_register_list (&insn, operand);
-
- /* The parse_register_list() function has already done
- everything, so fake a dummy expression. */
- ex.X_op = O_constant;
- ex.X_add_number = 0;
- }
- else if (operand->flags & V850E_IMMEDIATE16)
- {
- expression (&ex);
-
- if (ex.X_op != O_constant)
- errmsg = _("constant expression expected");
- else if (ex.X_add_number & 0xffff0000)
- {
- if (ex.X_add_number & 0xffff)
- errmsg = _("constant too big to fit into instruction");
- else if ((insn & 0x001fffc0) == 0x00130780)
- ex.X_add_number >>= 16;
- else
- errmsg = _("constant too big to fit into instruction");
- }
-
- extra_data_after_insn = true;
- extra_data_len = 2;
- extra_data = ex.X_add_number;
- ex.X_add_number = 0;
- }
- else if (operand->flags & V850E_IMMEDIATE32)
- {
- expression (&ex);
-
- if (ex.X_op != O_constant)
- errmsg = _("constant expression expected");
-
- extra_data_after_insn = true;
- extra_data_len = 4;
- extra_data = ex.X_add_number;
- ex.X_add_number = 0;
- }
- else if (register_name (&ex)
- && (operand->flags & V850_OPERAND_REG) == 0)
- {
- char c;
- int exists = 0;
-
- /* It is possible that an alias has been defined that
- matches a register name. For example the code may
- include a ".set ZERO, 0" directive, which matches
- the register name "zero". Attempt to reparse the
- field as an expression, and only complain if we
- cannot generate a constant. */
-
- input_line_pointer = str;
-
- c = get_symbol_end ();
-
- if (symbol_find (str) != NULL)
- exists = 1;
-
- *input_line_pointer = c;
- input_line_pointer = str;
-
- expression (&ex);
-
- if (ex.X_op != O_constant)
- {
- /* If this register is actually occuring too early on
- the parsing of the instruction, (because another
- field is missing) then report this. */
- if (opindex_ptr[1] != 0
- && (v850_operands[opindex_ptr[1]].flags
- & V850_OPERAND_REG))
- errmsg = _("syntax error: value is missing before the register name");
- else
- errmsg = _("syntax error: register not expected");
-
- /* If we created a symbol in the process of this
- test then delete it now, so that it will not
- be output with the real symbols... */
- if (exists == 0
- && ex.X_op == O_symbol)
- symbol_remove (ex.X_add_symbol,
- &symbol_rootP, &symbol_lastP);
- }
- }
- else if (system_register_name (&ex, false, false)
- && (operand->flags & V850_OPERAND_SRG) == 0)
- {
- errmsg = _("syntax error: system register not expected");
- }
- else if (cc_name (&ex)
- && (operand->flags & V850_OPERAND_CC) == 0)
- {
- errmsg = _("syntax error: condition code not expected");
- }
- else
- {
- expression (&ex);
- /* Special case:
- If we are assembling a MOV instruction (or a CALLT.... :-)
- and the immediate value does not fit into the bits
- available then create a fake error so that the next MOV
- instruction will be selected. This one has a 32 bit
- immediate field. */
-
- if (((insn & 0x07e0) == 0x0200)
- && ex.X_op == O_constant
- && (ex.X_add_number < (-(1 << (operand->bits - 1)))
- || ex.X_add_number > ((1 << (operand->bits - 1)) - 1)))
- errmsg = _("immediate operand is too large");
- }
-
- if (errmsg)
- goto error;
-
-#if 0
- fprintf (stderr,
- " insn: %x, operand %d, op: %d, add_number: %d\n",
- insn, opindex_ptr - opcode->operands,
- ex.X_op, ex.X_add_number);
-#endif
-
- switch (ex.X_op)
- {
- case O_illegal:
- errmsg = _("illegal operand");
- goto error;
- case O_absent:
- errmsg = _("missing operand");
- goto error;
- case O_register:
- if ((operand->flags
- & (V850_OPERAND_REG | V850_OPERAND_SRG)) == 0)
- {
- errmsg = _("invalid operand");
- goto error;
- }
- insn = v850_insert_operand (insn, operand, ex.X_add_number,
- (char *) NULL, 0,
- copy_of_instruction);
- break;
-
- case O_constant:
- insn = v850_insert_operand (insn, operand, ex.X_add_number,
- (char *) NULL, 0,
- copy_of_instruction);
- break;
-
- default:
- /* We need to generate a fixup for this expression. */
- if (fc >= MAX_INSN_FIXUPS)
- as_fatal (_("too many fixups"));
-
- fixups[fc].exp = ex;
- fixups[fc].opindex = *opindex_ptr;
- fixups[fc].reloc = BFD_RELOC_UNUSED;
- ++fc;
- break;
- }
- }
-
- str = input_line_pointer;
- input_line_pointer = hold;
-
- while (*str == ' ' || *str == ',' || *str == '[' || *str == ']'
- || *str == ')')
- ++str;
- }
- match = 1;
-
- error:
- if (match == 0)
- {
- next_opcode = opcode + 1;
- if (next_opcode->name != NULL
- && strcmp (next_opcode->name, opcode->name) == 0)
- {
- opcode = next_opcode;
-
- /* Skip versions that are not supported by the target
- processor. */
- if ((opcode->processors & processor_mask) == 0)
- goto error;
-
- continue;
- }
-
- as_bad ("%s: %s", copy_of_instruction, errmsg);
-
- if (*input_line_pointer == ']')
- ++input_line_pointer;
-
- ignore_rest_of_line ();
- input_line_pointer = saved_input_line_pointer;
- return;
- }
- break;
- }
-
- while (ISSPACE (*str))
- ++str;
-
- if (*str != '\0')
- /* xgettext:c-format */
- as_bad (_("junk at end of line: `%s'"), str);
-
- input_line_pointer = str;
-
- /* Tie dwarf2 debug info to the address at the start of the insn.
- We can't do this after the insn has been output as the current
- frag may have been closed off. eg. by frag_var. */
- dwarf2_emit_insn (0);
-
- /* Write out the instruction. */
-
- if (relaxable && fc > 0)
- {
- insn_size = 2;
- fc = 0;
-
- if (!strcmp (opcode->name, "br"))
- {
- f = frag_var (rs_machine_dependent, 4, 2, 2,
- fixups[0].exp.X_add_symbol,
- fixups[0].exp.X_add_number,
- (char *) fixups[0].opindex);
- md_number_to_chars (f, insn, insn_size);
- md_number_to_chars (f + 2, 0, 2);
- }
- else
- {
- f = frag_var (rs_machine_dependent, 6, 4, 0,
- fixups[0].exp.X_add_symbol,
- fixups[0].exp.X_add_number,
- (char *) fixups[0].opindex);
- md_number_to_chars (f, insn, insn_size);
- md_number_to_chars (f + 2, 0, 4);
- }
- }
- else
- {
- /* Four byte insns have an opcode with the two high bits on. */
- if ((insn & 0x0600) == 0x0600)
- insn_size = 4;
- else
- insn_size = 2;
-
- /* Special case: 32 bit MOV. */
- if ((insn & 0xffe0) == 0x0620)
- insn_size = 2;
-
- f = frag_more (insn_size);
- md_number_to_chars (f, insn, insn_size);
-
- if (extra_data_after_insn)
- {
- f = frag_more (extra_data_len);
- md_number_to_chars (f, extra_data, extra_data_len);
-
- extra_data_after_insn = false;
- }
- }
-
- /* Create any fixups. At this point we do not use a
- bfd_reloc_code_real_type, but instead just use the
- BFD_RELOC_UNUSED plus the operand index. This lets us easily
- handle fixups for any operand type, although that is admittedly
- not a very exciting feature. We pick a BFD reloc type in
- md_apply_fix3. */
- for (i = 0; i < fc; i++)
- {
- const struct v850_operand *operand;
- bfd_reloc_code_real_type reloc;
-
- operand = &v850_operands[fixups[i].opindex];
-
- reloc = fixups[i].reloc;
-
- if (reloc != BFD_RELOC_UNUSED)
- {
- reloc_howto_type *reloc_howto =
- bfd_reloc_type_lookup (stdoutput, reloc);
- int size;
- int address;
- fixS *fixP;
-
- if (!reloc_howto)
- abort ();
-
- size = bfd_get_reloc_size (reloc_howto);
-
- /* XXX This will abort on an R_V850_8 reloc -
- is this reloc actually used? */
- if (size != 2 && size != 4)
- abort ();
-
- address = (f - frag_now->fr_literal) + insn_size - size;
-
- if (reloc == BFD_RELOC_32)
- address += 2;
-
- fixP = fix_new_exp (frag_now, address, size,
- &fixups[i].exp,
- reloc_howto->pc_relative,
- reloc);
-
- switch (reloc)
- {
- case BFD_RELOC_LO16:
- case BFD_RELOC_HI16:
- case BFD_RELOC_HI16_S:
- fixP->fx_no_overflow = 1;
- break;
- default:
- break;
- }
- }
- else
- {
- fix_new_exp (frag_now,
- f - frag_now->fr_literal, 4,
- & fixups[i].exp,
- 1 /* FIXME: V850_OPERAND_RELATIVE ??? */,
- (bfd_reloc_code_real_type) (fixups[i].opindex
- + (int) BFD_RELOC_UNUSED));
- }
- }
-
- input_line_pointer = saved_input_line_pointer;
-}
-
-/* If while processing a fixup, a reloc really needs to be created
- then it is done here. */
-
-arelent *
-tc_gen_reloc (seg, fixp)
- asection *seg ATTRIBUTE_UNUSED;
- fixS *fixp;
-{
- arelent *reloc;
-
- reloc = (arelent *) xmalloc (sizeof (arelent));
- reloc->sym_ptr_ptr = (asymbol **) xmalloc (sizeof (asymbol *));
- *reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
- reloc->address = fixp->fx_frag->fr_address + fixp->fx_where;
- reloc->howto = bfd_reloc_type_lookup (stdoutput, fixp->fx_r_type);
-
- if (reloc->howto == (reloc_howto_type *) NULL)
- {
- as_bad_where (fixp->fx_file, fixp->fx_line,
- /* xgettext:c-format */
- _("reloc %d not supported by object file format"),
- (int) fixp->fx_r_type);
-
- xfree (reloc);
-
- return NULL;
- }
-
- if (fixp->fx_r_type == BFD_RELOC_VTABLE_ENTRY
- || fixp->fx_r_type == BFD_RELOC_VTABLE_INHERIT)
- reloc->addend = fixp->fx_offset;
- else
- reloc->addend = fixp->fx_addnumber;
-
- return reloc;
-}
-
-/* Return current size of variable part of frag. */
-
-int
-md_estimate_size_before_relax (fragp, seg)
- fragS *fragp;
- asection *seg ATTRIBUTE_UNUSED;
-{
- if (fragp->fr_subtype >= sizeof (md_relax_table) / sizeof (md_relax_table[0]))
- abort ();
-
- return md_relax_table[fragp->fr_subtype].rlx_length;
-}
-
-long
-v850_pcrel_from_section (fixp, section)
- fixS *fixp;
- segT section;
-{
- /* If the symbol is undefined, or in a section other than our own,
- or it is weak (in which case it may well be in another section,
- then let the linker figure it out. */
- if (fixp->fx_addsy != (symbolS *) NULL
- && (! S_IS_DEFINED (fixp->fx_addsy)
- || S_IS_WEAK (fixp->fx_addsy)
- || (S_GET_SEGMENT (fixp->fx_addsy) != section)))
- return 0;
-
- return fixp->fx_frag->fr_address + fixp->fx_where;
-}
-
-void
-md_apply_fix3 (fixP, valueP, seg)
- fixS *fixP;
- valueT *valueP;
- segT seg ATTRIBUTE_UNUSED;
-{
- valueT value = * valueP;
- char *where;
-
- if (fixP->fx_r_type == BFD_RELOC_VTABLE_INHERIT
- || fixP->fx_r_type == BFD_RELOC_VTABLE_ENTRY)
- {
- fixP->fx_done = 0;
- return;
- }
-
- if (fixP->fx_addsy == (symbolS *) NULL)
- fixP->fx_done = 1;
-
- else if (fixP->fx_pcrel)
- ;
-
- else
- {
- value = fixP->fx_offset;
- if (fixP->fx_subsy != (symbolS *) NULL)
- {
- if (S_GET_SEGMENT (fixP->fx_subsy) == absolute_section)
- value -= S_GET_VALUE (fixP->fx_subsy);
- else
- {
- /* We don't actually support subtracting a symbol. */
- as_bad_where (fixP->fx_file, fixP->fx_line,
- _("expression too complex"));
- }
- }
- }
-
- if ((int) fixP->fx_r_type >= (int) BFD_RELOC_UNUSED)
- {
- int opindex;
- const struct v850_operand *operand;
- unsigned long insn;
-
- opindex = (int) fixP->fx_r_type - (int) BFD_RELOC_UNUSED;
- operand = &v850_operands[opindex];
-
- /* Fetch the instruction, insert the fully resolved operand
- value, and stuff the instruction back again.
-
- Note the instruction has been stored in little endian
- format! */
- where = fixP->fx_frag->fr_literal + fixP->fx_where;
-
- insn = bfd_getl32 ((unsigned char *) where);
- insn = v850_insert_operand (insn, operand, (offsetT) value,
- fixP->fx_file, fixP->fx_line, NULL);
- bfd_putl32 ((bfd_vma) insn, (unsigned char *) where);
-
- if (fixP->fx_done)
- /* Nothing else to do here. */
- return;
-
- /* Determine a BFD reloc value based on the operand information.
- We are only prepared to turn a few of the operands into relocs. */
-
- if (operand->bits == 22)
- fixP->fx_r_type = BFD_RELOC_V850_22_PCREL;
- else if (operand->bits == 9)
- fixP->fx_r_type = BFD_RELOC_V850_9_PCREL;
- else
- {
-#if 0
- fprintf (stderr, "bits: %d, insn: %x\n", operand->bits, insn);
-#endif
-
- as_bad_where (fixP->fx_file, fixP->fx_line,
- _("unresolved expression that must be resolved"));
- fixP->fx_done = 1;
- return;
- }
- }
- else if (fixP->fx_done)
- {
- /* We still have to insert the value into memory! */
- where = fixP->fx_frag->fr_literal + fixP->fx_where;
-
- if (fixP->fx_size == 1)
- *where = value & 0xff;
- else if (fixP->fx_size == 2)
- bfd_putl16 (value & 0xffff, (unsigned char *) where);
- else if (fixP->fx_size == 4)
- bfd_putl32 (value, (unsigned char *) where);
- }
-
- fixP->fx_addnumber = value;
-}
-
-/* Parse a cons expression. We have to handle hi(), lo(), etc
- on the v850. */
-
-void
-parse_cons_expression_v850 (exp)
- expressionS *exp;
-{
- /* See if there's a reloc prefix like hi() we have to handle. */
- hold_cons_reloc = v850_reloc_prefix (NULL);
-
- /* Do normal expression parsing. */
- expression (exp);
-}
-
-/* Create a fixup for a cons expression. If parse_cons_expression_v850
- found a reloc prefix, then we use that reloc, else we choose an
- appropriate one based on the size of the expression. */
-
-void
-cons_fix_new_v850 (frag, where, size, exp)
- fragS *frag;
- int where;
- int size;
- expressionS *exp;
-{
- if (hold_cons_reloc == BFD_RELOC_UNUSED)
- {
- if (size == 4)
- hold_cons_reloc = BFD_RELOC_32;
- if (size == 2)
- hold_cons_reloc = BFD_RELOC_16;
- if (size == 1)
- hold_cons_reloc = BFD_RELOC_8;
- }
-
- if (exp != NULL)
- fix_new_exp (frag, where, size, exp, 0, hold_cons_reloc);
- else
- fix_new (frag, where, size, NULL, 0, 0, hold_cons_reloc);
-
- hold_cons_reloc = BFD_RELOC_UNUSED;
-}
-
-boolean
-v850_fix_adjustable (fixP)
- fixS *fixP;
-{
- if (fixP->fx_addsy == NULL)
- return 1;
-
- /* Prevent all adjustments to global symbols. */
- if (S_IS_EXTERN (fixP->fx_addsy))
- return 0;
-
- /* Similarly for weak symbols. */
- if (S_IS_WEAK (fixP->fx_addsy))
- return 0;
-
- /* Don't adjust function names. */
- if (S_IS_FUNCTION (fixP->fx_addsy))
- return 0;
-
- /* We need the symbol name for the VTABLE entries. */
- if (fixP->fx_r_type == BFD_RELOC_VTABLE_INHERIT
- || fixP->fx_r_type == BFD_RELOC_VTABLE_ENTRY)
- return 0;
-
- return 1;
-}
-
-int
-v850_force_relocation (fixP)
- struct fix *fixP;
-{
- if (fixP->fx_addsy && S_IS_WEAK (fixP->fx_addsy))
- return 1;
-
- if (fixP->fx_r_type == BFD_RELOC_VTABLE_INHERIT
- || fixP->fx_r_type == BFD_RELOC_VTABLE_ENTRY)
- return 1;
-
- return 0;
-}
diff --git a/contrib/binutils/gas/config/tc-v850.h b/contrib/binutils/gas/config/tc-v850.h
deleted file mode 100644
index 8257428..0000000
--- a/contrib/binutils/gas/config/tc-v850.h
+++ /dev/null
@@ -1,98 +0,0 @@
-/* tc-v850.h -- Header file for tc-v850.c.
- Copyright 1996, 1997, 1998, 2000, 2001, 2002
- Free Software Foundation, Inc.
-
- This file is part of GAS, the GNU Assembler.
-
- GAS is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2, or (at your option)
- any later version.
-
- GAS is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with GAS; see the file COPYING. If not, write to the Free
- Software Foundation, 59 Temple Place - Suite 330, Boston, MA
- 02111-1307, USA. */
-
-#define TC_V850
-
-#include "elf/v850.h"
-
-#define TARGET_BYTES_BIG_ENDIAN 0
-
-#ifndef BFD_ASSEMBLER
- #error V850 support requires BFD_ASSEMBLER
-#endif
-
-/* The target BFD architecture. */
-#define TARGET_ARCH bfd_arch_v850
-
-/* The target BFD format. */
-#define TARGET_FORMAT "elf32-v850"
-
-#define md_operand(x)
-
-#define obj_fix_adjustable(fixP) v850_fix_adjustable(fixP)
-extern boolean v850_fix_adjustable PARAMS ((struct fix *));
-
-#define TC_FORCE_RELOCATION(fixp) v850_force_relocation(fixp)
-extern int v850_force_relocation PARAMS ((struct fix *));
-
-#ifdef OBJ_ELF
-/* This arranges for gas/write.c to not apply a relocation if
- obj_fix_adjustable() says it is not adjustable. */
-#define TC_FIX_ADJUSTABLE(fixP) obj_fix_adjustable (fixP)
-#endif
-
-/* Permit temporary numeric labels. */
-#define LOCAL_LABELS_FB 1
-
-#define DIFF_EXPR_OK /* foo-. gets turned into PC relative relocs. */
-
-/* We don't need to handle .word strangely. */
-#define WORKING_DOT_WORD
-
-#define md_number_to_chars number_to_chars_littleendian
-
-/* We need to handle lo(), hi(), etc etc in .hword, .word, etc
- directives, so we have to parse "cons" expressions ourselves. */
-#define TC_PARSE_CONS_EXPRESSION(EXP, NBYTES) parse_cons_expression_v850 (EXP)
-extern void parse_cons_expression_v850 PARAMS ((expressionS *));
-
-#define TC_CONS_FIX_NEW cons_fix_new_v850
-extern void cons_fix_new_v850 PARAMS ((fragS *, int, int, expressionS *));
-
-#define TC_GENERIC_RELAX_TABLE md_relax_table
-extern const struct relax_type md_relax_table[];
-
-/* This section must be in the small data area (pointed to by GP). */
-#define SHF_V850_GPREL 0x10000000
-/* This section must be in the tiny data area (pointed to by EP). */
-#define SHF_V850_EPREL 0x20000000
-/* This section must be in the zero data area (pointed to by R0). */
-#define SHF_V850_R0REL 0x40000000
-
-#define ELF_TC_SPECIAL_SECTIONS \
- { ".sdata", SHT_PROGBITS, SHF_ALLOC + SHF_WRITE + SHF_V850_GPREL }, \
- { ".rosdata", SHT_PROGBITS, SHF_ALLOC + SHF_V850_GPREL }, \
- { ".sbss", SHT_NOBITS, SHF_ALLOC + SHF_WRITE + SHF_V850_GPREL }, \
- { ".scommon", SHT_V850_SCOMMON, SHF_ALLOC + SHF_WRITE + SHF_V850_GPREL }, \
- { ".tdata", SHT_PROGBITS, SHF_ALLOC + SHF_WRITE + SHF_V850_EPREL }, \
- { ".tbss", SHT_NOBITS, SHF_ALLOC + SHF_WRITE + SHF_V850_EPREL }, \
- { ".tcommon", SHT_V850_TCOMMON, SHF_ALLOC + SHF_WRITE + SHF_V850_R0REL }, \
- { ".zdata", SHT_PROGBITS, SHF_ALLOC + SHF_WRITE + SHF_V850_R0REL }, \
- { ".rozdata", SHT_PROGBITS, SHF_ALLOC + SHF_V850_R0REL }, \
- { ".zbss", SHT_NOBITS, SHF_ALLOC + SHF_WRITE + SHF_V850_R0REL }, \
- { ".zcommon", SHT_V850_ZCOMMON, SHF_ALLOC + SHF_WRITE + SHF_V850_R0REL }, \
- { ".call_table_data", SHT_PROGBITS, SHF_ALLOC + SHF_WRITE }, \
- { ".call_table_text", SHT_PROGBITS, SHF_ALLOC + SHF_WRITE + SHF_EXECINSTR },
-
-#define MD_PCREL_FROM_SECTION(fixP,section) v850_pcrel_from_section (fixP, section)
-extern long v850_pcrel_from_section PARAMS ((struct fix *, asection *));
-
-#define DWARF2_LINE_MIN_INSN_LENGTH 2
diff --git a/contrib/binutils/gas/config/tc-z8k.c b/contrib/binutils/gas/config/tc-z8k.c
deleted file mode 100644
index f5b05a6..0000000
--- a/contrib/binutils/gas/config/tc-z8k.c
+++ /dev/null
@@ -1,1566 +0,0 @@
-/* tc-z8k.c -- Assemble code for the Zilog Z800n
- Copyright 1992, 1993, 1994, 1995, 1996, 1998, 2000, 2001
- Free Software Foundation, Inc.
-
- This file is part of GAS, the GNU Assembler.
-
- GAS is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2, or (at your option)
- any later version.
-
- GAS is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with GAS; see the file COPYING. If not, write to the Free
- Software Foundation, 59 Temple Place - Suite 330, Boston, MA
- 02111-1307, USA. */
-
-/* Written By Steve Chamberlain <sac@cygnus.com>. */
-
-#define DEFINE_TABLE
-#include <stdio.h>
-
-#include "as.h"
-#include "bfd.h"
-#include "safe-ctype.h"
-#include "opcodes/z8k-opc.h"
-
-const char comment_chars[] = "!";
-const char line_comment_chars[] = "#";
-const char line_separator_chars[] = ";";
-
-extern int machine;
-extern int coff_flags;
-int segmented_mode;
-const int md_reloc_size;
-
-void cons ();
-
-void
-s_segm ()
-{
- segmented_mode = 1;
- machine = bfd_mach_z8001;
- coff_flags = F_Z8001;
-}
-
-void
-s_unseg ()
-{
- segmented_mode = 0;
- machine = bfd_mach_z8002;
- coff_flags = F_Z8002;
-}
-
-static void
-even ()
-{
- frag_align (1, 0, 0);
- record_alignment (now_seg, 1);
-}
-
-void obj_coff_section ();
-
-int
-tohex (c)
- int c;
-{
- if (ISDIGIT (c))
- return c - '0';
- if (ISLOWER (c))
- return c - 'a' + 10;
- return c - 'A' + 10;
-}
-
-void
-sval ()
-{
- SKIP_WHITESPACE ();
- if (*input_line_pointer == '\'')
- {
- int c;
- input_line_pointer++;
- c = *input_line_pointer++;
- while (c != '\'')
- {
- if (c == '%')
- {
- c = (tohex (input_line_pointer[0]) << 4)
- | tohex (input_line_pointer[1]);
- input_line_pointer += 2;
- }
- FRAG_APPEND_1_CHAR (c);
- c = *input_line_pointer++;
- }
- demand_empty_rest_of_line ();
- }
-}
-
-/* This table describes all the machine specific pseudo-ops the assembler
- has to support. The fields are:
- pseudo-op name without dot
- function to call to execute this pseudo-op
- Integer arg to pass to the function
- */
-
-const pseudo_typeS md_pseudo_table[] = {
- {"int" , cons , 2},
- {"data.b" , cons , 1},
- {"data.w" , cons , 2},
- {"data.l" , cons , 4},
- {"form" , listing_psize , 0},
- {"heading", listing_title , 0},
- {"import" , s_ignore , 0},
- {"page" , listing_eject , 0},
- {"program", s_ignore , 0},
- {"z8001" , s_segm , 0},
- {"z8002" , s_unseg , 0},
-
- {"segm" , s_segm , 0},
- {"unsegm" , s_unseg , 0},
- {"unseg" , s_unseg , 0},
- {"name" , s_app_file , 0},
- {"global" , s_globl , 0},
- {"wval" , cons , 2},
- {"lval" , cons , 4},
- {"bval" , cons , 1},
- {"sval" , sval , 0},
- {"rsect" , obj_coff_section, 0},
- {"sect" , obj_coff_section, 0},
- {"block" , s_space , 0},
- {"even" , even , 0},
- {0 , 0 , 0}
-};
-
-const char EXP_CHARS[] = "eE";
-
-/* Chars that mean this number is a floating point constant.
- As in 0f12.456
- or 0d1.2345e12 */
-const char FLT_CHARS[] = "rRsSfFdDxXpP";
-
-/* Opcode mnemonics. */
-static struct hash_control *opcode_hash_control;
-
-void
-md_begin ()
-{
- opcode_entry_type *opcode;
- char *prev_name = "";
- int idx = 0;
-
- opcode_hash_control = hash_new ();
-
- for (opcode = z8k_table; opcode->name; opcode++)
- {
- /* Only enter unique codes into the table. */
- if (strcmp (opcode->name, prev_name))
- {
- hash_insert (opcode_hash_control, opcode->name, (char *) opcode);
- idx++;
- }
- opcode->idx = idx;
- prev_name = opcode->name;
- }
-
- /* Default to z8002. */
- s_unseg ();
-
- /* Insert the pseudo ops, too. */
- for (idx = 0; md_pseudo_table[idx].poc_name; idx++)
- {
- opcode_entry_type *fake_opcode;
- fake_opcode = (opcode_entry_type *) malloc (sizeof (opcode_entry_type));
- fake_opcode->name = md_pseudo_table[idx].poc_name;
- fake_opcode->func = (void *) (md_pseudo_table + idx);
- fake_opcode->opcode = 250;
- hash_insert (opcode_hash_control, fake_opcode->name, fake_opcode);
- }
-
- linkrelax = 1;
-}
-
-struct z8k_exp {
- char *e_beg;
- char *e_end;
- expressionS e_exp;
-};
-
-typedef struct z8k_op {
- /* 'b','w','r','q'. */
- char regsize;
-
- /* 0 .. 15. */
- unsigned int reg;
-
- int mode;
-
- /* Any other register associated with the mode. */
- unsigned int x_reg;
-
- /* Any expression. */
- expressionS exp;
-} op_type;
-
-static expressionS *da_operand;
-static expressionS *imm_operand;
-
-int reg[16];
-int the_cc;
-int the_ctrl;
-int the_flags;
-int the_interrupt;
-
-char *
-whatreg (reg, src)
- int *reg;
- char *src;
-{
- if (ISDIGIT (src[1]))
- {
- *reg = (src[0] - '0') * 10 + src[1] - '0';
- return src + 2;
- }
- else
- {
- *reg = (src[0] - '0');
- return src + 1;
- }
-}
-
-/* Parse operands
-
- rh0-rh7, rl0-rl7
- r0-r15
- rr0-rr14
- rq0--rq12
- WREG r0,r1,r2,r3,r4,r5,r6,r7,fp,sp
- r0l,r0h,..r7l,r7h
- @WREG
- @WREG+
- @-WREG
- #const
-*/
-
-/* Try to parse a reg name. Return a pointer to the first character
- in SRC after the reg name. */
-
-char *
-parse_reg (src, mode, reg)
- char *src;
- int *mode;
- unsigned int *reg;
-{
- char *res = 0;
- char regno;
-
- if (src[0] == 's' && src[1] == 'p' && (src[2] == 0 || src[2] == ','))
- {
- if (segmented_mode)
- {
- *mode = CLASS_REG_LONG;
- *reg = 14;
- }
- else
- {
- *mode = CLASS_REG_WORD;
- *reg = 15;
- }
- return src + 2;
- }
- if (src[0] == 'r')
- {
- if (src[1] == 'r')
- {
- if (src[2] < '0' || src[2] > '9')
- return res; /* Assume no register name but a label starting with 'rr'. */
- *mode = CLASS_REG_LONG;
- res = whatreg (reg, src + 2);
- regno = *reg;
- if (regno > 14)
- as_warn (_("register rr%d, out of range."), regno);
- }
- else if (src[1] == 'h')
- {
- if (src[2] < '0' || src[2] > '9')
- return res; /* Assume no register name but a label starting with 'rh'. */
- *mode = CLASS_REG_BYTE;
- res = whatreg (reg, src + 2);
- regno = *reg;
- if (regno > 7)
- as_warn (_("register rh%d, out of range."), regno);
- }
- else if (src[1] == 'l')
- {
- if (src[2] < '0' || src[2] > '9')
- return res; /* Assume no register name but a label starting with 'rl'. */
- *mode = CLASS_REG_BYTE;
- res = whatreg (reg, src + 2);
- regno = *reg;
- if (regno > 7)
- as_warn (_("register rl%d, out of range."), regno);
- *reg += 8;
- }
- else if (src[1] == 'q')
- {
- if (src[2] < '0' || src[2] > '9')
- return res; /* Assume no register name but a label starting with 'rq'. */
- *mode = CLASS_REG_QUAD;
- res = whatreg (reg, src + 2);
- regno = *reg;
- if (regno > 12)
- as_warn (_("register rq%d, out of range."), regno);
- }
- else
- {
- if (src[1] < '0' || src[1] > '9')
- return res; /* Assume no register name but a label starting with 'r'. */
- *mode = CLASS_REG_WORD;
- res = whatreg (reg, src + 1);
- regno = *reg;
- if (regno > 15)
- as_warn (_("register r%d, out of range."), regno);
- }
- }
- return res;
-}
-
-char *
-parse_exp (s, op)
- char *s;
- expressionS *op;
-{
- char *save = input_line_pointer;
- char *new;
-
- input_line_pointer = s;
- expression (op);
- if (op->X_op == O_absent)
- as_bad (_("missing operand"));
- new = input_line_pointer;
- input_line_pointer = save;
- return new;
-}
-
-/* The many forms of operand:
-
- <rb>
- <r>
- <rr>
- <rq>
- @r
- #exp
- exp
- exp(r)
- r(#exp)
- r(r)
- */
-
-static char *
-checkfor (ptr, what)
- char *ptr;
- char what;
-{
- if (*ptr == what)
- ptr++;
- else
- as_bad (_("expected %c"), what);
-
- return ptr;
-}
-
-/* Make sure the mode supplied is the size of a word. */
-
-static void
-regword (mode, string)
- int mode;
- char *string;
-{
- int ok;
-
- ok = CLASS_REG_WORD;
- if (ok != mode)
- {
- as_bad (_("register is wrong size for a word %s"), string);
- }
-}
-
-/* Make sure the mode supplied is the size of an address. */
-
-static void
-regaddr (mode, string)
- int mode;
- char *string;
-{
- int ok;
-
- ok = segmented_mode ? CLASS_REG_LONG : CLASS_REG_WORD;
- if (ok != mode)
- {
- as_bad (_("register is wrong size for address %s"), string);
- }
-}
-
-struct ctrl_names {
- int value;
- char *name;
-};
-
-struct ctrl_names ctrl_table[] = {
- { 0x2, "fcw" },
- { 0x3, "refresh" },
- { 0x4, "psapseg" },
- { 0x5, "psapoff" },
- { 0x5, "psap" },
- { 0x6, "nspseg" },
- { 0x7, "nspoff" },
- { 0x7, "nsp" },
- { 0 , 0 }
-};
-
-static void
-get_ctrl_operand (ptr, mode, dst)
- char **ptr;
- struct z8k_op *mode;
- unsigned int dst ATTRIBUTE_UNUSED;
-{
- char *src = *ptr;
- int i;
-
- while (*src == ' ')
- src++;
-
- mode->mode = CLASS_CTRL;
- for (i = 0; ctrl_table[i].name; i++)
- {
- int j;
-
- for (j = 0; ctrl_table[i].name[j]; j++)
- {
- if (ctrl_table[i].name[j] != src[j])
- goto fail;
- }
- the_ctrl = ctrl_table[i].value;
- *ptr = src + j;
- return;
- fail:
- ;
- }
- the_ctrl = 0;
- return;
-}
-
-struct flag_names {
- int value;
- char *name;
-
-};
-
-struct flag_names flag_table[] = {
- { 0x1, "p" },
- { 0x1, "v" },
- { 0x2, "s" },
- { 0x4, "z" },
- { 0x8, "c" },
- { 0x0, "+" },
- { 0, 0 }
-};
-
-static void
-get_flags_operand (ptr, mode, dst)
- char **ptr;
- struct z8k_op *mode;
- unsigned int dst ATTRIBUTE_UNUSED;
-{
- char *src = *ptr;
- int i;
- int j;
-
- while (*src == ' ')
- src++;
-
- mode->mode = CLASS_FLAGS;
- the_flags = 0;
- for (j = 0; j <= 9; j++)
- {
- if (!src[j])
- goto done;
- for (i = 0; flag_table[i].name; i++)
- {
- if (flag_table[i].name[0] == src[j])
- {
- the_flags = the_flags | flag_table[i].value;
- goto match;
- }
- }
- goto done;
- match:
- ;
- }
- done:
- *ptr = src + j;
- return;
-}
-
-struct interrupt_names {
- int value;
- char *name;
-
-};
-
-struct interrupt_names intr_table[] = {
- { 0x1, "nvi" },
- { 0x2, "vi" },
- { 0x3, "both" },
- { 0x3, "all" },
- { 0, 0 }
-};
-
-static void
-get_interrupt_operand (ptr, mode, dst)
- char **ptr;
- struct z8k_op *mode;
- unsigned int dst ATTRIBUTE_UNUSED;
-{
- char *src = *ptr;
- int i;
-
- while (*src == ' ')
- src++;
-
- mode->mode = CLASS_IMM;
- for (i = 0; intr_table[i].name; i++)
- {
- int j;
-
- for (j = 0; intr_table[i].name[j]; j++)
- {
- if (intr_table[i].name[j] != src[j])
- goto fail;
- }
- the_interrupt = intr_table[i].value;
- *ptr = src + j;
- return;
- fail:
- ;
- }
- the_interrupt = 0x0;
- return;
-}
-
-struct cc_names {
- int value;
- char *name;
-
-};
-
-struct cc_names table[] = {
- { 0x0, "f" },
- { 0x1, "lt" },
- { 0x2, "le" },
- { 0x3, "ule" },
- { 0x4, "ov" },
- { 0x4, "pe" },
- { 0x5, "mi" },
- { 0x6, "eq" },
- { 0x6, "z" },
- { 0x7, "c" },
- { 0x7, "ult" },
- { 0x8, "t" },
- { 0x9, "ge" },
- { 0xa, "gt" },
- { 0xb, "ugt" },
- { 0xc, "nov" },
- { 0xc, "po" },
- { 0xd, "pl" },
- { 0xe, "ne" },
- { 0xe, "nz" },
- { 0xf, "nc" },
- { 0xf, "uge" },
- { 0 , 0 }
-};
-
-static void
-get_cc_operand (ptr, mode, dst)
- char **ptr;
- struct z8k_op *mode;
- unsigned int dst ATTRIBUTE_UNUSED;
-{
- char *src = *ptr;
- int i;
-
- while (*src == ' ')
- src++;
-
- mode->mode = CLASS_CC;
- for (i = 0; table[i].name; i++)
- {
- int j;
-
- for (j = 0; table[i].name[j]; j++)
- {
- if (table[i].name[j] != src[j])
- goto fail;
- }
- the_cc = table[i].value;
- *ptr = src + j;
- return;
- fail:
- ;
- }
- the_cc = 0x8;
-}
-
-static void
-get_operand (ptr, mode, dst)
- char **ptr;
- struct z8k_op *mode;
- unsigned int dst ATTRIBUTE_UNUSED;
-{
- char *src = *ptr;
- char *end;
-
- mode->mode = 0;
-
- while (*src == ' ')
- src++;
- if (*src == '#')
- {
- mode->mode = CLASS_IMM;
- imm_operand = &(mode->exp);
- src = parse_exp (src + 1, &(mode->exp));
- }
- else if (*src == '@')
- {
- int d;
-
- mode->mode = CLASS_IR;
- src = parse_reg (src + 1, &d, &mode->reg);
- }
- else
- {
- int regn;
-
- end = parse_reg (src, &mode->mode, &regn);
-
- if (end)
- {
- int nw, nr;
-
- src = end;
- if (*src == '(')
- {
- src++;
- end = parse_reg (src, &nw, &nr);
- if (end)
- {
- /* Got Ra(Rb). */
- src = end;
-
- if (*src != ')')
- as_bad (_("Missing ) in ra(rb)"));
- else
- src++;
-
- regaddr (mode->mode, "ra(rb) ra");
-#if 0
- regword (mode->mode, "ra(rb) rb");
-#endif
- mode->mode = CLASS_BX;
- mode->reg = regn;
- mode->x_reg = nr;
- reg[ARG_RX] = nr;
- }
- else
- {
- /* Got Ra(disp). */
- if (*src == '#')
- src++;
- src = parse_exp (src, &(mode->exp));
- src = checkfor (src, ')');
- mode->mode = CLASS_BA;
- mode->reg = regn;
- mode->x_reg = 0;
- imm_operand = &(mode->exp);
- }
- }
- else
- {
- mode->reg = regn;
- mode->x_reg = 0;
- }
- }
- else
- {
- /* No initial reg. */
- src = parse_exp (src, &(mode->exp));
- if (*src == '(')
- {
- src++;
- end = parse_reg (src, &(mode->mode), &regn);
- regword (mode->mode, "addr(Ra) ra");
- mode->mode = CLASS_X;
- mode->reg = regn;
- mode->x_reg = 0;
- da_operand = &(mode->exp);
- src = checkfor (end, ')');
- }
- else
- {
- /* Just an address. */
- mode->mode = CLASS_DA;
- mode->reg = 0;
- mode->x_reg = 0;
- da_operand = &(mode->exp);
- }
- }
- }
- *ptr = src;
-}
-
-static char *
-get_operands (opcode, op_end, operand)
- opcode_entry_type *opcode;
- char *op_end;
- op_type *operand;
-{
- char *ptr = op_end;
- char *savptr;
-
- switch (opcode->noperands)
- {
- case 0:
- operand[0].mode = 0;
- operand[1].mode = 0;
- break;
-
- case 1:
- ptr++;
- if (opcode->arg_info[0] == CLASS_CC)
- {
- get_cc_operand (&ptr, operand + 0, 0);
- }
- else if (opcode->arg_info[0] == CLASS_FLAGS)
- {
- get_flags_operand (&ptr, operand + 0, 0);
- }
- else if (opcode->arg_info[0] == (CLASS_IMM + (ARG_IMM2)))
- {
- get_interrupt_operand (&ptr, operand + 0, 0);
- }
- else
- {
- get_operand (&ptr, operand + 0, 0);
- }
- operand[1].mode = 0;
- break;
-
- case 2:
- ptr++;
- savptr = ptr;
- if (opcode->arg_info[0] == CLASS_CC)
- {
- get_cc_operand (&ptr, operand + 0, 0);
- }
- else if (opcode->arg_info[0] == CLASS_CTRL)
- {
- get_ctrl_operand (&ptr, operand + 0, 0);
- if (the_ctrl == 0)
- {
- ptr = savptr;
- get_operand (&ptr, operand + 0, 0);
- if (ptr == 0)
- return NULL;
- if (*ptr == ',')
- ptr++;
- get_ctrl_operand (&ptr, operand + 1, 1);
- return ptr;
- }
- }
- else
- {
- get_operand (&ptr, operand + 0, 0);
- }
- if (ptr == 0)
- return NULL;
- if (*ptr == ',')
- ptr++;
- get_operand (&ptr, operand + 1, 1);
- break;
-
- case 3:
- ptr++;
- get_operand (&ptr, operand + 0, 0);
- if (*ptr == ',')
- ptr++;
- get_operand (&ptr, operand + 1, 1);
- if (*ptr == ',')
- ptr++;
- get_operand (&ptr, operand + 2, 2);
- break;
-
- case 4:
- ptr++;
- get_operand (&ptr, operand + 0, 0);
- if (*ptr == ',')
- ptr++;
- get_operand (&ptr, operand + 1, 1);
- if (*ptr == ',')
- ptr++;
- get_operand (&ptr, operand + 2, 2);
- if (*ptr == ',')
- ptr++;
- get_cc_operand (&ptr, operand + 3, 3);
- break;
-
- default:
- abort ();
- }
-
- return ptr;
-}
-
-/* Passed a pointer to a list of opcodes which use different
- addressing modes. Return the opcode which matches the opcodes
- provided. */
-
-static opcode_entry_type *
-get_specific (opcode, operands)
- opcode_entry_type *opcode;
- op_type *operands;
-
-{
- opcode_entry_type *this_try = opcode;
- int found = 0;
- unsigned int noperands = opcode->noperands;
-
- int this_index = opcode->idx;
-
- while (this_index == opcode->idx && !found)
- {
- unsigned int i;
-
- this_try = opcode++;
- for (i = 0; i < noperands; i++)
- {
- unsigned int mode = operands[i].mode;
-
- if ((mode & CLASS_MASK) != (this_try->arg_info[i] & CLASS_MASK))
- {
- /* It could be an pc rel operand, if this is a da mode
- and we like disps, then insert it. */
-
- if (mode == CLASS_DA && this_try->arg_info[i] == CLASS_DISP)
- {
- /* This is the case. */
- operands[i].mode = CLASS_DISP;
- }
- else if (mode == CLASS_BA && this_try->arg_info[i])
- {
- /* Can't think of a way to turn what we've been
- given into something that's OK. */
- goto fail;
- }
- else if (this_try->arg_info[i] & CLASS_PR)
- {
- if (mode == CLASS_REG_LONG && segmented_mode)
- {
- /* OK. */
- }
- else if (mode == CLASS_REG_WORD && !segmented_mode)
- {
- /* OK. */
- }
- else
- goto fail;
- }
- else
- goto fail;
- }
- switch (mode & CLASS_MASK)
- {
- default:
- break;
- case CLASS_X:
- case CLASS_IR:
- case CLASS_BA:
- case CLASS_BX:
- case CLASS_DISP:
- case CLASS_REG:
- case CLASS_REG_WORD:
- case CLASS_REG_BYTE:
- case CLASS_REG_QUAD:
- case CLASS_REG_LONG:
- case CLASS_REGN0:
- reg[this_try->arg_info[i] & ARG_MASK] = operands[i].reg;
- break;
- }
- }
-
- found = 1;
- fail:
- ;
- }
- if (found)
- return this_try;
- else
- return 0;
-}
-
-#if 0 /* Not used. */
-static void
-check_operand (operand, width, string)
- struct z8k_op *operand;
- unsigned int width;
- char *string;
-{
- if (operand->exp.X_add_symbol == 0
- && operand->exp.X_op_symbol == 0)
- {
-
- /* No symbol involved, let's look at offset, it's dangerous if
- any of the high bits are not 0 or ff's, find out by oring or
- anding with the width and seeing if the answer is 0 or all
- fs. */
- if ((operand->exp.X_add_number & ~width) != 0 &&
- (operand->exp.X_add_number | width) != (~0))
- {
- as_warn (_("operand %s0x%x out of range."),
- string, operand->exp.X_add_number);
- }
- }
-
-}
-#endif
-
-static char buffer[20];
-
-static void
-newfix (ptr, type, operand)
- int ptr;
- int type;
- expressionS *operand;
-{
- if (operand->X_add_symbol
- || operand->X_op_symbol
- || operand->X_add_number)
- {
- fix_new_exp (frag_now,
- ptr,
- 1,
- operand,
- 0,
- type);
- }
-}
-
-static char *
-apply_fix (ptr, type, operand, size)
- char *ptr;
- int type;
- expressionS *operand;
- int size;
-{
- int n = operand->X_add_number;
-
- newfix ((ptr - buffer) / 2, type, operand);
- switch (size)
- {
- case 8: /* 8 nibbles == 32 bits. */
- *ptr++ = n >> 28;
- *ptr++ = n >> 24;
- *ptr++ = n >> 20;
- *ptr++ = n >> 16;
- case 4: /* 4 nibbles == 16 bits. */
- *ptr++ = n >> 12;
- *ptr++ = n >> 8;
- case 2:
- *ptr++ = n >> 4;
- case 1:
- *ptr++ = n >> 0;
- break;
- }
- return ptr;
-}
-
-/* Now we know what sort of opcodes it is. Let's build the bytes. */
-
-#define INSERT(x,y) *x++ = y>>24; *x++ = y>> 16; *x++=y>>8; *x++ =y;
-
-static void
-build_bytes (this_try, operand)
- opcode_entry_type *this_try;
- struct z8k_op *operand ATTRIBUTE_UNUSED;
-{
- char *output_ptr = buffer;
- int c;
- int nib;
- int nibble;
- unsigned int *class_ptr;
-
- frag_wane (frag_now);
- frag_new (0);
-
- memset (buffer, 20, 0);
- class_ptr = this_try->byte_info;
-
- for (nibble = 0; (c = *class_ptr++); nibble++)
- {
-
- switch (c & CLASS_MASK)
- {
- default:
- abort ();
-
- case CLASS_ADDRESS:
- /* Direct address, we don't cope with the SS mode right now. */
- if (segmented_mode)
- {
- /* da_operand->X_add_number |= 0x80000000; -- Now set at relocation time. */
- output_ptr = apply_fix (output_ptr, R_IMM32, da_operand, 8);
- }
- else
- {
- output_ptr = apply_fix (output_ptr, R_IMM16, da_operand, 4);
- }
- da_operand = 0;
- break;
- case CLASS_DISP8:
- /* pc rel 8 bit */
- output_ptr = apply_fix (output_ptr, R_JR, da_operand, 2);
- da_operand = 0;
- break;
-
- case CLASS_0DISP7:
- /* pc rel 7 bit */
- *output_ptr = 0;
- output_ptr = apply_fix (output_ptr, R_DISP7, da_operand, 2);
- da_operand = 0;
- break;
-
- case CLASS_1DISP7:
- /* pc rel 7 bit */
- *output_ptr = 0x80;
- output_ptr = apply_fix (output_ptr, R_DISP7, da_operand, 2);
- output_ptr[-2] = 0x8;
- da_operand = 0;
- break;
-
- case CLASS_BIT_1OR2:
- *output_ptr = c & 0xf;
- if (imm_operand)
- {
- if (imm_operand->X_add_number == 2)
- *output_ptr |= 2;
- else if (imm_operand->X_add_number != 1)
- as_bad (_("immediate must be 1 or 2"));
- }
- else
- as_bad (_("immediate 1 or 2 expected"));
- output_ptr++;
- break;
- case CLASS_CC:
- *output_ptr++ = the_cc;
- break;
- case CLASS_0CCC:
- *output_ptr++ = the_ctrl;
- break;
- case CLASS_1CCC:
- *output_ptr++ = the_ctrl | 0x8;
- break;
- case CLASS_00II:
- *output_ptr++ = (~the_interrupt & 0x3);
- break;
- case CLASS_01II:
- *output_ptr++ = (~the_interrupt & 0x3) | 0x4;
- break;
- case CLASS_FLAGS:
- *output_ptr++ = the_flags;
- break;
- case CLASS_BIT:
- *output_ptr++ = c & 0xf;
- break;
- case CLASS_REGN0:
- if (reg[c & 0xf] == 0)
- as_bad (_("can't use R0 here"));
- /* Fall through. */
- case CLASS_REG:
- case CLASS_REG_BYTE:
- case CLASS_REG_WORD:
- case CLASS_REG_LONG:
- case CLASS_REG_QUAD:
- /* Insert bit mattern of right reg. */
- *output_ptr++ = reg[c & 0xf];
- break;
- case CLASS_DISP:
- switch (c & ARG_MASK)
- {
- case ARG_DISP12:
- output_ptr = apply_fix (output_ptr, R_CALLR, da_operand, 4);
- break;
- case ARG_DISP16:
- output_ptr = apply_fix (output_ptr, R_REL16, da_operand, 4);
- break;
- default:
- output_ptr = apply_fix (output_ptr, R_IMM16, da_operand, 4);
- }
- da_operand = 0;
- break;
-
- case CLASS_IMM:
- {
- nib = 0;
- switch (c & ARG_MASK)
- {
- case ARG_IMM4:
- output_ptr = apply_fix (output_ptr, R_IMM4L, imm_operand, 1);
- break;
- case ARG_IMM4M1:
- imm_operand->X_add_number--;
- output_ptr = apply_fix (output_ptr, R_IMM4L, imm_operand, 1);
- break;
- case ARG_IMMNMINUS1:
- imm_operand->X_add_number--;
- output_ptr = apply_fix (output_ptr, R_IMM4L, imm_operand, 1);
- break;
- case ARG_NIM8:
- imm_operand->X_add_number = -imm_operand->X_add_number;
- case ARG_IMM8:
- output_ptr = apply_fix (output_ptr, R_IMM8, imm_operand, 2);
- break;
- case ARG_IMM16:
- output_ptr = apply_fix (output_ptr, R_IMM16, imm_operand, 4);
- break;
-
- case ARG_IMM32:
- output_ptr = apply_fix (output_ptr, R_IMM32, imm_operand, 8);
- break;
-
- default:
- abort ();
- }
- }
- }
- }
-
- /* Copy from the nibble buffer into the frag. */
- {
- int length = (output_ptr - buffer) / 2;
- char *src = buffer;
- char *fragp = frag_more (length);
-
- while (src < output_ptr)
- {
- *fragp = (src[0] << 4) | src[1];
- src += 2;
- fragp++;
- }
- }
-}
-
-/* This is the guts of the machine-dependent assembler. STR points to a
- machine dependent instruction. This function is supposed to emit
- the frags/bytes it assembles to. */
-
-void
-md_assemble (str)
- char *str;
-{
- char c;
- char *op_start;
- char *op_end;
- struct z8k_op operand[3];
- opcode_entry_type *opcode;
- opcode_entry_type *prev_opcode;
-
- /* Drop leading whitespace. */
- while (*str == ' ')
- str++;
-
- /* Find the op code end. */
- for (op_start = op_end = str;
- *op_end != 0 && *op_end != ' ';
- op_end++)
- ;
-
- if (op_end == op_start)
- {
- as_bad (_("can't find opcode "));
- }
- c = *op_end;
-
- *op_end = 0;
-
- opcode = (opcode_entry_type *) hash_find (opcode_hash_control, op_start);
-
- if (opcode == NULL)
- {
- as_bad (_("unknown opcode"));
- return;
- }
-
- if (opcode->opcode == 250)
- {
- /* Was really a pseudo op. */
-
- pseudo_typeS *p;
- char oc;
-
- char *old = input_line_pointer;
- *op_end = c;
-
- input_line_pointer = op_end;
-
- oc = *old;
- *old = '\n';
- while (*input_line_pointer == ' ')
- input_line_pointer++;
- p = (pseudo_typeS *) (opcode->func);
-
- (p->poc_handler) (p->poc_val);
- input_line_pointer = old;
- *old = oc;
- }
- else
- {
- input_line_pointer = get_operands (opcode, op_end, operand);
- prev_opcode = opcode;
-
- opcode = get_specific (opcode, operand);
-
- if (opcode == 0)
- {
- /* Couldn't find an opcode which matched the operands. */
- char *where = frag_more (2);
-
- where[0] = 0x0;
- where[1] = 0x0;
-
- as_bad (_("Can't find opcode to match operands"));
- return;
- }
-
- build_bytes (opcode, operand);
- }
-}
-
-void
-tc_crawl_symbol_chain (headers)
- object_headers *headers ATTRIBUTE_UNUSED;
-{
- printf (_("call to tc_crawl_symbol_chain \n"));
-}
-
-symbolS *
-md_undefined_symbol (name)
- char *name ATTRIBUTE_UNUSED;
-{
- return 0;
-}
-
-void
-tc_headers_hook (headers)
- object_headers *headers ATTRIBUTE_UNUSED;
-{
- printf (_("call to tc_headers_hook \n"));
-}
-
-/* Various routines to kill one day. */
-/* Equal to MAX_PRECISION in atof-ieee.c. */
-#define MAX_LITTLENUMS 6
-
-/* Turn a string in input_line_pointer into a floating point constant
- of type TYPE, and store the appropriate bytes in *LITP. The number
- of LITTLENUMS emitted is stored in *SIZEP. An error message is
- returned, or NULL on OK. */
-
-char *
-md_atof (type, litP, sizeP)
- char type;
- char *litP;
- int *sizeP;
-{
- int prec;
- LITTLENUM_TYPE words[MAX_LITTLENUMS];
- LITTLENUM_TYPE *wordP;
- char *t;
- char *atof_ieee ();
-
- switch (type)
- {
- case 'f':
- case 'F':
- case 's':
- case 'S':
- prec = 2;
- break;
-
- case 'd':
- case 'D':
- case 'r':
- case 'R':
- prec = 4;
- break;
-
- case 'x':
- case 'X':
- prec = 6;
- break;
-
- case 'p':
- case 'P':
- prec = 6;
- break;
-
- default:
- *sizeP = 0;
- return _("Bad call to MD_ATOF()");
- }
- t = atof_ieee (input_line_pointer, type, words);
- if (t)
- input_line_pointer = t;
-
- *sizeP = prec * sizeof (LITTLENUM_TYPE);
- for (wordP = words; prec--;)
- {
- md_number_to_chars (litP, (long) (*wordP++), sizeof (LITTLENUM_TYPE));
- litP += sizeof (LITTLENUM_TYPE);
- }
- return 0;
-}
-
-CONST char *md_shortopts = "z:";
-
-struct option md_longopts[] = {
- {NULL, no_argument, NULL, 0}
-};
-
-size_t md_longopts_size = sizeof (md_longopts);
-
-int
-md_parse_option (c, arg)
- int c;
- char *arg;
-{
- switch (c)
- {
- case 'z':
- if (!strcmp (arg, "8001"))
- s_segm ();
- else if (!strcmp (arg, "8002"))
- s_unseg ();
- else
- {
- as_bad (_("invalid architecture -z%s"), arg);
- return 0;
- }
- break;
-
- default:
- return 0;
- }
-
- return 1;
-}
-
-void
-md_show_usage (stream)
- FILE *stream;
-{
- fprintf (stream, _("\
-Z8K options:\n\
--z8001 generate segmented code\n\
--z8002 generate unsegmented code\n"));
-}
-
-void
-tc_aout_fix_to_chars ()
-{
- printf (_("call to tc_aout_fix_to_chars \n"));
- abort ();
-}
-
-void
-md_convert_frag (headers, seg, fragP)
- object_headers *headers ATTRIBUTE_UNUSED;
- segT seg ATTRIBUTE_UNUSED;
- fragS *fragP ATTRIBUTE_UNUSED;
-{
- printf (_("call to md_convert_frag \n"));
- abort ();
-}
-
-valueT
-md_section_align (seg, size)
- segT seg;
- valueT size;
-{
- return ((size + (1 << section_alignment[(int) seg]) - 1)
- & (-1 << section_alignment[(int) seg]));
-
-}
-
-void
-md_apply_fix3 (fixP, valP, segment)
- fixS *fixP;
- valueT * valP;
- segT segment ATTRIBUTE_UNUSED;
-{
- long val = * (long *) valP;
- char *buf = fixP->fx_where + fixP->fx_frag->fr_literal;
-
- switch (fixP->fx_r_type)
- {
- case R_IMM4L:
- buf[0] = (buf[0] & 0xf0) | ((buf[0] + val) & 0xf);
- break;
-
- case R_JR:
-
- *buf++ = val;
-#if 0
- if (val != 0)
- abort ();
-#endif
- break;
-
- case R_DISP7:
-
- *buf++ += val;
-#if 0
- if (val != 0)
- abort ();
-#endif
- break;
-
- case R_IMM8:
- buf[0] += val;
- break;
- case R_IMM16:
- *buf++ = (val >> 8);
- *buf++ = val;
- break;
- case R_IMM32:
- *buf++ = (val >> 24);
- *buf++ = (val >> 16);
- *buf++ = (val >> 8);
- *buf++ = val;
- break;
-#if 0
- case R_DA | R_SEG:
- *buf++ = (val >> 16);
- *buf++ = 0x00;
- *buf++ = (val >> 8);
- *buf++ = val;
- break;
-#endif
-
- case 0:
- md_number_to_chars (buf, val, fixP->fx_size);
- break;
-
- default:
- abort ();
- }
-
- if (fixP->fx_addsy == NULL && fixP->fx_pcrel == 0)
- fixP->fx_done = 1;
-}
-
-int
-md_estimate_size_before_relax (fragP, segment_type)
- register fragS *fragP ATTRIBUTE_UNUSED;
- register segT segment_type ATTRIBUTE_UNUSED;
-{
- printf (_("call tomd_estimate_size_before_relax \n"));
- abort ();
-}
-
-/* Put number into target byte order. */
-
-void
-md_number_to_chars (ptr, use, nbytes)
- char *ptr;
- valueT use;
- int nbytes;
-{
- number_to_chars_bigendian (ptr, use, nbytes);
-}
-
-long
-md_pcrel_from (fixP)
- fixS *fixP ATTRIBUTE_UNUSED;
-{
- abort ();
-}
-
-void
-tc_coff_symbol_emit_hook (s)
- symbolS *s ATTRIBUTE_UNUSED;
-{
-}
-
-void
-tc_reloc_mangle (fix_ptr, intr, base)
- fixS *fix_ptr;
- struct internal_reloc *intr;
- bfd_vma base;
-
-{
- symbolS *symbol_ptr;
-
- if (fix_ptr->fx_addsy
- && fix_ptr->fx_subsy)
- {
- symbolS *add = fix_ptr->fx_addsy;
- symbolS *sub = fix_ptr->fx_subsy;
-
- if (S_GET_SEGMENT (add) != S_GET_SEGMENT (sub))
- as_bad (_("Can't subtract symbols in different sections %s %s"),
- S_GET_NAME (add), S_GET_NAME (sub));
- else
- {
- int diff = S_GET_VALUE (add) - S_GET_VALUE (sub);
-
- fix_ptr->fx_addsy = 0;
- fix_ptr->fx_subsy = 0;
- fix_ptr->fx_offset += diff;
- }
- }
- symbol_ptr = fix_ptr->fx_addsy;
-
- /* If this relocation is attached to a symbol then it's ok
- to output it. */
- if (fix_ptr->fx_r_type == 0)
- {
- /* cons likes to create reloc32's whatever the size of the reloc. */
- switch (fix_ptr->fx_size)
- {
- case 2:
- intr->r_type = R_IMM16;
- break;
- case 1:
- intr->r_type = R_IMM8;
- break;
- case 4:
- intr->r_type = R_IMM32;
- break;
- default:
- abort ();
- }
- }
- else
- intr->r_type = fix_ptr->fx_r_type;
-
- intr->r_vaddr = fix_ptr->fx_frag->fr_address + fix_ptr->fx_where + base;
- intr->r_offset = fix_ptr->fx_offset;
-
- if (symbol_ptr)
- intr->r_symndx = symbol_ptr->sy_number;
- else
- intr->r_symndx = -1;
-}
diff --git a/contrib/binutils/gas/config/tc-z8k.h b/contrib/binutils/gas/config/tc-z8k.h
deleted file mode 100644
index d1899e1..0000000
--- a/contrib/binutils/gas/config/tc-z8k.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/* This file is tc-z8k.h
- Copyright 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1995, 1997, 1998,
- 2000
- Free Software Foundation, Inc.
-
- This file is part of GAS, the GNU Assembler.
-
- GAS is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2, or (at your option)
- any later version.
-
- GAS is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with GAS; see the file COPYING. If not, write to the Free
- Software Foundation, 59 Temple Place - Suite 330, Boston, MA
- 02111-1307, USA. */
-
-#define TC_Z8K
-#define TARGET_BYTES_BIG_ENDIAN 1
-
-#if ANSI_PROTOTYPES
-struct internal_reloc;
-#endif
-
-#define WORKING_DOT_WORD
-
-#ifndef BFD_ASSEMBLER
-#define LOCAL_LABEL(x) 0
-#endif
-
-/* This macro translates between an internal fix and an coff reloc type */
-#define TC_COFF_FIX2RTYPE(fixP) abort ();
-
-#define BFD_ARCH bfd_arch_z8k
-#define COFF_MAGIC 0x8000
-#define TC_COUNT_RELOC(x) (1)
-#define IGNORE_NONSTANDARD_ESCAPES
-
-#define TC_RELOC_MANGLE(s,a,b,c) tc_reloc_mangle(a,b,c)
-extern void tc_reloc_mangle
- PARAMS ((struct fix *, struct internal_reloc *, bfd_vma));
-
-#define DO_NOT_STRIP 0
-#define LISTING_HEADER "Zilog Z8000 GAS "
-#define NEED_FX_R_TYPE 1
-#define RELOC_32 1234
-
-#define md_operand(x)
OpenPOWER on IntegriCloud