3

According to browser solidity, after executing

000 PUSH1 60
002 PUSH1 40
004 MSTORE

Memory is:

0x00: 00000000000000000000000000000000  ????????????????
0x10: 00000000000000000000000000000000  ????????????????
0x20: 00000000000000000000000000000000  ????????????????
0x30: 00000000000000000000000000000000  ????????????????
0x40: 00000000000000000000000000000000  ????????????????
0x50: 00000000000000000000000000000060  ????????????????

And yet, according to what I can read in the yellow paper, and other resources, 0x60 should be stored at address 0x40. Is browser-solidity lying to me, or what am I misunderstanding?

5

Each word in the EVM is 32 = 0x20 bytes wide, so when you use PUSH1 40 to store a word at 0x40 it fills up all the bytes up to 0x5f. The EVM uses "big-endian" format, so the least significant bytes of the word are stored at the end. Thus the byte "0x60" is correctly written to location 0x5f in your example.

The layout of the data from Browser Solidity is a little misleading - you are seeing only half a word per line; the whole word spans two lines.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.