Guest lecture by Claire Wolf.
For string functions like strlen()
it can be useful to have a method
to detect quickly if any byte in a register is zero. How would you
perform that operation without and with bitmanip instructions?
The function rol(ror(x-2)+1)
maps 1 to 0 and 0 to 1 and all other
numbers to themself. (rol()
is a one-bit rotate left and ror()
a
one-bit rotate right in this example). How does this function work?
How can this be used to swap the two least significant bits of
a word using rotate and shfl
/unshfl
instructions?
Scan through the bitmanip instruction descriptions. Is there any instruction that you think is missing? Is there any bitmanip application that you feel isn’t covered by the bitmanip instruction set yet?