+static void
+genrshTwo (operand * result, operand * left,
+ int shCount, int sign)
+{
+ /* if shCount >= 8 */
+ if (shCount >= 8)
+ {
+ shCount -= 8;
+ if (shCount)
+ shiftR1Left2Result (left, MSB16, result, LSB,
+ shCount, sign);
+ else
+ movLeft2Result (left, MSB16, result, LSB, sign);
+ addSign (result, MSB16, sign);
+ }
+
+ /* 1 <= shCount <= 7 */
+ else
+ shiftR2Left2Result (left, LSB, result, LSB, shCount, sign);
+}
+
+/*-----------------------------------------------------------------*/
+/* shiftRLong - shift right one long from left to result */
+/* offl = LSB or MSB16 */
+/*-----------------------------------------------------------------*/
+static void
+shiftRLong (operand * left, int offl,
+ operand * result, int sign)
+{
+ if (!sign)
+ emitcode ("clr", "c");
+ MOVA (aopGet (AOP (left), MSB32, FALSE, FALSE));
+ if (sign)
+ emitcode ("mov", "c,acc.7");
+ emitcode ("rrc", "a");
+ aopPut (AOP (result), "a", MSB32 - offl);
+ if (offl == MSB16)
+ /* add sign of "a" */
+ addSign (result, MSB32, sign);
+
+ MOVA (aopGet (AOP (left), MSB24, FALSE, FALSE));
+ emitcode ("rrc", "a");
+ aopPut (AOP (result), "a", MSB24 - offl);
+
+ MOVA (aopGet (AOP (left), MSB16, FALSE, FALSE));
+ emitcode ("rrc", "a");
+ aopPut (AOP (result), "a", MSB16 - offl);
+
+ if (offl == LSB)
+ {
+ MOVA (aopGet (AOP (left), LSB, FALSE, FALSE));
+ emitcode ("rrc", "a");
+ aopPut (AOP (result), "a", LSB);
+ }
+}
+
+/*-----------------------------------------------------------------*/
+/* genrshFour - shift four byte by a known amount != 0 */
+/*-----------------------------------------------------------------*/
+static void
+genrshFour (operand * result, operand * left,
+ int shCount, int sign)
+{
+ /* if shifting more that 3 bytes */
+ if (shCount >= 24)
+ {
+ shCount -= 24;
+ if (shCount)
+ shiftR1Left2Result (left, MSB32, result, LSB, shCount, sign);
+ else
+ movLeft2Result (left, MSB32, result, LSB, sign);
+ addSign (result, MSB16, sign);
+ }
+ else if (shCount >= 16)
+ {
+ shCount -= 16;
+ if (shCount)
+ shiftR2Left2Result (left, MSB24, result, LSB, shCount, sign);
+ else
+ {
+ movLeft2Result (left, MSB24, result, LSB, 0);
+ movLeft2Result (left, MSB32, result, MSB16, sign);
+ }
+ addSign (result, MSB24, sign);
+ }
+ else if (shCount >= 8)
+ {
+ shCount -= 8;
+ if (shCount == 1)
+ shiftRLong (left, MSB16, result, sign);
+ else if (shCount == 0)
+ {
+ movLeft2Result (left, MSB16, result, LSB, 0);
+ movLeft2Result (left, MSB24, result, MSB16, 0);
+ movLeft2Result (left, MSB32, result, MSB24, sign);
+ addSign (result, MSB32, sign);
+ }
+ else
+ {
+ shiftR2Left2Result (left, MSB16, result, LSB, shCount, 0);
+ shiftLLeftOrResult (left, MSB32, result, MSB16, 8 - shCount);
+ /* the last shift is signed */
+ shiftR1Left2Result (left, MSB32, result, MSB24, shCount, sign);
+ addSign (result, MSB32, sign);
+ }
+ }
+ else
+ { /* 1 <= shCount <= 7 */
+ if (shCount <= 2)
+ {
+ shiftRLong (left, LSB, result, sign);
+ if (shCount == 2)
+ shiftRLong (result, LSB, result, sign);
+ }
+ else
+ {
+ shiftR2Left2Result (left, LSB, result, LSB, shCount, 0);
+ shiftLLeftOrResult (left, MSB24, result, MSB16, 8 - shCount);
+ shiftR2Left2Result (left, MSB24, result, MSB24, shCount, sign);
+ }
+ }
+}
+
+/*-----------------------------------------------------------------*/
+/* genRightShiftLiteral - right shifting by known count */
+/*-----------------------------------------------------------------*/
+static void
+genRightShiftLiteral (operand * left,
+ operand * right,
+ operand * result,
+ iCode * ic,
+ int sign)