* config/tc-z8k.c (whatreg): Add comment describing function.

Return NULL if symbol name characters follow the register number.
        (parse_reg): Use NULL instead of 0 for pointer values.  Stop
        processing if whatreg returned NULL.
This commit is contained in:
Christian Groessler 2006-12-08 22:15:11 +00:00
parent 0d2bd018fd
commit 41d3b0565d
2 changed files with 42 additions and 10 deletions

View File

@ -1,3 +1,10 @@
2006-12-08 Christian Groessler <chris@groessler.org>
* config/tc-z8k.c (whatreg): Add comment describing function.
Return NULL if symbol name characters follow the register number.
(parse_reg): Use NULL instead of 0 for pointer values. Stop
processing if whatreg returned NULL.
2006-12-07 Kazu Hirata <kazu@codesourcery.com>
* config/tc-m68k.c: Update uses of EF_M68K_*.

View File

@ -196,19 +196,34 @@ static int the_ctrl;
static int the_flags;
static int the_interrupt;
/* Determine register number. src points to the ascii number
(after "rl", "rh", "r", "rr", or "rq"). If a character
outside the set of {0,',',')','('} follows the number,
return NULL to indicate that it's not a valid register
number. */
static char *
whatreg (unsigned int *reg, char *src)
{
unsigned int new_reg;
/* src[0] is already known to be a digit. */
if (ISDIGIT (src[1]))
{
*reg = (src[0] - '0') * 10 + src[1] - '0';
return src + 2;
new_reg = (src[0] - '0') * 10 + src[1] - '0';
src += 2;
}
else
{
*reg = (src[0] - '0');
return src + 1;
new_reg = (src[0] - '0');
src += 1;
}
if (src[0] != 0 && src[0] != ',' && src[0] != '(' && src[0] != ')')
return NULL;
*reg = new_reg;
return src;
}
/* Parse operands
@ -231,7 +246,7 @@ whatreg (unsigned int *reg, char *src)
static char *
parse_reg (char *src, int *mode, unsigned int *reg)
{
char *res = 0;
char *res = NULL;
char regno;
/* Check for stack pointer "sp" alias. */
@ -257,9 +272,11 @@ parse_reg (char *src, int *mode, unsigned int *reg)
if (src[1] == 'r' || src[1] == 'R')
{
if (src[2] < '0' || src[2] > '9')
return res; /* Assume no register name but a label starting with 'rr'. */
return NULL; /* Assume no register name but a label starting with 'rr'. */
*mode = CLASS_REG_LONG;
res = whatreg (reg, src + 2);
if (res == NULL)
return NULL; /* Not a valid register name. */
regno = *reg;
if (regno > 14)
as_bad (_("register rr%d out of range"), regno);
@ -269,9 +286,11 @@ parse_reg (char *src, int *mode, unsigned int *reg)
else if (src[1] == 'h' || src[1] == 'H')
{
if (src[2] < '0' || src[2] > '9')
return res; /* Assume no register name but a label starting with 'rh'. */
return NULL; /* Assume no register name but a label starting with 'rh'. */
*mode = CLASS_REG_BYTE;
res = whatreg (reg, src + 2);
if (res == NULL)
return NULL; /* Not a valid register name. */
regno = *reg;
if (regno > 7)
as_bad (_("register rh%d out of range"), regno);
@ -279,9 +298,11 @@ parse_reg (char *src, int *mode, unsigned int *reg)
else if (src[1] == 'l' || src[1] == 'L')
{
if (src[2] < '0' || src[2] > '9')
return res; /* Assume no register name but a label starting with 'rl'. */
return NULL; /* Assume no register name but a label starting with 'rl'. */
*mode = CLASS_REG_BYTE;
res = whatreg (reg, src + 2);
if (res == NULL)
return NULL; /* Not a valid register name. */
regno = *reg;
if (regno > 7)
as_bad (_("register rl%d out of range"), regno);
@ -290,9 +311,11 @@ parse_reg (char *src, int *mode, unsigned int *reg)
else if (src[1] == 'q' || src[1] == 'Q')
{
if (src[2] < '0' || src[2] > '9')
return res; /* Assume no register name but a label starting with 'rq'. */
return NULL; /* Assume no register name but a label starting with 'rq'. */
*mode = CLASS_REG_QUAD;
res = whatreg (reg, src + 2);
if (res == NULL)
return NULL; /* Not a valid register name. */
regno = *reg;
if (regno > 12)
as_bad (_("register rq%d out of range"), regno);
@ -302,9 +325,11 @@ parse_reg (char *src, int *mode, unsigned int *reg)
else
{
if (src[1] < '0' || src[1] > '9')
return res; /* Assume no register name but a label starting with 'r'. */
return NULL; /* Assume no register name but a label starting with 'r'. */
*mode = CLASS_REG_WORD;
res = whatreg (reg, src + 1);
if (res == NULL)
return NULL; /* Not a valid register name. */
regno = *reg;
if (regno > 15)
as_bad (_("register r%d out of range"), regno);