-
-
Save lheckemann/1a36d656965edee1639abd752087da83 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; uint32_t unscramble(uint32_t) | |
; arg in eax, return in eax | |
0000:096e 51 push cx | |
0000:096f b90800 mov cx, 8 | |
0000:0972 66355555aaaa xor eax, 0xaaaa5555 | |
.-> 0000:0978 66d1e0 shl eax, 1 | |
,==< 0000:097b 7308 jae 0x985 | |
|: 0000:097d 663557000080 xor eax, 0x80000057 | |
|: 0000:0983 0c01 or al, 1 | |
``=< 0000:0985 e2f1 loop 0x978 | |
0000:0987 59 pop cx | |
0000:0988 c3 ret |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Unscramble where | |
import Data.Word | |
import Data.Bits | |
unscramble :: Word32 -> Word32 | |
unscramble x = result where | |
initial = x `xor` 0xaaaa5555 | |
t y = if y .&. 0x80000000 == 0 | |
then y `shift` 1 | |
else ((y `shift` 1) `xor` 0x80000057) .|. 1 | |
result = (iterate t initial) !! 8 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment