X86: Handle rotate right with carry instructions that go all the way around or more.

This commit is contained in:
Gabe Black 2009-08-05 03:01:49 -07:00
parent 77dc6b33ee
commit d265f7683e

View file

@ -762,13 +762,14 @@ let {{
code = ''' code = '''
uint8_t shiftAmt = uint8_t shiftAmt =
(op2 & ((dataSize == 8) ? mask(6) : mask(5))); (op2 & ((dataSize == 8) ? mask(6) : mask(5)));
if(shiftAmt) uint8_t realShiftAmt = shiftAmt % (dataSize * 8 + 1);
if(realShiftAmt)
{ {
CCFlagBits flags = ccFlagBits; CCFlagBits flags = ccFlagBits;
uint64_t top = flags.cf << (dataSize * 8 - shiftAmt); uint64_t top = flags.cf << (dataSize * 8 - realShiftAmt);
if(shiftAmt > 1) if (realShiftAmt > 1)
top |= psrc1 << (dataSize * 8 - shiftAmt + 1); top |= psrc1 << (dataSize * 8 - realShiftAmt + 1);
uint64_t bottom = bits(psrc1, dataSize * 8 - 1, shiftAmt); uint64_t bottom = bits(psrc1, dataSize * 8 - 1, realShiftAmt);
DestReg = merge(DestReg, top | bottom, dataSize); DestReg = merge(DestReg, top | bottom, dataSize);
} }
else else
@ -787,8 +788,11 @@ let {{
ccFlagBits = ccFlagBits | OFBit; ccFlagBits = ccFlagBits | OFBit;
} }
//If some combination of the CF bits need to be set, set them. //If some combination of the CF bits need to be set, set them.
if ((ext & (CFBit | ECFBit)) && bits(SrcReg1, shiftAmt - 1)) if ((ext & (CFBit | ECFBit)) &&
(realShiftAmt == 0) ? origCFBit :
bits(SrcReg1, realShiftAmt - 1)) {
ccFlagBits = ccFlagBits | (ext & (CFBit | ECFBit)); ccFlagBits = ccFlagBits | (ext & (CFBit | ECFBit));
}
//Use the regular mechanisms to calculate the other flags. //Use the regular mechanisms to calculate the other flags.
ccFlagBits = genFlags(ccFlagBits, ext & ~(CFBit | ECFBit | OFBit), ccFlagBits = genFlags(ccFlagBits, ext & ~(CFBit | ECFBit | OFBit),
DestReg, psrc1, op2); DestReg, psrc1, op2);