* 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.
This commit is contained in:
Ian Lance Taylor
1995-09-18 22:25:54 +00:00
parent f9680a0598
commit b3625fe62c
4 changed files with 57 additions and 31 deletions

View File

@ -1,5 +1,14 @@
Mon Sep 18 15:22:28 1995 Ian Lance Taylor <ian@cygnus.com> Mon Sep 18 15:22:28 1995 Ian Lance Taylor <ian@cygnus.com>
* 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.
* read.c (mri_comment_field): New function. * read.c (mri_comment_field): New function.
(mri_comment_end): New function. (mri_comment_end): New function.
(s_align_bytes): Use mri_comment_field. (s_align_bytes): Use mri_comment_field.

View File

@ -205,20 +205,6 @@ struct m68k_exp
expressionS 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. */ /* The operand modes. */
enum m68k_operand_type enum m68k_operand_type
@ -267,6 +253,10 @@ struct m68k_op
#endif /* ! defined (M68K_PARSE_H) */ #endif /* ! defined (M68K_PARSE_H) */
/* Parse a register. */
extern enum m68k_register m68k_reg_parse PARAMS ((char **));
/* The parsing function. */ /* The parsing function. */
extern int m68k_ip_op PARAMS ((char *, struct m68k_op *)); extern int m68k_ip_op PARAMS ((char *, struct m68k_op *));

View File

@ -81,7 +81,6 @@
/* Internal functions. */ /* Internal functions. */
static enum m68k_register m68k_reg_parse PARAMS ((char **));
static int yylex PARAMS (()); static int yylex PARAMS (());
static void yyerror PARAMS ((const char *)); static void yyerror PARAMS ((const char *));
@ -210,12 +209,17 @@ motorola_operand:
else else
op->mode = DISP; op->mode = DISP;
} }
| '(' LPC ')'
{
op->mode = DISP;
op->reg = $2;
}
| '(' ZAR ')' | '(' ZAR ')'
{ {
op->mode = BASE; op->mode = BASE;
op->reg = $2; op->reg = $2;
} }
| '(' zpc ')' | '(' LZPC ')'
{ {
op->mode = BASE; op->mode = BASE;
op->reg = $2; op->reg = $2;
@ -633,7 +637,7 @@ static char *strorig;
/* If *CCP could be a register, return the register number and advance /* If *CCP could be a register, return the register number and advance
*CCP. Otherwise don't change *CCP, and return 0. */ *CCP. Otherwise don't change *CCP, and return 0. */
static enum m68k_register enum m68k_register
m68k_reg_parse (ccp) m68k_reg_parse (ccp)
register char **ccp; register char **ccp;
{ {

View File

@ -4708,11 +4708,11 @@ static struct mri_control_info *push_mri_control
static void pop_mri_control PARAMS ((void)); static void pop_mri_control PARAMS ((void));
static int parse_mri_condition PARAMS ((int *)); static int parse_mri_condition PARAMS ((int *));
static int parse_mri_control_operand 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 swap_mri_condition PARAMS ((int));
static int reverse_mri_condition PARAMS ((int)); static int reverse_mri_condition PARAMS ((int));
static void build_mri_control_operand 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)); const char *, const char *, int));
static void parse_mri_control_expression static void parse_mri_control_expression
PARAMS ((char *, int, const char *, const char *, int)); PARAMS ((char *, int, const char *, const char *, int));
@ -4809,9 +4809,9 @@ parse_mri_condition (pcc)
static int static int
parse_mri_control_operand (pcc, leftstart, leftstop, rightstart, rightstop) parse_mri_control_operand (pcc, leftstart, leftstop, rightstart, rightstop)
int *pcc; int *pcc;
const char **leftstart; char **leftstart;
const char **leftstop; const char **leftstop;
const char **rightstart; char **rightstart;
const char **rightstop; const char **rightstop;
{ {
char *s; char *s;
@ -4936,30 +4936,53 @@ build_mri_control_operand (qual, cc, leftstart, leftstop, rightstart,
rightstop, truelab, falselab, extent) rightstop, truelab, falselab, extent)
int qual; int qual;
int cc; int cc;
const char *leftstart; char *leftstart;
const char *leftstop; const char *leftstop;
const char *rightstart; char *rightstart;
const char *rightstop; const char *rightstop;
const char *truelab; const char *truelab;
const char *falselab; const char *falselab;
int extent; int extent;
{ {
int leftreg, rightreg;
char *buf; char *buf;
char *s; char *s;
/* The 68k can't do a general comparision with an immediate operand /* See which sides of the comparison are plain registers. */
on the right hand side. */ if (leftstart == NULL)
if (rightstart != NULL && *rightstart == '#') leftreg = 0;
else
{ {
const char *temp; 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 == '#'))
{
char *temp;
const char *tempc;
cc = swap_mri_condition (cc); cc = swap_mri_condition (cc);
temp = leftstart; temp = leftstart;
leftstart = rightstart; leftstart = rightstart;
rightstart = temp; rightstart = temp;
temp = leftstop; tempc = leftstop;
leftstop = rightstop; leftstop = rightstop;
rightstop = temp; rightstop = tempc;
} }
if (truelab == NULL) if (truelab == NULL)
@ -5020,9 +5043,9 @@ parse_mri_control_expression (stop, qual, truelab, falselab, extent)
{ {
int c; int c;
int cc; int cc;
const char *leftstart; char *leftstart;
const char *leftstop; const char *leftstop;
const char *rightstart; char *rightstart;
const char *rightstop; const char *rightstop;
c = *stop; c = *stop;