static segT sdata2_segment = 0; /* Small read-only section. */
static segT rodata_segment = 0; /* read-only section. */
-/* Previous instruction (for pseudo instructions) */
-static char * last_output;
-static int last_inst;
-static int last_pseudo;
-
/* Generate a symbol for stabs information. */
void
*cond = COND_GE;
return s + 2;
}
- else
+ else
{
as_bad (_("condition expected, but saw '%.6s'"), s);
*cond = 0;
struct op_code_struct * opcode, *opcode1;
char * output = NULL;
int nlen = 0;
- int pseudo = 0;
+ int cond = 0;
int i;
unsigned long inst, inst1;
unsigned reg1;
switch (opcode->inst_type)
{
case INST_TYPE_RD_R1_R2:
- if (strcmp (op_end, ""))
- op_end = parse_reg (op_end + 1, ®1); /* Get rd. */
+ case INST_TYPE_COND_R1_R2:
+ if (opcode->inst_type == INST_TYPE_COND_R1_R2)
+ {
+ cond = 1;
+ if (strcmp (op_end, ""))
+ op_end = parse_cond (op_end + 1, ®1); /* Get rd. */
+ else
+ {
+ as_fatal (_("Error in statement syntax"));
+ reg1 = 0;
+ }
+ }
else
{
- as_fatal (_("Error in statement syntax"));
- reg1 = 0;
+ cond = 0;
+ if (strcmp (op_end, ""))
+ op_end = parse_reg (op_end + 1, ®1); /* Get rd. */
+ else
+ {
+ as_fatal (_("Error in statement syntax"));
+ reg1 = 0;
+ }
}
if (strcmp (op_end, ""))
op_end = parse_reg (op_end + 1, ®2); /* Get r1. */
}
/* Check for spl registers. */
- if (check_spl_reg (& reg1))
+ if (!cond && check_spl_reg (& reg1))
as_fatal (_("Cannot use special register with this instruction"));
if (check_spl_reg (& reg2))
as_fatal (_("Cannot use special register with this instruction"));
if (check_spl_reg (& reg3))
as_fatal (_("Cannot use special register with this instruction"));
+ if (cond)
+ inst |= (reg1 << COND_LOW) & COND_MASK;
+ else
+ inst |= (reg1 << RD_LOW) & RD_MASK;
+
if (streq (name, "sub"))
{
/* sub rd, r1, r2 becomes rsub rd, r2, r1. */
- inst |= (reg1 << RD_LOW) & RD_MASK;
inst |= (reg3 << RA_LOW) & RA_MASK;
inst |= (reg2 << RB_LOW) & RB_MASK;
}
else
{
- inst |= (reg1 << RD_LOW) & RD_MASK;
inst |= (reg2 << RA_LOW) & RA_MASK;
inst |= (reg3 << RB_LOW) & RB_MASK;
}
break;
case INST_TYPE_RD_R1_IMM:
- if (strcmp (op_end, ""))
- op_end = parse_reg (op_end + 1, ®1); /* Get rd. */
+ case INST_TYPE_COND_R1_IMM:
+ if (opcode->inst_type == INST_TYPE_COND_R1_IMM)
+ {
+ cond = 1;
+ if (strcmp (op_end, ""))
+ op_end = parse_cond (op_end + 1, ®1); /* Get rd. */
+ else
+ {
+ as_fatal (_("Error in statement syntax"));
+ reg1 = 0;
+ }
+ }
else
- {
- as_fatal (_("Error in statement syntax"));
- reg1 = 0;
+ {
+ cond = 0;
+ if (strcmp (op_end, ""))
+ op_end = parse_reg (op_end + 1, ®1); /* Get rd. */
+ else
+ {
+ as_fatal (_("Error in statement syntax"));
+ reg1 = 0;
+ }
}
if (strcmp (op_end, ""))
op_end = parse_reg (op_end + 1, ®2); /* Get r1. */
as_fatal (_("Error in statement syntax"));
/* Check for spl registers. */
- if (check_spl_reg (& reg1))
+ if (!cond && check_spl_reg (& reg1))
as_fatal (_("Cannot use special register with this instruction"));
if (check_spl_reg (& reg2))
as_fatal (_("Cannot use special register with this instruction"));
output[3] = INST_BYTE3 (inst1);
output = frag_more (isize);
}
- inst |= (reg1 << RD_LOW) & RD_MASK;
+ if (cond)
+ inst |= (reg1 << COND_LOW) & COND_MASK;
+ else
+ inst |= (reg1 << RD_LOW) & RD_MASK;
inst |= (reg2 << RA_LOW) & RA_MASK;
inst |= (immed << IMM_LOW) & IMM_MASK;
}
break;
#else
- case INST_TYPE_COND:
- if (strcmp (op_end, ""))
- op_end = parse_cond (op_end + 1, ®1); /* Get cond. */
- else
- {
- as_fatal (_("Error in statement syntax"));
- reg1 = 0;
- }
-
- if (last_pseudo != 0 || last_output == NULL)
- {
- as_fatal (_("IT, ITT, ITE pseudo instructions must follow CMP or CMPU isntructions"));
- return;
- }
-
- opcode1 = (struct op_code_struct *) hash_find (opcode_hash_control, "cmp");
- if ((opcode1 == NULL) || ((last_inst & opcode1->opcode_mask) != opcode1->bit_sequence))
- {
- opcode1 = (struct op_code_struct *) hash_find (opcode_hash_control, "cmpu");
- if ((opcode1 == NULL) || ((last_inst & opcode1->opcode_mask) != opcode1->bit_sequence))
- {
- as_fatal (_("IT, ITT, ITE pseudo instructions must follow CMP or CMPU isntructions"));
- return;
- }
- }
-
- /* Modify last instruction */
- last_inst |= (reg1 << COND_LOW) & COND_MASK;
- last_inst |= opcode->bit_sequence;
- last_output[0] = INST_BYTE0 (last_inst);
- last_output[1] = INST_BYTE1 (last_inst);
- last_output[2] = INST_BYTE2 (last_inst);
- last_output[3] = INST_BYTE3 (last_inst);
-
- /* Only one pseudo instruction follows */
- pseudo = 1;
- break;
#endif
case INST_TYPE_RD_SPECIAL:
if (strcmp (op_end, opcode->name) && strcmp (op_end, ""))
as_warn (_("ignoring operands: %s "), op_end);
- if (!pseudo)
- {
- output[0] = INST_BYTE0 (inst);
- output[1] = INST_BYTE1 (inst);
- output[2] = INST_BYTE2 (inst);
- output[3] = INST_BYTE3 (inst);
-
- last_output = output;
- last_inst = inst;
- }
- last_pseudo = pseudo;
+ output[0] = INST_BYTE0 (inst);
+ output[1] = INST_BYTE1 (inst);
+ output[2] = INST_BYTE2 (inst);
+ output[3] = INST_BYTE3 (inst);
#ifdef OBJ_ELF
dwarf2_emit_insn (4);