# Assembly shift storage

**URL:** <https://forum.openzeppelin.com/t/assembly-shift-storage/37583>\
**Category:** Smart Contracts\
**Created:** [August 23, 2023, 2:38pm UTC](https://forum.openzeppelin.com/t/assembly-shift-storage/37583 "2023-08-23T14:38:43Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![MATE\_VS](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/mate_vs/32/19242_2.png) [@MATE\_VS](https://forum.openzeppelin.com/u/MATE_VS)\
**Post date:** [August 23, 2023, 2:38pm UTC](https://forum.openzeppelin.com/t/assembly-shift-storage/37583/1 "2023-08-23T14:38:43Z")

</div>

I intend to modify the data in slot 0 using assembly, but the output is not as anticipated. Could someone help me identify where the mistakes are, please?

```auto
function changeSlot0()public returns(bytes32) onlyOwner{
        bytes32 re;
        assembly{
            let slot0 := sload(0)
            let ans := shl(slot0,16)
            sstore(0,ans)
            re := sload(0)
        }
        return re;
    }

```

---

<div class="post-metadata">

**Author:** ![bca\_service](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/bca_service/32/18904_2.png) [@bca\_service](https://forum.openzeppelin.com/u/bca_service)\
**Post date:** [August 23, 2023, 3:32pm UTC](https://forum.openzeppelin.com/t/assembly-shift-storage/37583/3 "2023-08-23T15:32:56Z")

</div>

The parameters for the left shift method are reversed. shl(x, y) represents a logical shift left of y by x bits. So you should swap slot0 and 16.

---

<div class="post-metadata">

**Author:** ![MATE\_VS](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/mate_vs/32/19242_2.png) [@MATE\_VS](https://forum.openzeppelin.com/u/MATE_VS)\
**Post date:** [August 24, 2023, 5:50am UTC](https://forum.openzeppelin.com/t/assembly-shift-storage/37583/4 "2023-08-24T05:50:48Z")

</div>

Thank you, I think it's very basic... anyway, I got it.
