-
-
Save tjade273/9ad091e16cb0085a2eed87efe73bd2b9 to your computer and use it in GitHub Desktop.
Created using browser-solidity: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://ethereum.github.io/browser-solidity/#version=soljson-v0.4.19+commit.c4cbbb05.js&optimize=false&gist=
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
pragma solidity ^0.4.19; | |
contract FlipEndian { | |
function flip32_1(bytes32 a) public constant returns (bytes32 b){ | |
assembly { | |
0 | |
and(div(a, 0x100000000000000000000000000000000000000000000000000000000000000), 0xFF) | |
or | |
and(div(a, 0x10000000000000000000000000000000000000000000000000000000000), 0xFF00) | |
or | |
and(div(a, 0x1000000000000000000000000000000000000000000000000000000), 0xFF0000) | |
or | |
and(div(a, 0x100000000000000000000000000000000000000000000000000), 0xFF000000) | |
or | |
and(div(a, 0x10000000000000000000000000000000000000000000000), 0xFF00000000) | |
or | |
and(div(a, 0x1000000000000000000000000000000000000000000), 0xFF0000000000) | |
or | |
and(div(a, 0x100000000000000000000000000000000000000), 0xFF000000000000) | |
or | |
and(div(a, 0x10000000000000000000000000000000000), 0xFF00000000000000) | |
or | |
and(div(a, 0x1000000000000000000000000000000), 0xFF0000000000000000) | |
or | |
and(div(a, 0x100000000000000000000000000), 0xFF000000000000000000) | |
or | |
and(div(a, 0x10000000000000000000000), 0xFF00000000000000000000) | |
or | |
and(div(a, 0x1000000000000000000), 0xFF0000000000000000000000) | |
or | |
and(div(a, 0x100000000000000), 0xFF000000000000000000000000) | |
or | |
and(div(a, 0x10000000000), 0xFF00000000000000000000000000) | |
or | |
and(div(a, 0x1000000), 0xFF0000000000000000000000000000) | |
or | |
and(div(a, 0x100), 0xFF000000000000000000000000000000) | |
or | |
=: b | |
a := mul(a, 0x100000000000000000000000000000000) | |
0 | |
and(div(a, 0x100000000000000000000000000000000000000000000000000000000000000), 0xFF) | |
or | |
and(div(a, 0x10000000000000000000000000000000000000000000000000000000000), 0xFF00) | |
or | |
and(div(a, 0x1000000000000000000000000000000000000000000000000000000), 0xFF0000) | |
or | |
and(div(a, 0x100000000000000000000000000000000000000000000000000), 0xFF000000) | |
or | |
and(div(a, 0x10000000000000000000000000000000000000000000000), 0xFF00000000) | |
or | |
and(div(a, 0x1000000000000000000000000000000000000000000), 0xFF0000000000) | |
or | |
and(div(a, 0x100000000000000000000000000000000000000), 0xFF000000000000) | |
or | |
and(div(a, 0x10000000000000000000000000000000000), 0xFF00000000000000) | |
or | |
and(div(a, 0x1000000000000000000000000000000), 0xFF0000000000000000) | |
or | |
and(div(a, 0x100000000000000000000000000), 0xFF000000000000000000) | |
or | |
and(div(a, 0x10000000000000000000000), 0xFF00000000000000000000) | |
or | |
and(div(a, 0x1000000000000000000), 0xFF0000000000000000000000) | |
or | |
and(div(a, 0x100000000000000), 0xFF000000000000000000000000) | |
or | |
and(div(a, 0x10000000000), 0xFF00000000000000000000000000) | |
or | |
and(div(a, 0x1000000), 0xFF0000000000000000000000000000) | |
or | |
and(div(a, 0x100), 0xFF000000000000000000000000000000) | |
or | |
and(div(a, 0x1), 0xFF000000000000000000000000000000) | |
or | |
0x100000000000000000000000000000000 | |
mul | |
b | |
or | |
=: b | |
} | |
return b; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment