X86: Fix the sar carry flag.
authorGabe Black <gblack@eecs.umich.edu>
Wed, 5 Aug 2009 09:58:03 +0000 (02:58 -0700)
committerGabe Black <gblack@eecs.umich.edu>
Wed, 5 Aug 2009 09:58:03 +0000 (02:58 -0700)
src/arch/x86/isa/microops/regop.isa

index 4d4079f5f4cc8add299119a4c7fb19e3d6cc6a5d..5461223a3a91816289a6ee0245c074e0eebdd2cf 100644 (file)
@@ -711,8 +711,12 @@ let {{
                 //worry about setting them.
                 ccFlagBits = ccFlagBits & ~(ext & (CFBit | ECFBit | OFBit));
                 //If some combination of the CF bits need to be set, set them.
-                if ((ext & (CFBit | ECFBit)) && bits(SrcReg1, shiftAmt - 1))
+                uint8_t effectiveShift =
+                    (shiftAmt <= dataSize * 8) ? shiftAmt : (dataSize * 8);
+                if ((ext & (CFBit | ECFBit)) &&
+                        bits(SrcReg1, effectiveShift - 1)) {
                     ccFlagBits = ccFlagBits | (ext & (CFBit | ECFBit));
+                }
                 //Use the regular mechanisms to calculate the other flags.
                 ccFlagBits = genFlags(ccFlagBits, ext & ~(CFBit | ECFBit | OFBit),
                         DestReg, psrc1, op2);