shifting a binary number to the right in assembly with SAR vs. SHR
问题 We know that when we shift a binary number to the right, it is divided by 2. For the number: 1001 0001 . Let's assume that is stored in AX register: If we consider it as unsigned number (which is equal to 145 in decimal): SHR AX, 1 will make AX equal to 0100 1000 which is equal to 72 in decimal, and this is right. But if we consider it as signed number (which is equal to -111 in decimal): SAR AX, 1 will make AX equal to 1100 0100 which is equal to -56 in decimal, and this is wrong because it