From b3625fe62c5dd321fb775f0c5a36b3fc91a62cea Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Mon, 18 Sep 1995 22:25:54 +0000 Subject: [PATCH] * 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. --- gas/ChangeLog | 9 +++++++++ gas/config/m68k-parse.h | 18 ++++------------- gas/config/m68k-parse.y | 10 +++++++--- gas/config/tc-m68k.c | 51 +++++++++++++++++++++++++++++++++++-------------- 4 files changed, 57 insertions(+), 31 deletions(-) diff --git a/gas/ChangeLog b/gas/ChangeLog index c8df738..27d5e78 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,5 +1,14 @@ Mon Sep 18 15:22:28 1995 Ian Lance Taylor + * 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. 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; -- 2.7.4