- /* Try to pop multiple registers. */
- if (regno == 7 || regno == 3)
- {
- int second_regno = pop_order[idx + 1];
- int third_regno = pop_order[idx + 2];
- int fourth_regno = pop_order[idx + 3];
-
- if (fourth_regno >= 0
- && WORD_REG_USED (fourth_regno)
- && (!frame_pointer_needed
- || fourth_regno != FRAME_POINTER_REGNUM)
- && third_regno >= 0
- && WORD_REG_USED (third_regno)
- && (!frame_pointer_needed
- || third_regno != FRAME_POINTER_REGNUM)
- && second_regno >= 0
- && WORD_REG_USED (second_regno)
- && (!frame_pointer_needed
- || second_regno != FRAME_POINTER_REGNUM))
- {
- fprintf (file, "\tldm.l @sp+,%s-%s\n",
- h8_reg_names[fourth_regno],
- h8_reg_names[regno]);
- idx += 3;
- continue;
- }
- }
- if (regno == 6 || regno == 2)
- {
- int second_regno = pop_order[idx + 1];
- int third_regno = pop_order[idx + 2];
-
- if (third_regno >= 0
- && WORD_REG_USED (third_regno)
- && (!frame_pointer_needed
- || third_regno != FRAME_POINTER_REGNUM)
- && second_regno >= 0
- && WORD_REG_USED (second_regno)
- && (!frame_pointer_needed
- || second_regno != FRAME_POINTER_REGNUM))
- {
- fprintf (file, "\tldm.l @sp+,%s-%s\n",
- h8_reg_names[third_regno],
- h8_reg_names[regno]);
- idx += 2;
- continue;
- }
- }
- if (regno == 7 || regno == 5 || regno == 3 || regno == 1)
- {
- int second_regno = pop_order[idx + 1];
-
- if (second_regno >= 0
- && WORD_REG_USED (second_regno)
- && (!frame_pointer_needed
- || second_regno != FRAME_POINTER_REGNUM))
- {
- fprintf (file, "\tldm.l @sp+,%s-%s\n",
- h8_reg_names[second_regno],
- h8_reg_names[regno]);
- idx += 1;
- continue;
- }
- }
+ /* See how many registers we can pop at the same time. */
+ if ((regno == 7 || regno == 3)
+ && pop_regs[idx + 1] >= 0
+ && pop_regs[idx + 2] >= 0
+ && pop_regs[idx + 3] >= 0)
+ n_regs = 4;
+
+ else if ((regno == 6 || regno == 2)
+ && pop_regs[idx + 1] >= 0
+ && pop_regs[idx + 2] >= 0)
+ n_regs = 3;
+
+ else if ((regno == 7 || regno == 5 || regno == 3 || regno == 1)
+ && pop_regs[idx + 1] >= 0)
+ n_regs = 2;