Sunday, August 07, 2011

Bug in bit field code at the end of Chapter 7

I have been testing all short sequences of code and found an error in the last part of Chapter 7 where I planned to use movsx with an immediate 32 bit field to prepare a mask.  The movsx instruction allows a register or memory 32 bit field to be sign-extended but not an immediate field.  The fix looked a little ugly and sign extension is not an elegant solution so I posted an better solution in the Chapter 7 errata page.

The better solution is shifting the rax register right 29 bits, followed by shifting it left 29 bits.  This is more generally applicable.  More importantly it actually works.


No comments: