Shifter mode

Juergen Buchmueller pullmoll at t-online.de
Mon Jun 11 08:56:11 PDT 2007


The shifter mode is determined solely by the F1, and not by the SH field of
the emulator IR. The SH field is used only in branching and has no
connection to the ALU's shift mode selection. This means that the cpu.c
function shifter() should look just like this:

static uint16_t shifter (void)
{
  uint16_t result;

  switch (current_uinst->f1)
    {
    case f1_l_lsh_1:
      shifter_carry_out = l >> 15;
      result = (l << 1) & 0177776;
      if (current_task == task_emulator)
        {
          if (current_uinst->f2 == f2_em_magic && (t & 0100000))
	    result |= 1;
          else if (current_uinst->f2 == f2_em_dns)
	    result |= l_alu_carry;
        }
      break;
    case f1_l_rsh_1:
      shifter_carry_out = l & 1;
      result = (l >> 1);
      if (current_task == task_emulator)
        {
          if (current_uinst->f2 == f2_em_magic && (t & 1))
	    result |= 0100000;
          else if (current_uinst->f2 == f2_em_dns)
	    result |= (l_alu_carry << 15);
        }
      break;
    case f1_l_lcy_8:
      shifter_carry_out = l_alu_carry;
      result = (l >> 8) | ((l & 0377) << 8);
      break;
    default:
      shifter_carry_out = l_alu_carry;
      result = l;
      break;
    }
  return (result);
}


More information about the Altogether-devel mailing list