Skip to content

Documenting the undocumented #4

@mras0

Description

@mras0

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions