You may recall from earlier modules - Negative numbers on the x86(_64) platform are represented via Two's Complement
In short, two's complement is just a way to differentiate between negative and positive numbers at the binary level
Negative numbers use the "complement" of positive numbers. So instead of starting at 0000... negative numbers start at 1111. The 1s and 0s are flipped.
If the left most bit is 0 - the number is positive.
If the left most bit is 1 - the number is negative.
To get the negative version of a number... take the positive number, subtract by 1, then invert.
This may be hard to understand at first, but let's look at it via positive numbers first. Use the decimal to bin chart below as reference.
3 = 0011
Let's get -3
Subtract 1 from 3 (3-1= 2) (2 = 0010)
Invert: -3 = (1101) aka 0010 inverted is 1101
In order to find the two's complement - you can also find a number's 1's complement then add 1
There are few downsides to Two's Complement. The biggest downside - signed numbers have a smaller range in order to account for the extra bit that determines sign.
Shift operations that are sign aware exist (SAR for right and SAL for left)
Work in the same fashion as shr/shl, except for what happens when bits are shifted off the end - bits still disappear, but the sign of the resulting value is retained