Search code examples
assemblyx86-64bit-shift

Assembly: How to define the Format Shifting (SHL,SHR)


How i can know how much to be shifted with using shl or shr in assembly. for example :

0x111111111111116f

To remove the 11111111111111 I will use shl and shr.

 mov    rsi, 0x111111111111116f
 shl    rsi, 0x38
 shr    rsi, 0x38

So, what is the meaning of 0x38 specifically? How do we know how many bits will be shifted?


Solution

  • So, what is the meaning 0x38 specifically? How do we can know how much will be shifted?

    0x38 is a number in the hexadecimal notation. In decimal it represents 56.

    shl    rsi, 0x38
    

    The value in RSI (whatever it may represent) will be shifted to the left 56 bits.

    shr    rsi, 0x38
    

    The value in RSI (whatever it may represent) will be shifted to the right 56 bits.