aboutsummaryrefslogtreecommitdiff
path: root/gas/config
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@airs.com>1995-09-18 22:25:54 +0000
committerIan Lance Taylor <ian@airs.com>1995-09-18 22:25:54 +0000
commitb3625fe62c5dd321fb775f0c5a36b3fc91a62cea (patch)
tree2d8ce8961c5f49458672482b97bb56f9e3b1ca06 /gas/config
parentf9680a0598d7a69750094b5efaee971406ceb083 (diff)
downloadgdb-b3625fe62c5dd321fb775f0c5a36b3fc91a62cea.zip
gdb-b3625fe62c5dd321fb775f0c5a36b3fc91a62cea.tar.gz
gdb-b3625fe62c5dd321fb775f0c5a36b3fc91a62cea.tar.bz2
* config/tc-m68k.c (parse_mri_control_operand): Change leftstart
and rightstart to not be const. (parse_mri_control_expression): Likewise. (build_mri_control_operand): Likewise. If the left side of the comparison is a register, and the right side is not, swap the two sides. * config/m68k-parse.y (m68k_reg_parse): Make globally visible. * config/m68k-parse.h (m68k_reg_parse): Declare.
Diffstat (limited to 'gas/config')
-rw-r--r--gas/config/m68k-parse.h18
-rw-r--r--gas/config/m68k-parse.y10
-rw-r--r--gas/config/tc-m68k.c51
3 files changed, 48 insertions, 31 deletions
diff --git a/gas/config/m68k-parse.h b/gas/config/m68k-parse.h
index 95a1cd8..31132cf 100644
--- a/gas/config/m68k-parse.h
+++ b/gas/config/m68k-parse.h
@@ -205,20 +205,6 @@ struct m68k_exp
expressionS exp;
};
-/* See whether an expression is a signed eight bit value. */
-
-#define expr8(ex) \
- ((ex)->exp.X_op == O_constant \
- && (ex)->exp.X_add_number >= -0x80 \
- && (ex)->exp.X_add_number < 0x80)
-
-/* See whether an expression is a signed sixteen bit value. */
-
-#define expr16(ex) \
- ((ex)->exp.X_op == O_constant \
- && (ex)->exp.X_add_number >= -0x8000 \
- && (ex)->exp.X_add_number < 0x8000)
-
/* The operand modes. */
enum m68k_operand_type
@@ -267,6 +253,10 @@ struct m68k_op
#endif /* ! defined (M68K_PARSE_H) */
+/* Parse a register. */
+
+extern enum m68k_register m68k_reg_parse PARAMS ((char **));
+
/* The parsing function. */
extern int m68k_ip_op PARAMS ((char *, struct m68k_op *));
diff --git a/gas/config/m68k-parse.y b/gas/config/m68k-parse.y
index d3d690a..dea1a53 100644
--- a/gas/config/m68k-parse.y
+++ b/gas/config/m68k-parse.y
@@ -81,7 +81,6 @@
/* Internal functions. */
-static enum m68k_register m68k_reg_parse PARAMS ((char **));
static int yylex PARAMS (());
static void yyerror PARAMS ((const char *));
@@ -210,12 +209,17 @@ motorola_operand:
else
op->mode = DISP;
}
+ | '(' LPC ')'
+ {
+ op->mode = DISP;
+ op->reg = $2;
+ }
| '(' ZAR ')'
{
op->mode = BASE;
op->reg = $2;
}
- | '(' zpc ')'
+ | '(' LZPC ')'
{
op->mode = BASE;
op->reg = $2;
@@ -633,7 +637,7 @@ static char *strorig;
/* If *CCP could be a register, return the register number and advance
*CCP. Otherwise don't change *CCP, and return 0. */
-static enum m68k_register
+enum m68k_register
m68k_reg_parse (ccp)
register char **ccp;
{
diff --git a/gas/config/tc-m68k.c b/gas/config/tc-m68k.c
index e4a1ff8..652b54a 100644
--- a/gas/config/tc-m68k.c
+++ b/gas/config/tc-m68k.c
@@ -4708,11 +4708,11 @@ static struct mri_control_info *push_mri_control
static void pop_mri_control PARAMS ((void));
static int parse_mri_condition PARAMS ((int *));
static int parse_mri_control_operand
- PARAMS ((int *, const char **, const char **, const char **, const char **));
+ PARAMS ((int *, char **, const char **, char **, const char **));
static int swap_mri_condition PARAMS ((int));
static int reverse_mri_condition PARAMS ((int));
static void build_mri_control_operand
- PARAMS ((int, int, const char *, const char *, const char *, const char *,
+ PARAMS ((int, int, char *, const char *, char *, const char *,
const char *, const char *, int));
static void parse_mri_control_expression
PARAMS ((char *, int, const char *, const char *, int));
@@ -4809,9 +4809,9 @@ parse_mri_condition (pcc)
static int
parse_mri_control_operand (pcc, leftstart, leftstop, rightstart, rightstop)
int *pcc;
- const char **leftstart;
+ char **leftstart;
const char **leftstop;
- const char **rightstart;
+ char **rightstart;
const char **rightstop;
{
char *s;
@@ -4936,30 +4936,53 @@ build_mri_control_operand (qual, cc, leftstart, leftstop, rightstart,
rightstop, truelab, falselab, extent)
int qual;
int cc;
- const char *leftstart;
+ char *leftstart;
const char *leftstop;
- const char *rightstart;
+ char *rightstart;
const char *rightstop;
const char *truelab;
const char *falselab;
int extent;
{
+ int leftreg, rightreg;
char *buf;
char *s;
- /* The 68k can't do a general comparision with an immediate operand
- on the right hand side. */
- if (rightstart != NULL && *rightstart == '#')
+ /* See which sides of the comparison are plain registers. */
+ if (leftstart == NULL)
+ leftreg = 0;
+ else
+ {
+ char *l;
+
+ l = leftstart;
+ leftreg = m68k_reg_parse (&l) != 0;
+ }
+ if (rightstart == NULL)
+ rightreg = 0;
+ else
+ {
+ char *l;
+
+ l = rightstart;
+ rightreg = m68k_reg_parse (&l) != 0;
+ }
+
+ /* Swap the compare operands, if necessary, to produce a legal m68k
+ compare instruction. */
+ if ((leftreg && ! rightreg)
+ || (rightstart != NULL && *rightstart == '#'))
{
- const char *temp;
+ char *temp;
+ const char *tempc;
cc = swap_mri_condition (cc);
temp = leftstart;
leftstart = rightstart;
rightstart = temp;
- temp = leftstop;
+ tempc = leftstop;
leftstop = rightstop;
- rightstop = temp;
+ rightstop = tempc;
}
if (truelab == NULL)
@@ -5020,9 +5043,9 @@ parse_mri_control_expression (stop, qual, truelab, falselab, extent)
{
int c;
int cc;
- const char *leftstart;
+ char *leftstart;
const char *leftstop;
- const char *rightstart;
+ char *rightstart;
const char *rightstop;
c = *stop;