This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [Patch] MIPS: Add mips16e save/restore instruction support.
David Ung wrote:
[snip]
> *** gas/config/tc-mips.c 1 Nov 2005 01:59:28 -0000 1.325
> --- gas/config/tc-mips.c 3 Nov 2005 17:39:48 -0000
> *************** mips16_ip (char *str, struct mips_cl_ins
> *** 9836,9841 ****
> --- 9836,10013 ----
> }
> continue;
>
> + case 'm': /* Register list for save insn. */
> + case 'M': /* Register list for restore insn. */
> + {
> + int opcode = 0;
> + int framesz = 0, seen_framesz = 0;
> + int args = 0, statics = 0, sregs = 0;
> +
> + while (*s != '\0')
> + {
> + unsigned int reg1, reg2;
> +
> + while (*s == ' ' || *s == ',')
> + ++s;
This could also see \t, and multiple ',' are an error, I think.
SKIP_WHITESPACE ();
if (*s == ',')
++s;
> + my_getExpression (&imm_expr, s);
> + if (imm_expr.X_op == O_constant)
> + {
> + /* Handle the frame size. */
> + if (seen_framesz)
> + {
> + as_bad (_("more than one frame size in list"));
> + break;
> + }
> + seen_framesz = 1;
> + framesz = imm_expr.X_add_number;
> + imm_expr.X_op = O_absent;
> + s = expr_end;
> + continue;
> + }
> +
> + if (*s != '$')
> + {
> + as_bad (_("can't parse register list"));
> + break;
> + }
> + ++s;
> +
> + reg1 = 0;
> + while (ISDIGIT (*s))
> + {
> + reg1 *= 10;
> + reg1 += *s - '0';
> + ++s;
> + }
> + if (*s == ' ')
> + ++s;
SKIP_WHITESPACE();
> + if (*s != '-')
> + reg2 = reg1;
> + else
> + {
> + ++s;
> + if (*s == '$')
> + ++s;
Is this '$' really meant to be optional?
> + reg2 = 0;
> + while (ISDIGIT (*s))
> + {
> + reg2 *= 10;
> + reg2 += *s - '0';
> + ++s;
> + }
> + }
> +
> + while (reg1 <= reg2)
> + {
> + if (reg1 >= 4 && reg1 <= 7)
> + {
> + if (c == 'm' && !seen_framesz)
> + /* args $a0-$a3 */
> + args |= 1 << (reg1 - 4);
> + else
> + /* statics $a0-$a3 */
> + statics |= 1 << (reg1 - 4);
> + }
> + else if ((reg1 >= 16 && reg1 <= 23) || reg1 == 30)
> + {
> + /* $s0-$s8 */
> + sregs |= 1 << ((reg1 == 30) ? 8 : (reg1 - 16));
> + }
> + else if (reg1 == 31)
> + {
> + /* Add $ra to insn. */
> + opcode |= 0x40;
> + }
> + else
> + {
> + as_bad (_("unexpected register in list"));
> + break;
> + }
> + if (++reg1 == 24)
> + reg1 = 30;
> + }
> + }
> +
> + /* Encode args/tatics combination. */
Typo.
[snip]
> *** opcodes/mips-dis.c 6 Sep 2005 18:46:57 -0000 1.54
> --- opcodes/mips-dis.c 3 Nov 2005 17:42:27 -0000
> *************** print_mips16_insn_arg (char type,
[snip]
> + (*info->fprintf_func) (info->stream, "-%s",
> + mips_gpr_names[j == 8 ? 30 : (16 + j)]);
> + i = j + 1;
> + }
> + }
> +
> + /* Statics $ax - $a3. */
$ax ?
Thiemo