I have the following simple Solidity contract:
pragma solidity ^0.4.0;
contract Test {
function Test() {
intfunc(5);
}
uint8 store;
function intfunc (uint8 a) internal {
store = a * 9;
}
}
I am compiling it using Remix, and I'm getting bytecode that I can't explain between addresses 0x11 and 0x1E (I'm including hex addresses on the left for convenience):
//Standard preamble:
0x00: PUSH1 0x60 PUSH1 0x40 MSTORE CALLVALUE ISZERO PUSH1 0xB JUMPI INVALID
//Beginning of Test() constructor:
0x0B: JUMPDEST JUMPDEST PUSH1 0x20 PUSH1 0x5
//Here's the really strange code:
0x11: PUSH5 0x100000000
0x17: PUSH1 0x7
0x19: PUSH1 0x25
0x1B: DUP3
0x1C: MUL
0x1D: OR
0x1E: DIV
//Here we jump to the intfunc() function
0x1F: JUMP
//Here we come back from intfunc() and jump to rest of the Test() constructor
0x20: JUMPDEST JUMPDEST PUSH1 0x3B JUMP
//intfunc() itself:
0x25: JUMPDEST PUSH1 0x0 DUP1 SLOAD PUSH1 0xFF NOT AND PUSH1 0x9 DUP4 MUL PUSH1 0xFF AND OR SWAP1 SSTORE JUMPDEST POP JUMP
//The rest of the Test() constructor and the rest of the code is here...
0x3B: JUMPDEST ...
//(The rest isn't really relevant to this question)
What is the deal with the code between 0x11 and 0x1E - why is it so cumbersome? Can't it just be replaced by a simple "PUSH1 0x25"? Isn't it just a waste of gas to go through all these strange steps just to compute the 0x25 value?
Moreover, where is the number 7 in the 0x17 instruction coming from? It seems completely pointless.
Note that I'm getting similar code for both "optimized" and "unoptimized" Remix modes.
Any insight would be appreciated!