1999-05-03 07:29:11 +00:00
|
|
|
/* tc-w65.c -- Assemble code for the W65816
|
2005-02-23 12:28:06 +00:00
|
|
|
Copyright 1995, 1998, 2000, 2001, 2002, 2005
|
|
|
|
Free Software Foundation, Inc.
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
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
|
2005-05-05 09:13:19 +00:00
|
|
|
Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA
|
|
|
|
02110-1301, USA. */
|
1999-05-03 07:29:11 +00:00
|
|
|
|
2000-07-17 20:59:47 +00:00
|
|
|
/* Written By Steve Chamberlain <sac@cygnus.com>. */
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include "as.h"
|
|
|
|
#include "bfd.h"
|
|
|
|
#include "subsegs.h"
|
|
|
|
#define DEFINE_TABLE
|
|
|
|
#include "../opcodes/w65-opc.h"
|
|
|
|
|
2005-03-24 20:40:28 +00:00
|
|
|
const char comment_chars[] = "!";
|
2002-06-08 07:37:16 +00:00
|
|
|
const char line_separator_chars[] = ";";
|
2005-03-24 20:40:28 +00:00
|
|
|
const char line_comment_chars[] = "!#";
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
/* This table describes all the machine specific pseudo-ops the assembler
|
|
|
|
has to support. The fields are:
|
2000-07-17 20:59:47 +00:00
|
|
|
|
1999-05-03 07:29:11 +00:00
|
|
|
pseudo-op name without dot
|
|
|
|
function to call to execute this pseudo-op
|
2005-03-24 20:40:28 +00:00
|
|
|
Integer arg to pass to the function. */
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
#define OP_BCC 0x90
|
|
|
|
#define OP_BCS 0xB0
|
|
|
|
#define OP_BEQ 0xF0
|
|
|
|
#define OP_BMI 0x30
|
|
|
|
#define OP_BNE 0xD0
|
|
|
|
#define OP_BPL 0x10
|
|
|
|
#define OP_BRA 0x80
|
|
|
|
#define OP_BRL 0x82
|
|
|
|
#define OP_BVC 0x50
|
|
|
|
#define OP_BVS 0x70
|
|
|
|
|
2005-03-24 20:40:28 +00:00
|
|
|
static int M; /* M flag. */
|
|
|
|
static int X; /* X flag. */
|
2002-12-03 12:01:45 +00:00
|
|
|
|
2005-03-24 20:40:28 +00:00
|
|
|
/* This function is called once, at assembler startup time. This
|
|
|
|
should set up all the tables, etc that the MD part of the assembler
|
|
|
|
needs. */
|
|
|
|
|
|
|
|
static void
|
|
|
|
s_longa (int xmode)
|
|
|
|
{
|
|
|
|
int *p = xmode ? &X : &M;
|
|
|
|
|
|
|
|
while (*input_line_pointer == ' ')
|
|
|
|
input_line_pointer++;
|
|
|
|
if (strncmp (input_line_pointer, "on", 2) == 0)
|
|
|
|
{
|
|
|
|
input_line_pointer += 2;
|
|
|
|
*p = 0;
|
|
|
|
}
|
|
|
|
else if (strncmp (input_line_pointer, "off", 3) == 0)
|
|
|
|
{
|
|
|
|
*p = 1;
|
|
|
|
input_line_pointer += 3;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
as_bad (_("need on or off."));
|
|
|
|
demand_empty_rest_of_line ();
|
|
|
|
}
|
2000-11-16 00:59:49 +00:00
|
|
|
|
2005-03-24 20:40:28 +00:00
|
|
|
const pseudo_typeS md_pseudo_table[] =
|
|
|
|
{
|
1999-05-03 07:29:11 +00:00
|
|
|
{"int", cons, 2},
|
|
|
|
{"word", cons, 2},
|
|
|
|
{"longa", s_longa, 0},
|
|
|
|
{"longi", s_longa, 1},
|
|
|
|
{0, 0, 0}
|
|
|
|
};
|
|
|
|
|
|
|
|
const char EXP_CHARS[] = "eE";
|
|
|
|
|
2000-11-16 00:59:49 +00:00
|
|
|
/* Chars that mean this number is a floating point constant. */
|
1999-05-03 07:29:11 +00:00
|
|
|
/* As in 0f12.456 */
|
|
|
|
/* or 0d1.2345e12 */
|
|
|
|
const char FLT_CHARS[] = "rRsSfFdDxXpP";
|
|
|
|
|
2000-11-16 00:59:49 +00:00
|
|
|
/* Opcode mnemonics */
|
|
|
|
static struct hash_control *opcode_hash_control;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
2005-03-24 20:40:28 +00:00
|
|
|
#define C(a, b) ENCODE_RELAX(a,b)
|
|
|
|
#define ENCODE_RELAX(what, length) (((what) << 2) + (length))
|
1999-05-03 07:29:11 +00:00
|
|
|
|
2005-03-24 20:40:28 +00:00
|
|
|
#define GET_WHAT(x) (((x) >> 2))
|
1999-05-03 07:29:11 +00:00
|
|
|
|
2005-03-24 20:40:28 +00:00
|
|
|
#define BYTE_DISP 1
|
|
|
|
#define WORD_DISP 2
|
1999-05-03 07:29:11 +00:00
|
|
|
#define UNDEF_BYTE_DISP 0
|
|
|
|
#define UNDEF_WORD_DISP 3
|
|
|
|
#define COND_BRANCH 1
|
|
|
|
#define UNCOND_BRANCH 2
|
2005-03-24 20:40:28 +00:00
|
|
|
#define END 3
|
1999-05-03 07:29:11 +00:00
|
|
|
|
2005-03-24 20:40:28 +00:00
|
|
|
#define BYTE_F 127 /* How far we can branch forwards. */
|
|
|
|
#define BYTE_B -126 /* How far we can branch backwards. */
|
1999-05-03 07:29:11 +00:00
|
|
|
#define WORD_F 32767
|
|
|
|
#define WORD_B 32768
|
|
|
|
|
2005-03-24 20:40:28 +00:00
|
|
|
relax_typeS md_relax_table[C (END, 0)] =
|
|
|
|
{
|
2001-04-05 04:21:36 +00:00
|
|
|
{ 0, 0, 0, 0 },
|
|
|
|
{ 0, 0, 0, 0 },
|
|
|
|
{ 0, 0, 0, 0 },
|
|
|
|
{ 0, 0, 0, 0 },
|
|
|
|
|
|
|
|
/* COND_BRANCH */
|
|
|
|
{ 0, 0, 0, 0 }, /* UNDEF_BYTE_DISP */
|
|
|
|
{ BYTE_F, BYTE_B, 2, C (COND_BRANCH, WORD_DISP) }, /* BYTE_DISP */
|
|
|
|
{ WORD_F, WORD_B, 5, 0 }, /* WORD_DISP */
|
|
|
|
{ 0, 0, 5, 0 }, /* UNDEF_WORD_DISP */
|
|
|
|
|
|
|
|
/* UNCOND_BRANCH */
|
|
|
|
{ 0, 0, 0, 0 }, /* UNDEF_BYTE_DISP */
|
|
|
|
{ BYTE_F, BYTE_B, 2, C (UNCOND_BRANCH, WORD_DISP) }, /* BYTE_DISP */
|
|
|
|
{ WORD_F, WORD_B, 3, 0 }, /* WORD_DISP */
|
|
|
|
{ 0, 0, 3, 0 } /* UNDEF_WORD_DISP */
|
|
|
|
};
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
void
|
2005-03-24 20:40:28 +00:00
|
|
|
md_begin (void)
|
1999-05-03 07:29:11 +00:00
|
|
|
{
|
2002-12-03 12:01:45 +00:00
|
|
|
const struct opinfo *opcode;
|
1999-05-03 07:29:11 +00:00
|
|
|
char *prev_name = "";
|
|
|
|
|
|
|
|
opcode_hash_control = hash_new ();
|
|
|
|
|
2000-07-17 20:59:47 +00:00
|
|
|
/* Insert unique names into hash table. */
|
1999-05-03 07:29:11 +00:00
|
|
|
for (opcode = optable; opcode->name; opcode++)
|
|
|
|
{
|
|
|
|
if (strcmp (prev_name, opcode->name))
|
|
|
|
{
|
|
|
|
prev_name = opcode->name;
|
|
|
|
hash_insert (opcode_hash_control, opcode->name, (char *) opcode);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
flag_signed_overflow_ok = 1;
|
|
|
|
}
|
|
|
|
|
2005-03-24 20:40:28 +00:00
|
|
|
static expressionS immediate; /* Absolute expression. */
|
|
|
|
static expressionS immediate1; /* Absolute expression. */
|
1999-05-03 07:29:11 +00:00
|
|
|
int expr_size;
|
|
|
|
int expr_shift;
|
|
|
|
int tc_cons_reloc;
|
2000-07-17 20:59:47 +00:00
|
|
|
|
1999-05-03 07:29:11 +00:00
|
|
|
void
|
2005-03-24 20:40:28 +00:00
|
|
|
w65_expression (expressionS *dest)
|
1999-05-03 07:29:11 +00:00
|
|
|
{
|
|
|
|
expr_size = 0;
|
|
|
|
expr_shift = 0;
|
|
|
|
tc_cons_reloc = 0;
|
|
|
|
while (*input_line_pointer == ' ')
|
|
|
|
input_line_pointer++;
|
|
|
|
|
|
|
|
if (*input_line_pointer == '<')
|
|
|
|
{
|
|
|
|
expr_size = 1;
|
|
|
|
input_line_pointer++;
|
|
|
|
}
|
|
|
|
else if (*input_line_pointer == '>')
|
|
|
|
{
|
|
|
|
expr_shift = 1;
|
|
|
|
input_line_pointer++;
|
|
|
|
}
|
|
|
|
else if (*input_line_pointer == '^')
|
|
|
|
{
|
|
|
|
expr_shift = 2;
|
|
|
|
input_line_pointer++;
|
|
|
|
}
|
|
|
|
|
|
|
|
expr (0, dest);
|
|
|
|
}
|
|
|
|
|
|
|
|
int amode;
|
2000-07-17 20:59:47 +00:00
|
|
|
|
|
|
|
static char *
|
2005-03-24 20:40:28 +00:00
|
|
|
parse_exp (char *s)
|
1999-05-03 07:29:11 +00:00
|
|
|
{
|
|
|
|
char *save;
|
|
|
|
char *new;
|
|
|
|
|
|
|
|
save = input_line_pointer;
|
|
|
|
input_line_pointer = s;
|
2002-12-03 12:01:45 +00:00
|
|
|
w65_expression (&immediate);
|
1999-05-03 07:29:11 +00:00
|
|
|
if (immediate.X_op == O_absent)
|
|
|
|
as_bad (_("missing operand"));
|
|
|
|
new = input_line_pointer;
|
|
|
|
input_line_pointer = save;
|
|
|
|
return new;
|
|
|
|
}
|
|
|
|
|
2000-07-17 20:59:47 +00:00
|
|
|
static char *
|
2005-03-24 20:40:28 +00:00
|
|
|
get_operands (const struct opinfo *info, char *ptr)
|
1999-05-03 07:29:11 +00:00
|
|
|
{
|
2005-03-24 20:40:28 +00:00
|
|
|
int override_len = 0;
|
|
|
|
int bytes = 0;
|
2000-07-17 20:59:47 +00:00
|
|
|
|
1999-05-03 07:29:11 +00:00
|
|
|
while (*ptr == ' ')
|
|
|
|
ptr++;
|
|
|
|
|
|
|
|
if (ptr[0] == '#')
|
|
|
|
{
|
|
|
|
ptr++;
|
|
|
|
switch (info->amode)
|
|
|
|
{
|
|
|
|
case ADDR_IMMTOI:
|
|
|
|
bytes = X ? 1 : 2;
|
|
|
|
amode = ADDR_IMMTOI;
|
|
|
|
break;
|
|
|
|
case ADDR_IMMTOA:
|
|
|
|
bytes = M ? 1 : 2;
|
|
|
|
amode = ADDR_IMMTOA;
|
|
|
|
break;
|
|
|
|
case ADDR_IMMCOP:
|
|
|
|
bytes = 1;
|
|
|
|
amode = ADDR_IMMCOP;
|
|
|
|
break;
|
|
|
|
case ADDR_DIR:
|
|
|
|
bytes = 2;
|
|
|
|
amode = ADDR_ABS;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
abort ();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
ptr = parse_exp (ptr);
|
|
|
|
}
|
|
|
|
else if (ptr[0] == '!')
|
|
|
|
{
|
|
|
|
ptr = parse_exp (ptr + 1);
|
|
|
|
if (ptr[0] == ',')
|
|
|
|
{
|
|
|
|
if (ptr[1] == 'y')
|
|
|
|
{
|
|
|
|
amode = ADDR_ABS_IDX_Y;
|
|
|
|
bytes = 2;
|
|
|
|
ptr += 2;
|
|
|
|
}
|
|
|
|
else if (ptr[1] == 'x')
|
|
|
|
{
|
|
|
|
amode = ADDR_ABS_IDX_X;
|
|
|
|
bytes = 2;
|
|
|
|
ptr += 2;
|
|
|
|
}
|
|
|
|
else
|
2005-03-24 20:40:28 +00:00
|
|
|
as_bad (_("syntax error after <exp"));
|
1999-05-03 07:29:11 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
amode = ADDR_ABS;
|
|
|
|
bytes = 2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (ptr[0] == '>')
|
|
|
|
{
|
|
|
|
ptr = parse_exp (ptr + 1);
|
|
|
|
if (ptr[0] == ',' && ptr[1] == 'x')
|
|
|
|
{
|
|
|
|
amode = ADDR_ABS_LONG_IDX_X;
|
|
|
|
bytes = 3;
|
|
|
|
ptr += 2;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
amode = ADDR_ABS_LONG;
|
|
|
|
bytes = 3;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (ptr[0] == '<')
|
|
|
|
{
|
|
|
|
ptr = parse_exp (ptr + 1);
|
|
|
|
if (ptr[0] == ',')
|
|
|
|
{
|
|
|
|
if (ptr[1] == 'y')
|
|
|
|
{
|
|
|
|
amode = ADDR_DIR_IDX_Y;
|
|
|
|
ptr += 2;
|
|
|
|
bytes = 2;
|
|
|
|
}
|
|
|
|
else if (ptr[1] == 'x')
|
|
|
|
{
|
|
|
|
amode = ADDR_DIR_IDX_X;
|
|
|
|
ptr += 2;
|
|
|
|
bytes = 2;
|
|
|
|
}
|
|
|
|
else
|
2005-03-24 20:40:28 +00:00
|
|
|
as_bad (_("syntax error after <exp"));
|
1999-05-03 07:29:11 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
amode = ADDR_DIR;
|
|
|
|
bytes = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (ptr[0] == 'a')
|
2005-03-24 20:40:28 +00:00
|
|
|
amode = ADDR_ACC;
|
1999-05-03 07:29:11 +00:00
|
|
|
else if (ptr[0] == '(')
|
|
|
|
{
|
|
|
|
/* Look for (exp),y
|
|
|
|
(<exp),y
|
|
|
|
(exp,x)
|
|
|
|
(<exp,x)
|
|
|
|
(exp)
|
|
|
|
(!exp)
|
|
|
|
(exp)
|
|
|
|
(<exp)
|
|
|
|
(exp,x)
|
|
|
|
(!exp,x)
|
|
|
|
(exp,s)
|
|
|
|
(exp,s),y */
|
|
|
|
|
|
|
|
ptr++;
|
|
|
|
if (ptr[0] == '<')
|
|
|
|
{
|
|
|
|
override_len = 1;
|
|
|
|
ptr++;
|
|
|
|
}
|
|
|
|
else if (ptr[0] == '!')
|
|
|
|
{
|
|
|
|
override_len = 2;
|
|
|
|
ptr++;
|
|
|
|
}
|
|
|
|
else if (ptr[0] == '>')
|
|
|
|
{
|
|
|
|
override_len = 3;
|
|
|
|
ptr++;
|
|
|
|
}
|
|
|
|
else
|
2005-03-24 20:40:28 +00:00
|
|
|
override_len = 0;
|
|
|
|
|
1999-05-03 07:29:11 +00:00
|
|
|
ptr = parse_exp (ptr);
|
|
|
|
|
|
|
|
if (ptr[0] == ',')
|
|
|
|
{
|
|
|
|
ptr++;
|
|
|
|
if (ptr[0] == 'x' && ptr[1] == ')')
|
|
|
|
{
|
|
|
|
ptr += 2;
|
|
|
|
|
|
|
|
if (override_len == 1)
|
|
|
|
{
|
|
|
|
amode = ADDR_DIR_IDX_IND_X;
|
|
|
|
bytes = 2;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
amode = ADDR_ABS_IND_IDX;
|
|
|
|
bytes = 2;
|
|
|
|
}
|
|
|
|
}
|
2000-07-17 20:59:47 +00:00
|
|
|
else if (ptr[0] == 's' && ptr[1] == ')'
|
|
|
|
&& ptr[2] == ',' && ptr[3] == 'y')
|
1999-05-03 07:29:11 +00:00
|
|
|
{
|
|
|
|
amode = ADDR_STACK_REL_INDX_IDX;
|
|
|
|
bytes = 1;
|
|
|
|
ptr += 4;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (ptr[0] == ')')
|
|
|
|
{
|
|
|
|
if (ptr[1] == ',' && ptr[2] == 'y')
|
|
|
|
{
|
|
|
|
amode = ADDR_DIR_IND_IDX_Y;
|
|
|
|
ptr += 3;
|
|
|
|
bytes = 2;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (override_len == 1)
|
|
|
|
{
|
|
|
|
amode = ADDR_DIR_IND;
|
|
|
|
bytes = 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
amode = ADDR_ABS_IND;
|
|
|
|
bytes = 2;
|
|
|
|
}
|
|
|
|
ptr++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (ptr[0] == '[')
|
|
|
|
{
|
|
|
|
ptr = parse_exp (ptr + 1);
|
2005-03-24 20:40:28 +00:00
|
|
|
|
1999-05-03 07:29:11 +00:00
|
|
|
if (ptr[0] == ']')
|
|
|
|
{
|
|
|
|
ptr++;
|
|
|
|
if (ptr[0] == ',' && ptr[1] == 'y')
|
|
|
|
{
|
|
|
|
bytes = 1;
|
|
|
|
amode = ADDR_DIR_IND_IDX_Y_LONG;
|
|
|
|
ptr += 2;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2000-07-17 20:59:47 +00:00
|
|
|
if (info->code == O_jmp)
|
1999-05-03 07:29:11 +00:00
|
|
|
{
|
2000-07-17 20:59:47 +00:00
|
|
|
bytes = 2;
|
|
|
|
amode = ADDR_ABS_IND_LONG;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
bytes = 1;
|
|
|
|
amode = ADDR_DIR_IND_LONG;
|
|
|
|
}
|
1999-05-03 07:29:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2002-12-03 12:01:45 +00:00
|
|
|
ptr = parse_exp (ptr);
|
1999-05-03 07:29:11 +00:00
|
|
|
if (ptr[0] == ',')
|
|
|
|
{
|
|
|
|
if (ptr[1] == 'y')
|
|
|
|
{
|
|
|
|
if (override_len == 1)
|
|
|
|
{
|
|
|
|
bytes = 1;
|
|
|
|
amode = ADDR_DIR_IDX_Y;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
amode = ADDR_ABS_IDX_Y;
|
|
|
|
bytes = 2;
|
|
|
|
}
|
|
|
|
ptr += 2;
|
|
|
|
}
|
|
|
|
else if (ptr[1] == 'x')
|
|
|
|
{
|
|
|
|
if (override_len == 1)
|
|
|
|
{
|
|
|
|
amode = ADDR_DIR_IDX_X;
|
|
|
|
bytes = 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
amode = ADDR_ABS_IDX_X;
|
|
|
|
bytes = 2;
|
|
|
|
}
|
|
|
|
ptr += 2;
|
|
|
|
}
|
|
|
|
else if (ptr[1] == 's')
|
|
|
|
{
|
|
|
|
bytes = 1;
|
|
|
|
amode = ADDR_STACK_REL;
|
|
|
|
ptr += 2;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
bytes = 1;
|
|
|
|
immediate1 = immediate;
|
|
|
|
ptr = parse_exp (ptr + 1);
|
|
|
|
amode = ADDR_BLOCK_MOVE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
switch (info->amode)
|
|
|
|
{
|
|
|
|
case ADDR_PC_REL:
|
|
|
|
amode = ADDR_PC_REL;
|
|
|
|
bytes = 1;
|
|
|
|
break;
|
|
|
|
case ADDR_PC_REL_LONG:
|
|
|
|
amode = ADDR_PC_REL_LONG;
|
|
|
|
bytes = 2;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
if (override_len == 1)
|
|
|
|
{
|
|
|
|
amode = ADDR_DIR;
|
|
|
|
bytes = 1;
|
|
|
|
}
|
|
|
|
else if (override_len == 3)
|
|
|
|
{
|
|
|
|
bytes = 3;
|
|
|
|
amode = ADDR_ABS_LONG;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
amode = ADDR_ABS;
|
|
|
|
bytes = 2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (bytes)
|
|
|
|
{
|
|
|
|
case 1:
|
|
|
|
switch (expr_shift)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
if (amode == ADDR_DIR)
|
2000-07-17 20:59:47 +00:00
|
|
|
tc_cons_reloc = R_W65_DP;
|
1999-05-03 07:29:11 +00:00
|
|
|
else
|
2000-07-17 20:59:47 +00:00
|
|
|
tc_cons_reloc = R_W65_ABS8;
|
1999-05-03 07:29:11 +00:00
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
tc_cons_reloc = R_W65_ABS8S8;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
tc_cons_reloc = R_W65_ABS8S16;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
switch (expr_shift)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
tc_cons_reloc = R_W65_ABS16;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
tc_cons_reloc = R_W65_ABS16S8;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
tc_cons_reloc = R_W65_ABS16S16;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return ptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Passed a pointer to a list of opcodes which use different
|
|
|
|
addressing modes, return the opcode which matches the opcodes
|
2000-07-17 20:59:47 +00:00
|
|
|
provided. */
|
1999-05-03 07:29:11 +00:00
|
|
|
|
2002-12-03 12:01:45 +00:00
|
|
|
static const struct opinfo *
|
2005-03-24 20:40:28 +00:00
|
|
|
get_specific (const struct opinfo *opcode)
|
1999-05-03 07:29:11 +00:00
|
|
|
{
|
|
|
|
int ocode = opcode->code;
|
|
|
|
|
|
|
|
for (; opcode->code == ocode; opcode++)
|
2005-03-24 20:40:28 +00:00
|
|
|
if (opcode->amode == amode)
|
|
|
|
return opcode;
|
|
|
|
|
1999-05-03 07:29:11 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2000-06-25 17:59:22 +00:00
|
|
|
/* Now we know what sort of opcodes it is, let's build the bytes. */
|
2000-07-17 20:59:47 +00:00
|
|
|
|
1999-05-03 07:29:11 +00:00
|
|
|
static void
|
2005-03-24 20:40:28 +00:00
|
|
|
build_Mytes (const struct opinfo *opcode)
|
1999-05-03 07:29:11 +00:00
|
|
|
{
|
|
|
|
int size;
|
|
|
|
int type;
|
|
|
|
int pcrel;
|
|
|
|
char *output;
|
|
|
|
|
|
|
|
if (opcode->amode == ADDR_IMPLIED)
|
2005-03-24 20:40:28 +00:00
|
|
|
output = frag_more (1);
|
|
|
|
|
1999-05-03 07:29:11 +00:00
|
|
|
else if (opcode->amode == ADDR_PC_REL)
|
|
|
|
{
|
|
|
|
int type;
|
2000-07-17 20:59:47 +00:00
|
|
|
|
|
|
|
/* This is a relaxable insn, so we do some special handling. */
|
1999-05-03 07:29:11 +00:00
|
|
|
type = opcode->val == OP_BRA ? UNCOND_BRANCH : COND_BRANCH;
|
|
|
|
output = frag_var (rs_machine_dependent,
|
|
|
|
md_relax_table[C (type, WORD_DISP)].rlx_length,
|
|
|
|
md_relax_table[C (type, BYTE_DISP)].rlx_length,
|
|
|
|
C (type, UNDEF_BYTE_DISP),
|
|
|
|
immediate.X_add_symbol,
|
|
|
|
immediate.X_add_number,
|
|
|
|
0);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
switch (opcode->amode)
|
|
|
|
{
|
|
|
|
GETINFO (size, type, pcrel);
|
2002-12-03 12:01:45 +00:00
|
|
|
default:
|
|
|
|
abort ();
|
1999-05-03 07:29:11 +00:00
|
|
|
}
|
|
|
|
|
2000-07-17 20:59:47 +00:00
|
|
|
/* If something special was done in the expression modify the
|
|
|
|
reloc type. */
|
1999-05-03 07:29:11 +00:00
|
|
|
if (tc_cons_reloc)
|
2000-07-17 20:59:47 +00:00
|
|
|
type = tc_cons_reloc;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
2000-07-17 20:59:47 +00:00
|
|
|
/* 1 byte for the opcode + the bytes for the addrmode. */
|
1999-05-03 07:29:11 +00:00
|
|
|
output = frag_more (size + 1);
|
|
|
|
|
|
|
|
if (opcode->amode == ADDR_BLOCK_MOVE)
|
|
|
|
{
|
2000-07-17 20:59:47 +00:00
|
|
|
/* Two relocs for this one. */
|
1999-05-03 07:29:11 +00:00
|
|
|
fix_new_exp (frag_now,
|
|
|
|
output + 1 - frag_now->fr_literal,
|
|
|
|
1,
|
|
|
|
&immediate,
|
|
|
|
0,
|
|
|
|
R_W65_ABS8S16);
|
|
|
|
|
|
|
|
fix_new_exp (frag_now,
|
|
|
|
output + 2 - frag_now->fr_literal,
|
|
|
|
1,
|
|
|
|
&immediate1,
|
|
|
|
0,
|
|
|
|
R_W65_ABS8S16);
|
|
|
|
}
|
|
|
|
else if (type >= 0
|
|
|
|
&& opcode->amode != ADDR_IMPLIED
|
|
|
|
&& opcode->amode != ADDR_ACC
|
|
|
|
&& opcode->amode != ADDR_STACK)
|
|
|
|
{
|
|
|
|
fix_new_exp (frag_now,
|
|
|
|
output + 1 - frag_now->fr_literal,
|
|
|
|
size,
|
|
|
|
&immediate,
|
|
|
|
pcrel,
|
|
|
|
type);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
output[0] = opcode->val;
|
|
|
|
}
|
|
|
|
|
2000-07-17 20:59:47 +00:00
|
|
|
/* 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. */
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
void
|
2005-03-24 20:40:28 +00:00
|
|
|
md_assemble (char *str)
|
1999-05-03 07:29:11 +00:00
|
|
|
{
|
2002-12-03 12:01:45 +00:00
|
|
|
const struct opinfo *opcode;
|
1999-05-03 07:29:11 +00:00
|
|
|
char name[20];
|
|
|
|
|
|
|
|
/* Drop leading whitespace */
|
|
|
|
while (*str == ' ')
|
|
|
|
str++;
|
|
|
|
|
2005-03-24 20:40:28 +00:00
|
|
|
/* All opcodes are three letters. */
|
1999-05-03 07:29:11 +00:00
|
|
|
name[0] = str[0];
|
|
|
|
name[1] = str[1];
|
|
|
|
name[2] = str[2];
|
|
|
|
name[3] = 0;
|
|
|
|
|
|
|
|
tc_cons_reloc = 0;
|
|
|
|
str += 3;
|
|
|
|
opcode = (struct opinfo *) hash_find (opcode_hash_control, name);
|
|
|
|
|
|
|
|
if (opcode == NULL)
|
|
|
|
{
|
|
|
|
as_bad (_("unknown opcode"));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (opcode->amode != ADDR_IMPLIED
|
|
|
|
&& opcode->amode != ADDR_STACK)
|
|
|
|
{
|
|
|
|
get_operands (opcode, str);
|
|
|
|
opcode = get_specific (opcode);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (opcode == 0)
|
|
|
|
{
|
2000-07-17 20:59:47 +00:00
|
|
|
/* Couldn't find an opcode which matched the operands. */
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
char *where = frag_more (1);
|
|
|
|
|
|
|
|
where[0] = 0x0;
|
|
|
|
where[1] = 0x0;
|
|
|
|
as_bad (_("invalid operands for opcode"));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
build_Mytes (opcode);
|
|
|
|
}
|
|
|
|
|
|
|
|
symbolS *
|
2005-03-24 20:40:28 +00:00
|
|
|
md_undefined_symbol (char *name ATTRIBUTE_UNUSED)
|
1999-05-03 07:29:11 +00:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2000-07-17 20:59:47 +00:00
|
|
|
/* Various routines to kill one day. */
|
|
|
|
/* Equal to MAX_PRECISION in atof-ieee.c. */
|
1999-05-03 07:29:11 +00:00
|
|
|
#define MAX_LITTLENUMS 6
|
|
|
|
|
2000-07-17 20:59:47 +00:00
|
|
|
/* 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. */
|
|
|
|
|
1999-05-03 07:29:11 +00:00
|
|
|
char *
|
2005-03-24 20:40:28 +00:00
|
|
|
md_atof (int type, char *litP, int *sizeP)
|
1999-05-03 07:29:11 +00:00
|
|
|
{
|
|
|
|
int prec;
|
|
|
|
LITTLENUM_TYPE words[MAX_LITTLENUMS];
|
|
|
|
LITTLENUM_TYPE *wordP;
|
|
|
|
char *t;
|
|
|
|
|
|
|
|
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_NTOF()");
|
|
|
|
}
|
|
|
|
t = atof_ieee (input_line_pointer, type, words);
|
|
|
|
if (t)
|
|
|
|
input_line_pointer = t;
|
|
|
|
|
|
|
|
*sizeP = prec * sizeof (LITTLENUM_TYPE);
|
|
|
|
for (wordP = words + prec - 1; prec--;)
|
|
|
|
{
|
|
|
|
md_number_to_chars (litP, (valueT) (*wordP--), sizeof (LITTLENUM_TYPE));
|
|
|
|
litP += sizeof (LITTLENUM_TYPE);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2005-03-24 20:40:28 +00:00
|
|
|
md_parse_option (int c ATTRIBUTE_UNUSED, char *a ATTRIBUTE_UNUSED)
|
1999-05-03 07:29:11 +00:00
|
|
|
{
|
2002-08-26 08:55:33 +00:00
|
|
|
return 0;
|
1999-05-03 07:29:11 +00:00
|
|
|
}
|
|
|
|
|
2000-07-17 20:59:47 +00:00
|
|
|
/* Called after relaxing, change the frags so they know how big they
|
|
|
|
are. */
|
|
|
|
|
1999-05-03 07:29:11 +00:00
|
|
|
void
|
2005-03-24 20:40:28 +00:00
|
|
|
md_convert_frag (object_headers *headers ATTRIBUTE_UNUSED,
|
|
|
|
segT seg ATTRIBUTE_UNUSED,
|
|
|
|
fragS *fragP)
|
1999-05-03 07:29:11 +00:00
|
|
|
{
|
|
|
|
int disp_size = 0;
|
|
|
|
int inst_size = 0;
|
2000-07-17 20:59:47 +00:00
|
|
|
unsigned char *buffer =
|
|
|
|
(unsigned char *) (fragP->fr_fix + fragP->fr_literal);
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
switch (fragP->fr_subtype)
|
|
|
|
{
|
|
|
|
case C (COND_BRANCH, BYTE_DISP):
|
|
|
|
case C (UNCOND_BRANCH, BYTE_DISP):
|
|
|
|
disp_size = 1;
|
|
|
|
inst_size = 1;
|
|
|
|
break;
|
|
|
|
|
2000-07-17 20:59:47 +00:00
|
|
|
/* Conditional branches to a known 16 bit displacement. */
|
1999-05-03 07:29:11 +00:00
|
|
|
case C (COND_BRANCH, WORD_DISP):
|
|
|
|
switch (buffer[0])
|
|
|
|
{
|
|
|
|
case OP_BCC:
|
|
|
|
case OP_BCS:
|
|
|
|
case OP_BEQ:
|
|
|
|
case OP_BMI:
|
|
|
|
case OP_BNE:
|
|
|
|
case OP_BPL:
|
|
|
|
case OP_BVS:
|
|
|
|
case OP_BVC:
|
2005-03-24 20:40:28 +00:00
|
|
|
/* Invert the sense of the test. */
|
1999-05-03 07:29:11 +00:00
|
|
|
buffer[0] ^= 0x20;
|
2005-03-24 20:40:28 +00:00
|
|
|
buffer[1] = 3; /* Jump over following brl. */
|
1999-05-03 07:29:11 +00:00
|
|
|
buffer[2] = OP_BRL;
|
|
|
|
buffer[3] = 0;
|
|
|
|
buffer[4] = 0;
|
|
|
|
disp_size = 2;
|
|
|
|
inst_size = 3;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
abort ();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case C (UNCOND_BRANCH, WORD_DISP):
|
2000-07-17 20:59:47 +00:00
|
|
|
/* Unconditional branches to a known 16 bit displacement. */
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
switch (buffer[0])
|
|
|
|
{
|
|
|
|
case OP_BRA:
|
|
|
|
buffer[0] = OP_BRL;
|
|
|
|
disp_size = 2;
|
|
|
|
inst_size = 1;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
abort ();
|
|
|
|
}
|
|
|
|
break;
|
2000-07-17 20:59:47 +00:00
|
|
|
/* Got to create a branch over a reloc here. */
|
1999-05-03 07:29:11 +00:00
|
|
|
case C (COND_BRANCH, UNDEF_WORD_DISP):
|
2005-03-24 20:40:28 +00:00
|
|
|
buffer[0] ^= 0x20; /* Invert test. */
|
1999-05-03 07:29:11 +00:00
|
|
|
buffer[1] = 3;
|
|
|
|
buffer[2] = OP_BRL;
|
|
|
|
buffer[3] = 0;
|
|
|
|
buffer[4] = 0;
|
|
|
|
fix_new (fragP,
|
|
|
|
fragP->fr_fix + 3,
|
|
|
|
4,
|
|
|
|
fragP->fr_symbol,
|
|
|
|
fragP->fr_offset,
|
|
|
|
0,
|
|
|
|
R_W65_PCR16);
|
|
|
|
|
|
|
|
fragP->fr_fix += disp_size + inst_size;
|
|
|
|
fragP->fr_var = 0;
|
|
|
|
break;
|
|
|
|
case C (UNCOND_BRANCH, UNDEF_WORD_DISP):
|
|
|
|
buffer[0] = OP_BRL;
|
|
|
|
buffer[1] = 0;
|
|
|
|
buffer[2] = 0;
|
|
|
|
fix_new (fragP,
|
|
|
|
fragP->fr_fix + 1,
|
|
|
|
4,
|
|
|
|
fragP->fr_symbol,
|
|
|
|
fragP->fr_offset,
|
|
|
|
0,
|
|
|
|
R_W65_PCR16);
|
|
|
|
|
|
|
|
fragP->fr_fix += disp_size + inst_size;
|
|
|
|
fragP->fr_var = 0;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
abort ();
|
|
|
|
}
|
|
|
|
if (inst_size)
|
|
|
|
{
|
2000-07-17 20:59:47 +00:00
|
|
|
/* Get the address of the end of the instruction. */
|
|
|
|
int next_inst = (fragP->fr_fix + fragP->fr_address
|
|
|
|
+ disp_size + inst_size);
|
1999-05-03 07:29:11 +00:00
|
|
|
int targ_addr = (S_GET_VALUE (fragP->fr_symbol) +
|
|
|
|
fragP->fr_offset);
|
|
|
|
int disp = targ_addr - next_inst;
|
|
|
|
|
2005-02-23 12:28:06 +00:00
|
|
|
md_number_to_chars ((char *) buffer + inst_size, disp, disp_size);
|
1999-05-03 07:29:11 +00:00
|
|
|
fragP->fr_fix += disp_size + inst_size;
|
|
|
|
fragP->fr_var = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
valueT
|
2005-03-24 20:40:28 +00:00
|
|
|
md_section_align (segT seg, valueT size)
|
1999-05-03 07:29:11 +00:00
|
|
|
{
|
|
|
|
return ((size + (1 << section_alignment[(int) seg]) - 1)
|
|
|
|
& (-1 << section_alignment[(int) seg]));
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
gas:
* cgen.c, cgen.h, tc.h, write.c, config/obj-coff.c
* config/tc-a29k.c, config/tc-alpha.c, config/tc-alpha.h
* config/tc-arc.c, config/tc-arc.h, config/tc-arm.c
* config/tc-arm.h, config/tc-avr.c, config/tc-avr.h
* config/tc-cris.c, config/tc-crx.c, config/tc-d10v.c
* config/tc-d10v.h, config/tc-d30v.c, config/tc-d30v.h
* config/tc-dlx.c, config/tc-dlx.h, config/tc-fr30.h
* config/tc-frv.c, config/tc-frv.h, config/tc-h8300.c
* config/tc-h8500.c, config/tc-hppa.c, config/tc-hppa.h
* config/tc-i370.c, config/tc-i370.h, config/tc-i386.c
* config/tc-i386.h, config/tc-i860.c, config/tc-i860.h
* config/tc-i960.c, config/tc-i960.h, config/tc-ia64.c
* config/tc-ip2k.c, config/tc-ip2k.h, config/tc-iq2000.c
* config/tc-iq2000.h, config/tc-m32r.c, config/tc-m32r.h
* config/tc-m68hc11.c, config/tc-m68hc11.h, config/tc-m68k.c
* config/tc-m68k.h, config/tc-m88k.c, config/tc-maxq.c
* config/tc-mcore.c, config/tc-mcore.h, config/tc-mips.c
* config/tc-mips.h, config/tc-mmix.c, config/tc-mn10200.c
* config/tc-mn10300.c, config/tc-msp430.c, config/tc-ns32k.c
* config/tc-openrisc.h, config/tc-or32.c, config/tc-or32.h
* config/tc-pdp11.c, config/tc-pj.c, config/tc-pj.h
* config/tc-ppc.c, config/tc-ppc.h, config/tc-s390.c
* config/tc-s390.h, config/tc-sh64.c, config/tc-sh.c
* config/tc-sh.h, config/tc-sparc.c, config/tc-sparc.h
* config/tc-tahoe.c, config/tc-tic30.c, config/tc-tic4x.c
* config/tc-tic54x.c, config/tc-tic80.c, config/tc-v850.c
* config/tc-v850.h, config/tc-vax.c, config/tc-vax.h
* config/tc-w65.c, config/tc-xstormy16.c, config/tc-xstormy16.h
* config/tc-xtensa.c, config/tc-z8k.c:
Replace all instances of the string "_apply_fix3" with
"_apply_fix".
* po/POTFILES.in, po/gas.pot: Regenerate.
bfd:
* coff-i386.c: Change md_apply_fix3 to md_apply_fix in comment.
cgen:
* doc/porting.texi: Change all mention of md_apply_fix3 and
gas_cgen_md_apply_fix3 to md_apply_fix and gas_cgen_md_apply_fix
respectively.
2005-06-07 17:54:22 +00:00
|
|
|
md_apply_fix (fixS *fixP, valueT * valP, segT seg ATTRIBUTE_UNUSED)
|
1999-05-03 07:29:11 +00:00
|
|
|
{
|
2001-11-15 21:29:00 +00:00
|
|
|
long val = * (long *) valP;
|
1999-05-03 07:29:11 +00:00
|
|
|
char *buf = fixP->fx_where + fixP->fx_frag->fr_literal;
|
|
|
|
int addr = fixP->fx_frag->fr_address + fixP->fx_where;
|
|
|
|
|
|
|
|
if (fixP->fx_r_type == 0)
|
|
|
|
{
|
|
|
|
if (fixP->fx_size == 1)
|
|
|
|
fixP->fx_r_type = R_W65_ABS8;
|
|
|
|
else
|
|
|
|
fixP->fx_r_type = R_W65_ABS16;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (fixP->fx_r_type)
|
|
|
|
{
|
|
|
|
case R_W65_ABS8S16:
|
|
|
|
val >>= 8;
|
|
|
|
case R_W65_ABS8S8:
|
|
|
|
val >>= 8;
|
|
|
|
case R_W65_ABS8:
|
|
|
|
*buf++ = val;
|
|
|
|
break;
|
|
|
|
case R_W65_ABS16S16:
|
|
|
|
val >>= 8;
|
|
|
|
case R_W65_ABS16S8:
|
|
|
|
val >>= 8;
|
|
|
|
case R_W65_ABS16:
|
|
|
|
*buf++ = val >> 0;
|
|
|
|
*buf++ = val >> 8;
|
|
|
|
break;
|
|
|
|
case R_W65_ABS24:
|
|
|
|
*buf++ = val >> 0;
|
|
|
|
*buf++ = val >> 8;
|
|
|
|
*buf++ = val >> 16;
|
|
|
|
break;
|
|
|
|
case R_W65_PCR8:
|
|
|
|
*buf++ = val - addr - 1;
|
|
|
|
break;
|
|
|
|
case R_W65_PCR16:
|
|
|
|
val = val - addr - 1;
|
|
|
|
*buf++ = val;
|
|
|
|
*buf++ = val >> 8;
|
|
|
|
break;
|
|
|
|
case R_W65_DP:
|
|
|
|
*buf++ = val;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
abort ();
|
|
|
|
}
|
2001-11-15 21:29:00 +00:00
|
|
|
|
|
|
|
if (fixP->fx_addsy == NULL && fixP->fx_pcrel == 0)
|
|
|
|
fixP->fx_done = 1;
|
1999-05-03 07:29:11 +00:00
|
|
|
}
|
|
|
|
|
2001-11-15 21:29:00 +00:00
|
|
|
/* Put number into target byte order. */
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
void
|
2005-03-24 20:40:28 +00:00
|
|
|
md_number_to_chars (char *ptr, valueT use, int nbytes)
|
1999-05-03 07:29:11 +00:00
|
|
|
{
|
|
|
|
number_to_chars_littleendian (ptr, use, nbytes);
|
|
|
|
}
|
|
|
|
|
|
|
|
long
|
2005-03-24 20:40:28 +00:00
|
|
|
md_pcrel_from (fixS *fixP)
|
1999-05-03 07:29:11 +00:00
|
|
|
{
|
|
|
|
int gap = fixP->fx_size + fixP->fx_where + fixP->fx_frag->fr_address - 1;
|
|
|
|
return gap;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2005-03-24 20:40:28 +00:00
|
|
|
tc_coff_symbol_emit_hook (symbolS *x ATTRIBUTE_UNUSED)
|
1999-05-03 07:29:11 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
short
|
2005-03-24 20:40:28 +00:00
|
|
|
tc_coff_fix2rtype (fixS *fix_ptr)
|
1999-05-03 07:29:11 +00:00
|
|
|
{
|
|
|
|
return fix_ptr->fx_r_type;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2005-03-24 20:40:28 +00:00
|
|
|
tc_reloc_mangle (fixS *fix_ptr,
|
|
|
|
struct internal_reloc *intr,
|
|
|
|
bfd_vma base)
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
symbolS *symbol_ptr;
|
|
|
|
|
|
|
|
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 == RELOC_32)
|
|
|
|
{
|
2005-03-24 20:40:28 +00:00
|
|
|
/* Cons likes to create reloc32's whatever the size of the reloc. */
|
1999-05-03 07:29:11 +00:00
|
|
|
switch (fix_ptr->fx_size)
|
|
|
|
{
|
|
|
|
case 2:
|
|
|
|
intr->r_type = R_IMM16;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
intr->r_type = R_IMM8;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
abort ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (fix_ptr->fx_size == 4)
|
|
|
|
intr->r_type = R_W65_ABS24;
|
|
|
|
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;
|
|
|
|
|
|
|
|
/* Turn the segment of the symbol into an offset. */
|
|
|
|
if (symbol_ptr)
|
|
|
|
{
|
|
|
|
symbolS *dot;
|
|
|
|
|
|
|
|
dot = segment_info[S_GET_SEGMENT (symbol_ptr)].dot;
|
|
|
|
if (dot)
|
|
|
|
{
|
|
|
|
intr->r_offset += S_GET_VALUE (symbol_ptr);
|
|
|
|
intr->r_symndx = dot->sy_number;
|
|
|
|
}
|
|
|
|
else
|
2005-03-24 20:40:28 +00:00
|
|
|
intr->r_symndx = symbol_ptr->sy_number;
|
1999-05-03 07:29:11 +00:00
|
|
|
}
|
|
|
|
else
|
2005-03-24 20:40:28 +00:00
|
|
|
intr->r_symndx = -1;
|
1999-05-03 07:29:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2005-03-24 20:40:28 +00:00
|
|
|
tc_coff_sizemachdep (fragS *frag)
|
1999-05-03 07:29:11 +00:00
|
|
|
{
|
|
|
|
return md_relax_table[frag->fr_subtype].rlx_length;
|
|
|
|
}
|
|
|
|
|
2000-07-17 20:59:47 +00:00
|
|
|
/* Called just before address relaxation, return the length by which a
|
|
|
|
fragment must grow to reach it's destination. */
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
int
|
2005-03-24 20:40:28 +00:00
|
|
|
md_estimate_size_before_relax (fragS *fragP, segT segment_type)
|
1999-05-03 07:29:11 +00:00
|
|
|
{
|
2001-04-05 04:21:36 +00:00
|
|
|
int what;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
switch (fragP->fr_subtype)
|
|
|
|
{
|
|
|
|
default:
|
|
|
|
abort ();
|
2001-03-30 00:06:10 +00:00
|
|
|
|
1999-05-03 07:29:11 +00:00
|
|
|
case C (COND_BRANCH, UNDEF_BYTE_DISP):
|
|
|
|
case C (UNCOND_BRANCH, UNDEF_BYTE_DISP):
|
2001-04-05 04:21:36 +00:00
|
|
|
what = GET_WHAT (fragP->fr_subtype);
|
2000-07-17 20:59:47 +00:00
|
|
|
/* Used to be a branch to somewhere which was unknown. */
|
1999-05-03 07:29:11 +00:00
|
|
|
if (S_GET_SEGMENT (fragP->fr_symbol) == segment_type)
|
2005-03-24 20:40:28 +00:00
|
|
|
/* Got a symbol and it's defined in this segment, become byte
|
|
|
|
sized - maybe it will fix up. */
|
|
|
|
fragP->fr_subtype = C (what, BYTE_DISP);
|
1999-05-03 07:29:11 +00:00
|
|
|
else
|
2005-03-24 20:40:28 +00:00
|
|
|
/* Its got a segment, but its not ours, so it will always be
|
|
|
|
long. */
|
|
|
|
fragP->fr_subtype = C (what, UNDEF_WORD_DISP);
|
2001-03-30 00:06:10 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case C (COND_BRANCH, BYTE_DISP):
|
|
|
|
case C (COND_BRANCH, WORD_DISP):
|
2001-04-05 04:21:36 +00:00
|
|
|
case C (COND_BRANCH, UNDEF_WORD_DISP):
|
2001-03-30 00:06:10 +00:00
|
|
|
case C (UNCOND_BRANCH, BYTE_DISP):
|
|
|
|
case C (UNCOND_BRANCH, WORD_DISP):
|
2001-04-05 04:21:36 +00:00
|
|
|
case C (UNCOND_BRANCH, UNDEF_WORD_DISP):
|
2001-03-30 00:06:10 +00:00
|
|
|
/* When relaxing a section for the second time, we don't need to
|
2001-04-05 04:21:36 +00:00
|
|
|
do anything besides return the current size. */
|
2001-03-30 00:06:10 +00:00
|
|
|
break;
|
1999-05-03 07:29:11 +00:00
|
|
|
}
|
2001-04-05 04:21:36 +00:00
|
|
|
|
|
|
|
fragP->fr_var = md_relax_table[fragP->fr_subtype].rlx_length;
|
1999-05-03 07:29:11 +00:00
|
|
|
return fragP->fr_var;
|
|
|
|
}
|
|
|
|
|
2002-06-08 07:37:16 +00:00
|
|
|
const char *md_shortopts = "";
|
2005-03-24 20:40:28 +00:00
|
|
|
struct option md_longopts[] =
|
|
|
|
{
|
1999-05-03 07:29:11 +00:00
|
|
|
#define OPTION_RELAX (OPTION_MD_BASE)
|
|
|
|
{NULL, no_argument, NULL, 0}
|
|
|
|
};
|
|
|
|
|
|
|
|
void
|
2005-03-24 20:40:28 +00:00
|
|
|
md_show_usage (FILE *stream ATTRIBUTE_UNUSED)
|
1999-05-03 07:29:11 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2000-07-17 20:59:47 +00:00
|
|
|
size_t md_longopts_size = sizeof (md_longopts);
|