Some of the tests cover undefined behavior which is great! Some of the flags are still a mystery to me (in particular AAM in the case of an exception), but I've also narrowed down a few that might be worth documenting:
SHLD/SHRD
Undefined results if ShiftAmt >= OperandSize, but actual behavior is:
The value of the bits flowing into the destination are rotated (ROL/ROR style) from the second operand ("inBits"). CF is set according to last bit going out of the destination.
SHL/SHR r/m8,CL
The original i386 PRM is not super clear, but later manuals say OF/CF is undefined for ShiftAmt >= 8.
Actual behavior when ShiftAmt > 8:
SHL: OF and CF is set to 1 if ((ShiftAmt = 16 OR ShiftAmt = 24) AND (SrcValue & 1) otherwise 0.
SHR: OF set to 0, CF set if ((ShiftAmt = 16 OR ShiftAmt = 24) AND (SrcValue & 80h) otherwise 0.
BT/BTR/BTC/BTS
Manual states most flags except CF are undefined. Actual behavior: Everything except CF/OF is left alone.
Rotate the "source" value right according to "bit index". Set OF equal to XOR of the top two bits of the rotated value.
Some of the tests cover undefined behavior which is great! Some of the flags are still a mystery to me (in particular AAM in the case of an exception), but I've also narrowed down a few that might be worth documenting:
SHLD/SHRD
Undefined results if ShiftAmt >= OperandSize, but actual behavior is:
The value of the bits flowing into the destination are rotated (ROL/ROR style) from the second operand ("inBits"). CF is set according to last bit going out of the destination.
SHL/SHR r/m8,CL
The original i386 PRM is not super clear, but later manuals say OF/CF is undefined for ShiftAmt >= 8.
Actual behavior when ShiftAmt > 8:
SHL: OF and CF is set to 1 if
((ShiftAmt = 16 OR ShiftAmt = 24) AND (SrcValue & 1)otherwise 0.SHR: OF set to 0, CF set if
((ShiftAmt = 16 OR ShiftAmt = 24) AND (SrcValue & 80h)otherwise 0.BT/BTR/BTC/BTS
Manual states most flags except CF are undefined. Actual behavior: Everything except CF/OF is left alone.
Rotate the "source" value right according to "bit index". Set OF equal to XOR of the top two bits of the rotated value.