## ALP Programming Guide and Reference

[prev][next][parent][TOC]

### Operation

    (* count is an unsigned integer corresponding to the last operand of the instruction, either an
    immediate byte or the byte in register CL *)
    ShiftAmt  count MOD 32;
    inBits  register; (* Allow overlapped operands *)
    IF ShiftAmt = 0
    THEN no operation
    ELSE
      IF ShiftAmt ò OperandSize
      THEN (* Bad parameters *)
        r/m  UNDEFINED;
        CF, OF, SF, ZF, AF, PF  UNDEFINED;
      ELSE (* Perform the shift *)
        CF  BIT[r/m, ShiftAmt - 1]; (* last bit shifted out on exit *)
        FOR i  0 TO OperandSize - 1 - ShiftAmt
        DO
          BIT[r/m, i]  BIT[r/m, i - ShiftAmt];
        OD;
        FOR i  OperandSize - ShiftAmt TO OperandSize-1
        DO
          BIT[r/m,i]  BIT[inBits,i+ShiftAmt - OperandSize];
        OD;
          (* SF, ZF, PF are set according to the value of the result *)
        Set SF, ZF, PF (r/m);
        AF UNDEFINED;
      FI;
    FI;