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.
(mri_comment_end): New function.
(s_align_bytes): Use mri_comment_field.
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
#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 *));
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));
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;
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)
{
int c;
int cc;
- const char *leftstart;
+ char *leftstart;
const char *leftstop;
- const char *rightstart;
+ char *rightstart;
const char *rightstop;
c = *stop;