Skip to content

Instantly share code, notes, and snippets.

@GeoffTidey
Created July 31, 2012 17:19
Show Gist options
  • Save GeoffTidey/3218681 to your computer and use it in GitHub Desktop.
Save GeoffTidey/3218681 to your computer and use it in GitHub Desktop.
A ruby interpretation of the shrd (Double Precision Shift Right) Assembly instruction
#see https://en.wikibooks.org/wiki/X86_Assembly/Shift_and_Rotate#Extended_Shift_Instructions for more info on shrd
def shrd(rm16, r16, cl)
rm16 >>= cl
r16 <<= (16 - cl)
rm16 | (r16 & 0xFFFF)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment